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>
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);
}