[opengtl-commits] [216] * cleanup

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


Revision: 216
Author:   cyrille
Date:     2008-06-22 11:13:29 +0200 (Sun, 22 Jun 2008)

Log Message:
-----------
* cleanup
* make it possible to have a custom visitor for types

Modified Paths:
--------------
    trunk/OpenGTL/OpenGTL/GTLCore/AST/BinaryExpression.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Type.h
    trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h
    trunk/OpenGTL/OpenGTL/GTLCore/Visitor_p.cpp


Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/BinaryExpression.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/BinaryExpression.cpp	2008-06-21 16:49:12 UTC (rev 215)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/BinaryExpression.cpp	2008-06-22 09:13:29 UTC (rev 216)
@@ -182,31 +182,9 @@
   return _gc.codeGenerator()->createModuloExpression(bb, leftHandSide()->generateValue( _gc, bb), leftHandSide()->type(), rightHandSide()->generateValue( _gc, bb), rightHandSide()->type() );
 }
 
-#if 0
-
 llvm::BasicBlock* AssignementBinaryExpression::generateStatement( GenerationContext& _gc, llvm::BasicBlock* _bb) const
 {
   GTL_ASSERT( m_lhs);
-  return m_lhs->assignValue( _gc, _bb, rightHandSide() );
-}
-
-#endif
-
-#if 0
-GTLCore::ExpressionResult AssignementBinaryExpression::generateValue( GenerationContext& _gc, llvm::BasicBlock* _bb ) const
-{
-  GTL_ASSERT( m_lhs);
-  llvm::BasicBlock* bbr = m_lhs->assignValue( _gc, _bb, rightHandSide() );
-  GTL_ASSERT( bbr == _bb);
-  return GTLCore::ExpressionResult( m_lhs->generateValue( _gc, _bb) );
-}
-#endif
-
-#if 1
-
-llvm::BasicBlock* AssignementBinaryExpression::generateStatement( GenerationContext& _gc, llvm::BasicBlock* _bb) const
-{
-  GTL_ASSERT( m_lhs);
   llvm::Value* ptr_ = m_lhs->pointer( _gc, _bb );
   const Visitor* visitor = Visitor::getVisitorFor( m_lhs->type() );
   GTL_DEBUG( *m_lhs->type() );
@@ -215,9 +193,6 @@
                       rightHandSide()->generateValue( _gc, _bb).value(), rightHandSide()->type() );
 }
 
-#endif
-
-
 GTLCore::ExpressionResult AssignementBinaryExpression::generateValue( GenerationContext& _gc, llvm::BasicBlock* _bb ) const
 {
   GTL_ASSERT( m_lhs);

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type.h	2008-06-21 16:49:12 UTC (rev 215)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type.h	2008-06-22 09:13:29 UTC (rev 216)
@@ -61,6 +61,7 @@
     friend class ParserBase;
     friend class Function;
     friend class TypeManager;
+    friend class Visitor;
     public:
       enum DataType {
         UNDEFINED,

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp	2008-06-21 16:49:12 UTC (rev 215)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp	2008-06-22 09:13:29 UTC (rev 216)
@@ -75,7 +75,7 @@
   return d->function;
 }
 
-Type::Private::Private( Type::DataType _dataType)
+Type::Private::Private( Type::DataType _dataType) : dataType(_dataType), m_visitor(0)
 {
   switch( _dataType )
   {
@@ -182,3 +182,13 @@
   return 0;
 }
 
+const Visitor* Type::Private::visitor() const
+{
+  return m_visitor;
+}
+
+void Type::Private::setVisitor( Visitor* _visitor )
+{
+  GTL_ASSERT( m_visitor == 0 );
+  m_visitor = _visitor;
+}

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h	2008-06-21 16:49:12 UTC (rev 215)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h	2008-06-22 09:13:29 UTC (rev 216)
@@ -28,6 +28,7 @@
 
 namespace GTLCore {
   class Function;
+  class Visitor;
   class Type::StructFunctionMember {
     public:
       /**
@@ -72,9 +73,8 @@
   struct Type::Private {
     friend class Type;
     public:
-      Private() : m_type(0) {}
+      Private() : m_type(0), m_visitor(0) {}
       Private( Type::DataType _dataType );
-      Private( const llvm::Type* _type ) : m_type(_type) {}
       const llvm::Type * type() const { return m_type; }
       void addFunctionMember( const StructFunctionMember& );
       void addPrivateFunctionMember( const StructFunctionMember& );
@@ -87,6 +87,8 @@
        * @return the private function member associated with that name, or null if none
        */
       const Type::StructFunctionMember* privateFunctionMember( const GTLCore::String&) const;
+      const Visitor* visitor() const;
+      void setVisitor( Visitor* );
     private:
       void setType( const llvm::Type* _type);
       const llvm::Type* m_type;
@@ -97,6 +99,7 @@
       std::vector<StructDataMember>* structDataMembers;
       std::vector<Type::StructFunctionMember>* structFunctionMembers;
       std::vector<Type::StructFunctionMember>* structPrivateFunctionMembers;
+      Visitor* m_visitor;
   };
   
 }

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Visitor_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Visitor_p.cpp	2008-06-21 16:49:12 UTC (rev 215)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Visitor_p.cpp	2008-06-22 09:13:29 UTC (rev 216)
@@ -65,8 +65,11 @@
 
 const Visitor* Visitor::getVisitorFor(const GTLCore::Type* _type)
 {
-  if( _type->dataType() == Type::ARRAY )
+  if( _type->d->visitor() )
   {
+    return _type->d->visitor();
+  } else if( _type->dataType() == Type::ARRAY )
+  {
     return arrayVisitor;
   } else if( _type->dataType() == Type::STRUCTURE ) {
     return structureVisitor;


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