[opengtl-commits] [514] * transform parameters into constants

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


Revision: 514
Author:   cyrille
Date:     2008-12-04 00:18:31 +0100 (Thu, 04 Dec 2008)

Log Message:
-----------
* transform parameters into constants

Modified Paths:
--------------
    trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.h
    trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.h
    trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Value.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Value.h
    trunk/OpenGTL/OpenGTL/GTLCore/VariableNG_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Visitor_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/tests/TestMetadata.h
    trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.h
    trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.h
    trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h
    trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.h
    trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp
    trunk/OpenGTL/OpenShiva/tests/convolution/copy.shiva
    trunk/OpenGTL/OpenShiva/tests/imagegenerators/Gradient.shiva
    trunk/OpenGTL/OpenShiva/tests/library/TestMetadataParser.h
    trunk/OpenGTL/OpenShiva/tests/parse/metadata.shiva
    trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp


Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.cpp	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.cpp	2008-12-03 23:18:31 UTC (rev 514)
@@ -31,6 +31,8 @@
 #include "GTLCore/Type.h"
 #include "GTLCore/Type_p.h"
 #include "GTLCore/Utils_p.h"
+#include "GTLCore/Value.h"
+#include "GTLCore/Macros_p.h"
 
 #include "GTLCore/Parameter.h"
 #include "GTLCore/Debug.h"
@@ -39,6 +41,7 @@
 
 #include "AccessorExpression.h"
 #include "GarbageCollectionStatement.h"
+#include "CoumpoundExpression.h"
 
 using namespace GTLCore::AST;
 
@@ -52,6 +55,30 @@
   return _bb;
 }
 
+Expression* Expression::fromValue( const GTLCore::Value& _val)
+{
+  switch( _val.type()->dataType() )
+  {
+    case Type::INTEGER32:
+      return new AST::NumberExpression<int>( _val.asInt32() );
+    case Type::FLOAT:
+      return new AST::NumberExpression<float>( _val.asFloat() );
+    case Type::VECTOR:
+    case Type::ARRAY:
+    {
+      std::vector<Expression*> expressions;
+      GTL_ASSERT( _val.asArray() );
+      foreach( const Value& val, *_val.asArray())
+      {
+        expressions.push_back( fromValue( val ) );
+      }
+      return new AST::CoumpoundExpression( _val.type(), expressions );
+    }
+    default:
+      return 0;
+  }
+}
+
 //------------------------------------------//
 //------------- ProxyExpression ------------//
 //------------------------------------------//

Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.h	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.h	2008-12-03 23:18:31 UTC (rev 514)
@@ -27,6 +27,7 @@
   class ExpressionResult;
   class Type;
   class Function;
+  class Value;
 
   namespace AST {
 
@@ -50,6 +51,11 @@
          * and not on the stack.
          */
         virtual void markAsReturnExpression() = 0;
+      public:
+        /**
+         * @return an \ref AST::Expression corresponding to the value @p _val given in parameter.
+         */
+        static AST::Expression* fromValue( const GTLCore::Value& _val);
     };
 
     /**

Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp	2008-12-03 23:18:31 UTC (rev 514)
@@ -379,7 +379,7 @@
   llvm::Value* CodeGenerator::_GTL_Function_Name_(llvm::BasicBlock* currentBlock, llvm::Value* lhs, const Type* lhsType, llvm::Value* rhs, const Type* rhsType) \
   { \
     UNIFORMIZE_VALUE_TYPES( lhs, rhs ) \
-    return llvm::BinaryOperator::_LLVM_Binary_Operator( v1, v2, "", currentBlock ); \
+    return llvm::BinaryOperator::_LLVM_Binary_Operator( v1, v2, #_GTL_Function_Name_, currentBlock ); \
   } \
   llvm::Constant* CodeGenerator::_GTL_Function_Name_( llvm::Constant* lhs, const Type* lhsType, llvm::Constant* rhs, const Type* rhsType) \
   { \
@@ -723,8 +723,8 @@
 {
   llvm::Value* pointerCF = countFieldPointer(_currentBlock, _pointer);
   llvm::Value* val = createAdditionExpression( _currentBlock,
-                                new llvm::LoadInst( pointerCF, "", _currentBlock ),
+                                new llvm::LoadInst( pointerCF, "CodeGenerator::incrementCountFieldOf", _currentBlock ),
                                 Type::Integer32, _increment, Type::Integer32 );
-  new llvm::StoreInst( val, pointerCF, "", _currentBlock );
+  new llvm::StoreInst( val, pointerCF, "CodeGenerator::incrementCountFieldOf", _currentBlock );
   return val;
 }

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.cpp	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.cpp	2008-12-03 23:18:31 UTC (rev 514)
@@ -35,12 +35,14 @@
   Value defaultValue;
   const Type* type;
   GTLCore::String description;
+  WidgetType widgetType;
 };
 
 ParameterEntry::ParameterEntry( const GTLCore::String& _name, const std::list< const Entry* >& _entries ) : Group( _name, _entries ), d(new Private)
 {
   // Type
   const Entry* typeEntry = entry( "type" );
+  bool widgetTypeSet = false;
   if( typeEntry )
   {
     const TextEntry* v = typeEntry->asTextEntry();
@@ -48,12 +50,20 @@
     if( v->text() == "int" )
     {
       d->type = Type::Integer32;
+      d->widgetType = IntegerWidget;
+      widgetTypeSet = true;
     } else if( v->text() == "float" ) {
       d->type = Type::Float;
+      d->widgetType = FloatWidget;
+      widgetTypeSet = true;
     } else if( v->text() == "curve" ) {
       d->type = TypeManager::getArray( TypeManager::getVector( Type::Float, 2 ) ); 
+      d->widgetType = CurveWidget;
+      widgetTypeSet = true;
     } else if( v->text() == "rgb" ) {
       d->type = TypeManager::getVector( Type::Float, 3 );
+      d->widgetType = RgbColorWidget;
+      widgetTypeSet = true;
     }
   }
   // DefaultValue
@@ -134,13 +144,34 @@
       std::vector< GTLCore::Value > v1; v1.push_back( 0.0f ); v1.push_back( 0.0f );
       std::vector< GTLCore::Value > v2; v2.push_back( 1.0f ); v2.push_back( 1.0f );
       std::vector< GTLCore::Value > v3; v3.push_back( v1 ); v3.push_back( v2 );
-      d->defaultValue.setArray( v3 );
+      d->defaultValue.setArray( v3, d->type );
     } else if( d->type == TypeManager::getVector( Type::Float, 3 ) )
     {
       std::vector< GTLCore::Value > v1; v1.push_back( 0.0f ); v1.push_back( 0.0f ); v1.push_back( 0.0f );
-      d->defaultValue.setArray( v1 );
+      d->defaultValue.setArray( v1, d->type );
     }
   }
+  // Set the widget type if not set
+  if( not widgetTypeSet )
+  {
+    switch( d->type->dataType() )
+    {
+      case Type::INTEGER32:
+        d->widgetType = IntegerWidget;
+        break;
+      case Type::FLOAT:
+        d->widgetType = FloatWidget;
+        break;
+      case Type::ARRAY:
+        d->widgetType = CurveWidget;
+        break;
+      case Type::VECTOR:
+        d->widgetType = RgbColorWidget;
+        break;
+      default:
+        GTL_ABORT("Unsupported datatype");
+    }
+  }
 }
 
 ParameterEntry::~ParameterEntry()
@@ -163,7 +194,7 @@
   return d->defaultValue;
 }
 
-const GTLCore::Type* ParameterEntry::type() const
+const GTLCore::Type* ParameterEntry::valueType() const
 {
   return d->type;
 }

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.h	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.h	2008-12-03 23:18:31 UTC (rev 514)
@@ -35,11 +35,18 @@
         ParameterEntry( const GTLCore::String& _name, const std::list< const Entry* >& _entries );
         virtual ~ParameterEntry();
       public:
+        enum WidgetType {
+          IntegerWidget, FloatWidget, CurveWidget, RgbColorWidget
+        };
+      public:
         const Value& minimumValue() const;
         const Value& maximumValue() const;
         const Value& defaultValue() const;
-        const Type* type() const;
+        const Type* valueType() const;
         const GTLCore::String& description() const;
+        /**
+         */
+        WidgetType widgetType() const;
       public:
         virtual const ParameterEntry* asParameterEntry() const;
       private:

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp	2008-12-03 23:18:31 UTC (rev 514)
@@ -253,6 +253,7 @@
 
 const Type* Type::Private::selectType(const Type* type1, const Type* type2)
 {
+  GTL_DEBUG("Select type : "<< *type1 << " " << *type2 );
   GTL_ASSERT( (type1->isNumber() or type1->dataType() == Type::VECTOR ) and (type2->isNumber() or type2->dataType() == Type::VECTOR ) );
   if( type1 == type2 )
   {

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Value.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Value.cpp	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Value.cpp	2008-12-03 23:18:31 UTC (rev 514)
@@ -26,6 +26,7 @@
 using namespace GTLCore;
 
 struct Value::Private {
+  Private() : type(0) {}
   union {
     bool b;
     float f;
@@ -34,6 +35,13 @@
     std::vector< Value >* array;
   } value;
   const Type* type;
+  void cleanup()
+  {
+    if( type and (type->dataType() == Type::ARRAY or type->dataType() == Type::VECTOR ) )
+    {
+      delete value.array;
+    }
+  }
 };
 
 Value::Value() : d(new Private)
@@ -65,15 +73,20 @@
   d->type = Type::UnsignedInteger32;
 }
 
-Value::Value(const std::vector< Value >& v) : d(new Private)
+Value::Value(const std::vector< Value >& v, const GTLCore::Type* _type ) : d(new Private)
 {
   d->value.array = new std::vector< Value >( v );
-  d->type = TypeManager::getArray( v[0].type() );
+  if( _type )
+  {
+    d->type = _type;
+  } else {
+    d->type = TypeManager::getArray( v[0].type() );
+  }
 }
 
 Value::Value(const Value& rhs) : d(new Private(*rhs.d))
 {
-  if( d->type->dataType() == Type::ARRAY )
+  if( d->type->dataType() == Type::ARRAY or d->type->dataType() == Type::VECTOR )
   {
     d->value.array = new std::vector< Value >( *rhs.d->value.array );
   }
@@ -81,8 +94,9 @@
 
 Value Value::operator=(const Value& rhs)
 {
+  d->cleanup();
   *d = *rhs.d;
-  if( d->type->dataType() == Type::ARRAY )
+  if( d->type->dataType() == Type::ARRAY or d->type->dataType() == Type::VECTOR )
   {
     d->value.array = new std::vector< Value >( *rhs.d->value.array );
   }
@@ -104,6 +118,7 @@
       case Type::UNSIGNED_INTEGER32:
         return d->value.ui == rhs.d->value.ui;
       case Type::ARRAY:
+      case Type::VECTOR:
       {
         if( d->value.array->size() == rhs.d->value.array->size() )
         {
@@ -126,10 +141,7 @@
 
 Value::~Value()
 {
-  if( d->type->dataType() == Type::ARRAY )
-  {
-    delete d->value.array;
-  }
+  d->cleanup();
   delete d;
 }
 
@@ -188,7 +200,7 @@
 
 const std::vector< Value >* Value::asArray() const
 {
-  if( d->type->dataType() == Type::ARRAY )
+  if( d->type->dataType() == Type::ARRAY or d->type->dataType() == Type::VECTOR )
   {
     return d->value.array;
   } else {
@@ -196,12 +208,14 @@
   }
 }
 
-void Value::setArray( const std::vector< Value >& _array )
+void Value::setArray( const std::vector< Value >& _array, const GTLCore::Type* _type )
 {
-  if( d->type->dataType() == Type::ARRAY )
+  d->cleanup();
+  d->value.array = new std::vector< Value >( _array );
+  if( _type )
   {
-    delete d->value.array;
+    d->type = _type;
+  } else {
+    d->type = TypeManager::getArray( _array[0].type() );
   }
-  d->value.array = new std::vector< Value >( _array );
-  d->type = TypeManager::getArray( _array[0].type() );
 }

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Value.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Value.h	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Value.h	2008-12-03 23:18:31 UTC (rev 514)
@@ -35,7 +35,7 @@
       Value(bool v);
       Value(int v);
       Value(unsigned int v);
-      Value(const std::vector< Value >& v);
+      Value(const std::vector< Value >& v, const GTLCore::Type* _type = 0);
       Value(const Value& v);
       Value operator=(const Value& rhs);
       ~Value();
@@ -73,7 +73,7 @@
       /**
        * @return the value as an array, or 0 if not an array
        */
-      void setArray( const std::vector< Value >& _array );
+      void setArray( const std::vector< Value >& _array, const GTLCore::Type* _type );
       /**
        * @return the type of the value.
        */

Modified: trunk/OpenGTL/OpenGTL/GTLCore/VariableNG_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/VariableNG_p.cpp	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenGTL/GTLCore/VariableNG_p.cpp	2008-12-03 23:18:31 UTC (rev 514)
@@ -58,6 +58,7 @@
   d->pointer = 0;
   d->constantPointer = false;
   d->allocatedInMemory = false;
+  setAllocatedInMemory( true ); // Currently it's not possible to not allocate array/structure in memory until function return a structure and not a pointer, and structure/arrays knows wether they are allocated on stack or not
   d->dependant = _dependant;
 #ifndef NDEBUG
   d->dependantWasChangedToConst = false;
@@ -103,9 +104,9 @@
   } else {
     if( d->allocatedInMemory )
     {
-      pointer_ = new llvm::MallocInst( d->type->d->type(), llvm::ConstantInt::get(llvm::Type::Int32Ty, 1), "", _bb);
+      pointer_ = new llvm::MallocInst( d->type->d->type(), llvm::ConstantInt::get(llvm::Type::Int32Ty, 1), "Variable", _bb);
     } else {
-      pointer_ = new llvm::AllocaInst( d->type->d->type(), llvm::ConstantInt::get(llvm::Type::Int32Ty, 1), "", _bb);
+      pointer_ = new llvm::AllocaInst( d->type->d->type(), llvm::ConstantInt::get(llvm::Type::Int32Ty, 1), "Variable", _bb);
     }
     initialise( _generationContext, _bb, pointer_ );
     _bb = d->visitor->initialise( _generationContext, _bb, pointer_, d->type, _initialSize, d->allocatedInMemory);
@@ -127,9 +128,9 @@
   d->directlyOnTheStack = _currentBlock and ( d->type->dataType() == Type::ARRAY or d->type->dataType() == Type::STRUCTURE );
   if( d->directlyOnTheStack )
   {
-    d->pointer = new llvm::AllocaInst( llvm::PointerType::get( d->type->d->type(), 0 ), "", _currentBlock );
+    d->pointer = new llvm::AllocaInst( llvm::PointerType::get( d->type->d->type(), 0 ), "Variable Pointer", _currentBlock );
     GTL_DEBUG( *d->pointer << " " << *_pointer );
-    new llvm::StoreInst( _pointer, d->pointer, "", _currentBlock );
+    new llvm::StoreInst( _pointer, d->pointer, "Variable Pointer", _currentBlock );
   } else {
     d->pointer = _pointer;
   }
@@ -164,7 +165,7 @@
   GTL_DEBUG( *d->pointer << " " << d->directlyOnTheStack );
   if( d->directlyOnTheStack )
   {
-    return new llvm::LoadInst( d->pointer, "", _currentBlock );
+    return new llvm::LoadInst( d->pointer, "Load Variable Pointer", _currentBlock );
   } else {
     return d->pointer;
   }

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Visitor_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Visitor_p.cpp	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Visitor_p.cpp	2008-12-03 23:18:31 UTC (rev 514)
@@ -108,7 +108,7 @@
 
 ExpressionResult PrimitiveVisitor::get( GenerationContext& _generationContext, llvm::BasicBlock* _currentBlock, llvm::Value* _pointer, const Type* _pointerType) const
 {
-  return ExpressionResult( new llvm::LoadInst( _pointer, "", _currentBlock), _pointerType);
+  return ExpressionResult( new llvm::LoadInst( _pointer, "PrimitiveVisitor::get", _currentBlock), _pointerType);
 }
 
 llvm::BasicBlock* PrimitiveVisitor::set( GenerationContext& _generationContext, llvm::BasicBlock* _currentBlock, llvm::Value* _pointer, const Type* _pointerType, llvm::Value* _value, const Type* _valueType, bool _allocatedInMemory ) const
@@ -117,7 +117,7 @@
   GTL_DEBUG( *_pointer );
   new llvm::StoreInst(
           _generationContext.codeGenerator()->convertValueTo( _currentBlock, _value, _valueType, _pointerType ),
-          _pointer, "", _currentBlock);
+          _pointer, "PrimitiveVisitor::set", _currentBlock);
   return _currentBlock;
 }
 
@@ -229,23 +229,23 @@
   indexes.push_back( llvm::ConstantInt::get(llvm::Type::Int32Ty, ArrayWrap::POS_SIZE)); // Access the size of the array
   { // Init the size
     GTL_DEBUG( *_pointer );
-    llvm::Value* ptr = llvm::GetElementPtrInst::Create( _pointer, indexes.begin(), indexes.end(), "", _currentBlock);
+    llvm::Value* ptr = llvm::GetElementPtrInst::Create( _pointer, indexes.begin(), indexes.end(), "ArrayVisitor::setSize", _currentBlock);
     new llvm::StoreInst(_generationContext.codeGenerator()->convertValueTo( _currentBlock, _size, Type::Integer32, Type::Integer32 ), ptr, "", _currentBlock);
   }
   // Allocate the Array
   indexes[1] = llvm::ConstantInt::get(llvm::Type::Int32Ty, ArrayWrap::POS_DATA);
   {
-    llvm::Value* ptr = llvm::GetElementPtrInst::Create( _pointer, indexes.begin(), indexes.end(), "", _currentBlock);
+    llvm::Value* ptr = llvm::GetElementPtrInst::Create( _pointer, indexes.begin(), indexes.end(), "ArrayVisitor::setSize", _currentBlock);
     llvm::Value* array = 0;
     if( _allocatedInMemory )
     {
       array = new llvm::MallocInst(
-                    _pointerType->embeddedType()->d->type(), _size, "", _currentBlock);
+                    _pointerType->embeddedType()->d->type(), _size, "ArrayVisitor::setSize", _currentBlock);
     } else {
       array = new llvm::AllocaInst(
-                    _pointerType->embeddedType()->d->type(), _size, "", _currentBlock);
+                    _pointerType->embeddedType()->d->type(), _size, "ArrayVisitor::setSize", _currentBlock);
     }
-    new llvm::StoreInst( array, ptr, "", _currentBlock);
+    new llvm::StoreInst( array, ptr, "ArrayVisitor::setSize", _currentBlock);
   }
   return _currentBlock;
 }
@@ -256,7 +256,7 @@
   indexes.push_back( llvm::ConstantInt::get(llvm::Type::Int32Ty, 0)); // Access the structure of the array
   indexes.push_back( llvm::ConstantInt::get(llvm::Type::Int32Ty, ArrayWrap::POS_SIZE)); // Access the size of the array
   llvm::Value* ptr = llvm::GetElementPtrInst::Create( _pointer, indexes.begin(), indexes.end(), "", currentBlock);
-  return new llvm::LoadInst( ptr, "", currentBlock);
+  return new llvm::LoadInst( ptr, "ArrayVisitor::getSize", currentBlock);
 }
 
 llvm::BasicBlock* ArrayVisitor::initialise(GenerationContext& _generationContext, llvm::BasicBlock* _currentBlock, llvm::Value* _pointer, const Type* _pointerType, const std::list< llvm::Value*>& _sizes, bool _allocatedInMemory) const
@@ -303,8 +303,8 @@
     indexes.push_back( llvm::ConstantInt::get(llvm::Type::Int32Ty, 0)); // Access the structure of the array
     indexes.push_back( llvm::ConstantInt::get(llvm::Type::Int32Ty, ArrayWrap::POS_SIZE)); // Access the size of the array
     // Init the size
-    llvm::Value* ptr = llvm::GetElementPtrInst::Create( _pointer, indexes.begin(), indexes.end(), "", _currentBlock);
-    new llvm::StoreInst( GTLCore::CodeGenerator::integerToConstant( 0 ), ptr, "", _currentBlock);
+    llvm::Value* ptr = llvm::GetElementPtrInst::Create( _pointer, indexes.begin(), indexes.end(), "ArrayVisitor::initialise", _currentBlock);
+    new llvm::StoreInst( GTLCore::CodeGenerator::integerToConstant( 0 ), ptr, "ArrayVisitor::initialise", _currentBlock);
   }
   return _currentBlock;
 }
@@ -362,8 +362,8 @@
       indexes.push_back( llvm::ConstantInt::get(llvm::Type::Int32Ty, 0)); // Access the structure of the array
       indexes.push_back( llvm::ConstantInt::get(llvm::Type::Int32Ty, ArrayWrap::POS_DATA )); // Access the data of the array
       // Free the array
-      llvm::Value* ptrToData = llvm::GetElementPtrInst::Create( _pointer, indexes.begin(), indexes.end(), "", afterBlock);
-      new llvm::FreeInst( new llvm::LoadInst( ptrToData, "", afterBlock ), afterBlock );
+      llvm::Value* ptrToData = llvm::GetElementPtrInst::Create( _pointer, indexes.begin(), indexes.end(), "ArrayVisitor::cleanUp", afterBlock);
+      new llvm::FreeInst( new llvm::LoadInst( ptrToData, "ArrayVisitor::cleanUp", afterBlock ), afterBlock );
       if( _deletePointer )
       {
         new llvm::FreeInst( _pointer, afterBlock );
@@ -436,7 +436,7 @@
   }
   // Initialize the pointer to the data
   llvm::ArrayType* arrType = llvm::ArrayType::get(embedded->d->type(), currentSize);
-  llvm::Constant* arrayData = new llvm::GlobalVariable( arrType, false, llvm::GlobalValue::InternalLinkage,  llvm::ConstantArray::get(arrType ,arrayInitialisers), "", _module );
+  llvm::Constant* arrayData = new llvm::GlobalVariable( arrType, false, llvm::GlobalValue::InternalLinkage,  llvm::ConstantArray::get(arrType ,arrayInitialisers), "ArrayVisitor::createStaticVariable", _module );
   // Get the pointer to the data
   
   std::vector<llvm::Constant*> indices;
@@ -466,12 +466,12 @@
   
   return llvm::GetElementPtrInst::Create( 
               CodeGenerator::convertPointerTo( _currentBlock, _pointer, _pointerType->embeddedType()->d->type() ),
-              _index, "", _currentBlock);
+              _index, "VectorVisitor::pointerToIndex", _currentBlock);
 }
 
 ExpressionResult VectorVisitor::get( GenerationContext& _generationContext, llvm::BasicBlock* _currentBlock, llvm::Value* _pointer, const Type* _pointerType) const
 {
-  return ExpressionResult(new llvm::LoadInst( _pointer, "", _currentBlock), _pointerType );
+  return ExpressionResult(new llvm::LoadInst( _pointer, "VectorVisitor::get", _currentBlock), _pointerType );
 }
 
 llvm::BasicBlock* VectorVisitor::set(GenerationContext& _generationContext, llvm::BasicBlock* _currentBlock, llvm::Value* _pointer, const Type* _pointerType, llvm::Value* _value, const Type* _valueType, bool _allocatedInMemory) const
@@ -480,7 +480,7 @@
   GTL_DEBUG( "value = " << *_value << " type = " << *_valueType );
   new llvm::StoreInst(
           _generationContext.codeGenerator()->convertValueTo( _currentBlock, _value, _valueType, _pointerType ),
-          _pointer, "", _currentBlock);
+          _pointer, "VectorVisitor::set", _currentBlock);
   return _currentBlock;
 }
 
@@ -535,7 +535,7 @@
   std::vector<llvm::Value*> indexes;
   indexes.push_back( llvm::ConstantInt::get(llvm::Type::Int32Ty, 0));
   indexes.push_back( llvm::ConstantInt::get(llvm::Type::Int32Ty, _index + STRUCT_FIRST_ELEMENT ));
-  return llvm::GetElementPtrInst::Create( _pointer, indexes.begin(), indexes.end(), "", _currentBlock);
+  return llvm::GetElementPtrInst::Create( _pointer, indexes.begin(), indexes.end(), "StructureVisitor::pointerToValue", _currentBlock);
 }
 
 llvm::Value* StructureVisitor::pointerToIndex(GenerationContext& _generationContext, llvm::BasicBlock* _currentBlock, llvm::Value* _pointer, const Type* _type, llvm::Value* _index) const

Modified: trunk/OpenGTL/OpenGTL/GTLCore/tests/TestMetadata.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/tests/TestMetadata.h	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenGTL/GTLCore/tests/TestMetadata.h	2008-12-03 23:18:31 UTC (rev 514)
@@ -79,9 +79,9 @@
 };
 
 #define TEST_PARAMETER_ENTRY_CONSISTENT_TYPE(entry) \
-  GTLTEST_CHECK_EQUAL( entry->minimumValue().type(), entry->type() ); \
-  GTLTEST_CHECK_EQUAL( entry->maximumValue().type(), entry->type() ); \
-  GTLTEST_CHECK_EQUAL( entry->defaultValue().type(), entry->type() );
+  GTLTEST_CHECK_EQUAL( entry->minimumValue().type(), entry->valueType() ); \
+  GTLTEST_CHECK_EQUAL( entry->maximumValue().type(), entry->valueType() ); \
+  GTLTEST_CHECK_EQUAL( entry->defaultValue().type(), entry->valueType() );
 
 #define TEST_PARAMETER_ENTRY(entry) \
   GTLTEST_CHECK_EQUAL( entry->asGroup(), entry); \
@@ -105,7 +105,7 @@
         GTLTEST_CHECK_EQUAL( entry->name(), "int" );
         TEST_PARAMETER_ENTRY_CONSISTENT_TYPE(entry);
         TEST_PARAMETER_ENTRY(entry);
-        GTLTEST_CHECK_EQUAL( GTLCore::Type::Integer32, entry->type() );
+        GTLTEST_CHECK_EQUAL( GTLCore::Type::Integer32, entry->valueType() );
         GTLTEST_CHECK_EQUAL( entry->minimumValue().asInt32(), -10 );
         GTLTEST_CHECK_EQUAL( entry->maximumValue().asInt32(), 20 );
         GTLTEST_CHECK_EQUAL( entry->defaultValue().asInt32(), 10 );
@@ -118,7 +118,7 @@
         entries.push_back( Metadata::Factory::createValueEntry( "defaultValue", 0.5f ) );
         const Metadata::ParameterEntry* entry = Metadata::Factory::createParameterEntry( "float", entries );
         GTLTEST_CHECK_EQUAL( entry->name(), "float" );
-        GTLTEST_CHECK_EQUAL( GTLCore::Type::Float, entry->type() );
+        GTLTEST_CHECK_EQUAL( GTLCore::Type::Float, entry->valueType() );
         TEST_PARAMETER_ENTRY_CONSISTENT_TYPE(entry);
         TEST_PARAMETER_ENTRY(entry);
         GTLTEST_CHECK_EQUAL( entry->minimumValue().asFloat(), -0.1f );
@@ -133,7 +133,7 @@
         GTLTEST_CHECK_EQUAL( entry->name(), "int" );
         TEST_PARAMETER_ENTRY_CONSISTENT_TYPE(entry);
         TEST_PARAMETER_ENTRY(entry);
-        GTLTEST_CHECK_EQUAL( GTLCore::Type::Integer32, entry->type() );
+        GTLTEST_CHECK_EQUAL( GTLCore::Type::Integer32, entry->valueType() );
         GTLTEST_CHECK_EQUAL( entry->minimumValue().asInt32(), 0 );
         GTLTEST_CHECK_EQUAL( entry->maximumValue().asInt32(), 100 );
         GTLTEST_CHECK_EQUAL( entry->defaultValue().asInt32(), 10 );
@@ -144,7 +144,7 @@
         entries.push_back( Metadata::Factory::createValueEntry( "defaultValue", 0.5f ) );
         const Metadata::ParameterEntry* entry = Metadata::Factory::createParameterEntry( "float", entries);
         GTLTEST_CHECK_EQUAL( entry->name(), "float" );
-        GTLTEST_CHECK_EQUAL( GTLCore::Type::Float, entry->type() );
+        GTLTEST_CHECK_EQUAL( GTLCore::Type::Float, entry->valueType() );
         TEST_PARAMETER_ENTRY_CONSISTENT_TYPE(entry);
         TEST_PARAMETER_ENTRY(entry);
         GTLTEST_CHECK_EQUAL( entry->minimumValue().asFloat(), 0.0f );

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.cpp	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.cpp	2008-12-03 23:18:31 UTC (rev 514)
@@ -33,6 +33,7 @@
 #include "GTLCore/Type.h"
 #include "GTLCore/Macros_p.h"
 #include "GTLCore/Function_p.h"
+#include "GTLCore/Value.h"
 
 #include "Debug.h"
 #include "Lexer_p.h"
@@ -50,6 +51,7 @@
   Parser* parser;
   int channelsNb;
   bool isKernel;
+  std::map< GTLCore::String, GTLCore::Value > parameters;
 };
 
 Compiler::Compiler( bool _isKernel, int _channelsNb ) : d(new Private)
@@ -71,7 +73,7 @@
   return d->isKernel;
 }
 
-bool Compiler::compile(bool _loadStdLibrary, const GTLCore::String& _sourceCode, const GTLCore::String& _kernelName, GTLCore::ModuleData* _moduleData, GTLCore::String& _nameSpace)
+bool Compiler::compile(bool _loadStdLibrary, const GTLCore::String& _sourceCode, const GTLCore::String& _kernelName, GTLCore::ModuleData* _moduleData, GTLCore::String& _nameSpace, const std::map< GTLCore::String, GTLCore::Value >& parameters)
 {
   SHIVA_DEBUG("Compile: " << _kernelName << " : " << _sourceCode);
   // Initialise the module structure
@@ -80,6 +82,7 @@
   d->moduleData = _moduleData;
   d->codeGenerator = new GTLCore::CodeGenerator( d->moduleData );
   setModuleData(d->moduleData);
+  d->parameters = parameters;
 
   // Create Standard Library functions
   // CtlStdLib functions (except print which get a special treatement)
@@ -195,5 +198,14 @@
 
 GTLCore::AST::Expression* Compiler::standardConstant( const GTLCore::String& _name )
 {
+  // TODO standardConstant
+  
+  // Check if it is a parameter
+  std::map< GTLCore::String, GTLCore::Value >::iterator it = d->parameters.find(_name);
+  if( it != d->parameters.end() )
+  {
+    return GTLCore::AST::Expression::fromValue( it->second );
+  }
+  
   return 0;
 }

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.h	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.h	2008-12-03 23:18:31 UTC (rev 514)
@@ -23,8 +23,11 @@
 #include <GTLCore/String.h>
 #include <GTLCore/CompilerBase_p.h>
 
+#include <map>
+
 namespace GTLCore {
   class ModuleData;
+  class Value;
 }
 
 namespace OpenShiva {
@@ -36,7 +39,7 @@
     public:
       Compiler( bool _isKernel, int _channelsNb );
       ~Compiler();
-      bool compile(bool _loadStdLibrary, const GTLCore::String& _sourceCode, const GTLCore::String& _kernelName, GTLCore::ModuleData* _moduleData, GTLCore::String& _nameSpace);
+      bool compile(bool _loadStdLibrary, const GTLCore::String& _sourceCode, const GTLCore::String& _kernelName, GTLCore::ModuleData* _moduleData, GTLCore::String& _nameSpace, const std::map< GTLCore::String, GTLCore::Value >& parameters );
       bool importModule(const GTLCore::String& name);
       virtual GTLCore::TypeManager* typeManager();
       bool isKernel() const;

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.h	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.h	2008-12-03 23:18:31 UTC (rev 514)
@@ -53,7 +53,6 @@
       std::list< const GTLCore::Type* > m_inputsTypes;
       const GTLCore::Type* m_outputPixelType;
       const GTLCore::Type* m_outputImageType;
-      
   };
 }
 

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp	2008-12-03 23:18:31 UTC (rev 514)
@@ -38,6 +38,8 @@
 #include "GTLCore/VirtualMachine_p.h"
 #include "GTLCore/wrappers/Allocate.h"
 #include "GTLCore/Metadata/Factory_p.h"
+#include "GTLCore/Metadata/Group.h"
+#include "GTLCore/Metadata/ParameterEntry.h"
 
 #include "Debug.h"
 #include "CodeGenerator_p.h"
@@ -68,8 +70,28 @@
   metadataCompilationFailed = not compilationErrors.empty();
   GTL_DEBUG( compilationErrors.size() );
   GTL_DEBUG( parser.errorMessages().size() );
+  parameters.clear();
+  if( metadata and metadata->parameters() )
+  {
+    metadataToParameters( metadata->parameters() );
+  }
 }
 
+void Library::Private::metadataToParameters( const GTLCore::Metadata::Group* group)
+{
+  SHIVA_ASSERT( group );
+  foreach( const GTLCore::Metadata::Entry* entry, group->entries() )
+  {
+    if( const GTLCore::Metadata::ParameterEntry* pe = entry->asParameterEntry() )
+    {
+      parameters[ pe->name() ] = pe->defaultValue();
+    } else if( const GTLCore::Metadata::Group* ge = entry->asGroup() )
+    {
+      metadataToParameters( ge );
+    }
+  }
+}
+
 // -------- Library -------- //
 
 Library::Library( bool _isKernel , int _channelsNb) : d(new Private)
@@ -148,7 +170,7 @@
   Compiler c( d->isKernel,  d->count_channels_generic );
   Wrapper::fillTypeManager( d->m_moduleData, d->m_moduleData->typeManager(), c.convertCenter() , d->count_channels_generic );
   GTLCore::String nameSpace;
-  bool result = c.compile( not d->isStandardLibrary, d->source, d->name, d->m_moduleData, nameSpace );
+  bool result = c.compile( not d->isStandardLibrary, d->source, d->name, d->m_moduleData, nameSpace, d->parameters );
 
   if(result)
   {

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h	2008-12-03 23:18:31 UTC (rev 514)
@@ -22,6 +22,11 @@
 
 #include "Library.h"
 
+#include <GTLCore/String.h>
+#include <GTLCore/Value.h>
+
+#include <map>
+
 namespace llvm {
   class ModuleProvider;
   class Function;
@@ -29,6 +34,9 @@
 
 namespace GTLCore {
   class ModuleData;
+  namespace Metadata {
+    class Group;
+  }
 }
 
 namespace OpenShiva {
@@ -37,6 +45,8 @@
     {
     }
     void compileMetaData();
+    void metadataToParameters( const GTLCore::Metadata::Group* );
+    
     GTLCore::String name;
     GTLCore::String source;
     bool compiled;
@@ -48,6 +58,7 @@
     bool isStandardLibrary;
     KernelMetadata* metadata;
     bool metadataCompilationFailed;
+    std::map< GTLCore::String, GTLCore::Value > parameters;
   };
 }
 

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.cpp	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.cpp	2008-12-03 23:18:31 UTC (rev 514)
@@ -21,7 +21,10 @@
 
 #include "GTLCore/ErrorMessage.h"
 #include "GTLCore/Macros_p.h"
+#include "GTLCore/Type.h"
+#include "GTLCore/TypeManager.h"
 #include "GTLCore/Value.h"
+
 #include "GTLCore/Metadata/TextEntry.h"
 #include "GTLCore/Metadata/ValueEntry.h"
 #include "GTLCore/Metadata/Factory_p.h"
@@ -163,65 +166,76 @@
   return 0;
 }
 
-const GTLCore::Metadata::ValueEntry* Parser::parseValueEntry(const GTLCore::String& name)
+GTLCore::Value Parser::parseCoumpoundValue()
 {
-  GTL_DEBUG( "parseValueEntry" );
-  GTLCore::Value val;
-  if( currentToken().type == GTLCore::Token::FLOAT_CONSTANT )
+  std::vector< GTLCore::Value > values;
+  enum { UNKNOWN, ARRAY, FLOAT } coumpoundType = UNKNOWN;
+  if( isOfType( currentToken(), GTLCore::Token::STARTBRACE ) )
   {
-    val.setFloat( currentToken().f );
-  } else if( currentToken().type == GTLCore::Token::INTEGER_CONSTANT )
-  {
-    val.setInt32( currentToken().i );
-  } else if( currentToken().type == GTLCore::Token::STARTBRACE )
-  {
     getNextToken();
-    std::vector< GTLCore::Value > values;
-    while( currentToken().type != GTLCore::Token::ENDBRACE )
+    if( currentToken().type == GTLCore::Token::STARTBRACE )
     {
-      if( isOfType( currentToken(), GTLCore::Token::STARTBRACE ) )
+      coumpoundType = ARRAY;
+    } else {
+      coumpoundType = FLOAT;
+    }
+    while(true )
+    {
+      if( coumpoundType == ARRAY and isOfType( currentToken(), GTLCore::Token::STARTBRACE ) )
       {
+        values.push_back( parseCoumpoundValue() );
         getNextToken();
-        std::vector< GTLCore::Value > valuesEntry(2);
+      } else if( coumpoundType == FLOAT )
+      {
         if( currentToken().type == GTLCore::Token::FLOAT_CONSTANT )
         {
-          valuesEntry[0].setFloat( currentToken().f );
+          values.push_back( currentToken().f );
         } else if( currentToken().type == GTLCore::Token::INTEGER_CONSTANT )
         {
-          valuesEntry[0].setFloat( currentToken().i );
+          values.push_back( (float)currentToken().i );
         } else {
           GTL_DEBUG("Unexpected");
           reportUnexpected( currentToken() );
         }
         getNextToken();
-        if( isOfType( currentToken(), GTLCore::Token::COMA ) )
+      } else {
+        GTL_DEBUG("Unexpected");
+        reportUnexpected( currentToken() );
+        return values;
+      }
+      if( currentToken().type == GTLCore::Token::ENDBRACE )
+      {
+        const GTLCore::Type* type = 0;
+        if( coumpoundType == FLOAT )
         {
-          getNextToken();
-          if( currentToken().type == GTLCore::Token::FLOAT_CONSTANT )
-          {
-            valuesEntry[1].setFloat( currentToken().f );
-          } else if( currentToken().type == GTLCore::Token::INTEGER_CONSTANT )
-          {
-            valuesEntry[1].setFloat( currentToken().i );
-          } else {
-            GTL_DEBUG("Unexpected");
-            reportUnexpected( currentToken() );
-          }
-          getNextToken();
-          isOfType( currentToken(), GTLCore::Token::ENDBRACE );
-          getNextToken();
-          values.push_back( valuesEntry );
+          type = GTLCore::TypeManager::getVector( GTLCore::Type::Float, values.size() );
         }
-      } else {
-        return 0;
+        return GTLCore::Value(values, type);
       }
-      if( currentToken().type == GTLCore::Token::COMA )
+      if( not isOfType( currentToken(), GTLCore::Token::COMA ) )
       {
-        getNextToken();
-        isOfType( currentToken(), GTLCore::Token::STARTBRACE );
+        return values;
       }
+      getNextToken();
     }
-    val = GTLCore::Value( values );
+    getNextToken();
+  }
+  return values;
+}
+
+const GTLCore::Metadata::ValueEntry* Parser::parseValueEntry(const GTLCore::String& name)
+{
+  GTL_DEBUG( "parseValueEntry" );
+  GTLCore::Value val;
+  if( currentToken().type == GTLCore::Token::FLOAT_CONSTANT )
+  {
+    val.setFloat( currentToken().f );
+  } else if( currentToken().type == GTLCore::Token::INTEGER_CONSTANT )
+  {
+    val.setInt32( currentToken().i );
+  } else if( currentToken().type == GTLCore::Token::STARTBRACE )
+  {
+    val = parseCoumpoundValue();
   } else {
     GTL_DEBUG("Unexpected");
     reportUnexpected( currentToken() );

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.h	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.h	2008-12-03 23:18:31 UTC (rev 514)
@@ -27,6 +27,7 @@
   class ErrorMessage;
   class String;
   class Token;
+  class Value;
   namespace Metadata {
     class Entry;
     class ParameterEntry;
@@ -52,6 +53,7 @@
         const std::list<GTLCore::ErrorMessage>& errorMessages() const;
       private:
         const GTLCore::Metadata::ValueEntry* parseValueEntry(const GTLCore::String& name);
+        GTLCore::Value parseCoumpoundValue();
         const GTLCore::Metadata::ParameterEntry* parseParameterEntry(const GTLCore::String& name);
         const GTLCore::Metadata::TextEntry* parseTextEntry(const GTLCore::String& name);
         const GTLCore::Metadata::Entry* parseGroupOrParameterEntry(const GTLCore::String& name, bool _parameter);

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp	2008-12-03 23:18:31 UTC (rev 514)
@@ -81,6 +81,10 @@
       }
       getNextToken();
     } while( count > 0 and currentToken().type != GTLCore::Token::END_OF_FILE  );
+    if( isOfType( currentToken(), GTLCore::Token::SEMI ) )
+    {
+      getNextToken();
+    }
   }
   
   // Parse "import"

Modified: trunk/OpenGTL/OpenShiva/tests/convolution/copy.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/convolution/copy.shiva	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenShiva/tests/convolution/copy.shiva	2008-12-03 23:18:31 UTC (rev 514)
@@ -2,6 +2,11 @@
 {
   void evaluatePixel(image img, out pixel result)
   {
-    result = img.sampleNearest( result.coord );
+    pixel p = img.sampleNearest( result.coord );
+    result = p;
   }
+  region changed(region changed_input_region, int input_index, region input_DOD[])
+  {
+    return changed_input_region;
+  }
 }

Modified: trunk/OpenGTL/OpenShiva/tests/imagegenerators/Gradient.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/imagegenerators/Gradient.shiva	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenShiva/tests/imagegenerators/Gradient.shiva	2008-12-03 23:18:31 UTC (rev 514)
@@ -1,3 +1,11 @@
+<
+  parameters: <
+    color: <
+      type: rgb;
+      defaultValue: { 0.5, 0.0, 0.0 };
+    >;
+  >;
+>;
 kernel Gradient
 {
   void evaluatePixel(out pixel result)
@@ -2,5 +10,8 @@
   {
-    result[0] = 0.5*( result.coord[0] / 200 + result.coord[1] / 300 );
-    result[1] = 0.0;
-    result[2] = 0.0;
+    float coef = ( result.coord[0] / 200 + result.coord[1] / 300 );
+    float3 v = color * coef;
+    result[0] = v[0];
+    result[1] = v[1];
+    result[2] = v[2];
+    result[3] = 1.0;
   }

Modified: trunk/OpenGTL/OpenShiva/tests/library/TestMetadataParser.h
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/library/TestMetadataParser.h	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenShiva/tests/library/TestMetadataParser.h	2008-12-03 23:18:31 UTC (rev 514)
@@ -21,6 +21,8 @@
 #include "OpenShiva/KernelMetadata.h"
 
 #include "GTLCore/ErrorMessage.h"
+#include "GTLCore/Type.h"
+#include "GTLCore/TypeManager.h"
 #include "GTLCore/Value.h"
 #include "GTLCore/Metadata/TextEntry.h"
 #include "GTLCore/Metadata/Group.h"
@@ -79,6 +81,7 @@
       OpenShiva::KernelMetadata* km = parser.parse();
       GTLTEST_CHECK_EQUAL( parser.errorMessages().size(), 0 );
       GTLTEST_CHECK_EQUAL( km->version(), 0 );
+      
       // Test info
       TESTMEDATAPARSER_TEST_TEXT_ENTRY( km->infos()->entry( "author" ), "Joe Doe; Joe Doe Jr");
       TESTMEDATAPARSER_TEST_TEXT_ENTRY( km->infos()->entry( "license" ), "LGPLv2+");
@@ -87,6 +90,7 @@
       GTLTEST_CHECK_NOT_EQUAL( vendorGroup, 0 );
       TESTMEDATAPARSER_TEST_TEXT_ENTRY( vendorGroup->entry( "name" ), "DoeGraphics");
       TESTMEDATAPARSER_TEST_TEXT_ENTRY( vendorGroup->entry( "address" ), "1242 Main Street");
+      
       // Test parameters
       GTLTEST_CHECK_NOT_EQUAL( km->parameters()->entry( "param1" ), 0 );
       const GTLCore::Metadata::ParameterEntry* param1 = km->parameters()->entry( "param1" )->asParameterEntry();
@@ -100,22 +104,35 @@
       GTLTEST_CHECK_EQUAL( param1->defaultValue(), 50);
       TESTMEDATAPARSER_TEST_VALUE_ENTRY( param1->entry( "maxValue" ), 100);
       GTLTEST_CHECK_EQUAL( param1->maximumValue(), 100);
+      
       // Test categorie parameter
       GTLTEST_CHECK_NOT_EQUAL( km->parameters()->entry( "categorie2" ), 0 );
       const GTLCore::Metadata::Group* categorie2 = km->parameters()->entry( "categorie2" )->asGroup();
       GTLTEST_CHECK_NOT_EQUAL( categorie2, 0 );
       TESTMEDATAPARSER_TEST_TEXT_ENTRY( categorie2->entry( "description" ), "This is a categorie of parameters");
+      
       // Test parameter2
       GTLTEST_CHECK_NOT_EQUAL( categorie2->entry("param2"), 0 );
       const GTLCore::Metadata::ParameterEntry* param2 = categorie2->entry( "param2" )->asParameterEntry();
       GTLTEST_CHECK_NOT_EQUAL( param2, 0 );
       TESTMEDATAPARSER_TEST_TEXT_ENTRY( param2->entry( "type" ), "curve");
+      const GTLCore::Type* typeVector2 = GTLCore::TypeManager::getVector( GTLCore::Type::Float, 2 );
       std::vector< GTLCore::Value > v1; v1.push_back( 0.25f ); v1.push_back( 0.0f );
       std::vector< GTLCore::Value > v2; v2.push_back( 1.0f ); v2.push_back( 0.5f );
-      std::vector< GTLCore::Value > v3; v3.push_back( v1 ); v3.push_back( v2 );
-      TESTMEDATAPARSER_TEST_TEXT_ENTRY( param2->entry( "type" ), "curve");
-      TESTMEDATAPARSER_TEST_VALUE_ENTRY( param2->entry( "defaultValue" ), v3);
-      GTLTEST_CHECK_EQUAL( param2->defaultValue(), v3);
+      std::vector< GTLCore::Value > v3; v3.push_back( GTLCore::Value( v1, typeVector2 ) ); v3.push_back( GTLCore::Value( v2, typeVector2 ) );
+      GTLCore::Value param2value( v3, GTLCore::TypeManager::getArray( typeVector2 ) );
+      TESTMEDATAPARSER_TEST_VALUE_ENTRY( param2->entry( "defaultValue" ), param2value);
+      GTLTEST_CHECK_EQUAL( param2->defaultValue(), param2value);
       
+      // Test parameter3
+      GTLTEST_CHECK_NOT_EQUAL( categorie2->entry("param3"), 0 );
+      const GTLCore::Metadata::ParameterEntry* param3 = categorie2->entry( "param3" )->asParameterEntry();
+      GTLTEST_CHECK_NOT_EQUAL( param3, 0 );
+      TESTMEDATAPARSER_TEST_TEXT_ENTRY( param3->entry( "type" ), "rgb");
+      std::vector< GTLCore::Value > v4; v4.push_back( 1.0f ); v4.push_back( 0.0f ); v4.push_back( 0.0f );
+      GTLCore::Value param3value( v4, GTLCore::TypeManager::getVector( GTLCore::Type::Float, 3 ) );
+      TESTMEDATAPARSER_TEST_VALUE_ENTRY( param3->entry( "defaultValue" ), param3value);
+      GTLTEST_CHECK_EQUAL( param3->defaultValue(), param3value);
+      GTLTEST_CHECK_EQUAL( param3->defaultValue().type(), param3->valueType());
     }
 };

Modified: trunk/OpenGTL/OpenShiva/tests/parse/metadata.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/parse/metadata.shiva	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenShiva/tests/parse/metadata.shiva	2008-12-03 23:18:31 UTC (rev 514)
@@ -22,9 +22,13 @@
         type: curve;
         defaultValue: {{0.25,0},{1,0.5}};
       >;
+      param3: <
+          type: rgb;
+          defaultValue: {1,0,0};
+        >;
     >;
   >;
->
+>;
 
 kernel Metadata {
   void evaluatePixel(input image source1, output pixel result)

Modified: trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp	2008-12-01 22:42:16 UTC (rev 513)
+++ trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp	2008-12-03 23:18:31 UTC (rev 514)
@@ -28,6 +28,7 @@
 #include <GTLCore/Debug.h>
 #include <GTLCore/Region.h>
 #include <GTLCore/Type.h>
+#include <GTLCore/Utils_p.h>
 
 // GTLImageIO Headers
 #include <GTLImageIO/ImageDC.h>
@@ -54,7 +55,7 @@
   std::cout << "  -S --asm-source         print the assembly source code generated after the execution of the kernel" << std::endl;
   std::cout << "  -w --width [w]          define the width of the output" << std::endl;
   std::cout << "  -h --height [h]         define the height of the output" << std::endl;
-//   std::cout << "  -L --module-dir   add a location where to find modules" << std::endl;
+  std::cout << "  -L --module-dir   add a location where to find modules" << std::endl;
   std::cout << std::endl;
   std::cout << "  -h --help               print this message" << std::endl;
   std::cout << "  -v --version            print the version information" << std::endl;
@@ -149,6 +150,7 @@
     if(not p.isCompiled())
     {
       std::cerr << "Error: " << std::endl << p.compilationErrorsMessage() << std::endl;
+      while(true) {}
       return EXIT_FAILURE;
     }
     
@@ -202,6 +204,7 @@
       std::cerr << "Can't encode " << outputFileName << " : " << errMsg << std::endl;
       return EXIT_FAILURE;
     }
+    GTLCore::deleteAll( images );
   }
   return EXIT_SUCCESS;
 }


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