[opengtl-commits] [266] add code to replace the pointer of a variable by an other one

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


Revision: 266
Author:   cyrille
Date:     2008-06-29 11:58:04 +0200 (Sun, 29 Jun 2008)

Log Message:
-----------
add code to replace the pointer of a variable by an other one

Modified Paths:
--------------
    trunk/OpenGTL/OpenGTL/GTLCore/VariableNG_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/VariableNG_p.h


Modified: trunk/OpenGTL/OpenGTL/GTLCore/VariableNG_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/VariableNG_p.cpp	2008-06-29 08:53:15 UTC (rev 265)
+++ trunk/OpenGTL/OpenGTL/GTLCore/VariableNG_p.cpp	2008-06-29 09:58:04 UTC (rev 266)
@@ -103,6 +103,14 @@
   return d->visitor->set( _generationContext, _currentBlock, d->pointer, d->type, _value, _valueType, d->allocatedInMemory);
 }
 
+llvm::BasicBlock* VariableNG::replacePointer( GenerationContext& _generationContext, llvm::BasicBlock* _currentBlock, llvm::Value* _pointer)
+{
+  GTL_ASSERT( _pointer->getType() == d->pointer->getType() );
+  _currentBlock = cleanUp( _generationContext, _currentBlock, 0 );
+  d->pointer = _pointer;
+  return _currentBlock;
+}
+
 llvm::Value* VariableNG::pointer()
 {
   return d->pointer;

Modified: trunk/OpenGTL/OpenGTL/GTLCore/VariableNG_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/VariableNG_p.h	2008-06-29 08:53:15 UTC (rev 265)
+++ trunk/OpenGTL/OpenGTL/GTLCore/VariableNG_p.h	2008-06-29 09:58:04 UTC (rev 266)
@@ -74,6 +74,16 @@
        */
       llvm::BasicBlock* set(GenerationContext&, llvm::BasicBlock* _currentBlock, llvm::Value* _value, const GTLCore::Type* _valueType);
       /**
+       * Replace the pointer of this variable by a pointer of the same type.
+       * 
+       * @param _pointer new pointer
+       * 
+       * WARNING: this VariableNG will then take ownership of the Value, and you can only
+       *          replace by a pointer which was allocated in memory.
+       *          This function will call cleanUp.
+       */
+      llvm::BasicBlock* replacePointer( GenerationContext& _generationContext, llvm::BasicBlock* _currentBlock, llvm::Value* _pointer);
+      /**
        * @return the pointer for this variable
        */
       llvm::Value* pointer();


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