diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-08-18 14:07:37 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-08-21 10:42:19 +0000 |
commit | 89b41b0e99e075673f4976e5b94919fa1917e203 (patch) | |
tree | e7d8be7d03505f1cb04ad14d55c81d24fc8802f8 /src/qml/compiler/qv4codegen.cpp | |
parent | 713ea747c25d10322510f21c8bce45d35b308b20 (diff) |
still emit global load instructions when 'undefined' is used as lhs
When using undefined/NaN as LHS instructions, we need to emit
them as global loads to get the correct runtime type error.
Amends c8a2e4acb101967c254d7e9d3c4e7d9f25c5eecc
Change-Id: Ic03fb88e43b4f1c7e5dfb99faa78e7d35a3a6f8a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index b4004765ff..f6ac4e7957 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -1389,14 +1389,6 @@ Codegen::Reference Codegen::referenceForName(const QString &name, bool isLhs) } if (!c->parent && !c->forceLookupByName() && _context->compilationMode != EvalCode && c->compilationMode != QmlBinding) { - // these value properties of the global object are immutable, we we can directly convert them - // to their numeric value here - if (name == QStringLiteral("undefined")) - return Reference::fromConst(this, Encode::undefined()); - else if (name == QStringLiteral("Infinity")) - return Reference::fromConst(this, Encode(qInf())); - else if (name == QStringLiteral("Nan")) - return Reference::fromConst(this, Encode(qQNaN())); Reference r = Reference::fromName(this, name); r.global = true; return r; @@ -3075,6 +3067,20 @@ void Codegen::Reference::loadInAccumulator() const return; } case Name: + if (global) { + // these value properties of the global object are immutable, we we can directly convert them + // to their numeric value here + if (name == QStringLiteral("undefined")) { + Reference::fromConst(codegen, Encode::undefined()).loadInAccumulator(); + return; + } else if (name == QStringLiteral("Infinity")) { + Reference::fromConst(codegen, Encode(qInf())).loadInAccumulator(); + return; + } else if (name == QStringLiteral("Nan")) { + Reference::fromConst(codegen, Encode(qQNaN())).loadInAccumulator(); + return; + } + } if (codegen->useFastLookups && global) { Instruction::LoadGlobalLookup load; load.index = codegen->registerGlobalGetterLookup(nameAsIndex()); |