return Value::fromObject(obj);
}
-Value FunctionObject::call(ExecutionContext *context, Value thisObject, Value *args, int argc)
+Value FunctionObject::call(ExecutionContext *, Value, Value *, int)
{
- uint size = requiredMemoryForExecutionContect(this, argc);
- ExecutionContext *ctx = static_cast<ExecutionContext *>(needsActivation ? malloc(size) : alloca(size));
-
- if (!strictMode && !thisObject.isObject()) {
- // Built-in functions allow for the this object to be null or undefined. This overrides
- // the behaviour of changing thisObject to the global object if null/undefined and allows
- // the built-in functions for example to throw a type error if null is passed.
- if (thisObject.isUndefined() || thisObject.isNull()) {
- if (!isBuiltinFunction)
- thisObject = context->engine->globalObject;
- } else {
- thisObject = thisObject.toObject(context);
- }
- }
-
- ctx->thisObject = thisObject;
- ctx->function = this;
- ctx->arguments = args;
- ctx->argumentCount = argc;
-
- ctx->initCallContext(context);
- Value result = call(ctx);
- ctx->leaveCallContext();
- return result;
+ return Value::undefinedValue();
}
void FunctionObject::markObjects(Managed *that)
Object::markObjects(that);
}
-Value FunctionObject::call(ExecutionContext *ctx)
-{
- Q_UNUSED(ctx);
- return Value::undefinedValue();
-}
-
const ManagedVTable FunctionObject::static_vtbl =
{
FunctionObject::markObjects,
Value ScriptFunction::construct(ExecutionContext *context, Value *args, int argc)
{
+ assert(function->code);
Object *obj = context->engine->newObject();
Value proto = __get__(context, context->engine->id_prototype);
if (proto.isObject())
ctx->argumentCount = argc;
ctx->initCallContext(context);
- Value result = call(ctx);
+ Value result = function->code(ctx, function->codeData);
ctx->leaveCallContext();
if (result.isObject())
return Value::fromObject(obj);
}
-
-
-Value ScriptFunction::call(ExecutionContext *ctx)
+Value ScriptFunction::call(ExecutionContext *context, Value thisObject, Value *args, int argc)
{
assert(function->code);
- return function->code(ctx, function->codeData);
+ uint size = requiredMemoryForExecutionContect(this, argc);
+ ExecutionContext *ctx = static_cast<ExecutionContext *>(needsActivation ? malloc(size) : alloca(size));
+
+ if (!strictMode && !thisObject.isObject()) {
+ // Built-in functions allow for the this object to be null or undefined. This overrides
+ // the behaviour of changing thisObject to the global object if null/undefined and allows
+ // the built-in functions for example to throw a type error if null is passed.
+ if (thisObject.isUndefined() || thisObject.isNull()) {
+ if (!isBuiltinFunction)
+ thisObject = context->engine->globalObject;
+ } else {
+ thisObject = thisObject.toObject(context);
+ }
+ }
+
+ ctx->thisObject = thisObject;
+ ctx->function = this;
+ ctx->arguments = args;
+ ctx->argumentCount = argc;
+
+ ctx->initCallContext(context);
+ Value result = function->code(ctx, function->codeData);
+ ctx->leaveCallContext();
+ return result;
}
+
BuiltinFunctionOld::BuiltinFunctionOld(ExecutionContext *scope, String *name, Value (*code)(ExecutionContext *))
: FunctionObject(scope)
, code(code)
return Value::undefinedValue();
}
+Value BuiltinFunctionOld::call(ExecutionContext *context, Value thisObject, Value *args, int argc)
+{
+ uint size = requiredMemoryForExecutionContect(this, argc);
+ ExecutionContext *ctx = static_cast<ExecutionContext *>(needsActivation ? malloc(size) : alloca(size));
+
+ if (!strictMode && !thisObject.isObject()) {
+ // Built-in functions allow for the this object to be null or undefined. This overrides
+ // the behaviour of changing thisObject to the global object if null/undefined and allows
+ // the built-in functions for example to throw a type error if null is passed.
+ if (thisObject.isUndefined() || thisObject.isNull()) {
+ if (!isBuiltinFunction)
+ thisObject = context->engine->globalObject;
+ } else {
+ thisObject = thisObject.toObject(context);
+ }
+ }
+
+ ctx->thisObject = thisObject;
+ ctx->function = this;
+ ctx->arguments = args;
+ ctx->argumentCount = argc;
+
+ ctx->initCallContext(context);
+ Value result = code(ctx);
+ ctx->leaveCallContext();
+ return result;
+}
+
BuiltinFunction::BuiltinFunction(ExecutionContext *scope, String *name, Value (*code)(ExecutionContext *, Value, Value *, int))
: FunctionObject(scope)
, code(code)
FunctionObject(ExecutionContext *scope);
virtual Value construct(ExecutionContext *context, Value *args, int argc);
- virtual Value call(ExecutionContext *context, Value thisObject, Value *args, int argc);
+ virtual Value call(ExecutionContext *, Value, Value *, int);
virtual struct ScriptFunction *asScriptFunction() { return 0; }
protected:
- virtual Value call(ExecutionContext *ctx);
-
static const ManagedVTable static_vtbl;
static void markObjects(Managed *that);
static bool hasInstance(Managed *that, ExecutionContext *ctx, const Value *value);
Value (*code)(ExecutionContext *);
BuiltinFunctionOld(ExecutionContext *scope, String *name, Value (*code)(ExecutionContext *));
- virtual Value call(ExecutionContext *ctx) { return code(ctx); }
+ virtual Value call(ExecutionContext *context, Value thisObject, Value *args, int argc);
virtual Value construct(ExecutionContext *ctx, Value *, int);
};
ScriptFunction(ExecutionContext *scope, VM::Function *function);
virtual ~ScriptFunction();
+ virtual Value call(ExecutionContext *context, Value thisObject, Value *args, int argc);
virtual Value construct(ExecutionContext *context, Value *args, int argc);
- virtual Value call(ExecutionContext *ctx);
virtual ScriptFunction *asScriptFunction() { return this; }
};