aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4codegen.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-06-13 16:28:23 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2017-06-19 14:25:09 +0000
commitf7feda182c4763d8c17375f5e16f43be5ba10b4d (patch)
treee7db114b121e337b7e1e0b43d209c0940d1db671 /src/qml/compiler/qv4codegen.cpp
parent56dca24f10f68b547cd3b409914c351c02a0e345 (diff)
Implement support for string and regexp literals
Change-Id: I4475bb9cbfb8ac545c5bd7fcd0f93d0695b122c7 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r--src/qml/compiler/qv4codegen.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 8667231cec..5cf638f7c8 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -2046,7 +2046,12 @@ bool Codegen::visit(RegExpLiteral *ast)
if (hasError)
return false;
- _expr.code = _block->REGEXP(_function->newString(ast->pattern.toString()), ast->flags);
+ _expr.result = Reference::fromTemp(this, bytecodeGenerator->newTemp());
+
+ Moth::Instruction::LoadRegExp instr;
+ instr.result = _expr.result.asLValue();
+ instr.regExpId = jsUnitGenerator->registerRegExp(ast);
+ bytecodeGenerator->addInstruction(instr);
return false;
}
@@ -2055,7 +2060,12 @@ bool Codegen::visit(StringLiteral *ast)
if (hasError)
return false;
- _expr.code = _block->STRING(_function->newString(ast->value.toString()));
+ _expr.result = Reference::fromTemp(this, bytecodeGenerator->newTemp());
+
+ Moth::Instruction::LoadRuntimeString instr;
+ instr.result = _expr.result.asLValue();
+ instr.stringId = jsUnitGenerator->registerString(ast->value.toString());
+ bytecodeGenerator->addInstruction(instr);
return false;
}