Selaa lähdekoodia

Allow the usage of inline float constant whenever it fits SQInt32

mingodad 7 vuotta sitten
vanhempi
sitoutus
9bc89af102
1 muutettua tiedostoa jossa 4 lisäystä ja 6 poistoa
  1. 4 6
      SquiLu/squirrel/sqcompiler.cpp

+ 4 - 6
SquiLu/squirrel/sqcompiler.cpp

@@ -1972,14 +1972,12 @@ start_again:
         {
         {
             target = _fs->PushTarget();
             target = _fs->PushTarget();
         }
         }
-        if(sizeof(SQFloat) == sizeof(SQInt32))
+        SQFloat32 f32 = value;
+        if(f32 == value) //same value no overflow/underflow/infinity
         {
         {
-            _fs->AddInstruction(_OP_LOADFLOAT, target,*((SQInt32 *)&value));
-        }
-        else
-        {
-            _fs->AddInstruction(_OP_LOAD, target, _fs->GetNumericConstant(value));
+            _fs->AddInstruction(_OP_LOADFLOAT, target,*((SQInt32 *)&f32));
         }
         }
+        else _fs->AddInstruction(_OP_LOAD, target, _fs->GetNumericConstant(value));
     }
     }
     void UnaryOP(SQOpcode op)
     void UnaryOP(SQOpcode op)
     {
     {