[opengtl-commits] [325] move SelectType to Type::Private

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 325
Author:   cyrille
Date:     2008-08-30 23:17:27 +0200 (Sat, 30 Aug 2008)

Log Message:
-----------
move SelectType to Type::Private

Modified Paths:
--------------
    trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h
    trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h


Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp	2008-08-30 20:49:47 UTC (rev 324)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp	2008-08-30 21:17:27 UTC (rev 325)
@@ -41,7 +41,7 @@
 #define UNIFORMIZE_TYPES( _v1_, _v2_) \
   GTL_ASSERT( _v1_.value() ); \
   GTL_ASSERT( _v2_.value() ); \
-  const Type* highestPriorityType = selectType( lhsType, rhsType); \
+  const Type* highestPriorityType = Type::Private::selectType( lhsType, rhsType); \
   GTL_ASSERT( highestPriorityType ); \
   GTLCore::ExpressionResult v1; \
   GTLCore::ExpressionResult v2; \
@@ -57,7 +57,7 @@
   GTL_ASSERT( v2.value() );
   
 #define UNIFORMIZE_VALUE_TYPES( _v1_, _v2_ ) \
-  const Type* highestPriorityType = selectType( lhsType, rhsType); \
+  const Type* highestPriorityType = Type::Private::selectType( lhsType, rhsType); \
   GTL_ASSERT( highestPriorityType ); \
   llvm::Value* v1 = convertValueTo( currentBlock, _v1_, lhsType, highestPriorityType); \
   llvm::Value* v2 = convertValueTo( currentBlock, _v2_, rhsType, highestPriorityType); \
@@ -65,7 +65,7 @@
   GTL_ASSERT( v2 );
 
 #define UNIFORMIZE_CONSTANT_TYPES( _v1_, _v2_ ) \
-  const Type* highestPriorityType = selectType( lhsType, rhsType); \
+  const Type* highestPriorityType = Type::Private::selectType( lhsType, rhsType); \
   GTL_ASSERT( highestPriorityType ); \
   llvm::Constant* v1 = convertConstantTo( _v1_, lhsType, highestPriorityType); \
   llvm::Constant* v2 = convertConstantTo( _v2_, rhsType, highestPriorityType); \
@@ -579,37 +579,6 @@
   return llvm::ConstantExpr::getXor(rhs, integerToConstant(0xFFFFFFFF ));
 }
 
-const Type* CodeGenerator::selectType(const Type* type1, const Type* type2)
-{
-  if( type1 == type2 )
-  {
-    return type1;
-  } else if( type1->dataType() == Type::VECTOR and type2->dataType() == Type::VECTOR )
-  {
-    const Type* best = selectType( type1->embeddedType(), type2->embeddedType() );
-    if( type1->embeddedType() == best) return type1;
-    else return type2;
-  } else if( type1->dataType() == Type::VECTOR ) {
-    return type1;
-  } else if( type2->dataType() == Type::VECTOR ) {
-    return type2;
-  } else if( type1 == Type::Float or type2 == Type::Float )
-  {
-    return Type::Float;
-  } else if( type1 == Type::Integer32 or type2 == Type::Integer32 )
-  {
-    return Type::Integer32;
-  } else if( type1 == Type::UnsignedInteger32 or type2 == Type::UnsignedInteger32 )
-  {
-    return Type::UnsignedInteger32;
-  } else if( type1 == Type::Boolean or type2 == Type::Boolean )
-  {
-    return Type::Boolean;
-  }
-  GTL_DEBUG("Select type failed : "<< *type1 << " " << *type2 );
-  return 0;
-}
-
 llvm::Value* CodeGenerator::accessArrayValue( llvm::BasicBlock* _currentBlock, llvm::Value* _pointer, llvm::Value* _index )
 {
   GTL_DEBUG( *_pointer << " " << *_index );

Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h	2008-08-30 20:49:47 UTC (rev 324)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h	2008-08-30 21:17:27 UTC (rev 325)
@@ -227,10 +227,6 @@
       static llvm::BasicBlock* createIterationForStatement( GenerationContext&, llvm::BasicBlock* before, GTLCore::VariableNG* variable, llvm::Value* maxValue, const Type* maxValueType, llvm::BasicBlock* firstAction, llvm::BasicBlock* lastAction);
       
       void createWhileStatement( llvm::BasicBlock* before, llvm::BasicBlock* test, llvm::Value* testResult, const Type* testType, llvm::BasicBlock* firstAction, llvm::BasicBlock* lastAction,  llvm::BasicBlock* after);
-      /**
-        * Select the type that has the higher priority
-        */
-      static const Type* selectType(const Type* type1, const Type* type2);
     public:
       /**
        * @param _currentBlock the current basic block

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp	2008-08-30 20:49:47 UTC (rev 324)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp	2008-08-30 21:17:27 UTC (rev 325)
@@ -247,3 +247,35 @@
   GTL_ASSERT( dataType != Type::ARRAY or arrayType );
   return dataType == Type::ARRAY and (arrayType->dataType() == Type::ARRAY or arrayType->dataType() == Type::STRUCTURE);
 }
+
+
+const Type* Type::Private::selectType(const Type* type1, const Type* type2)
+{
+  if( type1 == type2 )
+  {
+    return type1;
+  } else if( type1->dataType() == Type::VECTOR and type2->dataType() == Type::VECTOR )
+  {
+    const Type* best = selectType( type1->embeddedType(), type2->embeddedType() );
+    if( type1->embeddedType() == best) return type1;
+    else return type2;
+  } else if( type1->dataType() == Type::VECTOR ) {
+    return type1;
+  } else if( type2->dataType() == Type::VECTOR ) {
+    return type2;
+  } else if( type1 == Type::Float or type2 == Type::Float )
+  {
+    return Type::Float;
+  } else if( type1 == Type::Integer32 or type2 == Type::Integer32 )
+  {
+    return Type::Integer32;
+  } else if( type1 == Type::UnsignedInteger32 or type2 == Type::UnsignedInteger32 )
+  {
+    return Type::UnsignedInteger32;
+  } else if( type1 == Type::Boolean or type2 == Type::Boolean )
+  {
+    return Type::Boolean;
+  }
+  GTL_DEBUG("Select type failed : "<< *type1 << " " << *type2 );
+  return 0;
+}

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h	2008-08-30 20:49:47 UTC (rev 324)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h	2008-08-30 21:17:27 UTC (rev 325)
@@ -107,6 +107,10 @@
        */
       static Type* createArbitraryType( const llvm::Type* _type);
       /**
+        * Select the type that has the higher priority
+        */
+      static const Type* selectType(const Type* type1, const Type* type2);
+      /**
        * @return true if this a complex structure (a structure where one of its element
        *         is an array or an other structure)
        * 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/