void __qmljs_llvm_bit_and(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_bit_and(ctx, result, left, right);
+ __qmljs_bit_and(ctx, result, *left, *right);
}
void __qmljs_llvm_bit_or(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_bit_or(ctx, result, left, right);
+ __qmljs_bit_or(ctx, result, *left, *right);
}
void __qmljs_llvm_bit_xor(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_bit_xor(ctx, result, left, right);
+ __qmljs_bit_xor(ctx, result, *left, *right);
}
void __qmljs_llvm_add(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_add(ctx, result, left, right);
+ __qmljs_add(ctx, result, *left, *right);
}
void __qmljs_llvm_sub(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_sub(ctx, result, left, right);
+ __qmljs_sub(ctx, result, *left, *right);
}
void __qmljs_llvm_mul(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_mul(ctx, result, left, right);
+ __qmljs_mul(ctx, result, *left, *right);
}
void __qmljs_llvm_div(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_div(ctx, result, left, right);
+ __qmljs_div(ctx, result, *left, *right);
}
void __qmljs_llvm_mod(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_mod(ctx, result, left, right);
+ __qmljs_mod(ctx, result, *left, *right);
}
void __qmljs_llvm_shl(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_shl(ctx, result, left, right);
+ __qmljs_shl(ctx, result, *left, *right);
}
void __qmljs_llvm_shr(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_shr(ctx, result, left, right);
+ __qmljs_shr(ctx, result, *left, *right);
}
void __qmljs_llvm_ushr(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_ushr(ctx, result, left, right);
+ __qmljs_ushr(ctx, result, *left, *right);
}
void __qmljs_llvm_gt(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_gt(ctx, result, left, right);
+ __qmljs_gt(ctx, result, *left, *right);
}
void __qmljs_llvm_lt(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_lt(ctx, result, left, right);
+ __qmljs_lt(ctx, result, *left, *right);
}
void __qmljs_llvm_ge(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_ge(ctx, result, left, right);
+ __qmljs_ge(ctx, result, *left, *right);
}
void __qmljs_llvm_le(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_le(ctx, result, left, right);
+ __qmljs_le(ctx, result, *left, *right);
}
void __qmljs_llvm_eq(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_eq(ctx, result, left, right);
+ __qmljs_eq(ctx, result, *left, *right);
}
void __qmljs_llvm_ne(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_ne(ctx, result, left, right);
+ __qmljs_ne(ctx, result, *left, *right);
}
void __qmljs_llvm_se(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_se(ctx, result, left, right);
+ __qmljs_se(ctx, result, *left, *right);
}
void __qmljs_llvm_sne(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_sne(ctx, result, left, right);
+ __qmljs_sne(ctx, result, *left, *right);
}
void __qmljs_llvm_instanceof(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_instanceof(ctx, result, left, right);
+ __qmljs_instanceof(ctx, result, *left, *right);
}
void __qmljs_llvm_in(ExecutionContext *ctx, Value *result, Value *left, Value *right)
{
- __qmljs_in(ctx, result, left, right);
+ __qmljs_in(ctx, result, *left, *right);
}
void __qmljs_llvm_uplus(ExecutionContext *ctx, Value *result, const Value *value)
void __qmljs_llvm_inplace_bit_and_name(ExecutionContext *ctx, String *dest, Value *src)
{
- __qmljs_inplace_bit_and_name(ctx, dest, src);
+ __qmljs_inplace_bit_and_name(ctx, dest, *src);
}
void __qmljs_llvm_inplace_bit_or_name(ExecutionContext *ctx, String *dest, Value *src)
{
- __qmljs_inplace_bit_or_name(ctx, dest, src);
+ __qmljs_inplace_bit_or_name(ctx, dest, *src);
}
void __qmljs_llvm_inplace_bit_xor_name(ExecutionContext *ctx, String *dest, Value *src)
{
- __qmljs_inplace_bit_xor_name(ctx, dest, src);
+ __qmljs_inplace_bit_xor_name(ctx, dest, *src);
}
void __qmljs_llvm_inplace_add_name(ExecutionContext *ctx, String *dest, Value *src)
{
- __qmljs_inplace_add_name(ctx, dest, src);
+ __qmljs_inplace_add_name(ctx, dest, *src);
}
void __qmljs_llvm_inplace_sub_name(ExecutionContext *ctx, String *dest, Value *src)
{
- __qmljs_inplace_sub_name(ctx, dest, src);
+ __qmljs_inplace_sub_name(ctx, dest, *src);
}
void __qmljs_llvm_inplace_mul_name(ExecutionContext *ctx, String *dest, Value *src)
{
- __qmljs_inplace_mul_name(ctx, dest, src);
+ __qmljs_inplace_mul_name(ctx, dest, *src);
}
void __qmljs_llvm_inplace_div_name(ExecutionContext *ctx, String *dest, Value *src)
{
- __qmljs_inplace_div_name(ctx, dest, src);
+ __qmljs_inplace_div_name(ctx, dest, *src);
}
void __qmljs_llvm_inplace_mod_name(ExecutionContext *ctx, String *dest, Value *src)
{
- __qmljs_inplace_mod_name(ctx, dest, src);
+ __qmljs_inplace_mod_name(ctx, dest, *src);
}
void __qmljs_llvm_inplace_shl_name(ExecutionContext *ctx, String *dest, Value *src)
{
- __qmljs_inplace_shl_name(ctx, dest, src);
+ __qmljs_inplace_shl_name(ctx, dest, *src);
}
void __qmljs_llvm_inplace_shr_name(ExecutionContext *ctx, String *dest, Value *src)
{
- __qmljs_inplace_shr_name(ctx, dest, src);
+ __qmljs_inplace_shr_name(ctx, dest, *src);
}
void __qmljs_llvm_inplace_ushr_name(ExecutionContext *ctx, String *dest, Value *src)
{
- __qmljs_inplace_ushr_name(ctx, dest, src);
+ __qmljs_inplace_ushr_name(ctx, dest, *src);
}
void __qmljs_llvm_inplace_bit_and_element(ExecutionContext *ctx, Value *base, Value *index, Value *value)
{
- __qmljs_inplace_bit_and_element(ctx, base, index, value);
+ __qmljs_inplace_bit_and_element(ctx, *base, *index, *value);
}
void __qmljs_llvm_inplace_bit_or_element(ExecutionContext *ctx, Value *base, Value *index, Value *value)
{
- __qmljs_inplace_bit_or_element(ctx, base, index, value);
+ __qmljs_inplace_bit_or_element(ctx, *base, *index, *value);
}
void __qmljs_llvm_inplace_bit_xor_element(ExecutionContext *ctx, Value *base, Value *index, Value *value)
{
- __qmljs_inplace_bit_xor_element(ctx, base, index, value);
+ __qmljs_inplace_bit_xor_element(ctx, *base, *index, *value);
}
void __qmljs_llvm_inplace_add_element(ExecutionContext *ctx, Value *base, Value *index, Value *value)
{
- __qmljs_inplace_add_element(ctx, base, index, value);
+ __qmljs_inplace_add_element(ctx, *base, *index, *value);
}
void __qmljs_llvm_inplace_sub_element(ExecutionContext *ctx, Value *base, Value *index, Value *value)
{
- __qmljs_inplace_sub_element(ctx, base, index, value);
+ __qmljs_inplace_sub_element(ctx, *base, *index, *value);
}
void __qmljs_llvm_inplace_mul_element(ExecutionContext *ctx, Value *base, Value *index, Value *value)
{
- __qmljs_inplace_mul_element(ctx, base, index, value);
+ __qmljs_inplace_mul_element(ctx, *base, *index, *value);
}
void __qmljs_llvm_inplace_div_element(ExecutionContext *ctx, Value *base, Value *index, Value *value)
{
- __qmljs_inplace_div_element(ctx, base, index, value);
+ __qmljs_inplace_div_element(ctx, *base, *index, *value);
}
void __qmljs_llvm_inplace_mod_element(ExecutionContext *ctx, Value *base, Value *index, Value *value)
{
- __qmljs_inplace_mod_element(ctx, base, index, value);
+ __qmljs_inplace_mod_element(ctx, *base, *index, *value);
}
void __qmljs_llvm_inplace_shl_element(ExecutionContext *ctx, Value *base, Value *index, Value *value)
{
- __qmljs_inplace_shl_element(ctx, base, index, value);
+ __qmljs_inplace_shl_element(ctx, *base, *index, *value);
}
void __qmljs_llvm_inplace_shr_element(ExecutionContext *ctx, Value *base, Value *index, Value *value)
{
- __qmljs_inplace_shr_element(ctx, base, index, value);
+ __qmljs_inplace_shr_element(ctx, *base, *index, *value);
}
void __qmljs_llvm_inplace_ushr_element(ExecutionContext *ctx, Value *base, Value *index, Value *value)
{
- __qmljs_inplace_ushr_element(ctx, base, index, value);
+ __qmljs_inplace_ushr_element(ctx, *base, *index, *value);
}
void __qmljs_llvm_inplace_bit_and_member(ExecutionContext *ctx, Value *value, Value *base, String *member)
{
- __qmljs_inplace_bit_and_member(ctx, base, member, value);
+ __qmljs_inplace_bit_and_member(ctx, *base, member, *value);
}
void __qmljs_llvm_inplace_bit_or_member(ExecutionContext *ctx, Value *value, Value *base, String *member)
{
- __qmljs_inplace_bit_or_member(ctx, base, member, value);
+ __qmljs_inplace_bit_or_member(ctx, *base, member, *value);
}
void __qmljs_llvm_inplace_bit_xor_member(ExecutionContext *ctx, Value *value, Value *base, String *member)
{
- __qmljs_inplace_bit_xor_member(ctx, base, member, value);
+ __qmljs_inplace_bit_xor_member(ctx, *base, member, *value);
}
void __qmljs_llvm_inplace_add_member(ExecutionContext *ctx, Value *value, Value *base, String *member)
{
- __qmljs_inplace_add_member(ctx, base, member, value);
+ __qmljs_inplace_add_member(ctx, *base, member, *value);
}
void __qmljs_llvm_inplace_sub_member(ExecutionContext *ctx, Value *value, Value *base, String *member)
{
- __qmljs_inplace_sub_member(ctx, base, member, value);
+ __qmljs_inplace_sub_member(ctx, *base, member, *value);
}
void __qmljs_llvm_inplace_mul_member(ExecutionContext *ctx, Value *value, Value *base, String *member)
{
- __qmljs_inplace_mul_member(ctx, base, member, value);
+ __qmljs_inplace_mul_member(ctx, *base, member, *value);
}
void __qmljs_llvm_inplace_div_member(ExecutionContext *ctx, Value *value, Value *base, String *member)
{
- __qmljs_inplace_div_member(ctx, base, member, value);
+ __qmljs_inplace_div_member(ctx, *base, member, *value);
}
void __qmljs_llvm_inplace_mod_member(ExecutionContext *ctx, Value *value, Value *base, String *member)
{
- __qmljs_inplace_mod_member(ctx, base, member, value);
+ __qmljs_inplace_mod_member(ctx, *base, member, *value);
}
void __qmljs_llvm_inplace_shl_member(ExecutionContext *ctx, Value *value, Value *base, String *member)
{
- __qmljs_inplace_shl_member(ctx, base, member, value);
+ __qmljs_inplace_shl_member(ctx, *base, member, *value);
}
void __qmljs_llvm_inplace_shr_member(ExecutionContext *ctx, Value *value, Value *base, String *member)
{
- __qmljs_inplace_shr_member(ctx, base, member, value);
+ __qmljs_inplace_shr_member(ctx, *base, member, *value);
}
void __qmljs_llvm_inplace_ushr_member(ExecutionContext *ctx, Value *value, Value *base, String *member)
{
- __qmljs_inplace_ushr_member(ctx, base, member, value);
+ __qmljs_inplace_ushr_member(ctx, *base, member, *value);
}
String *__qmljs_llvm_identifier_from_utf8(ExecutionContext *ctx, const char *str)
void __qmljs_llvm_set_activation_property(ExecutionContext *ctx, String *name, Value *value)
{
- __qmljs_set_activation_property(ctx, name, value);
+ __qmljs_set_activation_property(ctx, name, *value);
}
void __qmljs_llvm_get_property(ExecutionContext *ctx, Value *result, Value *object, String *name)
{
- __qmljs_get_property(ctx, result, object, name);
+ __qmljs_get_property(ctx, result, *object, name);
}
void __qmljs_llvm_call_property(ExecutionContext *context, Value *result, const Value *base, String *name, Value *args, int argc)
void __qmljs_llvm_set_property(ExecutionContext *ctx, Value *object, String *name, Value *value)
{
- __qmljs_set_property(ctx, object, name, value);
+ __qmljs_set_property(ctx, *object, name, *value);
}
void __qmljs_llvm_builtin_declare_var(ExecutionContext *ctx, bool deletable, String *name)
};
struct instr_unop {
MOTH_INSTR_HEADER
- VM::Value (*alu)(const VM::Value value, VM::ExecutionContext *ctx);
+ VM::UnaryOpName alu;
Param source;
Param result;
};
void InstructionSelection::unop(IR::AluOp oper, IR::Temp *sourceTemp, IR::Temp *targetTemp)
{
- VM::Value (*op)(const VM::Value value, VM::ExecutionContext *ctx) = 0;
+ VM::Value (*op)(const VM::Value& value, VM::ExecutionContext *ctx) = 0;
switch (oper) {
case IR::OpIfTrue: assert(!"unreachable"); break;
case IR::OpNot: op = VM::__qmljs_not; break;
MOTH_BEGIN_INSTR(StoreName)
TRACE(inline, "property name = %s", instr.name->toQString().toUtf8().constData());
- __qmljs_set_activation_property(context, instr.name, VALUEPTR(instr.source));
+ __qmljs_set_activation_property(context, instr.name, VALUE(instr.source));
MOTH_END_INSTR(StoreName)
MOTH_BEGIN_INSTR(LoadElement)
MOTH_END_INSTR(StoreElement)
MOTH_BEGIN_INSTR(LoadProperty)
- __qmljs_get_property(context, VALUEPTR(instr.result), VALUEPTR(instr.base), instr.name);
+ __qmljs_get_property(context, VALUEPTR(instr.result), VALUE(instr.base), instr.name);
MOTH_END_INSTR(LoadProperty)
MOTH_BEGIN_INSTR(StoreProperty)
- __qmljs_set_property(context, VALUEPTR(instr.base), instr.name, VALUEPTR(instr.source));
+ __qmljs_set_property(context, VALUE(instr.base), instr.name, VALUE(instr.source));
MOTH_END_INSTR(StoreProperty)
MOTH_BEGIN_INSTR(Push)
MOTH_END_INSTR(CallBuiltinTypeofValue)
MOTH_BEGIN_INSTR(CallBuiltinPostIncMember)
- __qmljs_builtin_post_increment_member(context, VALUEPTR(instr.result), VALUEPTR(instr.base), instr.member);
+ __qmljs_builtin_post_increment_member(context, VALUEPTR(instr.result), VALUE(instr.base), instr.member);
MOTH_END_INSTR(CallBuiltinTypeofMember)
MOTH_BEGIN_INSTR(CallBuiltinPostIncSubscript)
- __qmljs_builtin_post_increment_element(context, VALUEPTR(instr.result), VALUEPTR(instr.base), VALUEPTR(instr.index));
+ __qmljs_builtin_post_increment_element(context, VALUEPTR(instr.result), VALUE(instr.base), VALUEPTR(instr.index));
MOTH_END_INSTR(CallBuiltinTypeofSubscript)
MOTH_BEGIN_INSTR(CallBuiltinPostIncName)
MOTH_END_INSTR(CallBuiltinTypeofValue)
MOTH_BEGIN_INSTR(CallBuiltinPostDecMember)
- __qmljs_builtin_post_decrement_member(context, VALUEPTR(instr.result), VALUEPTR(instr.base), instr.member);
+ __qmljs_builtin_post_decrement_member(context, VALUEPTR(instr.result), VALUE(instr.base), instr.member);
MOTH_END_INSTR(CallBuiltinTypeofMember)
MOTH_BEGIN_INSTR(CallBuiltinPostDecSubscript)
- __qmljs_builtin_post_decrement_element(context, VALUEPTR(instr.result), VALUEPTR(instr.base), VALUEPTR(instr.index));
+ __qmljs_builtin_post_decrement_element(context, VALUEPTR(instr.result), VALUE(instr.base), VALUE(instr.index));
MOTH_END_INSTR(CallBuiltinTypeofSubscript)
MOTH_BEGIN_INSTR(CallBuiltinPostDecName)
MOTH_END_INSTR(Unop)
MOTH_BEGIN_INSTR(Binop)
- instr.alu(context, VALUEPTR(instr.result), VALUEPTR(instr.lhs), VALUEPTR(instr.rhs));
+ instr.alu(context, VALUEPTR(instr.result), VALUE(instr.lhs), VALUE(instr.rhs));
MOTH_END_INSTR(Binop)
MOTH_BEGIN_INSTR(Ret)
MOTH_BEGIN_INSTR(InplaceElementOp)
instr.alu(context,
- VALUEPTR(instr.base),
- VALUEPTR(instr.index),
- VALUEPTR(instr.source));
+ VALUE(instr.base),
+ VALUE(instr.index),
+ VALUE(instr.source));
MOTH_END_INSTR(InplaceElementOp)
MOTH_BEGIN_INSTR(InplaceMemberOp)
instr.alu(context,
- VALUEPTR(instr.base),
+ VALUE(instr.base),
instr.member,
- VALUEPTR(instr.source));
+ VALUE(instr.source));
MOTH_END_INSTR(InplaceMemberOp)
MOTH_BEGIN_INSTR(InplaceNameOp)
TRACE(name, "%s", instr.name->toQString().toUtf8().constData());
- instr.alu(context, instr.name, VALUEPTR(instr.source));
+ instr.alu(context, instr.name, VALUE(instr.source));
MOTH_END_INSTR(InplaceNameOp)
#ifdef MOTH_THREADED_INTERPRETER
activation->__defineOwnProperty__(this, name, &desc);
}
-bool ExecutionContext::setMutableBinding(ExecutionContext *scope, String *name, Value value)
+bool ExecutionContext::setMutableBinding(ExecutionContext *scope, String *name, const Value &value)
{
// ### throw if scope->strict is true, and it would change an immutable binding
if (function) {
exceptionValue.mark();
}
-void ExecutionContext::setProperty(String *name, Value value)
+void ExecutionContext::setProperty(String *name, const Value& value)
{
// qDebug() << "=== SetProperty" << value.toString(this)->toQString();
for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) {
-void ExecutionContext::inplaceBitOp(String *name, const Value *value, BinOp op)
+void ExecutionContext::inplaceBitOp(String *name, const Value &value, BinOp op)
{
Value lhs = getProperty(name);
Value result;
- op(this, &result, &lhs, value);
+ op(this, &result, lhs, value);
setProperty(name, result);
}
bool hasBinding(String *name) const;
void createMutableBinding(String *name, bool deletable);
- bool setMutableBinding(ExecutionContext *scope, String *name, Value value);
+ bool setMutableBinding(ExecutionContext *scope, String *name, const Value &value);
Value getBindingValue(ExecutionContext *scope, String *name, bool strict) const;
bool deleteBinding(ExecutionContext *ctx, String *name);
void throwURIError(Value msg);
void throwUnimplemented(const QString &message);
- void setProperty(String *name, Value value);
+ void setProperty(String *name, const Value &value);
Value getProperty(String *name);
Value getPropertyNoThrow(String *name);
Value getPropertyAndBase(String *name, Object **base);
- void inplaceBitOp(String *name, const QQmlJS::VM::Value *value, BinOp op);
+ void inplaceBitOp(String *name, const QQmlJS::VM::Value &value, BinOp op);
bool deleteProperty(String *name);
inline Value argument(unsigned int index = 0)
return Value::fromString(ctx->engine->newString(QStringLiteral("function")));
}
-Value __qmljs_delete_subscript(ExecutionContext *ctx, Value base, Value index)
+Value __qmljs_delete_subscript(ExecutionContext *ctx, const Value &base, Value index)
{
if (Object *o = base.asObject()) {
uint n = UINT_MAX;
return __qmljs_delete_member(ctx, base, name);
}
-Value __qmljs_delete_member(ExecutionContext *ctx, Value base, String *name)
+Value __qmljs_delete_member(ExecutionContext *ctx, const Value &base, String *name)
{
Value obj = base.toObject(ctx);
return Value::fromBoolean(obj.objectValue()->__delete__(ctx, name));
return Value::fromBoolean(ctx->deleteProperty(name));
}
-void __qmljs_add_helper(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+void __qmljs_add_helper(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
- Value pleft = __qmljs_to_primitive(*left, ctx, PREFERREDTYPE_HINT);
- Value pright = __qmljs_to_primitive(*right, ctx, PREFERREDTYPE_HINT);
+ Value pleft = __qmljs_to_primitive(left, ctx, PREFERREDTYPE_HINT);
+ Value pright = __qmljs_to_primitive(right, ctx, PREFERREDTYPE_HINT);
if (pleft.isString() || pright.isString()) {
if (!pleft.isString())
pleft = __qmljs_to_string(pleft, ctx);
*result = Value::fromDouble(x + y);
}
-void __qmljs_instanceof(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+void __qmljs_instanceof(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
- Object *o = right->asObject();
+ Object *o = right.asObject();
if (!o)
__qmljs_throw_type_error(ctx);
*result = Value::fromBoolean(r);
}
-void __qmljs_in(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+void __qmljs_in(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
- if (!right->isObject())
+ if (!right.isObject())
__qmljs_throw_type_error(ctx);
- String *s = left->toString(ctx);
- bool r = right->objectValue()->__hasProperty__(ctx, s);
+ String *s = left.toString(ctx);
+ bool r = right.objectValue()->__hasProperty__(ctx, s);
*result = Value::fromBoolean(r);
}
-void __qmljs_inplace_bit_and_name(ExecutionContext *ctx, String *name, const Value *value)
+void __qmljs_inplace_bit_and_name(ExecutionContext *ctx, String *name, const Value &value)
{
ctx->inplaceBitOp(name, value, __qmljs_bit_and);
}
-void __qmljs_inplace_bit_or_name(ExecutionContext *ctx, String *name, const Value *value)
+void __qmljs_inplace_bit_or_name(ExecutionContext *ctx, String *name, const Value &value)
{
ctx->inplaceBitOp(name, value, __qmljs_bit_or);
}
-void __qmljs_inplace_bit_xor_name(ExecutionContext *ctx, String *name, const Value *value)
+void __qmljs_inplace_bit_xor_name(ExecutionContext *ctx, String *name, const Value &value)
{
ctx->inplaceBitOp(name, value, __qmljs_bit_xor);
}
-void __qmljs_inplace_add_name(ExecutionContext *ctx, String *name, const Value *value)
+void __qmljs_inplace_add_name(ExecutionContext *ctx, String *name, const Value &value)
{
ctx->inplaceBitOp(name, value, __qmljs_add);
}
-void __qmljs_inplace_sub_name(ExecutionContext *ctx, String *name, const Value *value)
+void __qmljs_inplace_sub_name(ExecutionContext *ctx, String *name, const Value &value)
{
ctx->inplaceBitOp(name, value, __qmljs_sub);
}
-void __qmljs_inplace_mul_name(ExecutionContext *ctx, String *name, const Value *value)
+void __qmljs_inplace_mul_name(ExecutionContext *ctx, String *name, const Value &value)
{
ctx->inplaceBitOp(name, value, __qmljs_mul);
}
-void __qmljs_inplace_div_name(ExecutionContext *ctx, String *name, const Value *value)
+void __qmljs_inplace_div_name(ExecutionContext *ctx, String *name, const Value &value)
{
ctx->inplaceBitOp(name, value, __qmljs_div);
}
-void __qmljs_inplace_mod_name(ExecutionContext *ctx, String *name, const Value *value)
+void __qmljs_inplace_mod_name(ExecutionContext *ctx, String *name, const Value &value)
{
ctx->inplaceBitOp(name, value, __qmljs_mod);
}
-void __qmljs_inplace_shl_name(ExecutionContext *ctx, String *name, const Value *value)
+void __qmljs_inplace_shl_name(ExecutionContext *ctx, String *name, const Value &value)
{
ctx->inplaceBitOp(name, value, __qmljs_shl);
}
-void __qmljs_inplace_shr_name(ExecutionContext *ctx, String *name, const Value *value)
+void __qmljs_inplace_shr_name(ExecutionContext *ctx, String *name, const Value &value)
{
ctx->inplaceBitOp(name, value, __qmljs_shr);
}
-void __qmljs_inplace_ushr_name(ExecutionContext *ctx, String *name, const Value *value)
+void __qmljs_inplace_ushr_name(ExecutionContext *ctx, String *name, const Value &value)
{
ctx->inplaceBitOp(name, value, __qmljs_ushr);
}
-void __qmljs_inplace_bit_and_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs)
+void __qmljs_inplace_bit_and_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs)
{
- Object *obj = base->toObject(ctx).objectValue();
+ Object *obj = base.toObject(ctx).objectValue();
obj->inplaceBinOp(ctx, __qmljs_bit_and, index, rhs);
}
-void __qmljs_inplace_bit_or_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs)
+void __qmljs_inplace_bit_or_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs)
{
- Object *obj = base->toObject(ctx).objectValue();
+ Object *obj = base.toObject(ctx).objectValue();
obj->inplaceBinOp(ctx, __qmljs_bit_or, index, rhs);
}
-void __qmljs_inplace_bit_xor_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs)
+void __qmljs_inplace_bit_xor_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs)
{
- Object *obj = base->toObject(ctx).objectValue();
+ Object *obj = base.toObject(ctx).objectValue();
obj->inplaceBinOp(ctx, __qmljs_bit_xor, index, rhs);
}
-void __qmljs_inplace_add_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs)
+void __qmljs_inplace_add_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs)
{
- Object *obj = base->toObject(ctx).objectValue();
+ Object *obj = base.toObject(ctx).objectValue();
obj->inplaceBinOp(ctx, __qmljs_add, index, rhs);
}
-void __qmljs_inplace_sub_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs)
+void __qmljs_inplace_sub_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs)
{
- Object *obj = base->toObject(ctx).objectValue();
+ Object *obj = base.toObject(ctx).objectValue();
obj->inplaceBinOp(ctx, __qmljs_sub, index, rhs);
}
-void __qmljs_inplace_mul_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs)
+void __qmljs_inplace_mul_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs)
{
- Object *obj = base->toObject(ctx).objectValue();
+ Object *obj = base.toObject(ctx).objectValue();
obj->inplaceBinOp(ctx, __qmljs_mul, index, rhs);
}
-void __qmljs_inplace_div_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs)
+void __qmljs_inplace_div_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs)
{
- Object *obj = base->toObject(ctx).objectValue();
+ Object *obj = base.toObject(ctx).objectValue();
obj->inplaceBinOp(ctx, __qmljs_div, index, rhs);
}
-void __qmljs_inplace_mod_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs)
+void __qmljs_inplace_mod_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs)
{
- Object *obj = base->toObject(ctx).objectValue();
+ Object *obj = base.toObject(ctx).objectValue();
obj->inplaceBinOp(ctx, __qmljs_mod, index, rhs);
}
-void __qmljs_inplace_shl_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs)
+void __qmljs_inplace_shl_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs)
{
- Object *obj = base->toObject(ctx).objectValue();
+ Object *obj = base.toObject(ctx).objectValue();
obj->inplaceBinOp(ctx, __qmljs_shl, index, rhs);
}
-void __qmljs_inplace_shr_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs)
+void __qmljs_inplace_shr_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs)
{
- Object *obj = base->toObject(ctx).objectValue();
+ Object *obj = base.toObject(ctx).objectValue();
obj->inplaceBinOp(ctx, __qmljs_shr, index, rhs);
}
-void __qmljs_inplace_ushr_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs)
+void __qmljs_inplace_ushr_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs)
{
- Object *obj = base->toObject(ctx).objectValue();
+ Object *obj = base.toObject(ctx).objectValue();
obj->inplaceBinOp(ctx, __qmljs_ushr, index, rhs);
}
-void __qmljs_inplace_bit_and_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs)
+void __qmljs_inplace_bit_and_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs)
{
- Object *o = base->toObject(ctx).objectValue();
+ Object *o = base.toObject(ctx).objectValue();
o->inplaceBinOp(ctx, __qmljs_bit_and, name, rhs);
}
-void __qmljs_inplace_bit_or_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs)
+void __qmljs_inplace_bit_or_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs)
{
- Object *o = base->toObject(ctx).objectValue();
+ Object *o = base.toObject(ctx).objectValue();
o->inplaceBinOp(ctx, __qmljs_bit_or, name, rhs);
}
-void __qmljs_inplace_bit_xor_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs)
+void __qmljs_inplace_bit_xor_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs)
{
- Object *o = base->toObject(ctx).objectValue();
+ Object *o = base.toObject(ctx).objectValue();
o->inplaceBinOp(ctx, __qmljs_bit_xor, name, rhs);
}
-void __qmljs_inplace_add_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs)
+void __qmljs_inplace_add_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs)
{
- Object *o = base->toObject(ctx).objectValue();
+ Object *o = base.toObject(ctx).objectValue();
o->inplaceBinOp(ctx, __qmljs_add, name, rhs);
}
-void __qmljs_inplace_sub_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs)
+void __qmljs_inplace_sub_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs)
{
- Object *o = base->toObject(ctx).objectValue();
+ Object *o = base.toObject(ctx).objectValue();
o->inplaceBinOp(ctx, __qmljs_sub, name, rhs);
}
-void __qmljs_inplace_mul_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs)
+void __qmljs_inplace_mul_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs)
{
- Object *o = base->toObject(ctx).objectValue();
+ Object *o = base.toObject(ctx).objectValue();
o->inplaceBinOp(ctx, __qmljs_mul, name, rhs);
}
-void __qmljs_inplace_div_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs)
+void __qmljs_inplace_div_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs)
{
- Object *o = base->toObject(ctx).objectValue();
+ Object *o = base.toObject(ctx).objectValue();
o->inplaceBinOp(ctx, __qmljs_div, name, rhs);
}
-void __qmljs_inplace_mod_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs)
+void __qmljs_inplace_mod_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs)
{
- Object *o = base->toObject(ctx).objectValue();
+ Object *o = base.toObject(ctx).objectValue();
o->inplaceBinOp(ctx, __qmljs_mod, name, rhs);
}
-void __qmljs_inplace_shl_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs)
+void __qmljs_inplace_shl_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs)
{
- Object *o = base->toObject(ctx).objectValue();
+ Object *o = base.toObject(ctx).objectValue();
o->inplaceBinOp(ctx, __qmljs_shl, name, rhs);
}
-void __qmljs_inplace_shr_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs)
+void __qmljs_inplace_shr_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs)
{
- Object *o = base->toObject(ctx).objectValue();
+ Object *o = base.toObject(ctx).objectValue();
o->inplaceBinOp(ctx, __qmljs_shr, name, rhs);
}
-void __qmljs_inplace_ushr_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs)
+void __qmljs_inplace_ushr_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs)
{
- Object *o = base->toObject(ctx).objectValue();
+ Object *o = base.toObject(ctx).objectValue();
o->inplaceBinOp(ctx, __qmljs_ushr, name, rhs);
}
return Value::fromObject(ctx->engine->newStringObject(ctx, value));
}
-void __qmljs_set_property(ExecutionContext *ctx, const Value *object, String *name, const Value *value)
+void __qmljs_set_property(ExecutionContext *ctx, const Value &object, String *name, const Value &value)
{
- Object *o = object->isObject() ? object->objectValue() : __qmljs_to_object(*object, ctx).objectValue();
- o->__put__(ctx, name, *value);
+ Object *o = object.isObject() ? object.objectValue() : __qmljs_to_object(object, ctx).objectValue();
+ o->__put__(ctx, name, value);
}
Value __qmljs_get_element(ExecutionContext *ctx, Value object, Value index)
}
-void __qmljs_set_activation_property(ExecutionContext *ctx, String *name, const Value *value)
+void __qmljs_set_activation_property(ExecutionContext *ctx, String *name, const Value &value)
{
- ctx->setProperty(name, *value);
+ ctx->setProperty(name, value);
}
-void __qmljs_get_property(ExecutionContext *ctx, Value *result, Value *object, String *name)
+void __qmljs_get_property(ExecutionContext *ctx, Value *result, const Value &object, String *name)
{
Value res;
- Object *o = object->asObject();
+ Object *o = object.asObject();
if (o) {
res = o->__get__(ctx, name);
- } else if (object->isString() && name->isEqualTo(ctx->engine->id_length)) {
- res = Value::fromInt32(object->stringValue()->toQString().length());
+ } else if (object.isString() && name->isEqualTo(ctx->engine->id_length)) {
+ res = Value::fromInt32(object.stringValue()->toQString().length());
} else {
- o = __qmljs_to_object(*object, ctx).objectValue();
+ o = __qmljs_to_object(object, ctx).objectValue();
res = o->__get__(ctx, name);
}
if (result)
*result = ctx->getProperty(name);
}
-void __qmljs_get_property_lookup(ExecutionContext *ctx, Value *result, const Value *object, int lookupIndex)
+void __qmljs_get_property_lookup(ExecutionContext *ctx, Value *result, const Value &object, int lookupIndex)
{
Value res;
Lookup *l = ctx->lookups + lookupIndex;
- if (Object *o = object->asObject()) {
+ if (Object *o = object.asObject()) {
PropertyDescriptor *p = 0;
if (o->internalClass == l->mainClass) {
if (!l->protoClass) {
else
res = o->__get__(ctx, l->name);
} else {
- if (object->isString() && l->name->isEqualTo(ctx->engine->id_length)) {
- res = Value::fromInt32(object->stringValue()->toQString().length());
+ if (object.isString() && l->name->isEqualTo(ctx->engine->id_length)) {
+ res = Value::fromInt32(object.stringValue()->toQString().length());
} else {
- o = __qmljs_to_object(*object, ctx).objectValue();
+ o = __qmljs_to_object(object, ctx).objectValue();
res = o->__get__(ctx, l->name);
}
}
*result = res;
}
-void __qmljs_set_property_lookup(ExecutionContext *ctx, const Value *object, int lookupIndex, const Value *value)
+void __qmljs_set_property_lookup(ExecutionContext *ctx, const Value &object, int lookupIndex, const Value &value)
{
- Object *o = object->isObject() ? object->objectValue() : __qmljs_to_object(*object, ctx).objectValue();
+ Object *o = object.isObject() ? object.objectValue() : __qmljs_to_object(object, ctx).objectValue();
Lookup *l = ctx->lookups + lookupIndex;
if (l->index != ArrayObject::LengthPropertyIndex || !o->isArrayObject()) {
if (o->internalClass == l->mainClass) {
- o->putValue(ctx, o->memberData + l->index, *value);
+ o->putValue(ctx, o->memberData + l->index, value);
return;
}
if (idx < UINT_MAX) {
l->mainClass = o->internalClass;
l->index = idx;
- return o->putValue(ctx, o->memberData + idx, *value);
+ return o->putValue(ctx, o->memberData + idx, value);
}
}
- o->__put__(ctx, l->name, *value);
+ o->__put__(ctx, l->name, value);
}
return ctx->thisObject;
}
-uint __qmljs_equal(Value x, Value y, ExecutionContext *ctx)
+uint __qmljs_equal(const Value &x, const Value &y, ExecutionContext *ctx)
{
if (x.type() == y.type()) {
switch (x.type()) {
context->setProperty(name, v);
}
-void __qmljs_builtin_post_increment_member(ExecutionContext *context, Value *result, const Value *base, String *name)
+void __qmljs_builtin_post_increment_member(ExecutionContext *context, Value *result, const Value &base, String *name)
{
- Object *o = __qmljs_to_object(*base, context).objectValue();
+ Object *o = __qmljs_to_object(base, context).objectValue();
Value v = o->__get__(context, name);
o->__put__(context, name, v);
}
-void __qmljs_builtin_post_increment_element(ExecutionContext *context, Value *result, const Value *base, const Value *index)
+void __qmljs_builtin_post_increment_element(ExecutionContext *context, Value *result, const Value &base, const Value *index)
{
- Object *o = __qmljs_to_object(*base, context).objectValue();
+ Object *o = __qmljs_to_object(base, context).objectValue();
uint idx = index->asArrayIndex();
context->setProperty(name, v);
}
-void __qmljs_builtin_post_decrement_member(ExecutionContext *context, Value *result, const Value *base, String *name)
+void __qmljs_builtin_post_decrement_member(ExecutionContext *context, Value *result, const Value &base, String *name)
{
- Object *o = __qmljs_to_object(*base, context).objectValue();
+ Object *o = __qmljs_to_object(base, context).objectValue();
Value v = o->__get__(context, name);
o->__put__(context, name, v);
}
-void __qmljs_builtin_post_decrement_element(ExecutionContext *context, Value *result, const Value *base, const Value *index)
+void __qmljs_builtin_post_decrement_element(ExecutionContext *context, Value *result, const Value &base, const Value &index)
{
- Object *o = __qmljs_to_object(*base, context).objectValue();
+ Object *o = __qmljs_to_object(base, context).objectValue();
- uint idx = index->asArrayIndex();
+ uint idx = index.asArrayIndex();
if (idx == UINT_MAX) {
- String *s = index->toString(context);
+ String *s = index.toString(context);
return __qmljs_builtin_post_decrement_member(context, result, base, s);
}
o->__defineOwnProperty__(ctx, name, &pd);
}
-Value __qmljs_increment(Value value, ExecutionContext *ctx)
+Value __qmljs_increment(const Value &value, ExecutionContext *ctx)
{
TRACE1(value);
return Value::fromDouble(d + 1);
}
-Value __qmljs_decrement(Value value, ExecutionContext *ctx)
+Value __qmljs_decrement(const Value &value, ExecutionContext *ctx)
{
TRACE1(value);
void __qmljs_builtin_post_increment(ExecutionContext *ctx, Value *result, Value *val);
void __qmljs_builtin_post_increment_name(ExecutionContext *context, Value *result, String *name);
-void __qmljs_builtin_post_increment_member(ExecutionContext *context, Value *result, const Value *base, String *name);
-void __qmljs_builtin_post_increment_element(ExecutionContext *context, Value *result, const Value *base, const Value *index);
+void __qmljs_builtin_post_increment_member(ExecutionContext *context, Value *result, const Value &base, String *name);
+void __qmljs_builtin_post_increment_element(ExecutionContext *context, Value *result, const Value &base, const Value *index);
void __qmljs_builtin_post_decrement(ExecutionContext *ctx, Value *result, Value *val);
void __qmljs_builtin_post_decrement_name(ExecutionContext *context, Value *result, String *name);
-void __qmljs_builtin_post_decrement_member(ExecutionContext *context, Value *result, const Value *base, String *name);
-void __qmljs_builtin_post_decrement_element(ExecutionContext *context, Value *result, const Value *base, const Value *index);
+void __qmljs_builtin_post_decrement_member(ExecutionContext *context, Value *result, const Value &base, String *name);
+void __qmljs_builtin_post_decrement_element(ExecutionContext *context, Value *result, const Value &base, const Value &index);
void __qmljs_builtin_throw(Value val, ExecutionContext *context);
void __qmljs_builtin_rethrow(ExecutionContext *context);
Value __qmljs_new_boolean_object(ExecutionContext *ctx, bool boolean);
Value __qmljs_new_number_object(ExecutionContext *ctx, double n);
Value __qmljs_new_string_object(ExecutionContext *ctx, String *string);
-void __qmljs_set_activation_property(ExecutionContext *ctx, String *name, const Value *value);
-void __qmljs_set_property(ExecutionContext *ctx, const Value *object, String *name, const Value *value);
-void __qmljs_get_property(ExecutionContext *ctx, Value *result, Value *object, String *name);
+void __qmljs_set_activation_property(ExecutionContext *ctx, String *name, const Value& value);
+void __qmljs_set_property(ExecutionContext *ctx, const Value &object, String *name, const Value &value);
+void __qmljs_get_property(ExecutionContext *ctx, Value *result, const Value &object, String *name);
void __qmljs_get_activation_property(ExecutionContext *ctx, Value *result, String *name);
-void __qmljs_get_property_lookup(ExecutionContext *ctx, Value *result, const Value *object, int lookupIndex);
-void __qmljs_set_property_lookup(ExecutionContext *ctx, const Value *object, int lookupIndex, const Value *value);
+void __qmljs_get_property_lookup(ExecutionContext *ctx, Value *result, const Value &object, int lookupIndex);
+void __qmljs_set_property_lookup(ExecutionContext *ctx, const Value &object, int lookupIndex, const Value &value);
Value __qmljs_get_element(ExecutionContext *ctx, Value object, Value index);
Value __qmljs_get_thisObject(ExecutionContext *ctx);
// type conversion and testing
-Value __qmljs_to_primitive(Value value, ExecutionContext *ctx, int typeHint);
-Bool __qmljs_to_boolean(Value value, ExecutionContext *ctx);
-double __qmljs_to_number(Value value, ExecutionContext *ctx);
-double __qmljs_to_integer(Value value, ExecutionContext *ctx);
-int __qmljs_to_int32(Value value, ExecutionContext *ctx);
-unsigned short __qmljs_to_uint16(Value value, ExecutionContext *ctx);
-Value __qmljs_to_string(Value value, ExecutionContext *ctx);
-Value __qmljs_to_object(Value value, ExecutionContext *ctx);
+Value __qmljs_to_primitive(const Value &value, ExecutionContext *ctx, int typeHint);
+Bool __qmljs_to_boolean(const Value &value, ExecutionContext *ctx);
+double __qmljs_to_number(const Value &value, ExecutionContext *ctx);
+double __qmljs_to_integer(const Value &value, ExecutionContext *ctx);
+int __qmljs_to_int32(const Value &value, ExecutionContext *ctx);
+unsigned short __qmljs_to_uint16(const Value &value, ExecutionContext *ctx);
+Value __qmljs_to_string(const Value &value, ExecutionContext *ctx);
+Value __qmljs_to_object(const Value &value, ExecutionContext *ctx);
//uint __qmljs_check_object_coercible(Context *ctx, Value *result, Value *value);
-Bool __qmljs_is_callable(Value value, ExecutionContext *ctx);
-Value __qmljs_default_value(Value value, ExecutionContext *ctx, int typeHint);
+Bool __qmljs_is_callable(const Value &value, ExecutionContext *ctx);
+Value __qmljs_default_value(const Value &value, ExecutionContext *ctx, int typeHint);
-Bool __qmljs_equal(Value x, Value y, ExecutionContext *ctx);
-Bool __qmljs_strict_equal(Value x, Value y);
+Bool __qmljs_equal(const Value &x, const Value &y, ExecutionContext *ctx);
+Bool __qmljs_strict_equal(const Value &x, const Value &y);
// unary operators
-Value __qmljs_uplus(Value value, ExecutionContext *ctx);
-Value __qmljs_uminus(Value value, ExecutionContext *ctx);
-Value __qmljs_compl(Value value, ExecutionContext *ctx);
-Value __qmljs_not(Value value, ExecutionContext *ctx);
-Value __qmljs_increment(Value value, ExecutionContext *ctx);
-Value __qmljs_decrement(Value value, ExecutionContext *ctx);
-
-Value __qmljs_delete_subscript(ExecutionContext *ctx, Value base, Value index);
-Value __qmljs_delete_member(ExecutionContext *ctx, Value base, String *name);
+typedef Value (*UnaryOpName)(const Value &, ExecutionContext* ctx);
+Value __qmljs_uplus(const Value &value, ExecutionContext *ctx);
+Value __qmljs_uminus(const Value &value, ExecutionContext *ctx);
+Value __qmljs_compl(const Value &value, ExecutionContext *ctx);
+Value __qmljs_not(const Value &value, ExecutionContext *ctx);
+Value __qmljs_increment(const Value &value, ExecutionContext *ctx);
+Value __qmljs_decrement(const Value &value, ExecutionContext *ctx);
+
+Value __qmljs_delete_subscript(ExecutionContext *ctx, const Value &base, Value index);
+Value __qmljs_delete_member(ExecutionContext *ctx, const Value &base, String *name);
Value __qmljs_delete_name(ExecutionContext *ctx, String *name);
void __qmljs_throw(Value value, ExecutionContext *context);
Value __qmljs_get_exception(ExecutionContext *context);
// binary operators
-typedef void (*BinOp)(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-
-void __qmljs_instanceof(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_in(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_bit_or(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_bit_xor(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_bit_and(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_add(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_sub(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_mul(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_div(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_mod(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_shl(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_shr(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_ushr(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_gt(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_lt(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_ge(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_le(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_eq(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_ne(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_se(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-void __qmljs_sne(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-
-void __qmljs_add_helper(ExecutionContext *ctx, Value *result, const Value *left, const Value *right);
-
-
-typedef void (*InplaceBinOpName)(ExecutionContext *ctx, String *name, const Value *value);
-void __qmljs_inplace_bit_and_name(ExecutionContext *ctx, String *name, const Value *value);
-void __qmljs_inplace_bit_or_name(ExecutionContext *ctx, String *name, const Value *value);
-void __qmljs_inplace_bit_xor_name(ExecutionContext *ctx, String *name, const Value *value);
-void __qmljs_inplace_add_name(ExecutionContext *ctx, String *name, const Value *value);
-void __qmljs_inplace_sub_name(ExecutionContext *ctx, String *name, const Value *value);
-void __qmljs_inplace_mul_name(ExecutionContext *ctx, String *name, const Value *value);
-void __qmljs_inplace_div_name(ExecutionContext *ctx, String *name, const Value *value);
-void __qmljs_inplace_mod_name(ExecutionContext *ctx, String *name, const Value *value);
-void __qmljs_inplace_shl_name(ExecutionContext *ctx, String *name, const Value *value);
-void __qmljs_inplace_shr_name(ExecutionContext *ctx, String *name, const Value *value);
-void __qmljs_inplace_ushr_name(ExecutionContext *ctx, String *name, const Value *value);
-
-typedef void (*InplaceBinOpElement)(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs);
-void __qmljs_inplace_bit_and_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs);
-void __qmljs_inplace_bit_or_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs);
-void __qmljs_inplace_bit_xor_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs);
-void __qmljs_inplace_add_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs);
-void __qmljs_inplace_sub_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs);
-void __qmljs_inplace_mul_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs);
-void __qmljs_inplace_div_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs);
-void __qmljs_inplace_mod_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs);
-void __qmljs_inplace_shl_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs);
-void __qmljs_inplace_shr_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs);
-void __qmljs_inplace_ushr_element(ExecutionContext *ctx, const Value *base, const Value *index, const Value *rhs);
-
-typedef void (*InplaceBinOpMember)(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs);
-void __qmljs_inplace_bit_and_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs);
-void __qmljs_inplace_bit_or_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs);
-void __qmljs_inplace_bit_xor_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs);
-void __qmljs_inplace_add_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs);
-void __qmljs_inplace_sub_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs);
-void __qmljs_inplace_mul_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs);
-void __qmljs_inplace_div_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs);
-void __qmljs_inplace_mod_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs);
-void __qmljs_inplace_shl_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs);
-void __qmljs_inplace_shr_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs);
-void __qmljs_inplace_ushr_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs);
-
-typedef Bool (*CmpOp)(ExecutionContext *ctx, const Value *left, const Value *right);
-Bool __qmljs_cmp_gt(ExecutionContext *ctx, const Value *left, const Value *right);
-Bool __qmljs_cmp_lt(ExecutionContext *ctx, const Value *left, const Value *right);
-Bool __qmljs_cmp_ge(ExecutionContext *ctx, const Value *left, const Value *right);
-Bool __qmljs_cmp_le(ExecutionContext *ctx, const Value *left, const Value *right);
-Bool __qmljs_cmp_eq(ExecutionContext *ctx, const Value *left, const Value *right);
-Bool __qmljs_cmp_ne(ExecutionContext *ctx, const Value *left, const Value *right);
-Bool __qmljs_cmp_se(ExecutionContext *ctx, const Value *left, const Value *right);
-Bool __qmljs_cmp_sne(ExecutionContext *ctx, const Value *left, const Value *right);
-Bool __qmljs_cmp_instanceof(ExecutionContext *ctx, const Value *left, const Value *right);
-Bool __qmljs_cmp_in(ExecutionContext *ctx, const Value *left, const Value *right);
+typedef void (*BinOp)(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+
+void __qmljs_instanceof(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_in(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_bit_or(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_bit_xor(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_bit_and(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_add(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_sub(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_mul(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_div(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_mod(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_shl(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_shr(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_ushr(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_gt(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_lt(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_ge(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_le(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_eq(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_ne(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_se(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_sne(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+
+void __qmljs_add_helper(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+
+
+typedef void (*InplaceBinOpName)(ExecutionContext *ctx, String *name, const Value &value);
+void __qmljs_inplace_bit_and_name(ExecutionContext *ctx, String *name, const Value &value);
+void __qmljs_inplace_bit_or_name(ExecutionContext *ctx, String *name, const Value &value);
+void __qmljs_inplace_bit_xor_name(ExecutionContext *ctx, String *name, const Value &value);
+void __qmljs_inplace_add_name(ExecutionContext *ctx, String *name, const Value &value);
+void __qmljs_inplace_sub_name(ExecutionContext *ctx, String *name, const Value &value);
+void __qmljs_inplace_mul_name(ExecutionContext *ctx, String *name, const Value &value);
+void __qmljs_inplace_div_name(ExecutionContext *ctx, String *name, const Value &value);
+void __qmljs_inplace_mod_name(ExecutionContext *ctx, String *name, const Value &value);
+void __qmljs_inplace_shl_name(ExecutionContext *ctx, String *name, const Value &value);
+void __qmljs_inplace_shr_name(ExecutionContext *ctx, String *name, const Value &value);
+void __qmljs_inplace_ushr_name(ExecutionContext *ctx, String *name, const Value &value);
+
+typedef void (*InplaceBinOpElement)(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs);
+void __qmljs_inplace_bit_and_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs);
+void __qmljs_inplace_bit_or_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs);
+void __qmljs_inplace_bit_xor_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs);
+void __qmljs_inplace_add_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs);
+void __qmljs_inplace_sub_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs);
+void __qmljs_inplace_mul_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs);
+void __qmljs_inplace_div_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs);
+void __qmljs_inplace_mod_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs);
+void __qmljs_inplace_shl_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs);
+void __qmljs_inplace_shr_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs);
+void __qmljs_inplace_ushr_element(ExecutionContext *ctx, const Value &base, const Value &index, const Value &rhs);
+
+typedef void (*InplaceBinOpMember)(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs);
+void __qmljs_inplace_bit_and_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs);
+void __qmljs_inplace_bit_or_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs);
+void __qmljs_inplace_bit_xor_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs);
+void __qmljs_inplace_add_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs);
+void __qmljs_inplace_sub_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs);
+void __qmljs_inplace_mul_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs);
+void __qmljs_inplace_div_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs);
+void __qmljs_inplace_mod_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs);
+void __qmljs_inplace_shl_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs);
+void __qmljs_inplace_shr_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs);
+void __qmljs_inplace_ushr_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs);
+
+typedef Bool (*CmpOp)(ExecutionContext *ctx, const Value &left, const Value &right);
+Bool __qmljs_cmp_gt(ExecutionContext *ctx, const Value &left, const Value &right);
+Bool __qmljs_cmp_lt(ExecutionContext *ctx, const Value &left, const Value &right);
+Bool __qmljs_cmp_ge(ExecutionContext *ctx, const Value &left, const Value &right);
+Bool __qmljs_cmp_le(ExecutionContext *ctx, const Value &left, const Value &right);
+Bool __qmljs_cmp_eq(ExecutionContext *ctx, const Value &left, const Value &right);
+Bool __qmljs_cmp_ne(ExecutionContext *ctx, const Value &left, const Value &right);
+Bool __qmljs_cmp_se(ExecutionContext *ctx, const Value &left, const Value &right);
+Bool __qmljs_cmp_sne(ExecutionContext *ctx, const Value &left, const Value &right);
+Bool __qmljs_cmp_instanceof(ExecutionContext *ctx, const Value &left, const Value &right);
+Bool __qmljs_cmp_in(ExecutionContext *ctx, const Value &left, const Value &right);
// type conversion and testing
-inline Value __qmljs_to_primitive(Value value, ExecutionContext *ctx, int typeHint)
+inline Value __qmljs_to_primitive(const Value &value, ExecutionContext *ctx, int typeHint)
{
if (!value.isObject())
return value;
return __qmljs_default_value(value, ctx, typeHint);
}
-inline Bool __qmljs_to_boolean(Value value, ExecutionContext *ctx)
+inline Bool __qmljs_to_boolean(const Value &value, ExecutionContext *ctx)
{
switch (value.type()) {
case Value::Undefined_Type:
}
}
-inline double __qmljs_to_number(Value value, ExecutionContext *ctx)
+inline double __qmljs_to_number(const Value &value, ExecutionContext *ctx)
{
switch (value.type()) {
case Value::Undefined_Type:
}
}
-inline double __qmljs_to_integer(Value value, ExecutionContext *ctx)
+inline double __qmljs_to_integer(const Value &value, ExecutionContext *ctx)
{
if (value.isConvertibleToInt())
return value.int_32;
return Value::toInteger(__qmljs_to_number(value, ctx));
}
-inline int __qmljs_to_int32(Value value, ExecutionContext *ctx)
+inline int __qmljs_to_int32(const Value &value, ExecutionContext *ctx)
{
if (value.isConvertibleToInt())
return value.int_32;
return Value::toInt32(__qmljs_to_number(value, ctx));
}
-inline unsigned short __qmljs_to_uint16(Value value, ExecutionContext *ctx)
+inline unsigned short __qmljs_to_uint16(const Value &value, ExecutionContext *ctx)
{
if (value.isConvertibleToInt())
return (ushort)(uint)value.integerValue();
return (unsigned short)number;
}
-inline Value __qmljs_to_string(Value value, ExecutionContext *ctx)
+inline Value __qmljs_to_string(const Value &value, ExecutionContext *ctx)
{
switch (value.type()) {
case Value::Undefined_Type:
} // switch
}
-inline Value __qmljs_to_object(Value value, ExecutionContext *ctx)
+inline Value __qmljs_to_object(const Value &value, ExecutionContext *ctx)
{
switch (value.type()) {
case Value::Undefined_Type:
}
*/
-inline Bool __qmljs_is_callable(Value value, ExecutionContext * /*ctx*/)
+inline Bool __qmljs_is_callable(const Value &value, ExecutionContext * /*ctx*/)
{
if (value.isObject())
return __qmljs_is_function(value);
return false;
}
-inline Value __qmljs_default_value(Value value, ExecutionContext *ctx, int typeHint)
+inline Value __qmljs_default_value(const Value &value, ExecutionContext *ctx, int typeHint)
{
if (value.isObject())
return __qmljs_object_default_value(ctx, value, typeHint);
}
-inline Value __qmljs_uplus(Value value, ExecutionContext *ctx)
+inline Value __qmljs_uplus(const Value &value, ExecutionContext *ctx)
{
TRACE1(value);
- if (value.tryIntegerConversion())
- return value;
+ Value copy = value;
+ if (copy.tryIntegerConversion())
+ return copy;
double n = __qmljs_to_number(value, ctx);
return Value::fromDouble(n);
}
-inline Value __qmljs_uminus(Value value, ExecutionContext *ctx)
+inline Value __qmljs_uminus(const Value &value, ExecutionContext *ctx)
{
TRACE1(value);
return Value::fromDouble(-n);
}
-inline Value __qmljs_compl(Value value, ExecutionContext *ctx)
+inline Value __qmljs_compl(const Value &value, ExecutionContext *ctx)
{
TRACE1(value);
return Value::fromInt32(~n);
}
-inline Value __qmljs_not(Value value, ExecutionContext *ctx)
+inline Value __qmljs_not(const Value &value, ExecutionContext *ctx)
{
TRACE1(value);
}
// binary operators
-inline void __qmljs_bit_or(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+inline void __qmljs_bit_or(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
- if (Value::integerCompatible(*left, *right)) {
- *result = Value::fromInt32(left->integerValue() | right->integerValue());
+ if (Value::integerCompatible(left, right)) {
+ *result = Value::fromInt32(left.integerValue() | right.integerValue());
return;
}
- int lval = Value::toInt32(__qmljs_to_number(*left, ctx));
- int rval = Value::toInt32(__qmljs_to_number(*right, ctx));
+ int lval = Value::toInt32(__qmljs_to_number(left, ctx));
+ int rval = Value::toInt32(__qmljs_to_number(right, ctx));
*result = Value::fromInt32(lval | rval);
}
-inline void __qmljs_bit_xor(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+inline void __qmljs_bit_xor(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
- if (Value::integerCompatible(*left, *right)) {
- *result = Value::fromInt32(left->integerValue() ^ right->integerValue());
+ if (Value::integerCompatible(left, right)) {
+ *result = Value::fromInt32(left.integerValue() ^ right.integerValue());
return;
}
- int lval = Value::toInt32(__qmljs_to_number(*left, ctx));
- int rval = Value::toInt32(__qmljs_to_number(*right, ctx));
+ int lval = Value::toInt32(__qmljs_to_number(left, ctx));
+ int rval = Value::toInt32(__qmljs_to_number(right, ctx));
*result = Value::fromInt32(lval ^ rval);
}
-inline void __qmljs_bit_and(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+inline void __qmljs_bit_and(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
- if (Value::integerCompatible(*left, *right)) {
- *result = Value::fromInt32(left->integerValue() & right->integerValue());
+ if (Value::integerCompatible(left, right)) {
+ *result = Value::fromInt32(left.integerValue() & right.integerValue());
return;
}
- int lval = Value::toInt32(__qmljs_to_number(*left, ctx));
- int rval = Value::toInt32(__qmljs_to_number(*right, ctx));
+ int lval = Value::toInt32(__qmljs_to_number(left, ctx));
+ int rval = Value::toInt32(__qmljs_to_number(right, ctx));
*result = Value::fromInt32(lval & rval);
}
-inline void __qmljs_add(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+inline void __qmljs_add(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
#ifdef QMLJS_INLINE_MATH
- if (Value::integerCompatible(*left, *right)) {
- *result = add_int32(left->integerValue(), right->integerValue());
+ if (Value::integerCompatible(left, right)) {
+ *result = add_int32(left.integerValue(), right.integerValue());
return;
}
#endif
- if (Value::bothDouble(*left, *right)) {
- *result = Value::fromDouble(left->doubleValue() + right->doubleValue());
+ if (Value::bothDouble(left, right)) {
+ *result = Value::fromDouble(left.doubleValue() + right.doubleValue());
return;
}
__qmljs_add_helper(ctx, result, left, right);
}
-inline void __qmljs_sub(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+inline void __qmljs_sub(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
#ifdef QMLJS_INLINE_MATH
- if (Value::integerCompatible(*left, *right)) {
- *result = sub_int32(left->integerValue(), right->integerValue());
+ if (Value::integerCompatible(left, right)) {
+ *result = sub_int32(left.integerValue(), right.integerValue());
return;
}
#endif
- double lval = __qmljs_to_number(*left, ctx);
- double rval = __qmljs_to_number(*right, ctx);
+ double lval = __qmljs_to_number(left, ctx);
+ double rval = __qmljs_to_number(right, ctx);
*result = Value::fromDouble(lval - rval);
}
-inline void __qmljs_mul(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+inline void __qmljs_mul(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
#ifdef QMLJS_INLINE_MATH
- if (Value::integerCompatible(*left, *right)) {
- *result = mul_int32(left->integerValue(), right->integerValue());
+ if (Value::integerCompatible(left, right)) {
+ *result = mul_int32(left.integerValue(), right.integerValue());
return;
}
#endif
- double lval = __qmljs_to_number(*left, ctx);
- double rval = __qmljs_to_number(*right, ctx);
+ double lval = __qmljs_to_number(left, ctx);
+ double rval = __qmljs_to_number(right, ctx);
*result = Value::fromDouble(lval * rval);
}
-inline void __qmljs_div(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+inline void __qmljs_div(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
- double lval = __qmljs_to_number(*left, ctx);
- double rval = __qmljs_to_number(*right, ctx);
+ double lval = __qmljs_to_number(left, ctx);
+ double rval = __qmljs_to_number(right, ctx);
*result = Value::fromDouble(lval / rval);
}
-inline void __qmljs_mod(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+inline void __qmljs_mod(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
- if (Value::integerCompatible(*left, *right) && right->integerValue() != 0) {
- *result = Value::fromInt32(left->integerValue() % right->integerValue());
+ if (Value::integerCompatible(left, right) && right.integerValue() != 0) {
+ *result = Value::fromInt32(left.integerValue() % right.integerValue());
return;
}
- double lval = __qmljs_to_number(*left, ctx);
- double rval = __qmljs_to_number(*right, ctx);
+ double lval = __qmljs_to_number(left, ctx);
+ double rval = __qmljs_to_number(right, ctx);
*result = Value::fromDouble(fmod(lval, rval));
}
-inline void __qmljs_shl(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+inline void __qmljs_shl(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
- if (Value::integerCompatible(*left, *right)) {
- *result = Value::fromInt32(left->integerValue() << ((uint(right->integerValue()) & 0x1f)));
+ if (Value::integerCompatible(left, right)) {
+ *result = Value::fromInt32(left.integerValue() << ((uint(right.integerValue()) & 0x1f)));
return;
}
- int lval = Value::toInt32(__qmljs_to_number(*left, ctx));
- unsigned rval = Value::toUInt32(__qmljs_to_number(*right, ctx)) & 0x1f;
+ int lval = Value::toInt32(__qmljs_to_number(left, ctx));
+ unsigned rval = Value::toUInt32(__qmljs_to_number(right, ctx)) & 0x1f;
*result = Value::fromInt32(lval << rval);
}
-inline void __qmljs_shr(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+inline void __qmljs_shr(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
- if (Value::integerCompatible(*left, *right)) {
- *result = Value::fromInt32(left->integerValue() >> ((uint(right->integerValue()) & 0x1f)));
+ if (Value::integerCompatible(left, right)) {
+ *result = Value::fromInt32(left.integerValue() >> ((uint(right.integerValue()) & 0x1f)));
return;
}
- int lval = Value::toInt32(__qmljs_to_number(*left, ctx));
- unsigned rval = Value::toUInt32(__qmljs_to_number(*right, ctx)) & 0x1f;
+ int lval = Value::toInt32(__qmljs_to_number(left, ctx));
+ unsigned rval = Value::toUInt32(__qmljs_to_number(right, ctx)) & 0x1f;
*result = Value::fromInt32(lval >> rval);
}
-inline void __qmljs_ushr(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+inline void __qmljs_ushr(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
uint res;
- if (Value::integerCompatible(*left, *right)) {
- res = uint(left->integerValue()) >> (uint(right->integerValue()) & 0x1f);
+ if (Value::integerCompatible(left, right)) {
+ res = uint(left.integerValue()) >> (uint(right.integerValue()) & 0x1f);
} else {
- unsigned lval = Value::toUInt32(__qmljs_to_number(*left, ctx));
- unsigned rval = Value::toUInt32(__qmljs_to_number(*right, ctx)) & 0x1f;
+ unsigned lval = Value::toUInt32(__qmljs_to_number(left, ctx));
+ unsigned rval = Value::toUInt32(__qmljs_to_number(right, ctx)) & 0x1f;
res = lval >> rval;
}
*result = Value::fromInt32(res);
}
-inline void __qmljs_gt(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+inline void __qmljs_gt(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
*result = Value::fromBoolean(__qmljs_cmp_gt(ctx, left, right));
}
-inline void __qmljs_lt(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+inline void __qmljs_lt(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
*result = Value::fromBoolean(__qmljs_cmp_lt(ctx, left, right));
}
-inline void __qmljs_ge(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+inline void __qmljs_ge(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
*result = Value::fromBoolean(__qmljs_cmp_ge(ctx, left, right));
}
-inline void __qmljs_le(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+inline void __qmljs_le(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
*result = Value::fromBoolean(__qmljs_cmp_le(ctx, left, right));
}
-inline void __qmljs_eq(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+inline void __qmljs_eq(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
*result = Value::fromBoolean(__qmljs_cmp_eq(ctx, left, right));
}
-inline void __qmljs_ne(ExecutionContext *ctx, Value *result, const Value *left, const Value *right)
+inline void __qmljs_ne(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
*result = Value::fromBoolean(!__qmljs_cmp_eq(ctx, left, right));
}
-inline void __qmljs_se(ExecutionContext *, Value *result, const Value *left, const Value *right)
+inline void __qmljs_se(ExecutionContext *, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
- bool r = __qmljs_strict_equal(*left, *right);
+ bool r = __qmljs_strict_equal(left, right);
*result = Value::fromBoolean(r);
}
-inline void __qmljs_sne(ExecutionContext *, Value *result, const Value *left, const Value *right)
+inline void __qmljs_sne(ExecutionContext *, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
- bool r = ! __qmljs_strict_equal(*left, *right);
+ bool r = ! __qmljs_strict_equal(left, right);
*result = Value::fromBoolean(r);
}
-inline Bool __qmljs_cmp_gt(ExecutionContext *ctx, const Value *left, const Value *right)
+inline Bool __qmljs_cmp_gt(ExecutionContext *ctx, const Value &left, const Value &right)
{
TRACE2(left, right);
- Value l = __qmljs_to_primitive(*left, ctx, NUMBER_HINT);
- Value r = __qmljs_to_primitive(*right, ctx, NUMBER_HINT);
+ Value l = __qmljs_to_primitive(left, ctx, NUMBER_HINT);
+ Value r = __qmljs_to_primitive(right, ctx, NUMBER_HINT);
if (Value::integerCompatible(l, r))
return l.integerValue() > r.integerValue();
}
}
-inline Bool __qmljs_cmp_lt(ExecutionContext *ctx, const Value *left, const Value *right)
+inline Bool __qmljs_cmp_lt(ExecutionContext *ctx, const Value &left, const Value &right)
{
TRACE2(left, right);
- Value l = __qmljs_to_primitive(*left, ctx, NUMBER_HINT);
- Value r = __qmljs_to_primitive(*right, ctx, NUMBER_HINT);
+ Value l = __qmljs_to_primitive(left, ctx, NUMBER_HINT);
+ Value r = __qmljs_to_primitive(right, ctx, NUMBER_HINT);
if (Value::integerCompatible(l, r))
return l.integerValue() < r.integerValue();
}
}
-inline Bool __qmljs_cmp_ge(ExecutionContext *ctx, const Value *left, const Value *right)
+inline Bool __qmljs_cmp_ge(ExecutionContext *ctx, const Value &left, const Value &right)
{
TRACE2(left, right);
- Value l = __qmljs_to_primitive(*left, ctx, NUMBER_HINT);
- Value r = __qmljs_to_primitive(*right, ctx, NUMBER_HINT);
+ Value l = __qmljs_to_primitive(left, ctx, NUMBER_HINT);
+ Value r = __qmljs_to_primitive(right, ctx, NUMBER_HINT);
if (Value::integerCompatible(l, r))
return l.integerValue() >= r.integerValue();
}
}
-inline Bool __qmljs_cmp_le(ExecutionContext *ctx, const Value *left, const Value *right)
+inline Bool __qmljs_cmp_le(ExecutionContext *ctx, const Value &left, const Value &right)
{
TRACE2(left, right);
- Value l = __qmljs_to_primitive(*left, ctx, NUMBER_HINT);
- Value r = __qmljs_to_primitive(*right, ctx, NUMBER_HINT);
+ Value l = __qmljs_to_primitive(left, ctx, NUMBER_HINT);
+ Value r = __qmljs_to_primitive(right, ctx, NUMBER_HINT);
if (Value::integerCompatible(l, r))
return l.integerValue() <= r.integerValue();
}
}
-inline Bool __qmljs_cmp_eq(ExecutionContext *ctx, const Value *left, const Value *right)
+inline Bool __qmljs_cmp_eq(ExecutionContext *ctx, const Value &left, const Value &right)
{
TRACE2(left, right);
// need to test for doubles first as NaN != NaN
- if (Value::bothDouble(*left, *right))
- return left->doubleValue() == right->doubleValue();
- if (left->val == right->val)
+ if (Value::bothDouble(left, right))
+ return left.doubleValue() == right.doubleValue();
+ if (left.val == right.val)
return true;
- if (left->isString() && right->isString())
- return __qmljs_string_equal(left->stringValue(), right->stringValue());
+ if (left.isString() && right.isString())
+ return __qmljs_string_equal(left.stringValue(), right.stringValue());
- return __qmljs_equal(*left, *right, ctx);
+ return __qmljs_equal(left, right, ctx);
}
-inline Bool __qmljs_cmp_ne(ExecutionContext *ctx, const Value *left, const Value *right)
+inline Bool __qmljs_cmp_ne(ExecutionContext *ctx, const Value &left, const Value &right)
{
TRACE2(left, right);
return !__qmljs_cmp_eq(ctx, left, right);
}
-inline Bool __qmljs_cmp_se(ExecutionContext *, const Value *left, const Value *right)
+inline Bool __qmljs_cmp_se(ExecutionContext *, const Value &left, const Value &right)
{
TRACE2(left, right);
- return __qmljs_strict_equal(*left, *right);
+ return __qmljs_strict_equal(left, right);
}
-inline Bool __qmljs_cmp_sne(ExecutionContext *, const Value *left, const Value *right)
+inline Bool __qmljs_cmp_sne(ExecutionContext *, const Value &left, const Value &right)
{
TRACE2(left, right);
- return ! __qmljs_strict_equal(*left, *right);
+ return ! __qmljs_strict_equal(left, right);
}
-inline Bool __qmljs_cmp_instanceof(ExecutionContext *ctx, const Value *left, const Value *right)
+inline Bool __qmljs_cmp_instanceof(ExecutionContext *ctx, const Value &left, const Value &right)
{
TRACE2(left, right);
return v.booleanValue();
}
-inline uint __qmljs_cmp_in(ExecutionContext *ctx, const Value *left, const Value *right)
+inline uint __qmljs_cmp_in(ExecutionContext *ctx, const Value &left, const Value &right)
{
TRACE2(left, right);
return v.booleanValue();
}
-inline Bool __qmljs_strict_equal(Value x, Value y)
+inline Bool __qmljs_strict_equal(const Value &x, const Value &y)
{
TRACE2(x, y);
struct Value;
extern "C" {
-double __qmljs_to_number(Value value, ExecutionContext *ctx);
+double __qmljs_to_number(const Value &value, ExecutionContext *ctx);
}
typedef uint Bool;
strictMode = false;
}
-bool FunctionObject::hasInstance(Managed *that, ExecutionContext *ctx, const Value *value)
+bool FunctionObject::hasInstance(Managed *that, ExecutionContext *ctx, const Value &value)
{
FunctionObject *f = static_cast<FunctionObject *>(that);
- Object *v = value->asObject();
+ Object *v = value.asObject();
if (!v)
return false;
return target->construct(context, newArgs, boundArgs.size() + argc);
}
-bool BoundFunction::hasInstance(Managed *that, ExecutionContext *ctx, const Value *value)
+bool BoundFunction::hasInstance(Managed *that, ExecutionContext *ctx, const Value &value)
{
BoundFunction *f = static_cast<BoundFunction *>(that);
return FunctionObject::hasInstance(f->target, ctx, value);
protected:
static const ManagedVTable static_vtbl;
static void markObjects(Managed *that);
- static bool hasInstance(Managed *that, ExecutionContext *ctx, const Value *value);
+ static bool hasInstance(Managed *that, ExecutionContext *ctx, const Value &value);
};
struct FunctionCtor: FunctionObject
static const ManagedVTable static_vtbl;
static void markObjects(Managed *that);
- static bool hasInstance(Managed *that, ExecutionContext *ctx, const Value *value);
+ static bool hasInstance(Managed *that, ExecutionContext *ctx, const Value &value);
};
} // namespace VM
void InstructionSelection::callBuiltinDeleteMember(IR::Temp *base, const QString &name, IR::Temp *result)
{
- generateFunctionCall(result, __qmljs_delete_member, Assembler::ContextRegister, base, identifier(name));
+ generateFunctionCall(result, __qmljs_delete_member, Assembler::ContextRegister, Assembler::PointerToValue(base), identifier(name));
}
void InstructionSelection::callBuiltinDeleteSubscript(IR::Temp *base, IR::Temp *index, IR::Temp *result)
{
- generateFunctionCall(result, __qmljs_delete_subscript, Assembler::ContextRegister, base, index);
+ generateFunctionCall(result, __qmljs_delete_subscript, Assembler::ContextRegister, Assembler::PointerToValue(base), index);
}
void InstructionSelection::callBuiltinDeleteName(const QString &name, IR::Temp *result)
void InstructionSelection::unop(IR::AluOp oper, IR::Temp *sourceTemp, IR::Temp *targetTemp)
{
- Value (*op)(const Value value, ExecutionContext *ctx) = 0;
+ Value (*op)(const Value& value, ExecutionContext *ctx) = 0;
const char *opName = 0;
switch (oper) {
case IR::OpIfTrue: assert(!"unreachable"); break;
} // switch
if (op)
- _as->generateFunctionCallImp(targetTemp, opName, op, sourceTemp,
+ _as->generateFunctionCallImp(targetTemp, opName, op, Assembler::PointerToValue(sourceTemp),
Assembler::ContextRegister);
}
booleanConversion.link(_as);
{
- generateFunctionCall(Assembler::ReturnValueRegister, __qmljs_to_boolean, t, Assembler::ContextRegister);
+ generateFunctionCall(Assembler::ReturnValueRegister, __qmljs_to_boolean, Assembler::PointerToValue(t), Assembler::ContextRegister);
}
testBoolean.link(_as);
return QString::fromLatin1(s);
}
-bool Managed::hasInstance(Managed *, ExecutionContext *ctx, const Value *)
+bool Managed::hasInstance(Managed *, ExecutionContext *ctx, const Value &)
{
ctx->throwTypeError();
}
EndOfVTable
};
void (*markObjects)(Managed *);
- bool (*hasInstance)(Managed *, ExecutionContext *ctx, const Value *value);
+ bool (*hasInstance)(Managed *, ExecutionContext *ctx, const Value &value);
_EndOfVTable endofVTable;
};
*reinterpret_cast<Managed **>(this) = m;
}
- inline bool hasInstance(ExecutionContext *ctx, const Value *v) {
+ inline bool hasInstance(ExecutionContext *ctx, const Value &v) {
return vtbl->hasInstance(this, ctx, v);
}
- static bool hasInstance(Managed *that, ExecutionContext *ctx, const Value *value);
+ static bool hasInstance(Managed *that, ExecutionContext *ctx, const Value &value);
protected:
return getValue(ctx, p);
}
-void Object::putValue(ExecutionContext *ctx, PropertyDescriptor *pd, Value value)
+void Object::putValue(ExecutionContext *ctx, PropertyDescriptor *pd, const Value &value)
{
if (pd->isAccessor()) {
if (pd->set) {
}
-void Object::inplaceBinOp(ExecutionContext *ctx, BinOp op, String *name, const Value *rhs)
+void Object::inplaceBinOp(ExecutionContext *ctx, BinOp op, String *name, const Value &rhs)
{
bool hasProperty = false;
Value v = __get__(ctx, name, &hasProperty);
Value result;
- op(ctx, &result, &v, rhs);
+ op(ctx, &result, v, rhs);
__put__(ctx, name, result);
}
-void Object::inplaceBinOp(ExecutionContext *ctx, BinOp op, const Value *index, const Value *rhs)
+void Object::inplaceBinOp(ExecutionContext *ctx, BinOp op, const Value &index, const Value &rhs)
{
- uint idx = index->asArrayIndex();
+ uint idx = index.asArrayIndex();
if (idx < UINT_MAX) {
bool hasProperty = false;
Value v = __get__(ctx, idx, &hasProperty);
Value result;
- op(ctx, &result, &v, rhs);
+ op(ctx, &result, v, rhs);
__put__(ctx, idx, result);
return;
}
- String *name = index->toString(ctx);
+ String *name = index.toString(ctx);
assert(name);
inplaceBinOp(ctx, op, name, rhs);
}
// Section 8.12.5
-void Object::__put__(ExecutionContext *ctx, String *name, Value value)
+void Object::__put__(ExecutionContext *ctx, String *name, const Value &value)
{
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
__qmljs_throw_type_error(ctx);
}
-void Object::__put__(ExecutionContext *ctx, uint index, Value value)
+void Object::__put__(ExecutionContext *ctx, uint index, const Value &value)
{
PropertyDescriptor *pd = __getOwnProperty__(ctx, index);
// clause 1
Value __get__(ExecutionContext *ctx, String *name, bool *hasProperty = 0);
Value __get__(ExecutionContext *ctx, uint index, bool *hasProperty = 0);
- void __put__(ExecutionContext *ctx, String *name, Value value);
- void __put__(ExecutionContext *ctx, uint index, Value value);
+ void __put__(ExecutionContext *ctx, String *name, const Value &value);
+ void __put__(ExecutionContext *ctx, uint index, const Value &value);
bool __hasProperty__(const ExecutionContext *ctx, String *name) const;
bool __hasProperty__(const ExecutionContext *ctx, uint index) const;
Value getValueChecked(ExecutionContext *ctx, const PropertyDescriptor *p) const;
Value getValueChecked(ExecutionContext *ctx, const PropertyDescriptor *p, bool *exists) const;
- void putValue(ExecutionContext *ctx, PropertyDescriptor *pd, Value value);
+ void putValue(ExecutionContext *ctx, PropertyDescriptor *pd, const Value &value);
- void inplaceBinOp(ExecutionContext *ctx, BinOp op, String *name, const Value *rhs);
- void inplaceBinOp(ExecutionContext *ctx, BinOp op, const Value *index, const Value *rhs);
+ void inplaceBinOp(ExecutionContext *ctx, BinOp op, String *name, const Value &rhs);
+ void inplaceBinOp(ExecutionContext *ctx, BinOp op, const Value &index, const Value &rhs);
/* The spec default: Writable: true, Enumerable: false, Configurable: true */
void defineDefaultProperty(String *name, Value value);