[opengtl-commits] [707] test if a function with the same signature already exists |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 707
Author: cyrille
Date: 2009-03-26 20:02:52 +0100 (Thu, 26 Mar 2009)
Log Message:
-----------
test if a function with the same signature already exists
Modified Paths:
--------------
trunk/OpenGTL/OpenGTL/GTLCore/CompilerBase_p.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/shivastdlib.shiva
trunk/OpenGTL/OpenShiva/tests/parse/CMakeLists.txt
Added Paths:
-----------
trunk/OpenGTL/OpenShiva/tests/parse/samefunctionsignature.shiva
Modified: trunk/OpenGTL/OpenGTL/GTLCore/CompilerBase_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CompilerBase_p.cpp 2009-03-26 18:39:55 UTC (rev 706)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CompilerBase_p.cpp 2009-03-26 19:02:52 UTC (rev 707)
@@ -129,6 +129,26 @@
d->functions[name] = funcs;
} else {
// TODO check that this overload of the function doesn't already exists
+
+ foreach( GTLCore::Function* function, it->second)
+ {
+ if( function->returnType() == func->returnType() and function->parameters().size() == func->parameters().size() )
+ {
+ bool allthesame = true;
+ for( std::size_t i = 0; i < function->parameters().size(); ++i)
+ {
+ const GTLCore::Parameter& param1 = function->parameters()[i];
+ const GTLCore::Parameter& param2 = func->parameters()[i];
+ if( param1.type() != param2.type())
+ {
+ allthesame = false;
+ break;
+ }
+ }
+ if(allthesame) return false;
+ }
+ }
+
it->second.push_back(func);
// return false;
}
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/shivastdlib.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/shivastdlib.shiva 2009-03-26 18:39:55 UTC (rev 706)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/shivastdlib.shiva 2009-03-26 19:02:52 UTC (rev 707)
@@ -31,11 +31,6 @@
if( v > 0 ) return 1;
return v;
}
- float length( float2 v)
- {
- v *= v;
- return sqrt( v[0] + v[1] );
- }
float min(float a, float b)
{
if( a > b) return b;
Modified: trunk/OpenGTL/OpenShiva/tests/parse/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/parse/CMakeLists.txt 2009-03-26 18:39:55 UTC (rev 706)
+++ trunk/OpenGTL/OpenShiva/tests/parse/CMakeLists.txt 2009-03-26 19:02:52 UTC (rev 707)
@@ -15,9 +15,10 @@
ADD_TEST(${TEST_FILE} ${SHIVAC} -L ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_FILE})
ENDFOREACH( TEST_FILE )
-# set( TESTS_FAIL_FILES
-# )
+set( TESTS_FAIL_FILES
+ samefunctionsignature.shiva
+ )
-# FOREACH( TEST_FILE ${TESTS_FAIL_FILES} )
-# ADD_TEST(${TEST_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../sdk/invertresult.sh ${SHIVAC} ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_FILE})
-# ENDFOREACH( TEST_FILE )
+FOREACH( TEST_FILE ${TESTS_FAIL_FILES} )
+ ADD_TEST(${TEST_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../sdk/invertresult.sh ${SHIVAC} ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_FILE})
+ENDFOREACH( TEST_FILE )
Added: trunk/OpenGTL/OpenShiva/tests/parse/samefunctionsignature.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/parse/samefunctionsignature.shiva (rev 0)
+++ trunk/OpenGTL/OpenShiva/tests/parse/samefunctionsignature.shiva 2009-03-26 19:02:52 UTC (rev 707)
@@ -0,0 +1,11 @@
+kernel MyKernel
+{
+ void hello(int a,float b,float2 c)
+ {}
+ void hello(int a,float b,float2 c)
+ {}
+ void evaluatePixel(input image source1, output pixel result)
+ {
+
+ }
+}