[opengtl-commits] [400] cleanup pointer in the pixel visitor too

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


Revision: 400
Author:   cyrille
Date:     2008-09-20 12:11:55 +0200 (Sat, 20 Sep 2008)

Log Message:
-----------
cleanup pointer in the pixel visitor too

Modified Paths:
--------------
    trunk/OpenGTL/OpenShiva/OpenShiva/PixelVisitor_p.cpp


Modified: trunk/OpenGTL/OpenShiva/OpenShiva/PixelVisitor_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/PixelVisitor_p.cpp	2008-09-20 09:57:09 UTC (rev 399)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/PixelVisitor_p.cpp	2008-09-20 10:11:55 UTC (rev 400)
@@ -20,10 +20,14 @@
 #include "PixelVisitor_p.h"
 
 // LLVM
+#include <llvm/Constant.h>
+#include <llvm/BasicBlock.h>
 #include <llvm/Instructions.h>
+#include <llvm/Function.h>
 
 #include "GTLCore/ExpressionResult_p.h"
 #include "GTLCore/CodeGenerator_p.h"
+#include "GTLCore/GenerationContext_p.h"
 #include "GTLCore/Macros_p.h"
 #include "GTLCore/Type.h"
 
@@ -104,6 +108,20 @@
 
 llvm::BasicBlock* PixelVisitor::cleanUp( GTLCore::GenerationContext& _generationContext, llvm::BasicBlock* _currentBlock, llvm::Value* _pointer, const GTLCore::Type* _pointerType, llvm::Value* _donttouch, bool _allocatedInMemory, bool _ignoreCount, bool _deletePointer ) const
 {
+  
+  if( _deletePointer )
+  {
+    
+    llvm::Value* test = GTLCore::CodeGenerator::createStrictInferiorExpression( _currentBlock, GTLCore::CodeGenerator::getCountFieldOf( _currentBlock, _pointer), GTLCore::Type::Integer32, GTLCore::CodeGenerator::integerToConstant( 1 ), GTLCore::Type::Integer32 );
+    llvm::BasicBlock* firstIfBlock = llvm::BasicBlock::Create("firstIfBlockStructureVisitorCleanUp");
+    _generationContext.llvmFunction()->getBasicBlockList().push_back( firstIfBlock);
+    llvm::BasicBlock* afterIfBlock = llvm::BasicBlock::Create("afterIfBlockStructureVisitorCleanUp");
+    _generationContext.llvmFunction()->getBasicBlockList().push_back( afterIfBlock);
+    new llvm::FreeInst( _pointer, firstIfBlock );
+    GTLCore::CodeGenerator::createIfStatement( _currentBlock, test, GTLCore::Type::Boolean, firstIfBlock, firstIfBlock, afterIfBlock );
+    return afterIfBlock;
+  }
+  
   return _currentBlock;
 }
 


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