void __qmljs_llvm_typeof(Context *ctx, Value *result, const Value *value)
{
- *result = __qmljs_typeof(ctx, *value);
+ *result = __qmljs_typeof(*value, ctx);
}
void __qmljs_llvm_throw(Context *context, Value *value)
{
- __qmljs_throw(context, *value);
+ __qmljs_throw(*value, context);
}
void __qmljs_llvm_rethrow(Context *context, Value *result)
String *Value::toString(Context *ctx) const
{
- Value v = __qmljs_to_string(ctx, *this);
+ Value v = __qmljs_to_string(*this, ctx);
assert(v.is(Value::String_Type));
return v.stringValue();
}
Value Value::toObject(Context *ctx) const
{
- return __qmljs_to_object(ctx, *this);
+ return __qmljs_to_object(*this, ctx);
}
bool Value::isFunctionObject() const
Value __qmljs_add_helper(const Value left, const Value right, Context *ctx)
{
- Value pleft = __qmljs_to_primitive(ctx, left, PREFERREDTYPE_HINT);
- Value pright = __qmljs_to_primitive(ctx, right, 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(ctx, pleft);
+ pleft = __qmljs_to_string(pleft, ctx);
if (!pright.isString())
- pright = __qmljs_to_string(ctx, pright);
+ pright = __qmljs_to_string(pright, ctx);
String *string = __qmljs_string_concat(ctx, pleft.stringValue(), pright.stringValue());
return Value::fromString(string);
}
Value __qmljs_in(const Value left, const Value right, Context *ctx)
{
if (right.isObject()) {
- Value s = __qmljs_to_string(ctx, left);
+ Value s = __qmljs_to_string(left, ctx);
bool r = right.objectValue()->hasProperty(ctx, s.stringValue());
return Value::fromBoolean(r);
} else {
}
}
-void __qmljs_inplace_bit_and_name(Context *ctx, String *name, Value *value)
+void __qmljs_inplace_bit_and_name(const Value value, String *name, Context *ctx)
{
- ctx->throwUnimplemented(QLatin1String(Q_FUNC_INFO));
+ if (Value *prop = ctx->lookupPropertyDescriptor(name))
+ *prop = __qmljs_bit_and(*prop, value, ctx);
+ else
+ ctx->throwReferenceError(Value::fromString(name));
}
-void __qmljs_inplace_bit_or_name(Context *ctx, String *name, Value *value)
+void __qmljs_inplace_bit_or_name(const Value value, String *name, Context *ctx)
{
- ctx->throwUnimplemented(QLatin1String(Q_FUNC_INFO));
+ if (Value *prop = ctx->lookupPropertyDescriptor(name))
+ *prop = __qmljs_bit_or(*prop, value, ctx);
+ else
+ ctx->throwReferenceError(Value::fromString(name));
}
-void __qmljs_inplace_bit_xor_name(Context *ctx, String *name, Value *value)
+void __qmljs_inplace_bit_xor_name(const Value value, String *name, Context *ctx)
{
- ctx->throwUnimplemented(QLatin1String(Q_FUNC_INFO));
+ if (Value *prop = ctx->lookupPropertyDescriptor(name))
+ *prop = __qmljs_bit_xor(*prop, value, ctx);
+ else
+ ctx->throwReferenceError(Value::fromString(name));
}
-void __qmljs_inplace_add_name(Context *ctx, String *name, Value *value)
+void __qmljs_inplace_add_name(const Value value, String *name, Context *ctx)
{
if (Value *prop = ctx->lookupPropertyDescriptor(name))
- *prop = __qmljs_add(*prop, *value, ctx);
+ *prop = __qmljs_add(*prop, value, ctx);
else
ctx->throwReferenceError(Value::fromString(name));
}
-void __qmljs_inplace_sub_name(Context *ctx, String *name, Value *value)
+void __qmljs_inplace_sub_name(const Value value, String *name, Context *ctx)
{
- ctx->throwUnimplemented(QLatin1String(Q_FUNC_INFO));
+ if (Value *prop = ctx->lookupPropertyDescriptor(name))
+ *prop = __qmljs_sub(*prop, value, ctx);
+ else
+ ctx->throwReferenceError(Value::fromString(name));
}
-void __qmljs_inplace_mul_name(Context *ctx, String *name, Value *value)
+void __qmljs_inplace_mul_name(const Value value, String *name, Context *ctx)
{
- ctx->throwUnimplemented(QLatin1String(Q_FUNC_INFO));
+ if (Value *prop = ctx->lookupPropertyDescriptor(name))
+ *prop = __qmljs_mul(*prop, value, ctx);
+ else
+ ctx->throwReferenceError(Value::fromString(name));
}
-void __qmljs_inplace_div_name(Context *ctx, String *name, Value *value)
+void __qmljs_inplace_div_name(const Value value, String *name, Context *ctx)
{
- ctx->throwUnimplemented(QLatin1String(Q_FUNC_INFO));
+ if (Value *prop = ctx->lookupPropertyDescriptor(name))
+ *prop = __qmljs_div(*prop, value, ctx);
+ else
+ ctx->throwReferenceError(Value::fromString(name));
}
-void __qmljs_inplace_mod_name(Context *ctx, String *name, Value *value)
+void __qmljs_inplace_mod_name(const Value value, String *name, Context *ctx)
{
- ctx->throwUnimplemented(QLatin1String(Q_FUNC_INFO));
+ if (Value *prop = ctx->lookupPropertyDescriptor(name))
+ *prop = __qmljs_mod(*prop, value, ctx);
+ else
+ ctx->throwReferenceError(Value::fromString(name));
}
-void __qmljs_inplace_shl_name(Context *ctx, String *name, Value *value)
+void __qmljs_inplace_shl_name(const Value value, String *name, Context *ctx)
{
- ctx->throwUnimplemented(QLatin1String(Q_FUNC_INFO));
+ if (Value *prop = ctx->lookupPropertyDescriptor(name))
+ *prop = __qmljs_shl(*prop, value, ctx);
+ else
+ ctx->throwReferenceError(Value::fromString(name));
}
-void __qmljs_inplace_shr_name(Context *ctx, String *name, Value *value)
+void __qmljs_inplace_shr_name(const Value value, String *name, Context *ctx)
{
- ctx->throwUnimplemented(QLatin1String(Q_FUNC_INFO));
+ if (Value *prop = ctx->lookupPropertyDescriptor(name))
+ *prop = __qmljs_shr(*prop, value, ctx);
+ else
+ ctx->throwReferenceError(Value::fromString(name));
}
-void __qmljs_inplace_ushr_name(Context *ctx, String *name, Value *value)
+void __qmljs_inplace_ushr_name(const Value value, String *name, Context *ctx)
{
- ctx->throwUnimplemented(QLatin1String(Q_FUNC_INFO));
+ if (Value *prop = ctx->lookupPropertyDescriptor(name))
+ *prop = __qmljs_ushr(*prop, value, ctx);
+ else
+ ctx->throwReferenceError(Value::fromString(name));
}
void __qmljs_inplace_bit_and_element(Context *ctx, Value *base, Value *index, Value *value)
String *name = index.toString(ctx);
if (! object.isObject())
- object = __qmljs_to_object(ctx, object);
+ object = __qmljs_to_object(object, ctx);
return object.property(ctx, name);
}
String *name = index.toString(ctx);
if (! object.isObject())
- object = __qmljs_to_object(ctx, object);
+ object = __qmljs_to_object(object, ctx);
object.objectValue()->setProperty(ctx, name, value, /*flags*/ 0);
}
} else if (object.isString() && name->isEqualTo(ctx->engine->id_length)) {
return Value::fromDouble(object.stringValue()->toQString().length());
} else {
- object = __qmljs_to_object(ctx, object);
+ object = __qmljs_to_object(object, ctx);
if (object.isObject()) {
return __qmljs_get_property(ctx, object, name);
return ctx->engine->globalObject;
}
-Value __qmljs_compare(Context *ctx, const Value x, const Value y, bool leftFirst)
+Value __qmljs_compare(const Value x, const Value y, Context *ctx, bool leftFirst)
{
Value px, py;
if (leftFirst) {
- px = __qmljs_to_primitive(ctx, x, NUMBER_HINT);
- py = __qmljs_to_primitive(ctx, y, NUMBER_HINT);
+ px = __qmljs_to_primitive(x, ctx, NUMBER_HINT);
+ py = __qmljs_to_primitive(y, ctx, NUMBER_HINT);
} else {
- px = __qmljs_to_primitive(ctx, x, NUMBER_HINT);
- py = __qmljs_to_primitive(ctx, y, NUMBER_HINT);
+ px = __qmljs_to_primitive(x, ctx, NUMBER_HINT);
+ py = __qmljs_to_primitive(y, ctx, NUMBER_HINT);
}
if (px.isString() && py.isString()) {
}
}
-uint __qmljs_equal(Context *ctx, const Value x, const Value y)
+uint __qmljs_equal(const Value x, const Value y, Context *ctx)
{
if (x.type() == y.type()) {
switch (x.type()) {
return true;
} else if (x.isNumber() && y.isString()) {
Value ny = Value::fromDouble(__qmljs_to_number(y, ctx));
- return __qmljs_equal(ctx, x, ny);
+ return __qmljs_equal(x, ny, ctx);
} else if (x.isString() && y.isNumber()) {
Value nx = Value::fromDouble(__qmljs_to_number(x, ctx));
- return __qmljs_equal(ctx, nx, y);
+ return __qmljs_equal(nx, y, ctx);
} else if (x.isBoolean()) {
Value nx = Value::fromDouble((double) x.booleanValue());
- return __qmljs_equal(ctx, nx, y);
+ return __qmljs_equal(nx, y, ctx);
} else if (y.isBoolean()) {
Value ny = Value::fromDouble((double) y.booleanValue());
- return __qmljs_equal(ctx, x, ny);
+ return __qmljs_equal(x, ny, ctx);
} else if ((x.isNumber() || x.isString()) && y.isObject()) {
- Value py = __qmljs_to_primitive(ctx, y, PREFERREDTYPE_HINT);
- return __qmljs_equal(ctx, x, py);
+ Value py = __qmljs_to_primitive(y, ctx, PREFERREDTYPE_HINT);
+ return __qmljs_equal(x, py, ctx);
} else if (x.isObject() && (y.isNumber() || y.isString())) {
- Value px = __qmljs_to_primitive(ctx, x, PREFERREDTYPE_HINT);
- return __qmljs_equal(ctx, px, y);
+ Value px = __qmljs_to_primitive(x, ctx, PREFERREDTYPE_HINT);
+ return __qmljs_equal(px, y, ctx);
}
}
if (!base.isUndefined()) {
baseObject = base;
if (!baseObject.isObject())
- baseObject = __qmljs_to_object(context, baseObject);
+ baseObject = __qmljs_to_object(baseObject, context);
assert(baseObject.isObject());
thisObject = baseObject;
} else {
{
Value thisObject = base;
if (!thisObject.isObject())
- thisObject = __qmljs_to_object(context, base);
+ thisObject = __qmljs_to_object(base, context);
assert(thisObject.isObject());
Value func = thisObject.property(context, name);
return Value::undefinedValue();
}
-void __qmljs_throw(Context *context, Value value)
+void __qmljs_throw(Value value, Context *context)
{
context->hasUncaughtException = true;
context->result = value;
Value __qmljs_builtin_typeof(Context *context, Value *args, int argc)
{
Q_UNUSED(argc);
- return __qmljs_typeof(context, args[0]);
+ return __qmljs_typeof(args[0], context);
}
Value __qmljs_builtin_throw(Context *context, Value *args, int argc)
{
Q_UNUSED(argc);
- __qmljs_throw(context, args[0]);
+ __qmljs_throw(args[0], context);
// ### change to void return value
return Value::undefinedValue();
}
Value __qmljs_get_thisObject(Context *ctx);
// type conversion and testing
-Value __qmljs_to_primitive(Context *ctx, const Value value, int typeHint);
+Value __qmljs_to_primitive(const Value value, Context *ctx, int typeHint);
Bool __qmljs_to_boolean(const Value value, Context *ctx);
double __qmljs_to_number(const Value value, Context *ctx);
double __qmljs_to_integer(const Value value, Context *ctx);
int __qmljs_to_int32(const Value value, Context *ctx);
unsigned __qmljs_to_uint32(const Value value, Context *ctx);
unsigned short __qmljs_to_uint16(const Value value, Context *ctx);
-Value __qmljs_to_string(Context *ctx, const Value value);
-Value __qmljs_to_object(Context *ctx, const Value value);
+Value __qmljs_to_string(const Value value, Context *ctx);
+Value __qmljs_to_object(const Value value, Context *ctx);
//uint __qmljs_check_object_coercible(Context *ctx, Value *result, const Value *value);
-Bool __qmljs_is_callable(Context *ctx, const Value value);
-Value __qmljs_default_value(Context *ctx, const Value value, int typeHint);
+Bool __qmljs_is_callable(const Value value, Context *ctx);
+Value __qmljs_default_value(const Value value, Context *ctx, int typeHint);
-Value __qmljs_compare(Context *ctx, const Value left, const Value right, bool leftFlag);
-Bool __qmljs_equal(Context *ctx, const Value x, const Value y);
-Bool __qmljs_strict_equal(Context *ctx, const Value x, const Value y);
+Value __qmljs_compare(const Value left, const Value right, Context *ctx, bool leftFlag);
+Bool __qmljs_equal(const Value x, const Value y, Context *ctx);
+Bool __qmljs_strict_equal(const Value x, const Value y, Context *ctx);
// unary operators
Value __qmljs_uplus(const Value value, Context *ctx);
Value __qmljs_delete_property(Context *ctx, String *name);
Value __qmljs_delete_value(Context *ctx, Value value);
-Value __qmljs_typeof(Context *ctx, const Value value);
-void __qmljs_throw(Context *context, Value value);
+Value __qmljs_typeof(const Value value, Context *ctx);
+void __qmljs_throw(Value value, Context *context);
Value __qmljs_rethrow(Context *context);
// binary operators
Value __qmljs_add_helper(const Value left, const Value right, Context *ctx);
+/*
+ unused and probably don't make sense with the new calling convention
void __qmljs_inplace_bit_and(Context *ctx, Value *result, Value *value);
void __qmljs_inplace_bit_or(Context *ctx, Value *result, Value *value);
void __qmljs_inplace_bit_xor(Context *ctx, Value *result, Value *value);
void __qmljs_inplace_shl(Context *ctx, Value *result, Value *value);
void __qmljs_inplace_shr(Context *ctx, Value *result, Value *value);
void __qmljs_inplace_ushr(Context *ctx, Value *result, Value *value);
+*/
-void __qmljs_inplace_bit_and_name(Context *ctx, String *name, Value *value);
-void __qmljs_inplace_bit_or_name(Context *ctx, String *name, Value *value);
-void __qmljs_inplace_bit_xor_name(Context *ctx, String *name, Value *value);
-void __qmljs_inplace_add_name(Context *ctx, String *name, Value *value);
-void __qmljs_inplace_sub_name(Context *ctx, String *name, Value *value);
-void __qmljs_inplace_mul_name(Context *ctx, String *name, Value *value);
-void __qmljs_inplace_div_name(Context *ctx, String *name, Value *value);
-void __qmljs_inplace_mod_name(Context *ctx, String *name, Value *value);
-void __qmljs_inplace_shl_name(Context *ctx, String *name, Value *value);
-void __qmljs_inplace_shr_name(Context *ctx, String *name, Value *value);
-void __qmljs_inplace_ushr_name(Context *ctx, String *name, Value *value);
+void __qmljs_inplace_bit_and_name(const Value value, String *name, Context *ctx);
+void __qmljs_inplace_bit_or_name(const Value value, String *name, Context *ctx);
+void __qmljs_inplace_bit_xor_name(const Value value, String *name, Context *ctx);
+void __qmljs_inplace_add_name(const Value value, String *name, Context *ctx);
+void __qmljs_inplace_sub_name(const Value value, String *name, Context *ctx);
+void __qmljs_inplace_mul_name(const Value value, String *name, Context *ctx);
+void __qmljs_inplace_div_name(const Value value, String *name, Context *ctx);
+void __qmljs_inplace_mod_name(const Value value, String *name, Context *ctx);
+void __qmljs_inplace_shl_name(const Value value, String *name, Context *ctx);
+void __qmljs_inplace_shr_name(const Value value, String *name, Context *ctx);
+void __qmljs_inplace_ushr_name(const Value value, String *name, Context *ctx);
void __qmljs_inplace_bit_and_element(Context *ctx, Value *base, Value *index, Value *value);
void __qmljs_inplace_bit_or_element(Context *ctx, Value *base, Value *index, Value *value);
}
// type conversion and testing
-inline Value __qmljs_to_primitive(Context *ctx, const Value value, int typeHint)
+inline Value __qmljs_to_primitive(const Value value, Context *ctx, int typeHint)
{
if (!value.isObject())
return value;
- return __qmljs_default_value(ctx, value, typeHint);
+ return __qmljs_default_value(value, ctx, typeHint);
}
inline Bool __qmljs_to_boolean(const Value value, Context *ctx)
case Value::String_Type:
return __qmljs_string_to_number(ctx, value.stringValue());
case Value::Object_Type: {
- Value prim = __qmljs_to_primitive(ctx, value, NUMBER_HINT);
+ Value prim = __qmljs_to_primitive(value, ctx, NUMBER_HINT);
return __qmljs_to_number(prim, ctx);
}
default: // double
return (unsigned short)number;
}
-inline Value __qmljs_to_string(Context *ctx, const Value value)
+inline Value __qmljs_to_string(const Value value, Context *ctx)
{
switch (value.type()) {
case Value::Undefined_Type:
return value;
break;
case Value::Object_Type: {
- Value prim = __qmljs_to_primitive(ctx, value, STRING_HINT);
+ Value prim = __qmljs_to_primitive(value, ctx, STRING_HINT);
if (prim.isPrimitive())
- return __qmljs_to_string(ctx, prim);
+ return __qmljs_to_string(prim, ctx);
else
return __qmljs_throw_type_error(ctx);
break;
} // switch
}
-inline Value __qmljs_to_object(Context *ctx, const Value value)
+inline Value __qmljs_to_object(const Value value, Context *ctx)
{
switch (value.type()) {
case Value::Undefined_Type:
}
*/
-inline Bool __qmljs_is_callable(Context *ctx, const Value value)
+inline Bool __qmljs_is_callable(const Value value, Context *ctx)
{
if (value.isObject())
return __qmljs_is_function(value);
return false;
}
-inline Value __qmljs_default_value(Context *ctx, const Value value, int typeHint)
+inline Value __qmljs_default_value(const Value value, Context *ctx, int typeHint)
{
if (value.isObject())
return __qmljs_object_default_value(ctx, value, typeHint);
// unary operators
-inline Value __qmljs_typeof(Context *ctx, const Value value)
+inline Value __qmljs_typeof(const Value value, Context *ctx)
{
switch (value.type()) {
case Value::Undefined_Type:
return __qmljs_string_literal_string(ctx);
break;
case Value::Object_Type:
- if (__qmljs_is_callable(ctx, value))
+ if (__qmljs_is_callable(value, ctx))
return __qmljs_string_literal_function(ctx);
else
return __qmljs_string_literal_object(ctx); // ### implementation-defined
return Value::fromInt32(lval & rval);
}
+/*
inline void __qmljs_inplace_bit_and(Context *ctx, Value *result, Value *value)
{
*result = __qmljs_bit_and(*result, *value, ctx);
{
*result = __qmljs_ushr(*result, *value, ctx);
}
+*/
inline Value __qmljs_add(const Value left, const Value right, Context *ctx)
{
if (left.isNumber() && right.isNumber()) {
return Value::fromBoolean(left.asDouble() > right.asDouble());
} else {
- Value result = __qmljs_compare(ctx, left, right, false);
+ Value result = __qmljs_compare(left, right, ctx, false);
if (result.isUndefined())
result = Value::fromBoolean(false);
if (left.isNumber() && right.isNumber()) {
return Value::fromBoolean(left.asDouble() < right.asDouble());
} else {
- Value result = __qmljs_compare(ctx, left, right, true);
+ Value result = __qmljs_compare(left, right, ctx, true);
if (result.isUndefined())
result = Value::fromBoolean(false);
if (left.isNumber() && right.isNumber()) {
return Value::fromBoolean(left.asDouble() >= right.asDouble());
} else {
- Value result = __qmljs_compare(ctx, right, left, false);
+ Value result = __qmljs_compare(right, left, ctx, false);
bool r = ! (result.isUndefined() || (result.isBoolean() && result.booleanValue()));
return Value::fromBoolean(r);
if (left.isNumber() && right.isNumber()) {
return Value::fromBoolean(left.asDouble() <= right.asDouble());
} else {
- Value result = __qmljs_compare(ctx, right, left, true);
+ Value result = __qmljs_compare(right, left, ctx, true);
bool r = ! (result.isUndefined() || (result.isBoolean() && result.booleanValue()));
return Value::fromBoolean(r);
} else if (left.isString() && right.isString()) {
return Value::fromBoolean(__qmljs_string_equal(ctx, left.stringValue(), right.stringValue()));
} else {
- bool r = __qmljs_equal(ctx, left, right);
+ bool r = __qmljs_equal(left, right, ctx);
return Value::fromBoolean(r);
}
}
inline Value __qmljs_se(const Value left, const Value right, Context *ctx)
{
- bool r = __qmljs_strict_equal(ctx, left, right);
+ bool r = __qmljs_strict_equal(left, right, ctx);
return Value::fromBoolean(r);
}
inline Value __qmljs_sne(const Value left, const Value right, Context *ctx)
{
- bool r = ! __qmljs_strict_equal(ctx, left, right);
+ bool r = ! __qmljs_strict_equal(left, right, ctx);
return Value::fromBoolean(r);
}
inline Bool __qmljs_cmp_se(Context *ctx, const Value left, const Value right)
{
- return __qmljs_strict_equal(ctx, left, right);
+ return __qmljs_strict_equal(left, right, ctx);
}
inline Bool __qmljs_cmp_sne(Context *ctx, const Value left, const Value right)
{
- return ! __qmljs_strict_equal(ctx, left, right);
+ return ! __qmljs_strict_equal(left, right, ctx);
}
inline Bool __qmljs_cmp_instanceof(Context *ctx, const Value left, const Value right)
return v.booleanValue();
}
-inline Bool __qmljs_strict_equal(Context *ctx, const Value x, const Value y)
+inline Bool __qmljs_strict_equal(const Value x, const Value y, Context *ctx)
{
if (x.rawValue() == y.rawValue())
return true;
if (arg.is(Value::Undefined_Type))
ctx->result = Value::fromString(ctx->engine->newString(QString()));
else
- ctx->result = __qmljs_to_string(ctx, arg);
+ ctx->result = __qmljs_to_string(arg, ctx);
}
void StringPrototype::init(Context *ctx, const Value &ctor)
QString value = getThisString(ctx);
for (unsigned i = 0; i < ctx->argumentCount; ++i) {
- Value v = __qmljs_to_string(ctx, ctx->arguments[i]);
+ Value v = __qmljs_to_string(ctx->arguments[i], ctx);
assert(v.is(Value::String_Type));
value += v.stringValue()->toQString();
}
QString searchString;
if (ctx->argumentCount) {
- Value v = __qmljs_to_string(ctx, ctx->arguments[0]);
+ Value v = __qmljs_to_string(ctx->arguments[0], ctx);
searchString = v.stringValue()->toQString();
}
if (DateObject *d = arg.asDateObject())
arg = d->value;
else
- arg = __qmljs_to_primitive(ctx, arg, PREFERREDTYPE_HINT);
+ arg = __qmljs_to_primitive(arg, ctx, PREFERREDTYPE_HINT);
if (arg.isString())
t = ParseString(arg.toString(ctx)->toQString());
}
} else if (IR::Name *n = s->target->asName()) {
if (IR::Temp *t = s->source->asTemp()) {
- void (*op)(Context *ctx, String *name, Value *value) = 0;
+ void (*op)(const Value value, String *name, Context *ctx) = 0;
const char *opName = 0;
switch (s->op) {
case IR::OpBitAnd: setOp(op, opName, __qmljs_inplace_bit_and_name); break;
break;
}
if (op) {
- generateFunctionCallImp(opName, op, ContextRegister, identifier(*n->id), t);
+ generateFunctionCallImp2(Void, opName, op, t, identifier(*n->id), ContextRegister);
checkExceptions();
}
return;