Simplify push(IR::Const*)
authorSimon Hausmann <simon.hausmann@digia.com>
Sat, 1 Dec 2012 22:59:53 +0000 (23:59 +0100)
committerLars Knoll <lars.knoll@digia.com>
Sun, 2 Dec 2012 14:15:11 +0000 (15:15 +0100)
Use the convertToValue() function instead of manually trying to
convert the IR::Const to a VM::Value.

Change-Id: Ib669def3c2ef3dfba6cabb0b0c0b3c1d014a13ca
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
qv4isel_masm_p.h

index 15ba5b0..1b3cee1 100644 (file)
@@ -394,26 +394,7 @@ private:
 
     void push(IR::Const* c)
     {
-        VM::Value v;
-        switch (c->type) {
-        case IR::NullType:
-            v = VM::Value::nullValue();
-            break;
-        case IR::UndefinedType:
-            v = VM::Value::undefinedValue();
-            break;
-        case IR::BoolType:
-            v = VM::Value::fromBoolean(c->value != 0);
-            break;
-        case IR::NumberType: {
-            int ival = (int)c->value;
-            if (ival == c->value) {
-                v = VM::Value::fromInt32(ival);
-            } else {
-                v = VM::Value::fromDouble(c->value);
-            }
-        }
-        }
+        VM::Value v = convertToValue(c);
         push(v);
     }