aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--src/qml/compiler/qv4codegen.cpp54
-rw-r--r--tests/auto/qml/ecmascripttests/TestExpectations16
2 files changed, 40 insertions, 30 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;
}
diff --git a/tests/auto/qml/ecmascripttests/TestExpectations b/tests/auto/qml/ecmascripttests/TestExpectations
index 1613888e77..d51b45b75c 100644
--- a/tests/auto/qml/ecmascripttests/TestExpectations
+++ b/tests/auto/qml/ecmascripttests/TestExpectations
@@ -224,10 +224,6 @@ built-ins/String/prototype/toLocaleLowerCase/Final_Sigma_U180E.js fails
built-ins/String/prototype/toLocaleLowerCase/special_casing_conditional.js fails
built-ins/String/prototype/toLowerCase/Final_Sigma_U180E.js fails
built-ins/String/prototype/toLowerCase/special_casing_conditional.js fails
-built-ins/String/raw/return-the-string-value-from-template.js fails
-built-ins/String/raw/special-characters.js fails
-built-ins/String/raw/template-substitutions-are-appended-on-same-index.js fails
-built-ins/String/raw/zero-literal-segments.js fails
built-ins/TypedArray/from/arylk-get-length-error.js fails
built-ins/TypedArray/from/arylk-to-length-error.js fails
built-ins/TypedArray/from/iter-access-error.js fails
@@ -580,19 +576,7 @@ language/expressions/tagged-template/tco-member.js strictFails
language/expressions/tagged-template/template-object-frozen-non-strict.js sloppyFails
language/expressions/tagged-template/template-object-frozen-strict.js strictFails
language/expressions/tagged-template/template-object.js fails
-language/expressions/template-literal/tv-character-escape-sequence.js fails
-language/expressions/template-literal/tv-hex-escape-sequence.js fails
-language/expressions/template-literal/tv-line-continuation.js fails
-language/expressions/template-literal/tv-line-terminator-sequence.js fails
-language/expressions/template-literal/tv-no-substitution.js fails
language/expressions/template-literal/tv-null-character-escape-sequence.js fails
-language/expressions/template-literal/tv-template-character.js fails
-language/expressions/template-literal/tv-template-characters.js fails
-language/expressions/template-literal/tv-template-head.js fails
-language/expressions/template-literal/tv-template-middle.js fails
-language/expressions/template-literal/tv-template-tail.js fails
-language/expressions/template-literal/tv-utf16-escape-sequence.js fails
-language/expressions/template-literal/tv-zwnbsp.js fails
language/function-code/each-param-has-own-non-shared-eval-scope.js sloppyFails
language/function-code/each-param-has-own-scope.js sloppyFails
language/function-code/eval-param-env-with-computed-key.js sloppyFails