[opengtl-commits] [308] allow constant array with no size

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


Revision: 308
Author:   cyrille
Date:     2008-07-31 22:05:14 +0200 (Thu, 31 Jul 2008)

Log Message:
-----------
allow constant array with no size

Modified Paths:
--------------
    trunk/OpenGTL/CMakeLists.txt
    trunk/OpenGTL/OpenCTL/tests/complextypes/CMakeLists.txt
    trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.h
    trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp

Added Paths:
-----------
    trunk/OpenGTL/OpenCTL/tests/complextypes/constarraynosize.ctl


Modified: trunk/OpenGTL/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/CMakeLists.txt	2008-07-29 07:10:44 UTC (rev 307)
+++ trunk/OpenGTL/CMakeLists.txt	2008-07-31 20:05:14 UTC (rev 308)
@@ -1,5 +1,7 @@
 project(OpenGTL)
 
+cmake_minimum_required(VERSION 2.4)
+
 set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
 
 enable_testing()

Modified: trunk/OpenGTL/OpenCTL/tests/complextypes/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/complextypes/CMakeLists.txt	2008-07-29 07:10:44 UTC (rev 307)
+++ trunk/OpenGTL/OpenCTL/tests/complextypes/CMakeLists.txt	2008-07-31 20:05:14 UTC (rev 308)
@@ -17,6 +17,7 @@
   copyarray.ctl
   returnstruct.ctl
   returnarray.ctl
+  constarraynosize.ctl
   )
 
 FOREACH( TEST_FILE ${TESTS_FILES} )

Added: trunk/OpenGTL/OpenCTL/tests/complextypes/constarraynosize.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/complextypes/constarraynosize.ctl	                        (rev 0)
+++ trunk/OpenGTL/OpenCTL/tests/complextypes/constarraynosize.ctl	2008-07-31 20:05:14 UTC (rev 308)
@@ -0,0 +1,12 @@
+import "TestFramework";
+
+const int array[] = { 2, 3 };
+
+int main()
+{
+  int errorcount = 0;
+  Test::checkIntEqual( array.size, 2, errorcount );
+  Test::checkIntEqual( array[0], 2, errorcount );
+  Test::checkIntEqual( array[1], 3, errorcount );
+  return errorcount;
+}

Modified: trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp	2008-07-29 07:10:44 UTC (rev 307)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp	2008-07-31 20:05:14 UTC (rev 308)
@@ -67,9 +67,9 @@
   return 0;
 }
 
-AST::ConvertExpression* ConvertCenter::createConvertExpressionForBinaryExpression( AST::Expression* value, const GTLCore::Type* _otherType ) const
+std::pair<AST::ConvertExpression*, AST::ConvertExpression*> ConvertCenter::createConvertExpression( AST::Expression* value1, AST::Expression* value2 ) const
 {
-  return 0;
+  return std::pair<AST::ConvertExpression*, AST::ConvertExpression*>(0, 0) ;
 }
 
 void ConvertCenter::addConvertExpressionFactory( ConvertExpressionFactory* cef)

Modified: trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.h	2008-07-29 07:10:44 UTC (rev 307)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.h	2008-07-31 20:05:14 UTC (rev 308)
@@ -20,6 +20,8 @@
 #ifndef _CONVERT_CENTER_H_
 #define _CONVERT_CENTER_H_
 
+#include <utility>
+
 namespace GTLCore {
   namespace AST {
     class ConvertExpression;
@@ -42,7 +44,7 @@
       ConvertCenter();
       ~ConvertCenter();
       AST::ConvertExpression* createConvertExpression( AST::Expression* value, const GTLCore::Type* _dstType ) const;
-      AST::ConvertExpression* createConvertExpressionForBinaryExpression( AST::Expression* value, const GTLCore::Type* _otherType ) const;
+      std::pair<AST::ConvertExpression*, AST::ConvertExpression*> createConvertExpression( AST::Expression* value1, AST::Expression* value2 ) const;
       void addConvertExpressionFactory( ConvertExpressionFactory* );
     private:
       struct Private;

Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp	2008-07-29 07:10:44 UTC (rev 307)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp	2008-07-31 20:05:14 UTC (rev 308)
@@ -1331,13 +1331,18 @@
   for( std::list< AST::Expression* >::const_iterator it = list.begin();
        it != list.end(); ++it)
   {
-    if( (*it)->isConstant() )
+    if( *it )
     {
-      llvm::ConstantInt* v = dynamic_cast<llvm::ConstantInt* >( (*it)->generateValue( gc, 0 ).constant() );
-      GTL_ASSERT( v );
-      integersList.push_back( v->getValue().getLimitedValue() );
+      if( (*it)->isConstant() )
+      {
+        llvm::ConstantInt* v = dynamic_cast<llvm::ConstantInt* >( (*it)->generateValue( gc, 0 ).constant() );
+        GTL_ASSERT( v );
+        integersList.push_back( v->getValue().getLimitedValue() );
+      } else {
+        reportError( "Expected constant expression.", d->currentToken );
+      }
     } else {
-      reportError( "Expected constant expression.", d->currentToken );
+      integersList.push_back( -1 );
     }
   }
   return integersList;


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