aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4runtime.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-07-01 12:00:57 +0200
committerLars Knoll <lars.knoll@qt.io>2018-07-03 08:09:17 +0000
commitd31541fd9d7d52ef3eae29e7e5d36733d7f55375 (patch)
treec5d17bea0119c9f0eb26e97eb523b281e9900783 /src/qml/jsruntime/qv4runtime.cpp
parent6e79a00cad2f5dd09bdf40e594a65af58b370d9d (diff)
Add support for super properties
Those are mostly working now, but when calling super properties the this object is not setup correctly. Change-Id: Ib42129ae6e729eeca00275f707f480371b7e42a5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4runtime.cpp')
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index eeb66509e3..7b2fd07f0b 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -856,6 +856,42 @@ ReturnedValue Runtime::method_loadName(ExecutionEngine *engine, int nameIndex)
return static_cast<ExecutionContext &>(engine->currentStackFrame->jsFrame->context).getProperty(name);
}
+ReturnedValue Runtime::method_loadSuperProperty(ExecutionEngine *engine, const Value &property)
+{
+ Scope scope(engine);
+ ScopedObject base(scope, engine->currentStackFrame->thisObject());
+ if (!base)
+ return engine->throwTypeError();
+ ScopedObject proto(scope, base->getPrototypeOf());
+ if (!proto)
+ return engine->throwTypeError();
+ ScopedPropertyKey key(scope, property.toPropertyKey(engine));
+ if (engine->hasException)
+ return Encode::undefined();
+ return proto->get(key, base);
+}
+
+void Runtime::method_storeSuperProperty(ExecutionEngine *engine, const Value &property, const Value &value)
+{
+ Scope scope(engine);
+ ScopedObject base(scope, engine->currentStackFrame->thisObject());
+ if (!base) {
+ engine->throwTypeError();
+ return;
+ }
+ ScopedObject proto(scope, base->getPrototypeOf());
+ if (!proto) {
+ engine->throwTypeError();
+ return;
+ }
+ ScopedPropertyKey key(scope, property.toPropertyKey(engine));
+ if (engine->hasException)
+ return;
+ bool result = proto->put(key, value, base);
+ if (!result && engine->currentStackFrame->v4Function->isStrict())
+ engine->throwTypeError();
+}
+
#endif // V4_BOOTSTRAP
uint RuntimeHelpers::equalHelper(const Value &x, const Value &y)