[opengtl-commits] [160] do signed cast

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


Revision: 160
Author:   cyrille
Date:     2008-05-01 14:37:48 +0200 (Thu, 01 May 2008)

Log Message:
-----------
do signed cast

Modified Paths:
--------------
    trunk/OpenGTL/OpenCTL/tests/arithmetic/multiplication.ctl
    trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp


Modified: trunk/OpenGTL/OpenCTL/tests/arithmetic/multiplication.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/arithmetic/multiplication.ctl	2008-04-29 11:42:57 UTC (rev 159)
+++ trunk/OpenGTL/OpenCTL/tests/arithmetic/multiplication.ctl	2008-05-01 12:37:48 UTC (rev 160)
@@ -7,5 +7,11 @@
   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);
+  float denom = 1.65;
+  int a = -37;
+  int b = 37;
+  float res = b / denom;
+  checkNearEqual( a / denom, -res, errorcount);
   return errorcount - 1;
 }

Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp	2008-04-29 11:42:57 UTC (rev 159)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp	2008-05-01 12:37:48 UTC (rev 160)
@@ -143,7 +143,7 @@
     return llvm::CastInst::createFPCast(value, type, "", currentBlock);
   } else { // Other casts
     return llvm::CastInst::create(
-                      llvm::CastInst::getCastOpcode(value, false, type, false), value, type, "", currentBlock );
+                      llvm::CastInst::getCastOpcode(value, true, type, true), value, type, "", currentBlock ); // TODO support for unsigned
   }
 }
 
@@ -178,7 +178,7 @@
     }
   } else { // Other casts
     return llvm::ConstantExpr::getCast(
-                      (unsigned)llvm::CastInst::getCastOpcode(constant, false, type, false), constant, type );
+                      (unsigned)llvm::CastInst::getCastOpcode(constant, true, type, true), constant, type ); // TODO support for unsigned
   }
 }
 


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