aboutsummaryrefslogtreecommitdiffstats
path: root/qmljs_environment.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2012-12-10 19:30:08 +0100
committerLars Knoll <lars.knoll@digia.com>2012-12-10 20:08:26 +0100
commit9c104bb97098f690e4c8af6e17b7217891a8c690 (patch)
tree00a85b1e91d5f64c186355807b416a248e2b92d8 /qmljs_environment.cpp
parentdf458859f443c6c559c39c667952bcb85f277e9a (diff)
Properly set up the 'this' pointer
Make sure the this pointer is setup correctly for function calls. Also make sure we set the strict mode flag correctly in all functions. Change-Id: Idaacc92bf6469145b7addfac2bbddea588e85c2d Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'qmljs_environment.cpp')
-rw-r--r--qmljs_environment.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/qmljs_environment.cpp b/qmljs_environment.cpp
index 4f2f7981cd..9f900f9e94 100644
--- a/qmljs_environment.cpp
+++ b/qmljs_environment.cpp
@@ -210,7 +210,7 @@ void ExecutionContext::init(ExecutionEngine *eng)
{
engine = eng;
parent = 0;
- thisObject = Value::nullValue();
+ thisObject = eng->globalObject;
function = 0;
arguments = 0;
@@ -385,11 +385,18 @@ void ExecutionContext::initCallContext(ExecutionContext *parent, const Value tha
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){