aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4codegen.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-06-12 11:32:58 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2017-06-19 12:51:01 +0000
commit021bc5d232a2802da8d667fd0360d4be706debf6 (patch)
tree42036028cb1547a9543a2669895efbf96fe456e1 /src/qml/compiler/qv4codegen.cpp
parent1267923830d08dee8eaf62654c5503a67466d72e (diff)
Create Param's for constant expressions in the codegen
Change-Id: I47c003cb019089e8b679ca31cb5ef50020aba249 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r--src/qml/compiler/qv4codegen.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index f5cce4fdba..74c462d70d 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -1577,6 +1577,33 @@ IR::Expr *Codegen::identifier(const QString &name, int line, int col)
}
+Moth::Param Codegen::paramForNull()
+{
+ return paramForConst(QV4::Encode::null());
+}
+
+Moth::Param Codegen::paramForUndefined()
+{
+ return paramForConst(QV4::Encode::undefined());
+}
+
+Moth::Param Codegen::paramForBool(bool b)
+{
+ return paramForConst(QV4::Encode(b));
+}
+
+Moth::Param Codegen::paramForNumber(double d)
+{
+ // ### specialize for integers
+ return paramForConst(QV4::Encode(d));
+}
+
+Moth::Param Codegen::paramForConst(QV4::ReturnedValue v)
+{
+ int idx = jsUnitGenerator->registerConstant(v);
+ return Moth::Param::createConstant(idx);
+}
+
Moth::Param Codegen::paramForName(const QString &name, bool isLhs)
{
uint scope = 0;