diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-08-31 15:35:20 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-09-02 07:12:22 +0000 |
commit | 020ad3d259f57c379fbcdd4e69c235dd1b0a3774 (patch) | |
tree | 170e5199a8b7327ca7f46eccf557e5803224c488 /src/qml/compiler/qv4codegen.cpp | |
parent | 74c8fe86755af485f8d0a47799d6d50f00070f05 (diff) |
Get rid of the hack for named expressions
Instead simply use the pointer to the FunctionObject
we have in the CallData now.
Change-Id: I6d7ed8af22e89e0217bef427110611b661ac7965
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 872833bfd3..f7c89e75fa 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -1488,7 +1488,7 @@ Codegen::Reference Codegen::referenceForName(const QString &name, bool isLhs) } while (c->parent) { - if (c->forceLookupByName() || (c->isNamedFunctionExpression && c->name == name)) + if (c->forceLookupByName()) goto loadByName; Context::Member m = c->findMember(name); @@ -2068,8 +2068,20 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast, if (it->canEscape) { it->index = _context->locals.size(); _context->locals.append(local); + if (it->type == Context::ThisFunctionName) { + // move the name from the stack to the call context + Instruction::LoadReg load; + load.reg = CallData::Function; + bytecodeGenerator->addInstruction(load); + Instruction::StoreLocal store; + store.index = it->index; + bytecodeGenerator->addInstruction(store); + } } else { - it->index = bytecodeGenerator->newRegister(); + if (it->type == Context::ThisFunctionName) + it->index = CallData::Function; + else + it->index = bytecodeGenerator->newRegister(); } } } else { |