summaryrefslogtreecommitdiff
path: root/src/qml/compiler/qv4codegen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-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;
}