diff options
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 62dbcdaa7d..d61f79f0fc 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -2300,7 +2300,7 @@ Codegen::Reference Codegen::referenceForName(const QString &name, bool isLhs, co return fallback; Reference r = Reference::fromName(this, name); - r.global = (resolved.type == Context::ResolvedName::Global); + r.global = useFastLookups && (resolved.type == Context::ResolvedName::Global); return r; } @@ -2717,6 +2717,12 @@ bool Codegen::visit(ThisExpression *) if (hasError) return false; + if (_context->isArrowFunction) { + Reference r = referenceForName(QStringLiteral("this"), false); + r.isReadonly = true; + _expr.setResult(r); + return false; + } _expr.setResult(Reference::fromThis(this)); return false; } @@ -3996,7 +4002,7 @@ Codegen::Reference Codegen::Reference::baseObject() const if (rval.isAccumulator()) return Reference::fromAccumulator(codegen); if (rval.isStackSlot()) - Reference::fromStackSlot(codegen, rval.stackSlot()); + return Reference::fromStackSlot(codegen, rval.stackSlot()); if (rval.isConst()) return Reference::fromConst(codegen, rval.constantValue()); Q_UNREACHABLE(); @@ -4279,7 +4285,7 @@ QT_WARNING_POP return; } } - if (!disable_lookups && codegen->useFastLookups && global) { + if (!disable_lookups && global) { Instruction::LoadGlobalLookup load; load.index = codegen->registerGlobalGetterLookup(nameAsIndex()); codegen->bytecodeGenerator->addInstruction(load); |