aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-10-12 16:17:20 +0200
committerLars Knoll <lars.knoll@qt.io>2018-11-02 18:44:11 +0000
commit9755cf48cbaa322ec918e0d70d54124e22f9c550 (patch)
treeccd98d3f475d6305ebed3e03ecac11a9ee341279 /src/qml/compiler
parent4241ce2cfc624ae51ac911c11d065fc703dfadc5 (diff)
Create proper template objects
Create the proper template object for a tagged template. This fixes quite a few use cases (esp. String.raw), but is not yet 100% spec compliant. Change-Id: I69eaee22c384c0d1bd2c6c56ad711d29521b0b86 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r--src/qml/compiler/qv4codegen.cpp54
1 files changed, 40 insertions, 14 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 295ce08071..ac596e2b5b 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -2260,8 +2260,6 @@ int Codegen::createTemplateArray(TemplateLiteral *t)
{
int arrayTemp = bytecodeGenerator->newRegister();
- RegisterScope scope(this);
-
int argc = 0;
int args = -1;
auto push = [this, &argc, &args](const QStringRef &arg) {
@@ -2278,22 +2276,50 @@ int Codegen::createTemplateArray(TemplateLiteral *t)
++argc;
};
- for (TemplateLiteral *it = t; it; it = it->next)
- push(it->value);
+ {
+ RegisterScope scope(this);
+
+ for (TemplateLiteral *it = t; it; it = it->next)
+ push(it->value);
+
+ if (args == -1) {
+ Q_ASSERT(argc == 0);
+ args = 0;
+ }
+
+ Instruction::DefineArray call;
+ call.argc = argc;
+ call.args = Moth::StackSlot::createRegister(args);
+ bytecodeGenerator->addInstruction(call);
- if (args == -1) {
- Q_ASSERT(argc == 0);
- args = 0;
+ Instruction::StoreReg store;
+ store.reg = arrayTemp;
+ bytecodeGenerator->addInstruction(store);
}
- Instruction::DefineArray call;
- call.argc = argc;
- call.args = Moth::StackSlot::createRegister(args);
- bytecodeGenerator->addInstruction(call);
+ {
+ RegisterScope scope(this);
+
+ argc = 0;
+ args = -1;
- Instruction::StoreReg store;
- store.reg = arrayTemp;
- bytecodeGenerator->addInstruction(store);
+ for (TemplateLiteral *it = t; it; it = it->next)
+ push(it->rawValue);
+
+ if (args == -1) {
+ Q_ASSERT(argc == 0);
+ args = 0;
+ }
+
+ Instruction::DefineArray call;
+ call.argc = argc;
+ call.args = Moth::StackSlot::createRegister(args);
+ bytecodeGenerator->addInstruction(call);
+
+ Reference a = Reference::fromStackSlot(this, arrayTemp);
+ Reference m = Reference::fromMember(a, QStringLiteral("raw"));
+ m.storeConsumeAccumulator();
+ }
return arrayTemp;
}