[opengtl-commits] [204] * make some function of GTLCore::CodeGenerator static |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 204
Author: cyrille
Date: 2008-06-19 21:27:31 +0200 (Thu, 19 Jun 2008)
Log Message:
-----------
* make some function of GTLCore::CodeGenerator static
* GTL_ASSERT(false) => GTL_ABORT
* implement most of the generation of evaluatePixeles (it is mostly missing the synchronisation between the output pixel / image, and it's also missing use of sources images)
* implement Image
Modified Paths:
--------------
trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp
trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp
trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h
trunk/OpenGTL/OpenGTL/GTLCore/Function.h
trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h
trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp
trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/Value.cpp
trunk/OpenGTL/OpenGTL/GTLCore/VirtualMachine_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/VirtualMachine_p.h
trunk/OpenGTL/OpenGTL/GTLCore/Visitor_p.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.h
trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.h
trunk/OpenGTL/OpenShiva/OpenShiva/Debug.h
trunk/OpenGTL/OpenShiva/OpenShiva/Image.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/Image.h
trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.h
trunk/OpenGTL/OpenShiva/OpenShiva/Lexer_p.h
trunk/OpenGTL/OpenShiva/tests/imagegenerators/PlainGenerator.shiva
trunk/OpenGTL/OpenShiva/tests/library/TestOpenShiva.cpp
trunk/OpenGTL/OpenShiva/tests/parse/CMakeLists.txt
trunk/OpenGTL/OpenShiva/tests/structures/region.shiva
trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp
Modified: trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp 2008-06-19 19:27:31 UTC (rev 204)
@@ -241,9 +241,9 @@
{ // if a buffer is needed that means that the value must be converted
if(srcChannelsTypes[i] == GTLCore::Type::Half)
{
- convertedIn = cg.convertFromHalf( bodyBlock, convertedIn);
+ convertedIn = GTLCore::CodeGenerator::convertFromHalf( gc, bodyBlock, convertedIn);
} else {
- convertedIn = cg.convertValueTo( bodyBlock, convertedIn, srcChannelsTypes[i], GTLCore::Type::Integer32);
+ convertedIn = GTLCore::CodeGenerator::convertValueTo( bodyBlock, convertedIn, srcChannelsTypes[i], GTLCore::Type::Integer32);
}
}
arguments.push_back( convertedIn );
@@ -302,9 +302,9 @@
llvm::Value* result = 0;
if( dstChannelsTypes[i] == GTLCore::Type::Half )
{
- result = cg.convertToHalf( bodyBlock, buffer[i]->get( gc, bodyBlock ), GTLCore::Type::Float );
+ result = GTLCore::CodeGenerator::convertToHalf( gc, bodyBlock, buffer[i]->get( gc, bodyBlock ), GTLCore::Type::Float );
} else {
- result = cg.convertValueTo( bodyBlock, buffer[i]->get( gc, bodyBlock ), GTLCore::Type::Integer32, dstChannelsTypes[i] );
+ result = GTLCore::CodeGenerator::convertValueTo( bodyBlock, buffer[i]->get( gc, bodyBlock ), GTLCore::Type::Integer32, dstChannelsTypes[i] );
}
OCTL_DEBUG( *result->getType() << *pointer->getType() );
new llvm::StoreInst( result, pointer, bodyBlock);
Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp 2008-06-19 19:27:31 UTC (rev 204)
@@ -98,6 +98,6 @@
return GTLCore::ExpressionResult(
llvm::ConstantStruct::get( structType, members ) );
}
- GTL_ASSERT(false);
+ GTL_ABORT("Can't generate coumpound value, neither array, neither expression.");
return GTLCore::ExpressionResult();
}
Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp 2008-06-19 19:27:31 UTC (rev 204)
@@ -236,22 +236,22 @@
-llvm::Value* CodeGenerator::convertToHalf( llvm::BasicBlock* currentBlock, llvm::Value* value, const GTLCore::Type* _valueType )
+llvm::Value* CodeGenerator::convertToHalf( GenerationContext& _generationContext, llvm::BasicBlock* currentBlock, llvm::Value* value, const GTLCore::Type* _valueType )
{
std::vector<const llvm::Type*> llvmArguments;
llvmArguments.push_back( llvm::Type::FloatTy );
- llvm::Function* func = dynamic_cast<llvm::Function*>( d->module->llvmModule()->getOrInsertFunction( "_Z10float2halff",
+ llvm::Function* func = dynamic_cast<llvm::Function*>( _generationContext.llvmModule()->getOrInsertFunction( "_Z10float2halff",
llvm::FunctionType::get( llvm::Type::Int16Ty , llvmArguments, false ) ) );
std::vector<llvm::Value*> convertedParams;
convertedParams.push_back( convertValueTo( currentBlock, value, _valueType, GTLCore::Type::Float ) );
return new llvm::CallInst( func, convertedParams.begin(), convertedParams.end(), "", currentBlock );
}
-llvm::Value* CodeGenerator::convertFromHalf( llvm::BasicBlock* currentBlock, llvm::Value* value)
+llvm::Value* CodeGenerator::convertFromHalf( GenerationContext& _generationContext, llvm::BasicBlock* currentBlock, llvm::Value* value)
{
std::vector<const llvm::Type*> llvmArguments;
llvmArguments.push_back( llvm::Type::Int16Ty );
- llvm::Function* func = dynamic_cast<llvm::Function*>( d->module->llvmModule()->getOrInsertFunction( "_Z10half2floatt",
+ llvm::Function* func = dynamic_cast<llvm::Function*>( _generationContext.llvmModule()->getOrInsertFunction( "_Z10half2floatt",
llvm::FunctionType::get( llvm::Type::FloatTy , llvmArguments, false ) ) );
std::vector<llvm::Value*> convertedParams;
convertedParams.push_back( convertValueTo( currentBlock, value, GTLCore::Type::Half, GTLCore::Type::Integer16 ) );
@@ -289,20 +289,20 @@
new llvm::BranchInst( test, update);
}
-llvm::BasicBlock* CodeGenerator::createIterationForStatement( llvm::Function* function, llvm::BasicBlock* before, GTLCore::VariableNG* variable, llvm::Value* maxValue, const Type* maxValueType, llvm::BasicBlock* firstAction, llvm::BasicBlock* lastAction)
+llvm::BasicBlock* CodeGenerator::createIterationForStatement( GenerationContext& generationContext, llvm::BasicBlock* before, GTLCore::VariableNG* variable, llvm::Value* maxValue, const Type* maxValueType, llvm::BasicBlock* firstAction, llvm::BasicBlock* lastAction)
{
// i < size
llvm::BasicBlock* forTestBlock = new llvm::BasicBlock("forTestBlock");
- function->getBasicBlockList().push_back( forTestBlock);
- GenerationContext generationContext( this, function, 0, d->module );
+ generationContext.llvmFunction()->getBasicBlockList().push_back( forTestBlock);
llvm::Value* forTest = createStrictInferiorExpression(forTestBlock, variable->get( generationContext, forTestBlock ), variable->type(), maxValue, maxValueType);
+ GTL_ASSERT(forTest);
// i += pixelSize
llvm::BasicBlock* updateBlock = new llvm::BasicBlock("updateBlock");
- function->getBasicBlockList().push_back( updateBlock);
- createIncrementExpression( updateBlock, variable );
+ generationContext.llvmFunction()->getBasicBlockList().push_back( updateBlock);
+ createIncrementExpression( generationContext, updateBlock, variable );
// Exit block
llvm::BasicBlock* finBlock = new llvm::BasicBlock("finBlock");
- function->getBasicBlockList().push_back( finBlock);
+ generationContext.llvmFunction()->getBasicBlockList().push_back( finBlock);
// Create for statement
createForStatement(before, forTestBlock, forTest, Type::Boolean, updateBlock, firstAction, lastAction, finBlock);
return finBlock;
@@ -323,9 +323,8 @@
name, d->module->llvmModule() );
}
-void CodeGenerator::createIncrementExpression( llvm::BasicBlock* currentBlock, VariableNG* var)
+void CodeGenerator::createIncrementExpression( GenerationContext& gc, llvm::BasicBlock* currentBlock, VariableNG* var)
{
- GenerationContext gc(this, 0, 0, 0);
var->set( gc, currentBlock, createAdditionExpression( currentBlock, var->get(gc, currentBlock), var->type(), integerToConstant(1), Type::Integer32), var->type());
}
@@ -505,9 +504,10 @@
if( v1->getType()->isFloatingPoint() )
{
return new llvm::FCmpInst( (llvm::FCmpInst::Predicate)floatPred, v1, v2, "", currentBlock );
- } else if( rhs->getType()->isInteger() ) {
+ } else if( v2->getType()->isInteger() ) {
return new llvm::ICmpInst( (llvm::ICmpInst::Predicate)integerPred, v1, v2, "", currentBlock );
} else {
+ GTL_ABORT("Invalid comparison");
return 0;
}
}
Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h 2008-06-19 19:27:31 UTC (rev 204)
@@ -90,10 +90,10 @@
// llvm::Value* convertValueTo(llvm::BasicBlock* currentBlock, llvm::Value* value, const llvm::Type* type);
// llvm::Constant* convertConstantTo(llvm::Constant* constant, const llvm::Type* type);
llvm::Value* convertPointerTo(llvm::BasicBlock* currentBlock, llvm::Value* value, const llvm::Type* type);
- llvm::Value* convertValueTo(llvm::BasicBlock* currentBlock, llvm::Value* value, const Type* valueType, const Type* type);
- llvm::Constant* convertConstantTo(llvm::Constant* constant, const Type* constantType, const Type* type);
- llvm::Value* convertToHalf( llvm::BasicBlock* currentBlock, llvm::Value* value, const Type* _valueType);
- llvm::Value* convertFromHalf( llvm::BasicBlock* currentBlock, llvm::Value* value);
+ static llvm::Value* convertValueTo(llvm::BasicBlock* currentBlock, llvm::Value* value, const Type* valueType, const Type* type);
+ static llvm::Constant* convertConstantTo(llvm::Constant* constant, const Type* constantType, const Type* type);
+ static llvm::Value* convertToHalf( GenerationContext& generationContext, llvm::BasicBlock* currentBlock, llvm::Value* value, const Type* _valueType);
+ static llvm::Value* convertFromHalf( GenerationContext& generationContext, llvm::BasicBlock* currentBlock, llvm::Value* value);
public: // Boolean Expression
llvm::Value* createOrExpression(llvm::BasicBlock* currentBlock, llvm::Value* lhs, const Type* lhsType, llvm::Value* rhs, const Type* rhsType);
ExpressionResult createOrExpression( llvm::BasicBlock* currentBlock, ExpressionResult lhs, const Type* lhsType, ExpressionResult rhs, const Type* rhsType);
@@ -113,9 +113,9 @@
llvm::Constant* createBitAndExpression( llvm::Constant* lhs, const Type* lhsType, llvm::Constant* rhs, const Type* rhsType);
public: // Arithmetic expressions
// Addition
- llvm::Value* createAdditionExpression(llvm::BasicBlock* currentBlock, llvm::Value* lhs, const Type* lhsType, llvm::Value* rhs, const Type* rhsType);
- ExpressionResult createAdditionExpression( llvm::BasicBlock* currentBlock, ExpressionResult lhs, const Type* lhsType, ExpressionResult rhs, const Type* rhsType);
- llvm::Constant* createAdditionExpression( llvm::Constant* lhs, const Type* lhsType, llvm::Constant* rhs, const Type* rhsType);
+ static llvm::Value* createAdditionExpression(llvm::BasicBlock* currentBlock, llvm::Value* lhs, const Type* lhsType, llvm::Value* rhs, const Type* rhsType);
+ static ExpressionResult createAdditionExpression( llvm::BasicBlock* currentBlock, ExpressionResult lhs, const Type* lhsType, ExpressionResult rhs, const Type* rhsType);
+ static llvm::Constant* createAdditionExpression( llvm::Constant* lhs, const Type* lhsType, llvm::Constant* rhs, const Type* rhsType);
// Substraction
llvm::Value* createSubstractionExpression(llvm::BasicBlock* currentBlock, llvm::Value* lhs, const Type* lhsType, llvm::Value* rhs, const Type* rhsType);
ExpressionResult createSubstractionExpression( llvm::BasicBlock* currentBlock, ExpressionResult lhs, const Type* lhsType, ExpressionResult rhs, const Type* rhsType);
@@ -148,7 +148,7 @@
ExpressionResult createDifferentExpression( llvm::BasicBlock* currentBlock, ExpressionResult lhs, const Type* lhsType, ExpressionResult rhs, const Type* rhsType);
llvm::Constant* createDifferentExpression( llvm::Constant* lhs, const Type* lhsType, llvm::Constant* rhs, const Type* rhsType);
//
- llvm::Value* createStrictInferiorExpression(llvm::BasicBlock* currentBlock, llvm::Value* lhs, const Type* lhsType, llvm::Value* rhs, const Type* rhsType);
+ static llvm::Value* createStrictInferiorExpression(llvm::BasicBlock* currentBlock, llvm::Value* lhs, const Type* lhsType, llvm::Value* rhs, const Type* rhsType);
ExpressionResult createStrictInferiorExpression( llvm::BasicBlock* currentBlock, ExpressionResult lhs, const Type* lhsType, ExpressionResult rhs, const Type* rhsType);
llvm::Constant* createStrictInferiorExpression( llvm::Constant* lhs, const Type* lhsType, llvm::Constant* rhs, const Type* rhsType);
// createInferiorExpression
@@ -177,8 +177,8 @@
llvm::Value* createTildeExpression(llvm::BasicBlock* currentBlock, llvm::Value* rhs, const Type* rhsType);
llvm::Constant* createTildeExpression( llvm::Constant* rhs, const Type* rhsType);
// Increment
- void createIncrementExpression( llvm::BasicBlock* currentBlock, VariableNG* var);
- void createIncrementExpression( llvm::BasicBlock* currentBlock, llvm::Value* pointer);
+ static void createIncrementExpression( GenerationContext& gc, llvm::BasicBlock* currentBlock, VariableNG* var);
+ static void createIncrementExpression( llvm::BasicBlock* currentBlock, llvm::Value* pointer);
void createDecrementExpression( llvm::BasicBlock* currentBlock, VariableNG* var);
void createDecrementExpression( llvm::BasicBlock* currentBlock, llvm::Value* pointer);
@@ -203,7 +203,7 @@
* @param lastAction the block with the last action of the loop
* @param after the basic block after the for statement
*/
- void createForStatement(llvm::BasicBlock* before, llvm::BasicBlock* test, llvm::Value* testResult, const Type* testType, llvm::BasicBlock* update, llvm::BasicBlock* firstAction, llvm::BasicBlock* lastAction, llvm::BasicBlock* after);
+ static void createForStatement(llvm::BasicBlock* before, llvm::BasicBlock* test, llvm::Value* testResult, const Type* testType, llvm::BasicBlock* update, llvm::BasicBlock* firstAction, llvm::BasicBlock* lastAction, llvm::BasicBlock* after);
/**
* Create an iteration for statement.
@@ -223,13 +223,13 @@
* @param lastAction the block with the last action of the loop
* @return the exit block of the loop
*/
- llvm::BasicBlock* createIterationForStatement( llvm::Function* function, llvm::BasicBlock* before, GTLCore::VariableNG* variable, llvm::Value* maxValue, const Type* maxValueType, llvm::BasicBlock* firstAction, llvm::BasicBlock* lastAction);
+ 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
*/
- const Type* selectType(const Type* type1, const Type* type2);
+ static const Type* selectType(const Type* type1, const Type* type2);
public:
/**
* @param _currentBlock the current basic block
@@ -241,9 +241,9 @@
public:
GTLCore::ExpressionResult callFunction( GenerationContext& _gc, llvm::BasicBlock* _bb, const GTLCore::Function* _function, const std::list<AST::Expression*>& m_arguments );
private:
- llvm::Value* createComparisonExpression(llvm::BasicBlock* currentBlock, llvm::Value* lhs, const Type* lhsType, llvm::Value* rhs, const Type* rhsType, unsigned int integerPred, unsigned int floatPred);
- ExpressionResult createComparisonExpression( llvm::BasicBlock* currentBlock, ExpressionResult lhs, const Type* lhsType, ExpressionResult rhs, const Type* rhsType, unsigned int integerPred, unsigned int floatPred);
- llvm::Constant* createComparisonExpression( llvm::Constant* lhs, const Type* lhsType, llvm::Constant* rhs, const Type* rhsType, unsigned int integerPred, unsigned int floatPred);
+ static llvm::Value* createComparisonExpression(llvm::BasicBlock* currentBlock, llvm::Value* lhs, const Type* lhsType, llvm::Value* rhs, const Type* rhsType, unsigned int integerPred, unsigned int floatPred);
+ static ExpressionResult createComparisonExpression( llvm::BasicBlock* currentBlock, ExpressionResult lhs, const Type* lhsType, ExpressionResult rhs, const Type* rhsType, unsigned int integerPred, unsigned int floatPred);
+ static llvm::Constant* createComparisonExpression( llvm::Constant* lhs, const Type* lhsType, llvm::Constant* rhs, const Type* rhsType, unsigned int integerPred, unsigned int floatPred);
private:
struct Private;
Private* const d;
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Function.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Function.h 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Function.h 2008-06-19 19:27:31 UTC (rev 204)
@@ -30,6 +30,7 @@
namespace OpenShiva {
class Types;
+ class CodeGenerator;
}
namespace GTLCore {
@@ -54,6 +55,8 @@
friend class OpenCTL::Program;
friend class OpenShiva::Types;
friend class CodeGenerator;
+ friend class OpenShiva::CodeGenerator;
+ friend class VirtualMachine;
class Data;
public:
/**
Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h 2008-06-19 19:27:31 UTC (rev 204)
@@ -51,6 +51,7 @@
ParserBase(CompilerBase* _compiler, LexerBase* _lexer);
virtual ~ParserBase();
virtual GTLCore::AST::Tree* parse() =0;
+ const GTLCore::String& nameSpace() const;
protected:
/**
* Get the next token.
@@ -141,7 +142,6 @@
void endContext();
std::list<int> expressionsListToIntegersList( const std::list< AST::Expression* >& );
void setNameSpace( const GTLCore::String& nameSpace );
- const GTLCore::String& nameSpace() const;
private:
struct Private;
Private* const d;
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp 2008-06-19 19:27:31 UTC (rev 204)
@@ -153,12 +153,12 @@
Type::Type(const Type& _rhs) : d(new Private(*_rhs.d))
{
- GTL_ASSERT(false);
+ GTL_ABORT("Can't copy type.");
}
Type& Type::operator=(const Type& _rhs)
{
- GTL_ASSERT(false);
+ GTL_ABORT("Can affect a type to an other type.");
}
Type::~Type()
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp 2008-06-19 19:27:31 UTC (rev 204)
@@ -114,7 +114,7 @@
break;
default:
m_type = 0;
- GTL_ASSERT(false);
+ GTL_ABORT("This isn't a primitive type.");
break;
}
}
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Value.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Value.cpp 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Value.cpp 2008-06-19 19:27:31 UTC (rev 204)
@@ -89,7 +89,7 @@
case Type::UNSIGNED_INTEGER32: \
return (_type_)d->value.ui; \
default: \
- GTL_ASSERT(false); \
+ GTL_ABORT("Can't convert to that type."); \
return (_type_)0; \
}
Modified: trunk/OpenGTL/OpenGTL/GTLCore/VirtualMachine_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/VirtualMachine_p.cpp 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenGTL/GTLCore/VirtualMachine_p.cpp 2008-06-19 19:27:31 UTC (rev 204)
@@ -19,8 +19,8 @@
#include "VirtualMachine_p.h"
-#include <GTLCore/Value.h>
-#include <GTLCore/String.h>
+#include "Function_p.h"
+#include "Value.h"
#include "Debug.h"
@@ -87,6 +87,11 @@
return d->executionEngine->getPointerToFunction(F);
}
+void *VirtualMachine::getPointerToFunction(Function *F, int _nbParameters)
+{
+ return getPointerToFunction( F->d->data->function(_nbParameters ) );
+}
+
void* VirtualMachine::getGlobalVariablePointer( llvm::GlobalVariable* GV)
{
return d->executionEngine->getPointerToGlobal( GV );
Modified: trunk/OpenGTL/OpenGTL/GTLCore/VirtualMachine_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/VirtualMachine_p.h 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenGTL/GTLCore/VirtualMachine_p.h 2008-06-19 19:27:31 UTC (rev 204)
@@ -28,6 +28,7 @@
}
namespace GTLCore {
+ class Function;
class Value;
/**
* @internal
@@ -58,6 +59,11 @@
* @return a pointer to the function
*/
void *getPointerToFunction(llvm::Function *F);
+ /**
+ * @param _nbParameters the number of parameters
+ * @return a pointer to the function
+ */
+ void *getPointerToFunction(Function *F, int _nbParameters);
void* getGlobalVariablePointer( llvm::GlobalVariable* _pointer);
#if 0
/**
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Visitor_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Visitor_p.cpp 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Visitor_p.cpp 2008-06-19 19:27:31 UTC (rev 204)
@@ -183,8 +183,8 @@
_valueType->embeddedType() );
// Create the for statement
- return _generationContext.codeGenerator()->createIterationForStatement(
- _generationContext.llvmFunction(),
+ return CodeGenerator::createIterationForStatement(
+ _generationContext,
_currentBlock,
index,
getSize( _generationContext, _currentBlock, _pointer),
@@ -250,11 +250,11 @@
sizeAfter );
// Create the for statement
- return _generationContext.codeGenerator()->createIterationForStatement(
- _generationContext.llvmFunction(),
+ return CodeGenerator::createIterationForStatement(
+ _generationContext,
_currentBlock,
index,
- _generationContext.codeGenerator()->integerToConstant(_sizes.size()),
+ CodeGenerator::integerToConstant(_sizes.size()),
Type::Integer32,
bodyBlock,
endBodyBlock );
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp 2008-06-19 19:27:31 UTC (rev 204)
@@ -29,14 +29,26 @@
#include <llvm/Value.h>
#include <llvm/ParameterAttributes.h>
+#include "GTLCore/CodeGenerator_p.h"
+#include "GTLCore/Function.h"
+#include "GTLCore/Function_p.h"
#include "GTLCore/GenerationContext_p.h"
-#include "GTLCore/CodeGenerator_p.h"
+#include "GTLCore/ModuleData_p.h"
+#include "GTLCore/Parameter.h"
+#include "GTLCore/Type.h"
+#include "GTLCore/TypeManager_p.h"
+#include "GTLCore/Value.h"
+#include "GTLCore/VariableNG_p.h"
#include "wrappers/PixelWrap_p.h"
+#include "Debug.h"
+#include "Kernel.h"
using namespace OpenShiva;
+int CodeGenerator::s_evaluatePixelesId = 0;
+
llvm::BasicBlock* CodeGenerator::memToPixel( GTLCore::GenerationContext& _gc, llvm::BasicBlock* _currentBlock, llvm::Value* _dataPointer, llvm::Value* _pixel, int _size )
{
// Initialise llvm_memcpy_i32
@@ -72,7 +84,6 @@
llvm::Value* _pointerToPixelVectorU8 = new llvm::BitCastInst(
_pointerToPixelVector, llvm::PointerType::get(llvm::IntegerType::get(8), 0), "", _currentBlock);
-
// Call llvm.memcpy.i32
std::vector<llvm::Value*> memcpy_params;
memcpy_params.push_back( _pointerToPixelVectorU8 );
@@ -87,7 +98,100 @@
return _currentBlock;
}
-GTLCore::Function* CodeGenerator::generateEvaluatePixeles( Kernel* )
+llvm::Function* CodeGenerator::generateEvaluatePixeles( const std::vector<const GTLCore::Type*>& _inputTypes, const GTLCore::Type* _outputType, Kernel* _kernel, GTLCore::ModuleData* _moduleData)
{
- return 0;
+ GTLCore::CodeGenerator codeGenerator( _moduleData );
+
+ // Pseudo-code explaining step-by-step what an evaluatePixeles function does :
+ //
+ // AbstractImage* are seen as a void*.
+ //
+ // template< int nbSources >
+ // void evaluatePixeles( int _width, int _height, AbstractImage** _sources, AbstractImage* _result)
+ // {
+ // for( int i = 0; i < nbSource; ++i )
+ // {
+ // imageWrap[i] = wrap(sources[i]);
+ // }
+ // for( int j = 0; j < height; ++j )
+ // {
+ // for( int i = 0; i < width; ++i )
+ // {
+ // pixel result;
+ // evaluatePixel( imageWrap[0], imageWrap[1], ..., imageWrap[nbSource-1], result );
+ // memcpy(result.data, _result.data( width, height );
+ // }
+ // }
+ // }
+ //
+ // Simple, isn't it ?
+
+ // Create the function
+ std::vector<const llvm::Type*> params;
+ params.push_back( llvm::PointerType::get( llvm::Type::Int32Ty, 0 ) );
+ params.push_back( llvm::PointerType::get( llvm::Type::Int32Ty, 0 ) );
+ params.push_back( llvm::PointerType::get( llvm::PointerType::get( llvm::Type::Int8Ty, 0 ), 0 ) );
+ params.push_back( llvm::PointerType::get( llvm::Type::Int8Ty, 0 ) );
+ llvm::FunctionType* definitionType = llvm::FunctionType::get( llvm::Type::VoidTy, params, false );
+ int evaluatePixelesId = ++CodeGenerator::s_evaluatePixelesId;
+ llvm::Function* func = codeGenerator.createFunction( definitionType, "evaluatePixeles" + GTLCore::String::number(evaluatePixelesId));
+ // Initialise a generation context
+ GTLCore::GenerationContext generationContext( &codeGenerator, func, 0, _moduleData );
+
+ // {
+ llvm::BasicBlock* initialBlock = new llvm::BasicBlock;
+ func->getBasicBlockList().push_back( initialBlock );
+ // Get the args.
+ llvm::Function::arg_iterator arg_it = func->arg_begin();
+ // int _width = first arg;
+ llvm::Value* arg_width = arg_it;
+ // int _height = second arg;
+ ++arg_it;
+ llvm::Value* arg_height = arg_it;
+ // void** _sources = third arg;
+ ++arg_it;
+// llvm::Value* arg_sources = arg_it;
+ // void* _result = fourth arg;
+ ++arg_it;
+// llvm::Value* arg_result = arg_it;
+ // Construct the "conditions" of the first loop
+ // int j = 0;
+ GTLCore::VariableNG* incJ = new GTLCore::VariableNG( GTLCore::Type::Integer32, false);
+ incJ->initialise( generationContext, initialBlock,
+ GTLCore::CodeGenerator::integerToConstant(0),
+ GTLCore::Type::Integer32, std::list<llvm::Value*>());
+ // {
+ llvm::BasicBlock* firstBlockJLoop = new llvm::BasicBlock;
+ func->getBasicBlockList().push_back( firstBlockJLoop );
+ // int i = 0;
+ GTLCore::VariableNG* incI = new GTLCore::VariableNG( GTLCore::Type::Integer32, false);
+ incI->initialise( generationContext, firstBlockJLoop,
+ GTLCore::CodeGenerator::integerToConstant(0),
+ GTLCore::Type::Integer32, std::list<llvm::Value*>());
+ // {
+ llvm::BasicBlock* firstBlockILoop = new llvm::BasicBlock;
+ func->getBasicBlockList().push_back( firstBlockILoop );
+ // Create the pixel
+ GTLCore::VariableNG* resultVar = new GTLCore::VariableNG( _moduleData->typeManager()->getStructure( "pixel" ), false );
+ resultVar->initialise( generationContext, firstBlockILoop, 0, 0, std::list<llvm::Value*>());
+ // Call evaluatePixel
+ GTLCore::Function* ePFunction = _moduleData->function( _kernel->name(), "evaluatePixel" );
+ SHIVA_ASSERT( ePFunction );
+ std::vector<llvm::Value*> evaluatePixel_params;
+ evaluatePixel_params.push_back( resultVar->pointer() );
+ llvm::Function* llvmEPFunction = ePFunction->d->data->function( 1 );
+ SHIVA_ASSERT( llvmEPFunction );
+ new llvm::CallInst( llvmEPFunction, evaluatePixel_params.begin(), evaluatePixel_params.end(), "", firstBlockILoop );
+ // Synchronize the output pixel with input
+ // Call image_wrap_data on the result to get the pointer on destination data
+ // }
+ llvm::BasicBlock* lastBlockJLoop = GTLCore::CodeGenerator::createIterationForStatement( generationContext, firstBlockJLoop, incI, arg_width, GTLCore::Type::Integer32, firstBlockILoop, firstBlockILoop);
+ // }
+ llvm::BasicBlock* lastBlock = GTLCore::CodeGenerator::createIterationForStatement( generationContext, initialBlock, incJ, arg_height, GTLCore::Type::Integer32, firstBlockJLoop, lastBlockJLoop);
+ new llvm::ReturnInst(lastBlock);
+ // Cleanup
+ delete resultVar;
+ delete incJ;
+ delete incI;
+ return func;
}
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.h 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.h 2008-06-19 19:27:31 UTC (rev 204)
@@ -20,14 +20,19 @@
#ifndef _OPENSHIVA_CODE_GENERATOR_P_H_
#define _OPENSHIVA_CODE_GENERATOR_P_H_
+#include <vector>
+
namespace llvm {
class BasicBlock;
+ class Function;
class Value;
}
namespace GTLCore {
class Function;
class GenerationContext;
+ class ModuleData;
+ class Type;
}
namespace OpenShiva {
@@ -39,7 +44,10 @@
* Copy a pixel from memory to the vector.
*/
static llvm::BasicBlock* memToPixel( GTLCore::GenerationContext& _gc, llvm::BasicBlock* _currentBlock, llvm::Value* _dataPointer, llvm::Value* _pixel, int _size );
- static GTLCore::Function* generateEvaluatePixeles( Kernel* );
+ static llvm::BasicBlock* pixelToMem( GTLCore::GenerationContext& _gc, llvm::BasicBlock* _currentBlock, llvm::Value* _pixel, llvm::Value* _dataPointer, int _size );
+ static llvm::Function* generateEvaluatePixeles( const std::vector<const GTLCore::Type*>& _inputTypes, const GTLCore::Type* _outputType, Kernel* _kernel, GTLCore::ModuleData* _moduleData);
+ private:
+ static int s_evaluatePixelesId;
};
}
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.cpp 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.cpp 2008-06-19 19:27:31 UTC (rev 204)
@@ -57,7 +57,7 @@
delete d;
}
-bool Compiler::compile(const GTLCore::String& _sourceCode, const GTLCore::String& _kernelName, GTLCore::ModuleData* _moduleData)
+bool Compiler::compile(const GTLCore::String& _sourceCode, const GTLCore::String& _kernelName, GTLCore::ModuleData* _moduleData, GTLCore::String& _nameSpace)
{
SHIVA_DEBUG("Compile: " << _kernelName << " : " << _sourceCode);
// Initialise the module structure
@@ -94,7 +94,7 @@
// delete d->module;
d->module = 0;
}
-
+ _nameSpace = d->parser->nameSpace();
// Clean up
SHIVA_DEBUG("Clean up");
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.h 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.h 2008-06-19 19:27:31 UTC (rev 204)
@@ -33,7 +33,7 @@
public:
Compiler();
~Compiler();
- bool compile(const GTLCore::String& _sourceCode, const GTLCore::String& _kernelName, GTLCore::ModuleData* _moduleData);
+ bool compile(const GTLCore::String& _sourceCode, const GTLCore::String& _kernelName, GTLCore::ModuleData* _moduleData, GTLCore::String& _nameSpace);
virtual GTLCore::TypeManager* typeManager();
public:
GTLCore::AST::Expression* standardConstant( const GTLCore::String& _name );
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Debug.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Debug.h 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Debug.h 2008-06-19 19:27:31 UTC (rev 204)
@@ -17,13 +17,14 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef _OPENCTL_DEBUG_H_
-#define _OPENCTL_DEBUG_H_
+#ifndef _OPENSHIVA_DEBUG_H_
+#define _OPENSHIVA_DEBUG_H_
#include <GTLCore/Debug.h>
#define SHIVA_WARNING(msg) GTL_WARNING(msg)
#define SHIVA_DEBUG(msg) GTL_DEBUG(msg)
#define SHIVA_ASSERT(assrt) GTL_ASSERT(assrt)
+#define SHIVA_ABORT(msg) GTL_ABORT(msg)
#endif
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Image.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Image.cpp 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Image.cpp 2008-06-19 19:27:31 UTC (rev 204)
@@ -17,3 +17,35 @@
* Boston, MA 02110-1301, USA.
*/
+#include "Image.h"
+
+#include "GTLCore/PixelDescription.h"
+
+#include "Debug.h"
+
+using namespace OpenShiva;
+
+struct Image::Private {
+ char* data;
+ int lineWidth;
+ int pixelSize;
+};
+
+Image::Image(int _width, int _height, const GTLCore::PixelDescription& _pixelDescription) : d(new Private)
+{
+ GTL_ASSERT(_pixelDescription.bitsSize() % 8 == 0);
+ d->pixelSize = _pixelDescription.bitsSize() / 8;
+ d->lineWidth = _width * d->pixelSize;
+ d->data = new char[ d->lineWidth * _height];
+}
+
+Image::~Image()
+{
+ delete[] d->data;
+ delete d;
+}
+
+char* Image::data(int _x, int _y)
+{
+ return d->data + (_x * d->pixelSize + _y * d->lineWidth);
+}
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Image.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Image.h 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Image.h 2008-06-19 19:27:31 UTC (rev 204)
@@ -22,8 +22,19 @@
#include <OpenShiva/AbstractImage.h>
+namespace GTLCore {
+ class PixelDescription;
+}
+
namespace OpenShiva {
class Image : public AbstractImage {
+ public:
+ Image(int _width, int _height, const GTLCore::PixelDescription& _pixelDescription);
+ ~Image();
+ char* data(int _x, int _y);
+ private:
+ struct Private;
+ Private* const d;
};
};
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp 2008-06-19 19:27:31 UTC (rev 204)
@@ -30,6 +30,7 @@
#include "GTLCore/ModuleData_p.h"
#include "GTLCore/PixelDescription.h"
#include "GTLCore/Type.h"
+#include "GTLCore/TypeManager.h"
#include "GTLCore/Value.h"
#include "GTLCore/VirtualMachine_p.h"
@@ -52,7 +53,7 @@
GTLCore::ModuleData* moduleData;
const GTLCore::PixelDescription pixelDescription;
const GTLCore::Type* referenceDepth;
- GTLCore::Function* evaluatePixelesFunction;
+ llvm::Function* evaluatePixelesFunction;
};
Kernel::Kernel(const GTLCore::String& _name) : d(new Private(GTLCore::PixelDescription( GTLCore::Type::Float, 4 )) )
@@ -102,8 +103,7 @@
}
delete d->moduleData;
d->moduleData = 0;
- delete d->evaluatePixelesFunction;
- d->evaluatePixelesFunction = 0;
+ d->evaluatePixelesFunction = 0; // It's deleted by the moduleData
}
@@ -144,14 +144,16 @@
d->moduleData = new GTLCore::ModuleData(new llvm::Module(d->name));
Types::fillTypeManager( d->moduleData->llvmModule(), d->moduleData->typeManager(), d->pixelDescription, d->referenceDepth );
Compiler c;
- bool result = c.compile( d->source, d->name, d->moduleData );
+ GTLCore::String nameSpace;
+ bool result = c.compile( d->source, d->name, d->moduleData, nameSpace );
if(result)
{
d->compiled = true;
d->moduleProvider = new llvm::ExistingModuleProvider( d->moduleData->llvmModule() );
GTLCore::VirtualMachine::instance()->registerModule( d->moduleProvider );
- d->evaluatePixelesFunction = CodeGenerator::generateEvaluatePixeles( this );
+ d->evaluatePixelesFunction = CodeGenerator::generateEvaluatePixeles( std::vector<const GTLCore::Type*>(), d->moduleData->typeManager()->getStructure("image1"), this, d->moduleData ); // TODO call with correct types
+ d->name = nameSpace;
} else {
cleanup();
d->compilationErrors = c.errorMessages();
@@ -161,8 +163,10 @@
void Kernel::evaluatePixeles( const std::list< AbstractImage* >& _inputImages, AbstractImage* _outputImage) const
{
- GTL_ASSERT( d->evaluatePixelesFunction );
- // TODO call function
+ SHIVA_ASSERT( d->evaluatePixelesFunction );
+ void (*func)( int, int, void**, void*) = ( void(*)(int, int, void**, void*))GTLCore::VirtualMachine::instance()->getPointerToFunction( d->evaluatePixelesFunction);
+ SHIVA_ASSERT(func);
+ (*func)( 200, 300, 0, (void*)_outputImage); // TODO s/200/width s/300/height
}
int Kernel::runTest() const
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.h 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.h 2008-06-19 19:27:31 UTC (rev 204)
@@ -47,8 +47,7 @@
void cleanup();
public:
/**
- * @return the name of the module (it's usually the name of the file without the .ctl
- * extension, and without the path)
+ * @return the name of the kernel
*/
const GTLCore::String& name() const;
/**
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Lexer_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Lexer_p.h 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Lexer_p.h 2008-06-19 19:27:31 UTC (rev 204)
@@ -33,7 +33,7 @@
* Creates a new lexer with the given stream.
* @code
* std::istringstream iss(sourceCode);
- * OpenCTL::LexerNG lng( &iss);
+ * OpenShiva::Lexer lng( &iss);
* @endcode
*/
Lexer(std::istream* sstream);
Modified: trunk/OpenGTL/OpenShiva/tests/imagegenerators/PlainGenerator.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/imagegenerators/PlainGenerator.shiva 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenShiva/tests/imagegenerators/PlainGenerator.shiva 2008-06-19 19:27:31 UTC (rev 204)
@@ -4,7 +4,7 @@
{
for(int i = 0; i < result.size; ++i )
{
- result[i] = 0.5;
+// result[i] = 0.5;
}
}
}
Modified: trunk/OpenGTL/OpenShiva/tests/library/TestOpenShiva.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/library/TestOpenShiva.cpp 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenShiva/tests/library/TestOpenShiva.cpp 2008-06-19 19:27:31 UTC (rev 204)
@@ -25,6 +25,6 @@
#include "TestLexer.h"
-GTLTEST_MAIN_BEGIN(TestOpenCTL)
+GTLTEST_MAIN_BEGIN(TestOpenShiva)
GTLTEST_MAIN_ADD_CASE(TestLexer)
GTLTEST_MAIN_END()
Modified: trunk/OpenGTL/OpenShiva/tests/parse/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/parse/CMakeLists.txt 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenShiva/tests/parse/CMakeLists.txt 2008-06-19 19:27:31 UTC (rev 204)
@@ -13,5 +13,5 @@
# )
# FOREACH( TEST_FILE ${TESTS_FAIL_FILES} )
-# ADD_TEST(${TEST_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../sdk/invertresult.sh ${CTLC} ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_FILE})
+# ADD_TEST(${TEST_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../sdk/invertresult.sh ${SHIVAC} ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_FILE})
# ENDFOREACH( TEST_FILE )
Modified: trunk/OpenGTL/OpenShiva/tests/structures/region.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/structures/region.shiva 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenShiva/tests/structures/region.shiva 2008-06-19 19:27:31 UTC (rev 204)
@@ -1,5 +1,8 @@
kernel MyKernel
{
+ void evaluatePixel(out pixel result)
+ {
+ }
int runTest()
{
int count = 0;
Modified: trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp 2008-06-17 18:23:48 UTC (rev 203)
+++ trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp 2008-06-19 19:27:31 UTC (rev 204)
@@ -22,8 +22,13 @@
#include <fstream>
#include <cstdlib>
+// GTLCore Headers
+#include <GTLCore/PixelDescription.h>
+#include <GTLCore/Type.h>
+
// OpenShiva Headers
#include <OpenShiva/Debug.h>
+#include <OpenShiva/Image.h>
#include <OpenShiva/Kernel.h>
#include <OpenShiva/Version.h>
@@ -106,6 +111,10 @@
std::cout << "Error: " << std::endl << p.compilationErrorsMessage() << std::endl;
return EXIT_FAILURE;
}
+ OpenShiva::Image image(200,300, GTLCore::PixelDescription( GTLCore::Type::UnsignedInteger8, 1 ) );
+ memset( image.data(0, 0), 0, 200 * 300 );
+ p.evaluatePixeles( std::list<OpenShiva::AbstractImage*>(), &image );
+ std::cout << (int)*image.data( 0, 0);
}
return EXIT_SUCCESS;
}