VM::Object *glo = newObject(/*rootContext*/);
globalObject = Value::fromObject(glo);
rootContext->activation = glo;
+ rootContext->thisObject = Value::fromObject(glo);
glo->__put__(rootContext, identifier(QStringLiteral("Object")), objectCtor);
glo->__put__(rootContext, identifier(QStringLiteral("String")), stringCtor);
{
engine = eng;
parent = 0;
- thisObject = Value::nullValue();
+ thisObject = eng->globalObject;
function = 0;
arguments = 0;
engine = parent->engine;
this->parent = parent;
- thisObject = that;
function = f;
strictMode = f->strictMode;
+ thisObject = that;
+ if (!strictMode && !thisObject.isObject()) {
+ if (thisObject.isUndefined() || thisObject.isNull())
+ thisObject = engine->globalObject;
+ else
+ thisObject = thisObject.toObject(this);
+ }
+
arguments = args;
argumentCount = argc;
if (function->needsActivation || argc < function->formalParameterCount){
{
ExecutionContext k;
ExecutionContext *ctx = needsActivation ? context->engine->newContext() : &k;
- ctx->initCallContext(context, Value::nullValue(), this, args, argc);
+ ctx->initCallContext(context, Value::undefinedValue(), this, args, argc);
Value result = construct(ctx);
ctx->wireUpPrototype();
ctx->leaveCallContext();
ExecutionContext k;
ExecutionContext *ctx = needsActivation ? context->engine->newContext() : &k;
- if (!strictMode && !thisObject.isObject()) {
- if (thisObject.isUndefined() || thisObject.isNull())
- thisObject = context->engine->globalObject;
- else
- thisObject = __qmljs_to_object(thisObject, context);
- }
ctx->initCallContext(context, thisObject, this, args, argc);
Value result = call(ctx);
ctx->leaveCallContext();
Value __qmljs_get_thisObject(ExecutionContext *ctx)
{
- if (ctx->thisObject.isObject())
- return ctx->thisObject;
- return ctx->engine->globalObject;
+ return ctx->thisObject;
}
uint __qmljs_equal(Value x, Value y, ExecutionContext *ctx)
inline void enterEnvironment(Node *node)
{
Environment *e = _cg->newEnvironment(node, _env);
- e->isStrict = _cg->_context->strictMode;
+ if (!e->isStrict)
+ e->isStrict = _cg->_context->strictMode;
_envStack.append(e);
_env = e;
}