[opengtl-commits] [165] OpenCTL:

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


Revision: 165
Author:   cyrille
Date:     2008-05-18 12:53:01 +0200 (Sun, 18 May 2008)

Log Message:
-----------
OpenCTL:
* functions and variables are scoped in the namespace
OpenShiva:
* add to the specification some pixels information and pixels arithmetic
* add pixel description and reference depth to the kernel initialisation
Sdk:
* allow more than one parameters in 'invertresult.sh'

Modified Paths:
--------------
    trunk/OpenGTL/OpenCTL/OpenCTL/Module.cpp
    trunk/OpenGTL/OpenCTL/OpenCTL/Module.h
    trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp
    trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp
    trunk/OpenGTL/OpenCTL/OpenCTL/compiler/ParserNG.cpp
    trunk/OpenGTL/OpenCTL/tests/arithmetic/addition_bad.ctl
    trunk/OpenGTL/OpenCTL/tests/arithmetic/bitsoperations.ctl
    trunk/OpenGTL/OpenCTL/tests/arithmetic/comparisons.ctl
    trunk/OpenGTL/OpenCTL/tests/arithmetic/division.ctl
    trunk/OpenGTL/OpenCTL/tests/arithmetic/modulo.ctl
    trunk/OpenGTL/OpenCTL/tests/arithmetic/multiplication.ctl
    trunk/OpenGTL/OpenCTL/tests/arithmetic/orandnot.ctl
    trunk/OpenGTL/OpenCTL/tests/arithmetic/shift.ctl
    trunk/OpenGTL/OpenCTL/tests/arithmetic/substraction_bad.ctl
    trunk/OpenGTL/OpenCTL/tests/complextypes/array.ctl
    trunk/OpenGTL/OpenCTL/tests/complextypes/arrayarraysimplecoumpoundinitialiser.ctl
    trunk/OpenGTL/OpenCTL/tests/complextypes/arrayfunctioncoumpoundinitialisation.ctl
    trunk/OpenGTL/OpenCTL/tests/complextypes/structfunctioncoumpoundinitialisation.ctl
    trunk/OpenGTL/OpenCTL/tests/misc/testTestFramework.ctl
    trunk/OpenGTL/OpenCTL/tests/parse/CMakeLists.txt
    trunk/OpenGTL/OpenCTL/tests/statements/initialiserlist.ctl
    trunk/OpenGTL/OpenCTL/tests/stdlib/constants.ctl
    trunk/OpenGTL/OpenCTL/tests/stdlib/exponentials.ctl
    trunk/OpenGTL/OpenCTL/tests/stdlib/lookup.ctl
    trunk/OpenGTL/OpenCTL/tests/stdlib/powers.ctl
    trunk/OpenGTL/OpenCTL/tests/stdlib/trigonometric.ctl
    trunk/OpenGTL/OpenGTL/GTLCore/AST/FunctionDeclaration.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Debug.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Debug.h
    trunk/OpenGTL/OpenGTL/GTLCore/Function.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Function.h
    trunk/OpenGTL/OpenGTL/GTLCore/Function_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Function_p.h
    trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.h
    trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h
    trunk/OpenGTL/OpenGTL/GTLCore/Token_p.h
    trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.h
    trunk/OpenGTL/OpenShiva/doc/specification/ShivaSpec.tex
    trunk/OpenGTL/sdk/invertresult.sh

Property Changed:
----------------
    trunk/OpenGTL/OpenShiva/doc/specification/


Modified: trunk/OpenGTL/OpenCTL/OpenCTL/Module.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/Module.cpp	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/Module.cpp	2008-05-18 10:53:01 UTC (rev 165)
@@ -45,6 +45,7 @@
 struct Module::Private {
   Private() : moduleData(0), moduleProvider(0) {}
   GTLCore::String name;
+  GTLCore::String nameSpace;
   GTLCore::String source;
   bool compiled;
   GTLCore::ModuleData* moduleData;
@@ -69,6 +70,11 @@
   return d->name;
 }
 
+const GTLCore::String& Module::nameSpace() const
+{
+  return d->nameSpace;
+}
+
 void Module::setSource(const GTLCore::String& str)
 {
   d->source = str;
@@ -97,7 +103,7 @@
 {
   if( d->moduleData )
   {
-    return d->moduleData->function(name);
+    return d->moduleData->function( nameSpace(), name);
   }
   return 0;
 }

Modified: trunk/OpenGTL/OpenCTL/OpenCTL/Module.h
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/Module.h	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/Module.h	2008-05-18 10:53:01 UTC (rev 165)
@@ -48,6 +48,10 @@
        */
       const GTLCore::String& name() const;
       /**
+       * @return the namespace used for this module
+       */
+      const GTLCore::String& nameSpace() const;
+      /**
        * Set the code source of the module.
        */
       void setSource(const GTLCore::String& source);

Modified: trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp	2008-05-18 10:53:01 UTC (rev 165)
@@ -25,6 +25,7 @@
 #include "GTLCore/GenerationContext_p.h"
 #include "GTLCore/PixelDescription.h"
 #include "GTLCore/Function.h"
+#include "GTLCore/Function_p.h"
 #include "GTLCore/Parameter.h"
 #include "GTLCore/String.h"
 #include "GTLCore/Type.h"
@@ -115,7 +116,7 @@
     d->module = llvm::CloneModule(module->data()->llvmModule());
     const GTLCore::Function* functionDef = module->function( functionName );
     if( not functionDef ) return;
-    llvm::Function* function = d->module->getFunction(functionName + GTLCore::String::number( (int) functionDef->parameters().size() ));
+    llvm::Function* function = d->module->getFunction( GTLCore::Function::Data::symbolName( GTLCore::ScopedName( "", functionName), functionDef->parameters() ) );
     if(function)
     {
       GTLCore::CodeGenerator cg( d->module );

Modified: trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp	2008-05-18 10:53:01 UTC (rev 165)
@@ -125,7 +125,7 @@
   GTLCore::Function::Data* data = new GTLCore::Function::Data(arguments, arguments.size() );
   data->setFunctions( functions );
   data->setModule( d->module );
-  GTLCore::Function* function = new GTLCore::Function( _name, retType, data );
+  GTLCore::Function* function = new GTLCore::Function( GTLCore::ScopedName("", _name), retType, data );
   OCTL_ASSERT( declareFunction(GTLCore::ScopedName("", _name), function) );
   d->functionsToDelete.push_back(function);
 }
@@ -296,14 +296,14 @@
       std::vector<llvm::Function*> functions(max + 1);
       for(int i = min; i <= max; ++i)
       {
-        GTLCore::String name = (*it)->name() + GTLCore::String::number((int)(*it)->parameters().size());
+        GTLCore::String name = GTLCore::Function::Data::symbolName( (*it)->name(), (*it)->parameters() );
         functions[i] = d->module->getFunction(name);
       }
       GTLCore::Function::Data* data = new GTLCore::Function::Data( (*it)->parameters(), min );
       data->setFunctions( functions );
       data->setModule( d->module );
       GTLCore::Function* function = new GTLCore::Function( (*it)->name(), (*it)->returnType(), data);
-      declareFunction( GTLCore::ScopedName("", (*it)->name()), function );
+      declareFunction( (*it)->name(), function );
       d->functionsToDelete.push_back( function );
     }
   }

Modified: trunk/OpenGTL/OpenCTL/OpenCTL/compiler/ParserNG.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/compiler/ParserNG.cpp	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/compiler/ParserNG.cpp	2008-05-18 10:53:01 UTC (rev 165)
@@ -50,7 +50,6 @@
 struct ParserNG::Private {
   Compiler* compiler;
   AST::Tree* tree;
-  GTLCore::String nameSpace;
 };
 
 ParserNG::ParserNG(Compiler* _compiler, LexerNG* _lexer) : ParserBase(_compiler, _lexer), d(new Private)
@@ -79,7 +78,7 @@
     getNextToken();
     if( isOfType( currentToken(), GTLCore::Token::IDENTIFIER ) )
     {
-      d->nameSpace = currentToken().string;
+      setNameSpace( currentToken().string );
       getNextToken();
       isOfType( currentToken(), GTLCore::Token::STARTBRACE );
       getNextToken();
@@ -182,7 +181,7 @@
               getNextToken();
               if(expression)
               {
-                GTLCore::ScopedName scopedName( d->nameSpace, name );
+                GTLCore::ScopedName scopedName( nameSpace(), name );
                 if( d->tree->containsGlobalConstant( scopedName ) )
                 {
                   reportError("Constant '" + scopedName.toString() + "' has allready been declared", currentToken());

Modified: trunk/OpenGTL/OpenCTL/tests/arithmetic/addition_bad.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/arithmetic/addition_bad.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/arithmetic/addition_bad.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -4,8 +4,6 @@
 int main()
 {
   int errorcount = 0;
-  check(( (2+2) == 5), errorcount);
-  print( (2+2) == 5);
-  print(errorcount);
+  Test::check(( (2+2) == 5), errorcount);
   return errorcount - 1;
 }

Modified: trunk/OpenGTL/OpenCTL/tests/arithmetic/bitsoperations.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/arithmetic/bitsoperations.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/arithmetic/bitsoperations.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -3,14 +3,14 @@
 int main()
 {
   int errorcount = 0;
-  check( (2 & 1) == 0, errorcount);
-  check( (3 & 2) == 2, errorcount);
-  check( (4 & 2) == 0, errorcount);
-  check( (1 | 2) == 3, errorcount);
-  check( (1 | 3) == 3, errorcount);
-  check( (4 | 2) == 6, errorcount);
-  check( (1 ^ 3) == 2, errorcount);
-  check( (4 ^ 2) == 6, errorcount);
-  check( (6 ^ 2) == 4, errorcount);
+  Test::check( (2 & 1) == 0, errorcount);
+  Test::check( (3 & 2) == 2, errorcount);
+  Test::check( (4 & 2) == 0, errorcount);
+  Test::check( (1 | 2) == 3, errorcount);
+  Test::check( (1 | 3) == 3, errorcount);
+  Test::check( (4 | 2) == 6, errorcount);
+  Test::check( (1 ^ 3) == 2, errorcount);
+  Test::check( (4 ^ 2) == 6, errorcount);
+  Test::check( (6 ^ 2) == 4, errorcount);
   return errorcount;
 }

Modified: trunk/OpenGTL/OpenCTL/tests/arithmetic/comparisons.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/arithmetic/comparisons.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/arithmetic/comparisons.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -3,17 +3,17 @@
 int main()
 {
   int errorcount = 0;
-  check( 2 > 1, errorcount);
-  check( 2 > 1.0, errorcount);
-  check( 2.0 > 1, errorcount);
-  check( 1 < 2, errorcount);
-  check( 1.0 < 2, errorcount);
-  check( 1 < 2.0, errorcount);
-  check( 2.0 == 2.0, errorcount);
-  check( 2.0 != 3.0, errorcount);
-  check( 2.0 <= 3.0, errorcount);
-  check( 2 <= 2, errorcount);
-  check( 2 >= 2, errorcount);
-  check( 3 >= 2, errorcount);
+  Test::check( 2 > 1, errorcount);
+  Test::check( 2 > 1.0, errorcount);
+  Test::check( 2.0 > 1, errorcount);
+  Test::check( 1 < 2, errorcount);
+  Test::check( 1.0 < 2, errorcount);
+  Test::check( 1 < 2.0, errorcount);
+  Test::check( 2.0 == 2.0, errorcount);
+  Test::check( 2.0 != 3.0, errorcount);
+  Test::check( 2.0 <= 3.0, errorcount);
+  Test::check( 2 <= 2, errorcount);
+  Test::check( 2 >= 2, errorcount);
+  Test::check( 3 >= 2, errorcount);
   return errorcount;
 }

Modified: trunk/OpenGTL/OpenCTL/tests/arithmetic/division.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/arithmetic/division.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/arithmetic/division.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -3,10 +3,10 @@
 int main()
 {
   int errorcount = 0;
-  check( 2 / 3 == 0, errorcount);
-  check( 3 / 2 == 1, errorcount);
-  check( 3 / 2.0 == 1.5, errorcount);
-  check( 3.0 / 2 == 1.5, errorcount);
+  Test::check( 2 / 3 == 0, errorcount);
+  Test::check( 3 / 2 == 1, errorcount);
+  Test::check( 3 / 2.0 == 1.5, errorcount);
+  Test::check( 3.0 / 2 == 1.5, errorcount);
   return errorcount;
 
 }

Modified: trunk/OpenGTL/OpenCTL/tests/arithmetic/modulo.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/arithmetic/modulo.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/arithmetic/modulo.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -3,9 +3,9 @@
 int main()
 {
   int errorcount = 0;
-  check( 2 % 3 == 2, errorcount);
-  check( 3 % 2 == 1, errorcount);
-  check( 2 % 2 == 0, errorcount);
+  Test::check( 2 % 3 == 2, errorcount);
+  Test::check( 3 % 2 == 1, errorcount);
+  Test::check( 2 % 2 == 0, errorcount);
   return errorcount;
 
 }

Modified: trunk/OpenGTL/OpenCTL/tests/arithmetic/multiplication.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/arithmetic/multiplication.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/arithmetic/multiplication.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -3,15 +3,15 @@
 int main()
 {
   int errorcount = 0;
-  check( 2 * 3 == 6, errorcount);
-  check( 2.0 * 3 == 6, errorcount);
-  check( 2 * 3.0 == 6, errorcount);
-  check( 2 * 3.0 == 5, errorcount);
-  checkNearEqual( (-37) / 1.65, (-37.0 / 1.65), errorcount);
+  Test::check( 2 * 3 == 6, errorcount);
+  Test::check( 2.0 * 3 == 6, errorcount);
+  Test::check( 2 * 3.0 == 6, errorcount);
+  Test::check( 2 * 3.0 == 5, errorcount);
+  Test::checkNearEqual( (-37) / 1.65, (-37.0 / 1.65), errorcount);
   float denom = 1.65;
   int a = -37;
   int b = 37;
   float res = b / denom;
-  checkNearEqual( a / denom, -res, errorcount);
+  Test::checkNearEqual( a / denom, -res, errorcount);
   return errorcount - 1;
 }

Modified: trunk/OpenGTL/OpenCTL/tests/arithmetic/orandnot.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/arithmetic/orandnot.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/arithmetic/orandnot.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -3,14 +3,14 @@
 int main()
 {
   int errorcount = 0;
-  check( true || false, errorcount);
-  check( false || false, errorcount);
-  check( false || true, errorcount);
-  check( true && true, errorcount);
-  check( false && true, errorcount);
-  check( true && false, errorcount);
-  check( false && false, errorcount);
-  check( ! false, errorcount);
-  check( ! true, errorcount);
+  Test::check( true || false, errorcount);
+  Test::check( false || false, errorcount);
+  Test::check( false || true, errorcount);
+  Test::check( true && true, errorcount);
+  Test::check( false && true, errorcount);
+  Test::check( true && false, errorcount);
+  Test::check( false && false, errorcount);
+  Test::check( ! false, errorcount);
+  Test::check( ! true, errorcount);
   return errorcount - 5;
 }

Modified: trunk/OpenGTL/OpenCTL/tests/arithmetic/shift.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/arithmetic/shift.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/arithmetic/shift.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -3,11 +3,11 @@
 int main()
 {
   int errorcount = 0;
-  check( 2 << 1 == 4, errorcount);
-  check( 4 << 1 == 8, errorcount);
-  check( 4 >> 1 == 2, errorcount);
-  check( 4 >> 1 == 4 / 2, errorcount);
-  check( 8 >> 2 == 8 / 4, errorcount);
-  check( 8 << 2 == 8 >> 2, errorcount);
+  Test::check( 2 << 1 == 4, errorcount);
+  Test::check( 4 << 1 == 8, errorcount);
+  Test::check( 4 >> 1 == 2, errorcount);
+  Test::check( 4 >> 1 == 4 / 2, errorcount);
+  Test::check( 8 >> 2 == 8 / 4, errorcount);
+  Test::check( 8 << 2 == 8 >> 2, errorcount);
   return errorcount - 1;
 }

Modified: trunk/OpenGTL/OpenCTL/tests/arithmetic/substraction_bad.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/arithmetic/substraction_bad.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/arithmetic/substraction_bad.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -4,7 +4,7 @@
 int main()
 {
   int errorcount = 0;
-  check(( (2-2) == 5), errorcount);
+  Test::check(( (2-2) == 5), errorcount);
   assert(errorcount == 1);
   return 0;
 }

Modified: trunk/OpenGTL/OpenCTL/tests/complextypes/array.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/complextypes/array.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/complextypes/array.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -7,8 +7,8 @@
   int m[2];
   m[0] = 12;
   m[1] = 42;
-  checkIntEqual( m[0], 12, errorcount);
-  checkIntEqual( m[1], 42, errorcount );
-  checkIntEqual( m.size, 2, errorcount );
+  Test::checkIntEqual( m[0], 12, errorcount);
+  Test::checkIntEqual( m[1], 42, errorcount );
+  Test::checkIntEqual( m.size, 2, errorcount );
   return errorcount;
 }

Modified: trunk/OpenGTL/OpenCTL/tests/complextypes/arrayarraysimplecoumpoundinitialiser.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/complextypes/arrayarraysimplecoumpoundinitialiser.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/complextypes/arrayarraysimplecoumpoundinitialiser.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -6,12 +6,12 @@
 int main()
 {
   int errorCount = 0;
-  checkIntEqual( m[0][0], 12, errorCount);
-  checkIntEqual( m[0][1], 42, errorCount);
-  checkIntEqual( m[1][0], -12, errorCount);
-  checkIntEqual( m[1][1], -42, errorCount);
-  checkIntEqual( m.size, 2, errorCount);
-  checkIntEqual( m[0].size, 2, errorCount);
-  checkIntEqual( m[1].size, 2, errorCount);
+  Test::checkIntEqual( m[0][0], 12, errorCount);
+  Test::checkIntEqual( m[0][1], 42, errorCount);
+  Test::checkIntEqual( m[1][0], -12, errorCount);
+  Test::checkIntEqual( m[1][1], -42, errorCount);
+  Test::checkIntEqual( m.size, 2, errorCount);
+  Test::checkIntEqual( m[0].size, 2, errorCount);
+  Test::checkIntEqual( m[1].size, 2, errorCount);
   return errorCount;
 }

Modified: trunk/OpenGTL/OpenCTL/tests/complextypes/arrayfunctioncoumpoundinitialisation.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/complextypes/arrayfunctioncoumpoundinitialisation.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/complextypes/arrayfunctioncoumpoundinitialisation.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -5,8 +5,8 @@
 {
   int errorcount = 0;
   int m[2] = { 12, 42 };
-  checkIntEqual( m[0], 12, errorcount);
-  checkIntEqual( m[1], 42, errorcount );
-  checkIntEqual( m.size, 2, errorcount );
+  Test::checkIntEqual( m[0], 12, errorcount);
+  Test::checkIntEqual( m[1], 42, errorcount );
+  Test::checkIntEqual( m.size, 2, errorcount );
   return errorcount;
 }

Modified: trunk/OpenGTL/OpenCTL/tests/complextypes/structfunctioncoumpoundinitialisation.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/complextypes/structfunctioncoumpoundinitialisation.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/complextypes/structfunctioncoumpoundinitialisation.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -10,7 +10,7 @@
 {
   int errorcount = 0;
   MyStruct m = { 12, 42.0 };
-  checkIntEqual( m.a, 12, errorcount);
-  checkIntEqual( m.b, 42, errorcount );
+  Test::checkIntEqual( m.a, 12, errorcount);
+  Test::checkIntEqual( m.b, 42, errorcount );
   return errorcount;
 }

Modified: trunk/OpenGTL/OpenCTL/tests/misc/testTestFramework.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/misc/testTestFramework.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/misc/testTestFramework.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -4,9 +4,9 @@
 int main()
 {
   int errorcount = 0;
-  check(true, errorcount);
-  check(false, errorcount);
-  check(false, errorcount);
+  Test::check(true, errorcount);
+  Test::check(false, errorcount);
+  Test::check(false, errorcount);
   return errorcount - 2;
 }
 

Modified: trunk/OpenGTL/OpenCTL/tests/parse/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/parse/CMakeLists.txt	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/parse/CMakeLists.txt	2008-05-18 10:53:01 UTC (rev 165)
@@ -31,11 +31,13 @@
   function_output_variable.ctl
   function_use_global_constant.ctl
   unaryoperator_tilde_integer.ctl
+  variable_scope.ctl
   varying.ctl
+  function_scope.ctl
   )
 
 FOREACH( TEST_FILE ${TESTS_FILES} )
-  ADD_TEST(${TEST_FILE} ${CTLC} ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_FILE})
+  ADD_TEST(${TEST_FILE} ${CTLC} -L ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_FILE})
 ENDFOREACH( TEST_FILE )
 
 set( TESTS_FAIL_FILES
@@ -49,8 +51,9 @@
   name_conflict.ctl
   global_const_non_const_initializer.ctl
   function_output_not_variable.ctl
+  function_out_of_scope.ctl
   )
 
 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 ${CTLC} -L ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_FILE})
 ENDFOREACH( TEST_FILE )

Modified: trunk/OpenGTL/OpenCTL/tests/statements/initialiserlist.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/statements/initialiserlist.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/statements/initialiserlist.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -10,9 +10,9 @@
   int b[3] = a;
   
   int errorCount = 0;
-  checkIntEqual( b[0], 10, errorCount );
-  checkIntEqual( b[1],  8, errorCount );
-  checkIntEqual( b[2], 15, errorCount );
+  Test::checkIntEqual( b[0], 10, errorCount );
+  Test::checkIntEqual( b[1],  8, errorCount );
+  Test::checkIntEqual( b[2], 15, errorCount );
   
   return errorCount;
 }

Modified: trunk/OpenGTL/OpenCTL/tests/stdlib/constants.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/stdlib/constants.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/stdlib/constants.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -4,13 +4,13 @@
 int main()
 {
   int errorCount = 0;
-  checkNearEqual(M_PI, 3.141592, errorCount);
-  checkNearEqual(M_E, 2.718281, errorCount);
-  check(FLT_MAX > 3.4028e38, errorCount);
-  check(FLT_MAX < 3.4029e38, errorCount);
-  check(FLT_MIN > 1.1754e-38, errorCount);
-  check(FLT_MIN < 1.1755e-38, errorCount);
-  checkIntEqual(INT_MAX, 2147483647, errorCount );
+  Test::checkNearEqual(M_PI, 3.141592, errorCount);
+  Test::checkNearEqual(M_E, 2.718281, errorCount);
+  Test::check(FLT_MAX > 3.4028e38, errorCount);
+  Test::check(FLT_MAX < 3.4029e38, errorCount);
+  Test::check(FLT_MIN > 1.1754e-38, errorCount);
+  Test::check(FLT_MIN < 1.1755e-38, errorCount);
+  Test::checkIntEqual(INT_MAX, 2147483647, errorCount );
 //  checkIntEqual(INT_MIN, -2147483648, errorCount ); // TODO: for some reason on x86-32 integer saturates to -2147483647 while INT_MIN is correctly set at -2147483648
   assert(isinf_f(FLT_POS_INF));
   assert(isinf_f(FLT_NEG_INF));

Modified: trunk/OpenGTL/OpenCTL/tests/stdlib/exponentials.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/stdlib/exponentials.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/stdlib/exponentials.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -4,31 +4,31 @@
 int main()
 {
   int errorcount = 0;
-  checkNearEqual( cosh(0.0), 1.0, errorcount);
-  checkNearEqual( cosh(1.0), cosh(-1.0), errorcount);
-  checkNearEqual( cosh(1.0), 0.5 * (M_E + 1.0 / M_E), errorcount);
-  checkNearEqual( sinh(0.0), 0.0, errorcount);
-  checkNearEqual( sinh(-1.0), -sinh(1.0), errorcount);
-  checkNearEqual( sinh(1.0), 0.5 * (M_E - 1.0 / M_E), errorcount);
-  checkNearEqual( tanh(0.0), 0, errorcount);
-  checkNearEqual( tanh(-1.0), -tanh(1.0), errorcount);
+  Test::checkNearEqual( cosh(0.0), 1.0, errorcount);
+  Test::checkNearEqual( cosh(1.0), cosh(-1.0), errorcount);
+  Test::checkNearEqual( cosh(1.0), 0.5 * (M_E + 1.0 / M_E), errorcount);
+  Test::checkNearEqual( sinh(0.0), 0.0, errorcount);
+  Test::checkNearEqual( sinh(-1.0), -sinh(1.0), errorcount);
+  Test::checkNearEqual( sinh(1.0), 0.5 * (M_E - 1.0 / M_E), errorcount);
+  Test::checkNearEqual( tanh(0.0), 0, errorcount);
+  Test::checkNearEqual( tanh(-1.0), -tanh(1.0), errorcount);
   
-  checkNearEqual( exp(1.0), M_E, errorcount);
-  checkNearEqual( exp(0.0), 1.0, errorcount);
-  checkNearEqual( exp(-1.0), 1 / M_E, errorcount);
-  checkNearEqual( log(1.0), 0.0, errorcount);
-  checkNearEqual( log(M_E), 1.0, errorcount);
-  checkNearEqual( log10(10.0), 1.0, errorcount);
-  checkNearEqual( log10(100.0), 2.0, errorcount);
+  Test::checkNearEqual( exp(1.0), M_E, errorcount);
+  Test::checkNearEqual( exp(0.0), 1.0, errorcount);
+  Test::checkNearEqual( exp(-1.0), 1 / M_E, errorcount);
+  Test::checkNearEqual( log(1.0), 0.0, errorcount);
+  Test::checkNearEqual( log(M_E), 1.0, errorcount);
+  Test::checkNearEqual( log10(10.0), 1.0, errorcount);
+  Test::checkNearEqual( log10(100.0), 2.0, errorcount);
   
   // Multiple checks
   float v = -10.0;
   while(v <= 10.0)
   {
-    checkNearEqual( tanh(v), sinh(v)/cosh(v), errorcount);
-    checkNearEqual( exp(log(v)), v, errorcount);
-    checkNearEqual( exp(v), 1.0 / exp( -v), errorcount);
-    checkNearEqual( log(v), -log(1.0 / v), errorcount);
+    Test::checkNearEqual( tanh(v), sinh(v)/cosh(v), errorcount);
+    Test::checkNearEqual( exp(log(v)), v, errorcount);
+    Test::checkNearEqual( exp(v), 1.0 / exp( -v), errorcount);
+    Test::checkNearEqual( log(v), -log(1.0 / v), errorcount);
     v = v + 0.1;
   }
 

Modified: trunk/OpenGTL/OpenCTL/tests/stdlib/lookup.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/stdlib/lookup.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/stdlib/lookup.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -4,9 +4,9 @@
 {
   int errorcount = 0;
   float table[] = { 1, 4, 5 };
-  checkNearEqual( lookup1D( table, 0.0, 1.0, -1.0 ), 1.0, errorcount);
-  checkNearEqual( lookup1D( table, 0.0, 1.0, 2.0 ), 5.0, errorcount);
-  checkNearEqual( lookup1D( table, 0.0, 1.0, 0.5 ), 4.0, errorcount);
+  Test::checkNearEqual( lookup1D( table, 0.0, 1.0, -1.0 ), 1.0, errorcount);
+  Test::checkNearEqual( lookup1D( table, 0.0, 1.0, 2.0 ), 5.0, errorcount);
+  Test::checkNearEqual( lookup1D( table, 0.0, 1.0, 0.5 ), 4.0, errorcount);
   
   
   return errorcount;

Modified: trunk/OpenGTL/OpenCTL/tests/stdlib/powers.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/stdlib/powers.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/stdlib/powers.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -4,19 +4,19 @@
 int main()
 {
   int errorcount = 0;
-  checkNearEqual( pow(3.0, 2.0), 9.0, errorcount);
+  Test::checkNearEqual( pow(3.0, 2.0), 9.0, errorcount);
   
   // Multiple checks
   float v = -10.0;
   while(v <= 10.0)
   {
-    checkNearEqual( pow(v, 0.0), 1.0, errorcount);
-    checkNearEqual( sqrt(v*v), fabs(v), errorcount);
+    Test::checkNearEqual( pow(v, 0.0), 1.0, errorcount);
+    Test::checkNearEqual( sqrt(v*v), fabs(v), errorcount);
     if(v >= 0.0)
     {
-      checkNearEqual( pow(v, 0.5), sqrt(v), errorcount);
+      Test::checkNearEqual( pow(v, 0.5), sqrt(v), errorcount);
     }
-    checkNearEqual( pow(v, 2.0), v*v, errorcount);
+    Test::checkNearEqual( pow(v, 2.0), v*v, errorcount);
     v = v + 0.1;
   }
 

Modified: trunk/OpenGTL/OpenCTL/tests/stdlib/trigonometric.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/stdlib/trigonometric.ctl	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenCTL/tests/stdlib/trigonometric.ctl	2008-05-18 10:53:01 UTC (rev 165)
@@ -4,30 +4,30 @@
 int main()
 {
   int errorcount = 0;
-  checkNearEqual( acos(1.0), 0.0, errorcount);
-  checkNearEqual( asin(1.0), M_PI * 0.5, errorcount);
-  checkNearEqual( atan(0.0), 0, errorcount);
-  checkNearEqual( atan(1.0), M_PI * 0.25, errorcount);
-  checkNearEqual( atan(FLT_POS_INF), M_PI * 0.5, errorcount);
-  checkNearEqual( atan(FLT_NEG_INF), -M_PI * 0.5, errorcount);
-  checkNearEqual( atan2(1.0, 0.0), M_PI * 0.5, errorcount);
-  checkNearEqual( atan2(-1.0, 0.0), -M_PI * 0.5, errorcount);
-  checkNearEqual( cos(M_PI), -1.0, errorcount);
-  checkNearEqual( cos(0.5 * M_PI), 0.0, errorcount);
-  checkNearEqual( cos(0.0), 1.0, errorcount);
-  checkNearEqual( sin(-0.5 * M_PI), -1.0, errorcount);
-  checkNearEqual( sin(0.5 * M_PI), 1.0, errorcount);
-  checkNearEqual( sin(0.0), 0.0, errorcount);
-  checkNearEqual( tan(0.0), 0, errorcount);
-  checkNearEqual( tan(0.25 * M_PI), 1.0, errorcount);
-  checkNearEqual( tan(-0.25 * M_PI), -1.0, errorcount);
+  Test::checkNearEqual( acos(1.0), 0.0, errorcount);
+  Test::checkNearEqual( asin(1.0), M_PI * 0.5, errorcount);
+  Test::checkNearEqual( atan(0.0), 0, errorcount);
+  Test::checkNearEqual( atan(1.0), M_PI * 0.25, errorcount);
+  Test::checkNearEqual( atan(FLT_POS_INF), M_PI * 0.5, errorcount);
+  Test::checkNearEqual( atan(FLT_NEG_INF), -M_PI * 0.5, errorcount);
+  Test::checkNearEqual( atan2(1.0, 0.0), M_PI * 0.5, errorcount);
+  Test::checkNearEqual( atan2(-1.0, 0.0), -M_PI * 0.5, errorcount);
+  Test::checkNearEqual( cos(M_PI), -1.0, errorcount);
+  Test::checkNearEqual( cos(0.5 * M_PI), 0.0, errorcount);
+  Test::checkNearEqual( cos(0.0), 1.0, errorcount);
+  Test::checkNearEqual( sin(-0.5 * M_PI), -1.0, errorcount);
+  Test::checkNearEqual( sin(0.5 * M_PI), 1.0, errorcount);
+  Test::checkNearEqual( sin(0.0), 0.0, errorcount);
+  Test::checkNearEqual( tan(0.0), 0, errorcount);
+  Test::checkNearEqual( tan(0.25 * M_PI), 1.0, errorcount);
+  Test::checkNearEqual( tan(-0.25 * M_PI), -1.0, errorcount);
   
   // Multiple checks
   float v = -10.0;
   while(v <= 10.0)
   {
-    checkNearEqual( hypot(sin(v), cos(v)), 1.0, errorcount);
-    checkNearEqual( tan(v), sin(v) / cos(v), errorcount);
+    Test::checkNearEqual( hypot(sin(v), cos(v)), 1.0, errorcount);
+    Test::checkNearEqual( tan(v), sin(v) / cos(v), errorcount);
     v = v + 0.1;
   }
 

Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/FunctionDeclaration.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/FunctionDeclaration.cpp	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/FunctionDeclaration.cpp	2008-05-18 10:53:01 UTC (rev 165)
@@ -68,7 +68,7 @@
                                     ( type->dataType() == Type::STRUCTURE or type->dataType() == Type::ARRAY ) and ( not m_parameters[i]->parameter().output() ) ) );
   }
   m_functionData = new Function::Data( parameters, minimumParameters );
-  m_function = new Function( _name.name(), _returnType, m_functionData );
+  m_function = new Function( _name, _returnType, m_functionData );
 }
 
 GTLCore::Function* FunctionDeclaration::function()
@@ -102,19 +102,21 @@
   std::vector<llvm::Function*> functions( params.size() + 1 );
   // Generate the full function
   llvm::FunctionType* definitionType = llvm::FunctionType::get( m_function->returnType()->data()->type(), params, false );
-  GTLCore::String fullFunctionName = m_function->name() + GTLCore::String::number((int)params.size());
+  GTLCore::String fullFunctionName = GTLCore::Function::Data::symbolName( m_function->name(), m_function->parameters());
   llvm::Function* fullFunction = _codeGenerator->createFunction(definitionType, fullFunctionName );
   functions[ params.size() ] = fullFunction;
-  
+  std::vector< Parameter > gtlParams = m_function->parameters(); // Use a copy of this to create the symbol name
   // Generates functions for default parameters
   llvm::Function* previousFunction = fullFunction;
   for( unsigned int i = m_function->parameters().size(); i > m_function->data()->minimumParameters(); i--)
   {
     // Create the function type
     params.pop_back(); // remove the last parameter
+    gtlParams.pop_back(); // remove the last parameter
     llvm::FunctionType* definitionType = llvm::FunctionType::get( m_function->returnType()->data()->type(), params, false );
     // Create the function
-    llvm::Function* function = _codeGenerator->createFunction( definitionType, m_function->name() + GTLCore::String::number((int)params.size()));
+    llvm::Function* function = _codeGenerator->createFunction( definitionType, 
+        GTLCore::Function::Data::symbolName(m_function->name() , gtlParams ) );
     GenerationContext generationContext( _codeGenerator, function, m_function, _module);
     // Create a block for the call to the function with one more parameter
     llvm::BasicBlock* BB = new llvm::BasicBlock("CallForwarder");

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Debug.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Debug.cpp	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Debug.cpp	2008-05-18 10:53:01 UTC (rev 165)
@@ -19,6 +19,7 @@
 
 #include "Debug.h"
 #include "ScopedName.h"
+#include "Token_p.h"
 #include "Type.h"
 
 using namespace GTLCore;
@@ -67,5 +68,14 @@
     }
   return ostr;
   }
+  std::ostream& operator<< (std::ostream& ostr, const GTLCore::Token& token)
+  {
+    ostr << Token::typeToString( token.type );
+    if( token.isPrimary() )
+    {
+      ostr << " primary";
+    }
+    return ostr;
+  }
 
 }

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Debug.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Debug.h	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Debug.h	2008-05-18 10:53:01 UTC (rev 165)
@@ -25,9 +25,11 @@
 namespace GTLCore {
   class ScopedName;
   class Type;
+  class Token;
 
   std::ostream& operator<< (std::ostream& ostr, const GTLCore::ScopedName& name);
   std::ostream& operator<< (std::ostream& ostr, const GTLCore::Type& type);
+  std::ostream& operator<< (std::ostream& ostr, const GTLCore::Token& token);
 }
 
 

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Function.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Function.cpp	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Function.cpp	2008-05-18 10:53:01 UTC (rev 165)
@@ -23,6 +23,7 @@
 #include "Debug.h"
 #include "Function_p.h"
 #include "Value.h"
+#include "ScopedName.h"
 #include "Type.h"
 #include "FunctionCaller_p.h"
 
@@ -30,13 +31,13 @@
 
 struct Function::Private
 {
-  GTLCore::String name;
+  GTLCore::ScopedName name;
   const GTLCore::Type* returnType;
   Function::Data* data;
   std::vector<FunctionCaller*> functionsCaller;
 };
 
-Function::Function(const GTLCore::String& _name, const GTLCore::Type* _returnType, Data* _data) : d(new Private)
+Function::Function(const GTLCore::ScopedName& _name, const GTLCore::Type* _returnType, Data* _data) : d(new Private)
 {
   d->name = _name;
   d->returnType = _returnType;
@@ -54,7 +55,7 @@
   delete d;
 }
 
-const GTLCore::String& Function::name() const
+const GTLCore::ScopedName& Function::name() const
 {
   return d->name;
 }

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Function.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Function.h	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Function.h	2008-05-18 10:53:01 UTC (rev 165)
@@ -27,6 +27,7 @@
   class Type;
   class Value;
   class Parameter;
+  class ScopedName;
   /**
    * This class contains the information about a function, it also allow to
    * execute the function.
@@ -43,12 +44,12 @@
        * @param _returnType the return type of the function
        * @param _data private data of the function
        */
-      Function(const GTLCore::String& _name, const GTLCore::Type* _returnType, Data* _data);
+      Function(const GTLCore::ScopedName& _name, const GTLCore::Type* _returnType, Data* _data);
       ~Function();
       /**
        * @return the name of the function
        */
-      const GTLCore::String& name() const;
+      const GTLCore::ScopedName& name() const;
       /**
        * Call this function with the given parameters.
        */

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Function_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Function_p.cpp	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Function_p.cpp	2008-05-18 10:53:01 UTC (rev 165)
@@ -22,6 +22,7 @@
 #include "Parameter.h"
 
 #include "Debug.h"
+#include "ScopedName.h"
 
 using namespace GTLCore;
 
@@ -61,3 +62,7 @@
   return m_functions[count];
 }
 
+GTLCore::String Function::Data::symbolName( const ScopedName& _functionName, const std::vector< Parameter >& _parameters )
+{
+  return _functionName.nameSpace() + "_" + _functionName.name() + GTLCore::String::number( (int)_parameters.size() );
+}

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Function_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Function_p.h	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Function_p.h	2008-05-18 10:53:01 UTC (rev 165)
@@ -59,6 +59,10 @@
       unsigned int minimumParameters() const { return m_minimumParameters; }
       unsigned int maximumParameters() const { return m_maximumParameters; }
       const std::vector< Parameter >& parameters() { return m_parameters; }
+      /**
+       * @return the symbol name for the function with the given scoped name and parameters
+       */
+      static GTLCore::String symbolName( const ScopedName& _functionName, const std::vector< Parameter >& _parameters );
     private:
       std::vector< Parameter > m_parameters;
       std::vector<llvm::Function*> m_functions;

Modified: trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.cpp	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.cpp	2008-05-18 10:53:01 UTC (rev 165)
@@ -34,7 +34,7 @@
 
 ModuleData::~ModuleData()
 {
-  for( std::map<GTLCore::String, GTLCore::Function*>::iterator it = m_functions.begin();
+  for( std::map<ScopedName, Function*>::iterator it = m_functions.begin();
        it != m_functions.end(); ++it)
   {
     delete it->second;
@@ -43,7 +43,7 @@
   delete m_typeManager;
 }
 
-bool ModuleData::appendFunction(const GTLCore::String& name, GTLCore::Function* function)
+bool ModuleData::appendFunction(const ScopedName& name, Function* function)
 {
   GTL_DEBUG(name);
   if( m_functions.find(name) != m_functions.end())
@@ -54,9 +54,23 @@
   return true;
 }
 
-GTLCore::Function* ModuleData::function(const GTLCore::String& name)
+Function* ModuleData::function(const String& _currentNameSpace, const String& _name)
 {
-  std::map<GTLCore::String, GTLCore::Function*>::iterator it = m_functions.find(name);
+  for( std::map<ScopedName, Function*>::iterator it = m_functions.begin();
+       it != m_functions.end(); ++it)
+  {
+    if( (it->first.nameSpace() == "" or it->first.nameSpace() == _currentNameSpace )
+        and it->first.name() == _name )
+    {
+      return it->second;
+    }
+  }
+  return 0;
+}
+
+Function* ModuleData::function(const ScopedName& name)
+{
+  std::map<ScopedName, Function*>::iterator it = m_functions.find(name);
   if( it == m_functions.end())
   {
     return 0;
@@ -65,11 +79,11 @@
   }
 }
 
-std::list<GTLCore::Function*> ModuleData::functions()
+std::list<Function*> ModuleData::functions()
 {
-  std::list<GTLCore::Function*> functions;
+  std::list<Function*> functions;
   GTL_DEBUG( m_functions.size());
-  for( std::map<GTLCore::String, GTLCore::Function*>::iterator it = m_functions.begin();
+  for( std::map<ScopedName, Function*>::iterator it = m_functions.begin();
        it != m_functions.end(); ++it)
   {
     functions.push_back(it->second);

Modified: trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.h	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.h	2008-05-18 10:53:01 UTC (rev 165)
@@ -22,9 +22,10 @@
 
 #include <map>
 #include <list>
-#include <GTLCore/String.h>
+#include <GTLCore/ScopedName.h>
 
 namespace llvm {
+  class Constant;
   class Module;
 }
 
@@ -34,23 +35,30 @@
   /**
    * @internal
    * This class is not part of the public API of GTLCore.
-   * 
+   * @ingroup GTLCore
    */
   class ModuleData {
     public:
       ModuleData( llvm::Module* llvmModule);
       ~ModuleData();
-      bool appendFunction(const GTLCore::String& name, GTLCore::Function* function);
-      GTLCore::Function* function(const GTLCore::String& name);
-      std::list<GTLCore::Function*> functions();
+      bool appendFunction(const ScopedName& name, Function* function);
+      Function* function(const String& _currentNameSpace, const String& _name);
+      Function* function(const ScopedName& name);
+      std::list<Function*> functions();
+      std::map< ScopedName, llvm::Constant* > constants() { return m_constants; }
+      void addConstant( const ScopedName& _scopedName, llvm::Constant* _constant )
+      {
+        m_constants[_scopedName] = _constant;
+      }
       llvm::Module* llvmModule() { return m_llvmModule; }
       const llvm::Module* llvmModule() const { return m_llvmModule; }
       TypeManager* typeManager() { return m_typeManager; }
       const TypeManager* typeManager() const { return m_typeManager; }
     private:
       llvm::Module* m_llvmModule;
-      std::map<GTLCore::String, GTLCore::Function*> m_functions;
+      std::map<ScopedName, Function*> m_functions;
       TypeManager* m_typeManager;
+      std::map< ScopedName, llvm::Constant* > m_constants;
   };
 }
 

Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp	2008-05-18 10:53:01 UTC (rev 165)
@@ -257,6 +257,7 @@
     return expr;
   } else if( d->currentToken.isPrimary() )
   {
+    GTL_DEBUG( d->currentToken.isPrimary() << " " << d->currentToken);
     AST::Expression* exprConst = parsePrimaryExpression(_constantExpression);
     if( exprConst )
     { // What's next ? A binary operator or a ;
@@ -268,6 +269,9 @@
       } else {
         GTL_DEBUG("unexpected");
         reportUnexpected( d->currentToken );
+        getNextToken();
+        delete exprConst;
+        return 0;
       }
     } else {
       // An error has occured
@@ -569,6 +573,10 @@
   while(d->currentToken.type != GTLCore::Token::ENDBRACE)
   {
     AST::Statement* statement = parseStatement();
+    if( not statement )
+    {
+      return 0;
+    }
     list.push_back( statement );
   }
   getNextToken();
@@ -909,7 +917,13 @@
         // It can be either a call to a function or a variable access
         GTLCore::ScopedName name("", d->currentToken.string );
         GTLCore::MemberArray* memberArray = 0;
-        getNextToken();
+        getNextToken(); // eat the identifier
+        if( d->currentToken.type == GTLCore::Token::COLONCOLON )
+        {
+          getNextToken(); // eat the ::
+          name = GTLCore::ScopedName( name.name(), d->currentToken.string );
+          getNextToken(); // eat the name
+        }
         if( d->currentToken.type == GTLCore::Token::STARTBRACKET )
         { // It's a function call
           GTLCore::Function* function = d->compiler->function( name );
@@ -933,7 +947,7 @@
               {
                 if( not dynamic_cast< AST::VariableExpression* >( expression ) )
                 {
-                  reportError( "Parameter of function '" + function->name() + "' is an output parameter and requires a variable as argument", d->currentToken );
+                  reportError( "Parameter of function '" + function->name().toString() + "' is an output parameter and requires a variable as argument", d->currentToken );
                 }
               }
               if( d->currentToken.type == GTLCore::Token::COMA )
@@ -1112,13 +1126,19 @@
 
 GTLCore::VariableNG* ParserBase::getVariable( const GTLCore::ScopedName& n ) const
 {
+  GTL_DEBUG("getVariable " << n );
   for( std::list<Context>::const_iterator cit = d->contextes.begin();
        cit != d->contextes.end(); cit++)
   {
-    std::map<GTLCore::ScopedName, GTLCore::VariableNG*>::const_iterator it = cit->variables.find( n );
-    if( it != cit->variables.end())
+    for( std::map<GTLCore::ScopedName, GTLCore::VariableNG*>::const_iterator it = cit->variables.begin();
+         it != cit->variables.end(); ++it)
     {
-      return it->second;
+      GTL_DEBUG( " storage: " << it->first << " namespace: " << d->nameSpace );
+      if( it->first == n
+          or ( it->first.nameSpace() == d->nameSpace and it->first.name() == n.name() ) )
+      {
+        return it->second;
+      }
     }
   }
   return 0;
@@ -1148,3 +1168,13 @@
   }
   return integersList;
 }
+
+void ParserBase::setNameSpace( const GTLCore::String& _nameSpace )
+{
+  d->nameSpace = _nameSpace;
+}
+
+const GTLCore::String& ParserBase::nameSpace() const
+{
+  return d->nameSpace;
+}

Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h	2008-05-18 10:53:01 UTC (rev 165)
@@ -130,6 +130,8 @@
       void startContext();
       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/Token_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Token_p.h	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Token_p.h	2008-05-18 10:53:01 UTC (rev 165)
@@ -39,39 +39,39 @@
       END_OF_FILE = -2,
       UNKNOWN = - 1,
     // Special characters
-      SEMI = 0,
-      COLONCOLON,
-      COMA,
-      DOT,
+      SEMI = 0, ///< ;
+      COLONCOLON, ///< :
+      COMA, ///< ,
+      DOT, ///< .
       STARTBRACE, ///< {
       ENDBRACE, ///< }
       STARTBRACKET, ///< (
       ENDBRACKET, ///< )
       STARTBOXBRACKET, ///< [
       ENDBOXBRACKET, ///< ]
-      EQUAL,
-      EQUALEQUAL,
-      DIFFERENT,
-      AND,
-      OR,
-      BITAND,
-      BITXOR,
-      BITOR,
-      INFERIOR,
-      INFERIOREQUAL,
-      SUPPERIOR,
-      SUPPERIOREQUAL,
-      LEFTSHIFT,
-      RIGHTSHIFT,
-      PLUS,
-      PLUSPLUS,
-      MINUS,
-      MINUSMINUS,
-      MULTIPLY,
-      DIVIDE,
-      MODULO,
-      TILDE,
-      NOT,
+      EQUAL, ///< =
+      EQUALEQUAL, ///< ==
+      DIFFERENT, ///< !=
+      AND, ///< and &&
+      OR, ///< or ||
+      BITAND, ///< &
+      BITXOR, ///< ^
+      BITOR, ///< |
+      INFERIOR, ///< <
+      INFERIOREQUAL, ///< <=
+      SUPPERIOR, ///< >
+      SUPPERIOREQUAL, ///< >=
+      LEFTSHIFT, ///< <<
+      RIGHTSHIFT, ///< >>
+      PLUS, ///< +
+      PLUSPLUS, ///< ++
+      MINUS, ///< -
+      MINUSMINUS, ///< --
+      MULTIPLY, ///< *
+      DIVIDE, ///< /
+      MODULO, ///< %
+      TILDE, ///< ~
+      NOT, ///< not !
       // Constants
       FLOAT_CONSTANT,
       INTEGER_CONSTANT,

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp	2008-05-18 10:53:01 UTC (rev 165)
@@ -27,6 +27,8 @@
 
 #include "GTLCore/ErrorMessage.h"
 #include "GTLCore/ModuleData_p.h"
+#include "GTLCore/PixelDescription.h"
+#include "GTLCore/Type.h"
 #include "GTLCore/VirtualMachine_p.h"
 
 #include "Debug.h"
@@ -46,6 +48,26 @@
 
 Kernel::Kernel(const GTLCore::String& _name) : d(new Private)
 {
+  init(_name, GTLCore::PixelDescription( GTLCore::Type::Float, 4 ), GTLCore::Type::Float );
+}
+
+Kernel::Kernel(const GTLCore::String& _name, const GTLCore::Type* _referenceDepth, int _channelsNb ) : d(new Private)
+{
+  init(_name, GTLCore::PixelDescription( _referenceDepth, _channelsNb ), _referenceDepth );
+}
+
+Kernel::Kernel(const GTLCore::String& _name, const GTLCore::PixelDescription& _pixelDescription ) : d(new Private)
+{
+  init(_name, _pixelDescription, _pixelDescription.channelTypes()[0] );
+}
+
+Kernel::Kernel(const GTLCore::String& _name, const GTLCore::PixelDescription& _pixelDescription, const GTLCore::Type* _referenceDepth ) : d(new Private)
+{
+  init(_name, _pixelDescription, _referenceDepth );
+}
+
+void Kernel::init(const GTLCore::String& _name, const GTLCore::PixelDescription& , const GTLCore::Type* _referenceDepth )
+{
   d->name = _name;
   d->compiled = false;
   d->enableHydraCompatibility = false;
@@ -53,6 +75,7 @@
   d->moduleData = 0;
 }
 
+
 const GTLCore::String& Kernel::name() const
 {
   return d->name;

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.h	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.h	2008-05-18 10:53:01 UTC (rev 165)
@@ -24,15 +24,25 @@
 
 namespace GTLCore {
   class ErrorMessage;
+  class Type;
+  class PixelDescription;
 }
 
 #include <GTLCore/String.h>
 
 namespace OpenShiva {
   class AbstractImage;
+  /**
+   * @ingroup OpenShiva
+   */
   class Kernel {
     public:
-      Kernel(const GTLCore::String& _name);
+      Kernel(const GTLCore::String& _name );
+      Kernel(const GTLCore::String& _name, const GTLCore::Type* _referenceDepth, int _channelsNb );
+      Kernel(const GTLCore::String& _name, const GTLCore::PixelDescription& _pixelDescription );
+      Kernel(const GTLCore::String& _name, const GTLCore::PixelDescription& _pixelDescription, const GTLCore::Type* _referenceDepth );
+    private:
+      void init(const GTLCore::String& _name, const GTLCore::PixelDescription& , const GTLCore::Type* _referenceDepth );
     public:
       /**
        * @return the name of the module (it's usually the name of the file without the .ctl


Property changes on: trunk/OpenGTL/OpenShiva/doc/specification
___________________________________________________________________
Name: svn:ignore
   - ShivaSpec.toc
ShivaSpec.tex.backup
ShivaSpec.pdf
ShivaSpec.log
ShivaSpec.idx
ShivaSpec.aux

   + ShivaSpec.toc
ShivaSpec.tex.backup
ShivaSpec.pdf
ShivaSpec.log
ShivaSpec.idx
ShivaSpec.aux
ShivaSpec.dvi


Modified: trunk/OpenGTL/OpenShiva/doc/specification/ShivaSpec.tex
===================================================================
--- trunk/OpenGTL/OpenShiva/doc/specification/ShivaSpec.tex	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/OpenShiva/doc/specification/ShivaSpec.tex	2008-05-18 10:53:01 UTC (rev 165)
@@ -177,7 +177,7 @@
 
 \section{Complex types}
 
-\subsection{Image types}
+\subsection{Images types}
 
 Shiva defines five specific image types:
 \begin{itemize}
@@ -188,7 +188,8 @@
  \item \verb|image5| five channels image
 \end{itemize}
 
-And the generic image type \verb|image| whose number of channels is undefined.
+And the generic image type \verb|image| whose number of channels is defined
+at compile time.
 
 \subsubsection{Members}
 \paragraph{sampleNearest and sampleLinear}
@@ -226,11 +227,8 @@
 \end{verbatim}
 
 
+\subsection{Pixeles types}
 
-\subsection{Region types}
-
-\subsection{Pixel types}
-
 Shiva defines five specific pixel types:
 \begin{itemize}
  \item \verb|pixel1| one channel pixel
@@ -240,8 +238,15 @@
  \item \verb|pixel5| five channels pixel
 \end{itemize}
 
-And the generic pixel type \verb|pixel| whose number of channels is undefined.
+And the generic pixel type \verb|pixel| whose number of channels is defined at compile type.
 
+\subsection{Channel type for pixel and image}
+
+The channels type of generic \verb|pixel| and \verb|image| can either be an array of elements
+of the same type which should be the reference depth or any kind of structure.
+
+\subsection{Region types}
+
 \section{Special types}
 
 \subsection{Void}
@@ -298,6 +303,31 @@
 \hline
 \end{tabular}
 
+\subsection{Pixel arithmetic}
+
+Pixel arithmetic is defined depending on the type of the channel, for floating point channels
+the arithmetic is the same as for numbers. But for integer channels, the arithmetic is defined
+by the following formulas:
+
+$ MAX $ is the maximum value of an integer channel, $ MAX = 255 $ for 8bits, $ MAX = 65535 $ for 16bits
+and $ MAX = 4294967295 $ for 32bits.
+
+\begin{itemize}
+  \item \verb|+| : $ ( a + b ) / MAX $
+  \item \verb|-| : $ ( a - b ) / MAX $
+  \item \verb|*| : $ ( a * b ) / MAX $
+  \item \verb|/| : $ ( a * MAX ) / b $
+\end{itemize}
+
+To avoid overflow, operations are computed at a higher level of bit depth, 8bits operations are done in 16bits,
+16bits operations in 32bits, and 32bits operation in 64bits.
+
+\subsection{Type conversion}
+Type conversion between primary types is implicit. They follow the following priority, from low to highest : bool, unsigned int, int, float, when a low priority is added to a high priority type, then the result is in the high priority
+type.
+Pixels types can be converted as a vector of float in the range $ [ 0, 1 ] $ for integer pixels, or directly
+for float pixels. The opposite conversion is also possible from float vectors to pixels.
+
 \chapter{Grammar}
 
 \section{Keywords}

Modified: trunk/OpenGTL/sdk/invertresult.sh
===================================================================
--- trunk/OpenGTL/sdk/invertresult.sh	2008-05-02 19:18:22 UTC (rev 164)
+++ trunk/OpenGTL/sdk/invertresult.sh	2008-05-18 10:53:01 UTC (rev 165)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-if $1 $2
+if $@
 then
 exit 1
 else


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