Value __qmljs_instanceof(Value left, Value right, ExecutionContext *ctx)
{
- if (FunctionObject *function = right.asFunctionObject()) {
- bool r = function->hasInstance(ctx, left);
- return Value::fromBoolean(r);
- }
+ FunctionObject *function = right.asFunctionObject();
+ if (!function)
+ __qmljs_throw_type_error(ctx);
- return __qmljs_throw_type_error(ctx);
+ bool r = function->hasInstance(ctx, left);
+ return Value::fromBoolean(r);
}
Value __qmljs_in(Value left, Value right, ExecutionContext *ctx)
{
- if (right.isObject()) {
- String *s = left.toString(ctx);
- bool r = right.objectValue()->__hasProperty__(ctx, s);
- return Value::fromBoolean(r);
- } else {
- return __qmljs_throw_type_error(ctx);
- }
+ if (!right.isObject())
+ __qmljs_throw_type_error(ctx);
+ String *s = left.toString(ctx);
+ bool r = right.objectValue()->__hasProperty__(ctx, s);
+ return Value::fromBoolean(r);
}
void __qmljs_inplace_bit_and_name(Value value, String *name, ExecutionContext *ctx)
return Value::undefinedValue();
}
-Value __qmljs_throw_type_error(ExecutionContext *ctx)
+void __qmljs_throw_type_error(ExecutionContext *ctx)
{
ctx->throwTypeError();
- return Value::undefinedValue();
}
Value __qmljs_new_object(ExecutionContext *ctx)
// objects
Value __qmljs_object_default_value(ExecutionContext *ctx, Value object, int typeHint);
-Value __qmljs_throw_type_error(ExecutionContext *ctx);
+void __qmljs_throw_type_error(ExecutionContext *ctx);
Value __qmljs_new_object(ExecutionContext *ctx);
Value __qmljs_new_boolean_object(ExecutionContext *ctx, bool boolean);
Value __qmljs_new_number_object(ExecutionContext *ctx, double n);
if (prim.isPrimitive())
return __qmljs_to_string(prim, ctx);
else
- return __qmljs_throw_type_error(ctx);
+ __qmljs_throw_type_error(ctx);
break;
}
case Value::Integer_Type:
switch (value.type()) {
case Value::Undefined_Type:
case Value::Null_Type:
- return __qmljs_throw_type_error(ctx);
+ __qmljs_throw_type_error(ctx);
break;
case Value::Boolean_Type:
return __qmljs_new_boolean_object(ctx, value.booleanValue());
namespace QQmlJS {
namespace VM {
+static Value throwTypeError(ExecutionContext *ctx)
+{
+ ctx->throwTypeError();
+ return Value::undefinedValue();
+}
ArgumentsObject::ArgumentsObject(ExecutionContext *context, int formalParameterCount, int actualParameterCount)
: Object(context->engine), context(context)
if (context->strictMode) {
for (uint i = 0; i < context->argumentCount; ++i)
Object::__put__(context, QString::number(i), context->arguments[i]);
- FunctionObject *thrower = context->engine->newBuiltinFunction(context, 0, __qmljs_throw_type_error);
+ FunctionObject *thrower = context->engine->newBuiltinFunction(context, 0, throwTypeError);
PropertyDescriptor pd = PropertyDescriptor::fromAccessor(thrower, thrower);
pd.configurable = PropertyDescriptor::Disabled;
pd.enumberable = PropertyDescriptor::Disabled;
return Value::fromObject(f);
}
+
+static Value throwTypeError(ExecutionContext *ctx)
+{
+ ctx->throwTypeError();
+ return Value::undefinedValue();
+}
+
ScriptFunction::ScriptFunction(ExecutionContext *scope, Function *function)
: FunctionObject(scope)
{
pd->value = Value::fromObject(proto);
if (scope->strictMode) {
- FunctionObject *thrower = scope->engine->newBuiltinFunction(scope, 0, __qmljs_throw_type_error);
+ FunctionObject *thrower = scope->engine->newBuiltinFunction(scope, 0, throwTypeError);
PropertyDescriptor pd = PropertyDescriptor::fromAccessor(thrower, thrower);
pd.configurable = PropertyDescriptor::Disabled;
pd.enumberable = PropertyDescriptor::Disabled;
len = 0;
defineReadonlyProperty(scope->engine->id_length, Value::fromInt32(len));
- FunctionObject *thrower = scope->engine->newBuiltinFunction(scope, 0, __qmljs_throw_type_error);
+ FunctionObject *thrower = scope->engine->newBuiltinFunction(scope, 0, throwTypeError);
PropertyDescriptor pd = PropertyDescriptor::fromAccessor(thrower, thrower);
pd.configurable = PropertyDescriptor::Disabled;
pd.enumberable = PropertyDescriptor::Disabled;