From: Lars Knoll Date: Sun, 9 Dec 2012 04:16:04 +0000 (+0100) Subject: Return the this object if we ask for it X-Git-Tag: upstream/5.2.1~669^2~659^2~727 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df458859f443c6c559c39c667952bcb85f277e9a;p=platform%2Fupstream%2Fqtdeclarative.git Return the this object if we ask for it This makes expressions such as typeof(this) work correctly. Change-Id: I44270f877fdee648e69ae44089ffc8fb57243401 Reviewed-by: Erik Verbruggen --- diff --git a/qmljs_engine.cpp b/qmljs_engine.cpp index b0a964f..a694d3e 100644 --- a/qmljs_engine.cpp +++ b/qmljs_engine.cpp @@ -84,6 +84,7 @@ ExecutionEngine::ExecutionEngine(MemoryManager *memoryManager, EvalISelFactory * id_prototype = identifier(QStringLiteral("prototype")); id_constructor = identifier(QStringLiteral("constructor")); id_arguments = identifier(QStringLiteral("arguments")); + id_this = identifier(QStringLiteral("this")); id___proto__ = identifier(QStringLiteral("__proto__")); id_enumerable = identifier(QStringLiteral("enumerable")); id_configurable = identifier(QStringLiteral("configurable")); diff --git a/qmljs_engine.h b/qmljs_engine.h index 85a3909..1b4e593 100644 --- a/qmljs_engine.h +++ b/qmljs_engine.h @@ -135,6 +135,7 @@ struct ExecutionEngine String *id_prototype; String *id_constructor; String *id_arguments; + String *id_this; String *id___proto__; String *id_enumerable; String *id_configurable; diff --git a/qmljs_environment.cpp b/qmljs_environment.cpp index a64d9dc..4f2f798 100644 --- a/qmljs_environment.cpp +++ b/qmljs_environment.cpp @@ -267,6 +267,9 @@ void ExecutionContext::setProperty(String *name, Value value) Value ExecutionContext::getProperty(String *name) { + if (name == engine->id_this) + return thisObject; + for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer()) { if (ctx->withObject) { With *w = ctx->withObject; @@ -298,6 +301,9 @@ Value ExecutionContext::getProperty(String *name) Value ExecutionContext::getPropertyNoThrow(String *name) { + if (name == engine->id_this) + return thisObject; + for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer()) { if (ctx->withObject) { With *w = ctx->withObject;