diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-10-15 10:22:47 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-11-05 21:15:39 +0000 |
commit | b1f07986c30978ed6636457e8d3f4a65c5db38a3 (patch) | |
tree | 6dd48a2901219b4268a95b9d5acd08a3c49988c0 /src/qml/jsruntime | |
parent | 0fce92af2cab51d03f33230718ab5ae35149b9e1 (diff) |
Create proper template objects for tagged templates
If a tagged template gets evaluated multiple times, the
underlying template object is shared.
Change-Id: Ie2f476fbc93d5991322ce1087c42719a8d8333ae
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtime_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 4 |
3 files changed, 12 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index b576bb4d87..13244fdd95 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -595,6 +595,12 @@ QV4::ReturnedValue RuntimeHelpers::addHelper(ExecutionEngine *engine, const Valu return Encode(x + y); } +ReturnedValue RuntimeHelpers::getTemplateObject(Function *function, int index) +{ + return function->compilationUnit->templateObjectAt(index)->asReturnedValue(); +} + + void Runtime::method_storeProperty(ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value) { Scope scope(engine); diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h index 72af90d1dc..2be3ebf012 100644 --- a/src/qml/jsruntime/qv4runtime_p.h +++ b/src/qml/jsruntime/qv4runtime_p.h @@ -114,6 +114,8 @@ struct Q_QML_PRIVATE_EXPORT RuntimeHelpers { static Bool strictEqual(const Value &x, const Value &y); static ReturnedValue addHelper(ExecutionEngine *engine, const Value &left, const Value &right); + + static ReturnedValue getTemplateObject(Function *function, int index); }; diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 1cca50f6c1..5208894934 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -1378,6 +1378,10 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine, } MOTH_END_INSTR(ThrowOnNullOrUndefined) + MOTH_BEGIN_INSTR(GetTemplateObject) + acc = RuntimeHelpers::getTemplateObject(function, index); + MOTH_END_INSTR(GetTemplateObject) + MOTH_BEGIN_INSTR(Debug) #if QT_CONFIG(qml_debug) STORE_IP(); |