[opengtl-commits] [182] Clean up a little bit the Type and TypeManager's API

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


Revision: 182
Author:   cyrille
Date:     2008-05-21 23:56:42 +0200 (Wed, 21 May 2008)

Log Message:
-----------
Clean up a little bit the Type and TypeManager's API

Modified Paths:
--------------
    trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp
    trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/AST/FunctionDeclaration.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Accessor_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt
    trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Type.h
    trunk/OpenGTL/OpenGTL/GTLCore/TypeManager.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/TypeManager.h
    trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h
    trunk/OpenGTL/OpenGTL/GTLCore/VariableNG_p.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.h

Added Paths:
-----------
    trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.h


Modified: trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp	2008-05-21 21:56:42 UTC (rev 182)
@@ -235,7 +235,7 @@
         llvm::Value* convertedIn = new llvm::LoadInst(
                         cg.convertPointerTo( bodyBlock,
                                            new llvm::GetElementPtrInst( in, cg.createAdditionExpression( bodyBlock, srcIndex, posSrc->type(), srcIndexes[i], GTLCore::Type::Integer32), "", bodyBlock),
-                                           srcChannelsTypes[i]->data()->type()),
+                                           srcChannelsTypes[i]->d->type()),
                         "", bodyBlock);
         if( srcNeedBuffer[i])
         { // if a buffer is needed that means that the value must be converted
@@ -253,7 +253,7 @@
       llvm::Value* dstIndex = posDst->get( gc, bodyBlock);
       for(int i = 0; i < dstCountChannels; ++i)
       {
-        llvm::Value* pointer = cg.convertPointerTo( bodyBlock, new llvm::GetElementPtrInst( out, cg.createAdditionExpression( bodyBlock, dstIndex, GTLCore::Type::Integer32, dstIndexes[i], GTLCore::Type::Integer32), "", bodyBlock), dstPixelDescription.channelTypes()[i]->data()->type());
+        llvm::Value* pointer = cg.convertPointerTo( bodyBlock, new llvm::GetElementPtrInst( out, cg.createAdditionExpression( bodyBlock, dstIndex, GTLCore::Type::Integer32, dstIndexes[i], GTLCore::Type::Integer32), "", bodyBlock), dstPixelDescription.channelTypes()[i]->d->type());
         if( dstNeedBuffer[i])
         {
           OCTL_ASSERT(buffer[i]);
@@ -272,7 +272,7 @@
         {
           llvm::GlobalVariable* globalVar =
               new llvm::GlobalVariable(
-                    parameters[i].type()->data()->type(),
+                    parameters[i].type()->d->type(),
                     false, llvm::GlobalValue::ExternalLinkage,
                     cg.valueToConstant( parameters[i].defaultValue() ),
                     "", d->module );
@@ -297,7 +297,7 @@
       {
         if( dstNeedBuffer[i])
         {
-          const llvm::Type* channelType = dstChannelsTypes[i]->data()->type();
+          const llvm::Type* channelType = dstChannelsTypes[i]->d->type();
           llvm::Value* pointer = cg.convertPointerTo( bodyBlock, new llvm::GetElementPtrInst( out, cg.createAdditionExpression( bodyBlock, dstIndex, GTLCore::Type::Integer32, dstIndexes[i], GTLCore::Type::Integer32), "", bodyBlock), channelType);
           llvm::Value* result = 0;
           if( dstChannelsTypes[i] == GTLCore::Type::Half )

Modified: trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp	2008-05-21 21:56:42 UTC (rev 182)
@@ -118,11 +118,11 @@
   {
     const GTLCore::Type* type = va_arg(argp, const GTLCore::Type*);
     arguments.push_back(GTLCore::Parameter("", type, false, false, GTLCore::Value() ) );
-    llvmArguments.push_back(type->data()->type());
+    llvmArguments.push_back(type->d->type());
   }
   va_end(argp);
   std::vector<llvm::Function*> functions(arguments.size() + 1);
-  functions[arguments.size() ] = dynamic_cast<llvm::Function*>( d->module->getOrInsertFunction( _symbolName, llvm::FunctionType::get(retType->data()->type(), llvmArguments, false ) ) );
+  functions[arguments.size() ] = dynamic_cast<llvm::Function*>( d->module->getOrInsertFunction( _symbolName, llvm::FunctionType::get(retType->d->type(), llvmArguments, false ) ) );
   GTLCore::Function::Data* data = new GTLCore::Function::Data(arguments, arguments.size() );
   data->setFunctions( functions );
   data->setModule( d->module );

Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp	2008-05-21 21:56:42 UTC (rev 182)
@@ -70,7 +70,7 @@
     std::vector<llvm::Constant*> arrayStruct;
     arrayStruct.push_back( _gc.codeGenerator()->integerToConstant( members.size() ) );
     llvm::Constant* constant = llvm::ConstantArray::get(
-                  llvm::ArrayType::get( arrayType->data()->type(), members.size()), members );
+                  llvm::ArrayType::get( arrayType->d->type(), members.size()), members );
     llvm::GlobalVariable* gvar = new llvm::GlobalVariable( constant->getType(), true, llvm::GlobalValue::ExternalLinkage, constant, "", _gc.llvmModule() );
     
     llvm::Constant* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0); // Access the structure of the array
@@ -79,7 +79,7 @@
     
     arrayStruct.push_back( iptr );
     
-    const llvm::StructType* structType = dynamic_cast<const llvm::StructType*>( m_type->data()->type() );
+    const llvm::StructType* structType = dynamic_cast<const llvm::StructType*>( m_type->d->type() );
     
 /*    GTL_DEBUG( *structType );
     GTL_DEBUG( arrayStruct[0] );
@@ -94,7 +94,7 @@
     {
       members.push_back( _gc.codeGenerator()->convertConstantTo( m_expressions[i]->generateValue( _gc, _bb).constant(), m_expressions[i]->type(), (*m_type->structDataMembers())[i].type() ) );
     }
-    const llvm::StructType* structType = dynamic_cast<const llvm::StructType*>( m_type->data()->type() );
+    const llvm::StructType* structType = dynamic_cast<const llvm::StructType*>( m_type->d->type() );
     return GTLCore::ExpressionResult(
           llvm::ConstantStruct::get( structType, members ) );
   }

Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.cpp	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.cpp	2008-05-21 21:56:42 UTC (rev 182)
@@ -128,13 +128,13 @@
     {
       VariableExpression* varex = dynamic_cast<VariableExpression*>( *it);
       GTL_ASSERT( varex );
-      GTL_ASSERT( varex->variable()->pointer()->getType() == llvm::PointerType::get( oparam_it->type()->data()->type(), 0) );
+      GTL_ASSERT( varex->variable()->pointer()->getType() == llvm::PointerType::get( oparam_it->type()->d->type(), 0) );
       convertedParams.push_back( varex->variable()->pointer() );
-      GTL_DEBUG(*varex->variable()->pointer()->getType() << " " << *oparam_it->type()->data()->type() );
+      GTL_DEBUG(*varex->variable()->pointer()->getType() << " " << *oparam_it->type()->d->type() );
     } else {
       llvm::Value* value = (*it)->generateValue(_gc, bb).value();
       GTL_ASSERT( value );
-      if( oparam_it->type()->data()->type()->isFirstClassType() )
+      if( oparam_it->type()->d->type()->isFirstClassType() )
       {
         value = _gc.codeGenerator()-> convertValueTo( bb, value, (*it)->type(), oparam_it->type() );
       }

Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/FunctionDeclaration.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/FunctionDeclaration.cpp	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/FunctionDeclaration.cpp	2008-05-21 21:56:42 UTC (rev 182)
@@ -92,17 +92,17 @@
   for(std::vector< Parameter >::const_iterator it = m_function->parameters().begin();
       it != m_function->parameters().end(); ++it)
   {
-    if( it->output() or not it->type()->data()->type()->isFirstClassType() )
+    if( it->output() or not it->type()->d->type()->isFirstClassType() )
     {
-      params.push_back( llvm::PointerType::get( it->type()->data()->type(), 0 ) );
+      params.push_back( llvm::PointerType::get( it->type()->d->type(), 0 ) );
     } else {
-      params.push_back( it->type()->data()->type() );
+      params.push_back( it->type()->d->type() );
     }
   }
   // List of functions
   std::vector<llvm::Function*> functions( params.size() + 1 );
   // Generate the full function
-  llvm::FunctionType* definitionType = llvm::FunctionType::get( m_function->returnType()->data()->type(), params, false );
+  llvm::FunctionType* definitionType = llvm::FunctionType::get( m_function->returnType()->d->type(), params, false );
   GTLCore::String fullFunctionName = GTLCore::Function::Data::symbolName( m_function->name(), m_function->parameters());
   llvm::Function* fullFunction = _codeGenerator->createFunction(definitionType, fullFunctionName );
   functions[ params.size() ] = fullFunction;
@@ -114,7 +114,7 @@
     // Create the function type
     params.pop_back(); // remove the last parameter
     gtlParams.pop_back(); // remove the last parameter
-    llvm::FunctionType* definitionType = llvm::FunctionType::get( m_function->returnType()->data()->type(), params, false );
+    llvm::FunctionType* definitionType = llvm::FunctionType::get( m_function->returnType()->d->type(), params, false );
     // Create the function
     llvm::Function* function = _codeGenerator->createFunction( definitionType, 
         GTLCore::Function::Data::symbolName(m_function->name() , gtlParams ) );

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Accessor_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Accessor_p.cpp	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Accessor_p.cpp	2008-05-21 21:56:42 UTC (rev 182)
@@ -236,7 +236,7 @@
   {
     llvm::Value* ptr = new llvm::GetElementPtrInst( _pointer, indexes.begin(), indexes.end(), "", _currentBlock);
     llvm::Value* array = new llvm::AllocaInst::AllocaInst(
-                    type()->arrayType()->data()->type(), _size, "", _currentBlock);
+                    type()->arrayType()->d->type(), _size, "", _currentBlock);
     new llvm::StoreInst( array, ptr, "", _currentBlock);
   }
 }

Modified: trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt	2008-05-21 21:56:42 UTC (rev 182)
@@ -40,6 +40,7 @@
   ParserBase_p.cpp
   Token_p.cpp
   Type_p.cpp
+  TypeManager_p.cpp
   VariableNG_p.cpp
   VirtualMachine_p.cpp
   ${LLVM_NATIVE_OBJECTS}

Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp	2008-05-21 21:56:42 UTC (rev 182)
@@ -207,27 +207,27 @@
   GTL_ASSERT(_value);
   GTL_ASSERT(_valueType);
   GTL_ASSERT(_targetType);
-  if(_value->getType() == _targetType->data()->type() )
+  if(_value->getType() == _targetType->d->type() )
   { // Don't cast the value as it has allready the correct type
     return _value;
   }
-  GTL_ASSERT(_targetType->data()->type()->isFirstClassType());
+  GTL_ASSERT(_targetType->d->type()->isFirstClassType());
   GTL_ASSERT(_value->getType()->isFirstClassType());
   return llvm::CastInst::create(
-                      llvm::CastInst::getCastOpcode(_value, _valueType->isSigned(), _targetType->data()->type(), _targetType->isSigned()), _value, _targetType->data()->type(), "", _currentBlock );
+                      llvm::CastInst::getCastOpcode(_value, _valueType->isSigned(), _targetType->d->type(), _targetType->isSigned()), _value, _targetType->d->type(), "", _currentBlock );
 }
 
 llvm::Constant* CodeGenerator::convertConstantTo(llvm::Constant* _constant, const Type* _constantType, const Type* _targetType)
 {
-  GTL_DEBUG( *_constant->getType() << " " << *_targetType->data()->type() );
-  if(_constant->getType() == _targetType->data()->type() )
+  GTL_DEBUG( *_constant->getType() << " " << *_targetType->d->type() );
+  if(_constant->getType() == _targetType->d->type() )
   { // Don't cast the value as it has allready the correct type
     return _constant;
   }
-  GTL_ASSERT(_targetType->data()->type()->isFirstClassType());
+  GTL_ASSERT(_targetType->d->type()->isFirstClassType());
   GTL_ASSERT(_constant->getType()->isFirstClassType());
   return llvm::ConstantExpr::getCast(
-                      (unsigned)llvm::CastInst::getCastOpcode(_constant, _constantType->isSigned(), _targetType->data()->type(), _targetType->isSigned()), _constant, _targetType->data()->type() );
+                      (unsigned)llvm::CastInst::getCastOpcode(_constant, _constantType->isSigned(), _targetType->d->type(), _targetType->isSigned()), _constant, _targetType->d->type() );
 }
 
 

Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp	2008-05-21 21:56:42 UTC (rev 182)
@@ -45,6 +45,7 @@
 #include "Function_p.h"
 
 #include "TypeManager.h"
+#include "TypeManager_p.h"
 
 using namespace GTLCore;
 
@@ -90,7 +91,7 @@
   {
     GTLCore::String name = d->currentToken.string;
     getNextToken();
-    if( d->compiler->typeManager()->isKnownType( name ) )
+    if( d->compiler->typeManager()->d->isKnownType( name ) )
     { // It has allready been declared
       reportError( name + " has allready been declared", d->currentToken);
     } else {
@@ -135,7 +136,7 @@
         if( isOfType( d->currentToken, GTLCore::Token::SEMI ) )
         {
           getNextToken();
-          d->compiler->typeManager()->createStructure( name, members);
+          d->compiler->typeManager()->d->createStructure( name, members);
         }
       }
     }
@@ -1109,7 +1110,7 @@
 
 bool ParserBase::isType( const GTLCore::Token& token )
 {
-  return token.isNativeType() or ( token.type == GTLCore::Token::IDENTIFIER and d->compiler->typeManager()->isKnownType( token.string ) );
+  return token.isNativeType() or ( token.type == GTLCore::Token::IDENTIFIER and d->compiler->typeManager()->d->isKnownType( token.string ) );
 }
 
 // Context management

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp	2008-05-21 21:56:42 UTC (rev 182)
@@ -85,16 +85,6 @@
 
 //-------- Type -------//
 
-struct Type::Private {
-  DataType dataType;
-  int size;
-  const Type* arrayType;
-  GTLCore::String structName;
-  std::vector<StructDataMember>* structDataMembers;
-  std::vector<Type::StructFunctionMember>* structFunctionMembers;
-  Data* data;
-};
-
 const Type* Type::Undefined = new Type(Type::UNDEFINED);
 const Type* Type::Boolean = new Type(Type::BOOLEAN);
 const Type* Type::Integer8 = new Type(Type::INTEGER8);
@@ -109,7 +99,7 @@
 const Type* Type::Void = new Type(Type::VOID);
 const Type* Type::Pointer = new Type(Type::POINTER);
 
-Type::Type(DataType _dataType) : d(new Private)
+Type::Type(DataType _dataType) : d(new Private(_dataType))
 {
   GTL_DEBUG("Create type for " << _dataType);
   assert(_dataType != STRUCTURE and _dataType != ARRAY);
@@ -121,7 +111,6 @@
   d->arrayType = 0;
   d->structDataMembers = 0;
   d->structFunctionMembers = 0;
-  d->data = new Data( _dataType );
 }
 
 Type::Type(const GTLCore::String& _structName, const std::vector<StructDataMember>& _members) : d(new Private)
@@ -135,9 +124,9 @@
   for(std::vector<StructDataMember>::iterator it = d->structDataMembers->begin();
       it != d->structDataMembers->end(); ++it)
   {
-    types.push_back(it->type()->data()->type());
+    types.push_back(it->type()->d->type());
   }
-  d->data = new Data(llvm::StructType::get(types));
+  d->setType(llvm::StructType::get(types));
 }
 
 Type::Type(const GTLCore::String& _structName, const std::vector<Type::StructDataMember>& _members, const std::vector<Type::StructFunctionMember>& _functionMembers) : d(new Private)
@@ -151,9 +140,9 @@
   for(std::vector<StructDataMember>::iterator it = d->structDataMembers->begin();
       it != d->structDataMembers->end(); ++it)
   {
-    types.push_back(it->type()->data()->type());
+    types.push_back(it->type()->d->type());
   }
-  d->data = new Data(llvm::StructType::get(types));
+  d->setType( llvm::StructType::get(types));
 }
 
 Type::Type(const Type* _arrayType) : d(new Private)
@@ -164,8 +153,8 @@
   d->structFunctionMembers = 0;
   std::vector< const llvm::Type * > types;
   types.push_back(llvm::Type::Int32Ty);
-  types.push_back( llvm::PointerType::get( _arrayType->data()->type(), 0));
-  d->data = new Data(llvm::StructType::get(types));
+  types.push_back( llvm::PointerType::get( _arrayType->d->type(), 0));
+  d->setType( llvm::StructType::get(types));
 }
 
 Type::Type(const Type& _rhs) : d(new Private(*_rhs.d))
@@ -180,7 +169,6 @@
 
 Type::~Type()
 {
-  delete d->data;
   delete d;
 }
 
@@ -189,14 +177,14 @@
   return d->dataType;
 }
 
-const Type::Data* Type::data() const
+const Type* Type::arrayType() const
 {
-  return d->data;
+  return d->arrayType;
 }
 
-const Type* Type::arrayType() const
+const GTLCore::String& Type::structName() const
 {
-  return d->arrayType;
+  return d->structName;
 }
 
 const std::vector<Type::StructDataMember>* Type::structDataMembers() const

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type.h	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type.h	2008-05-21 21:56:42 UTC (rev 182)
@@ -24,15 +24,32 @@
 #include <list>
 #include <vector>
 
+namespace OpenCTL {
+  class Compiler;
+  class Program;
+}
+
 namespace GTLCore {
   class Parameter;
+  namespace AST {
+    class CoumpoundExpression;
+    class FunctionCallExpression;
+    class FunctionDeclaration;
+  }
   /**
    * This class holds information about a type.
    * 
    */
   class Type {
+    friend class ArrayAccessor;
+    friend class AST::CoumpoundExpression;
+    friend class AST::FunctionCallExpression;
+    friend class AST::FunctionDeclaration;
+    friend class OpenCTL::Compiler;
+    friend class OpenCTL::Program;
+    friend class CodeGenerator;
+    friend class VariableNG;
     public:
-      class Data;
       enum DataType {
         UNDEFINED,
         BOOLEAN,
@@ -125,16 +142,14 @@
     public:
       DataType dataType() const;
       /**
-       * The pointer return by this function is part of the private API.
-       * @return a point to the internal pointer of the Type
-       * @internal
-       */
-      const Data* data() const;
-      /**
        * @return the type of the array, or 0 if not an array
        */
       const Type* arrayType() const;
       /**
+       * @return the name of the structure
+       */
+      const GTLCore::String& structName() const;
+      /**
        * @return a vector of the struct members, or 0 if not a structure
        */
       const std::vector<Type::StructDataMember>* structDataMembers() const;

Modified: trunk/OpenGTL/OpenGTL/GTLCore/TypeManager.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/TypeManager.cpp	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenGTL/GTLCore/TypeManager.cpp	2008-05-21 21:56:42 UTC (rev 182)
@@ -19,19 +19,14 @@
 
 #include "TypeManager.h"
 
-#include <map>
+#include "TypeManager_p.h"
 
 using namespace GTLCore;
 
-struct TypeManager::Private {
-  std::map< GTLCore::String, const GTLCore::Type*> knownTypes;
-  mutable std::map< const GTLCore::Type*, const GTLCore::Type*> knownArrays;
-  int count;
-};
+std::map< const GTLCore::Type*, const GTLCore::Type*> TypeManager::Private::knownArrays;
 
 TypeManager::TypeManager() : d(new Private)
 {
-  d->count = 0;
 }
 
 TypeManager::~TypeManager()
@@ -39,11 +34,6 @@
   delete d;
 }
 
-bool TypeManager::isKnownType(const GTLCore::String& _name) const
-{
-  return d->knownTypes.find(_name) != d->knownTypes.end();
-}
-
 const GTLCore::Type* TypeManager::getStructure( const GTLCore::String& _name) const
 {
   std::map< GTLCore::String, const GTLCore::Type*>::const_iterator it = d->knownTypes.find(_name);
@@ -54,17 +44,6 @@
   return it->second;
 }
 
-const GTLCore::Type* TypeManager::createStructure( const GTLCore::String& _name, const std::vector<GTLCore::Type::StructDataMember>& _members)
-{
-  if(isKnownType( _name) )
-  {
-    return 0;
-  }
-  GTLCore::Type* t = new GTLCore::Type( _name, _members);
-  d->knownTypes[ _name ] = t;
-  return t;
-}
-
 const GTLCore::Type* TypeManager::getArray( const GTLCore::Type* _type) const
 {
   std::map< const GTLCore::Type*, const GTLCore::Type*>::const_iterator it = d->knownArrays.find( _type );

Modified: trunk/OpenGTL/OpenGTL/GTLCore/TypeManager.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/TypeManager.h	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenGTL/GTLCore/TypeManager.h	2008-05-21 21:56:42 UTC (rev 182)
@@ -25,17 +25,11 @@
 
 namespace GTLCore {
   class TypeManager {
+    friend class ParserBase;
     public:
       TypeManager();
       ~TypeManager();
-      /**
-       * @param name the name of the type
-       * @return true if the name given as argument is the name of a known type
-       *         for this manager
-       */
-      bool isKnownType(const GTLCore::String& name) const;
       const GTLCore::Type* getStructure( const GTLCore::String& name) const;
-      const GTLCore::Type* createStructure( const GTLCore::String& name, const std::vector<GTLCore::Type::StructDataMember>& members);
       /**
        * @param type the type of the elements in the array
        * @return the array type

Added: trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.cpp	                        (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.cpp	2008-05-21 21:56:42 UTC (rev 182)
@@ -0,0 +1,38 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "TypeManager_p.h"
+
+using namespace GTLCore;
+
+bool TypeManager::Private::isKnownType(const GTLCore::String& _name) const
+{
+  return knownTypes.find(_name) != knownTypes.end();
+}
+
+const GTLCore::Type* TypeManager::Private::createStructure( const GTLCore::String& _name, const std::vector<GTLCore::Type::StructDataMember>& _members)
+{
+  if(isKnownType( _name) )
+  {
+    return 0;
+  }
+  GTLCore::Type* t = new GTLCore::Type( _name, _members);
+  knownTypes[ _name ] = t;
+  return t;
+}


Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.h	                        (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.h	2008-05-21 21:56:42 UTC (rev 182)
@@ -0,0 +1,41 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _GTLCORE_TYPEMANAGER_P_H
+#define _GTLCORE_TYPEMANAGER_P_H
+
+#include "GTLCore/TypeManager.h"
+
+#include <map>
+
+namespace GTLCore {
+  struct TypeManager::Private {
+    std::map< GTLCore::String, const GTLCore::Type*> knownTypes;
+    static std::map< const GTLCore::Type*, const GTLCore::Type*> knownArrays;
+    /**
+      * @param name the name of the type
+      * @return true if the name given as argument is the name of a known type
+      *         for this manager
+      */
+    bool isKnownType(const GTLCore::String& name) const;
+    const GTLCore::Type* createStructure( const GTLCore::String& name, const std::vector<GTLCore::Type::StructDataMember>& members);
+  };
+}
+
+#endif


Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp	2008-05-21 21:56:42 UTC (rev 182)
@@ -79,7 +79,7 @@
   return d->parameters;
 }
 
-Type::Data::Data( Type::DataType _dataType)
+Type::Private::Private( Type::DataType _dataType)
 {
   switch( _dataType )
   {
@@ -122,3 +122,9 @@
       break;
   }
 }
+
+void Type::Private::setType( const llvm::Type* _type)
+{
+  GTL_ASSERT(m_type == 0);
+  m_type = _type;
+}

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h	2008-05-21 21:56:42 UTC (rev 182)
@@ -63,13 +63,22 @@
       Private* const d;
   };
   
-  class Type::Data {
+  struct Type::Private {
+    friend class Type;
     public:
-      Data( Type::DataType _dataType );
-      Data( const llvm::Type* _type ) : m_type(_type) {}
+      Private() : m_type(0) {}
+      Private( Type::DataType _dataType );
+      Private( const llvm::Type* _type ) : m_type(_type) {}
       const llvm::Type * type() const { return m_type; }
     private:
+      void setType( const llvm::Type* _type);
       const llvm::Type* m_type;
+      DataType dataType;
+      int size;
+      const Type* arrayType;
+      GTLCore::String structName;
+      std::vector<StructDataMember>* structDataMembers;
+      std::vector<Type::StructFunctionMember>* structFunctionMembers;
   };
   
 }

Modified: trunk/OpenGTL/OpenGTL/GTLCore/VariableNG_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/VariableNG_p.cpp	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenGTL/GTLCore/VariableNG_p.cpp	2008-05-21 21:56:42 UTC (rev 182)
@@ -65,7 +65,7 @@
 llvm::BasicBlock* VariableNG::initialise( GTLCore::GenerationContext& _generationContext, llvm::BasicBlock* _bb, llvm::Value* _initialiser, const GTLCore::Type* _initialiserType, const std::list<llvm::Value*>& _initialSize )
 {
   GTL_DEBUG( _initialSize.size() );
-  initialise( _generationContext, new llvm::AllocaInst::AllocaInst( d->type->data()->type(), llvm::ConstantInt::get(llvm::Type::Int32Ty, 1), "", _bb) );
+  initialise( _generationContext, new llvm::AllocaInst::AllocaInst( d->type->d->type(), llvm::ConstantInt::get(llvm::Type::Int32Ty, 1), "", _bb) );
   _bb = d->accessor->initialise( _generationContext, _bb, d->pointer, _initialSize);
   _bb = d->accessor->initialiseValue( _generationContext, _bb,  d->pointer, _initialiser, _initialiserType);
   return _bb;

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp	2008-05-21 21:56:42 UTC (rev 182)
@@ -104,6 +104,7 @@
 
 const GTLCore::Type* Parser::parseType()
 {
+#if 0
   switch( currentToken().type )
   {
     case GTLCore::Token::IMAGE:
@@ -118,6 +119,8 @@
     default:
       return ParserBase::parseType();
   }
+#endif
+  return 0;
 }
 
 AST::Statement* Parser::parseStatement()

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.cpp	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.cpp	2008-05-21 21:56:42 UTC (rev 182)
@@ -22,34 +22,62 @@
 #include "GTLCore/Type.h"
 #include "GTLCore/Type_p.h"
 #include "GTLCore/Macros.h"
+#include "GTLCore/TypeManager.h"
 
 #include "Debug.h"
 
 using namespace OpenShiva;
 
-static GTLCore::Type* s_imageType = 0;
-static GTLCore::Type* s_regionType = 0;
-static GTLCore::Type* s_pixelType = 0;
+// static GTLCore::Type* s_imageType = 0;
+// static GTLCore::Type* s_regionType = 0;
+// static GTLCore::Type* s_pixelType = 0;
+// 
+// const GTLCore::Type* Types::image()
+// {
+//   SHIVA_ASSERT( s_imageType );
+//   return s_imageType;
+// }
+// 
+// const GTLCore::Type* Types::region()
+// {
+//   SHIVA_ASSERT( s_regionType );
+//   return s_regionType;
+// }
+// 
+// const GTLCore::Type* Types::pixel()
+// {
+//   SHIVA_ASSERT( s_pixelType );
+//   return s_pixelType;
+// }
 
-const GTLCore::Type* Types::image()
-{
-  SHIVA_ASSERT( s_imageType );
-  return s_imageType;
-}
+// typedef std::map< GTLCore::Type*, std::vector< GTLCore::Type* > > typeToVTypes;
+// typedef std::map< GTLCore::PixelDescription&, GTLCore::Type* > pdToType;
 
-const GTLCore::Type* Types::region()
+struct Types::Private
 {
-  SHIVA_ASSERT( s_regionType );
-  return s_regionType;
-}
-
-const GTLCore::Type* Types::pixel()
+//   static typeToVTypes s_fixTypes;
+//   static pdToType s_specialTypes;
+};
+/*
+void Types::fillTypeManager( GTLCore::TypeManager* _typeManager, const GTLCore::PixelDescription& _pixelDescription, const GTLCore::Type* _referenceDepth  )
 {
-  SHIVA_ASSERT( s_pixelType );
-  return s_pixelType;
+  typeToVTypes::iterator it = Private::s_fixTypes.find( _referenceDepth );
+  if( it == Private::s_fixTypes.end() )
+  {
+  } else {
+    for( std::vector< GTLCore::Type* >::iterator itTypes = it->second.begin();
+         itTypes != it->second.end(); ++itTypes )
+    {
+      _typeManager->createStructure( (*itTypes)->
+    }
+  }
+  
+  
 }
+*/
 
 
+#if 0
 STATIC_INITIALISATION(OpenShivaTypes)
 {
   { // Image
@@ -74,3 +102,4 @@
     s_pixelType = new GTLCore::Type("pixel", dataMembers, functionMembers);
   }
 }
+#endif

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.h	2008-05-19 13:01:37 UTC (rev 181)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.h	2008-05-21 21:56:42 UTC (rev 182)
@@ -22,6 +22,7 @@
 
 namespace GTLCore {
   class Type;
+  class TypeManager;
 }
 
 namespace OpenShiva {
@@ -42,9 +43,9 @@
   }
   class Types {
     public:
-      static const GTLCore::Type* image();
-      static const GTLCore::Type* region();
-      static const GTLCore::Type* pixel();
+//       static void fillTypeManager( GTLCore::TypeManager*, const GTLCore::PixelDescription& _pixelDescription, const GTLCore::Type* _referenceDepth  );
+    private:
+      struct Private;
   };
 }
 


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