return ctx->engine->newString(msg);
}
-void ExecutionContext::init(FunctionObject *f, Value *args, uint argc)
-{
- function = f;
- engine = f->scope->engine;
- strictMode = f->strictMode;
-
- arguments = args;
- argumentCount = argc;
- if (function->needsActivation || argc < function->formalParameterCount){
- arguments = new Value[qMax(argc, function->formalParameterCount)];
- if (argc)
- std::copy(args, args + argc, arguments);
- if (argc < function->formalParameterCount)
- std::fill(arguments + argc, arguments + function->formalParameterCount, Value::undefinedValue());
- }
- locals = function->varCount ? new Value[function->varCount] : 0;
- if (function->varCount)
- std::fill(locals, locals + function->varCount, Value::undefinedValue());
-
- if (function->needsActivation)
- activation = engine->newActivationObject(this);
- else
- activation = 0;
-
- withObject = 0;
-}
-
bool ExecutionContext::hasBinding(String *name) const
{
if (!function)
{
engine = parent->engine;
this->parent = parent;
+ thisObject = that;
+
+ function = f;
+ strictMode = f->strictMode;
- init(f, args, argc);
+ arguments = args;
+ argumentCount = argc;
+ if (function->needsActivation || argc < function->formalParameterCount){
+ arguments = new Value[qMax(argc, function->formalParameterCount)];
+ if (argc)
+ std::copy(args, args + argc, arguments);
+ if (argc < function->formalParameterCount)
+ std::fill(arguments + argc, arguments + function->formalParameterCount, Value::undefinedValue());
+ }
+ locals = function->varCount ? new Value[function->varCount] : 0;
+ if (function->varCount)
+ std::fill(locals, locals + function->varCount, Value::undefinedValue());
+
+ if (function->needsActivation)
+ activation = engine->newActivationObject(this);
+ else
+ activation = 0;
+
+ withObject = 0;
- thisObject = that;
if (engine->debugger)
engine->debugger->aboutToCall(f, this);
delete[] locals;
locals = 0;
}
+ parent = 0;
if (engine->debugger)
engine->debugger->justLeft(this);
}
-void ExecutionContext::initConstructorContext(ExecutionContext *parent, Value that, FunctionObject *f, Value *args, unsigned argc)
-{
- initCallContext(parent, that, f, args, argc);
-}
-
-void ExecutionContext::leaveConstructorContext(FunctionObject *f)
-{
- wireUpPrototype(f);
- leaveCallContext();
-}
-
-void ExecutionContext::wireUpPrototype(FunctionObject *f)
+void ExecutionContext::wireUpPrototype()
{
assert(thisObject.isObject());
- Value proto = f->__get__(this, engine->id_prototype);
+ Value proto = function->__get__(this, engine->id_prototype);
if (proto.isObject())
thisObject.objectValue()->prototype = proto.objectValue();
else
void init(ExecutionEngine *e);
- void init(FunctionObject *f, Value *args, uint argc);
bool hasBinding(String *name) const;
void createMutableBinding(ExecutionContext *ctx, String *name, bool deletable);
void initCallContext(ExecutionContext *parent, const Value that, FunctionObject *f, Value *args, unsigned argc);
void leaveCallContext();
- void initConstructorContext(ExecutionContext *parent, Value that, FunctionObject *f, Value *args, unsigned argc);
- void leaveConstructorContext(FunctionObject *f);
- void wireUpPrototype(FunctionObject *f);
+ void wireUpPrototype();
void throwError(Value value);
void throwError(const QString &message);
{
ExecutionContext k;
ExecutionContext *ctx = needsActivation ? context->engine->newContext() : &k;
- ctx->initConstructorContext(context, Value::nullValue(), this, args, argc);
+ ctx->initCallContext(context, Value::nullValue(), this, args, argc);
Value result = construct(ctx);
- ctx->leaveConstructorContext(this);
+ ctx->wireUpPrototype();
+ ctx->leaveCallContext();
if (ctx != &k)
delete ctx;
return result;