diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-03-25 19:14:23 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-02 14:17:03 +0000 |
commit | 1e974dd01c074ae9f32a5a1210f2fc55dba8dd3c (patch) | |
tree | 08d93f9278cfcab33d7ad4c1309737d45f1270ad /src/qml/compiler/qv4codegen.cpp | |
parent | 3f82c8131fed248c24ed8c8be7449b4732afcd0b (diff) | |
download | qtdeclarative-1e974dd01c074ae9f32a5a1210f2fc55dba8dd3c.tar.gz |
Properly set names of most anonymous functions
In ES6, anonymous functions assigned to a variable/property with
a known name, inherit the name of that variable/property.
Change-Id: I79479b9358b24d610e3e696eb19fe0ec4aee15d1
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, 13 insertions, 3 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 4e6d56adcf..a4d00ce37b 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -397,18 +397,27 @@ void Codegen::initializeAndDestructureBindingElement(AST::PatternElement *e, con if (e->initializer) { if (!baseRef.isValid()) { // assignment - expression(e->initializer).loadInAccumulator(); + Reference expr = expression(e->initializer); + if (hasError) + return; + expr.loadInAccumulator(); varToStore.storeConsumeAccumulator(); } else if (baseRef == varToStore) { baseRef.loadInAccumulator(); BytecodeGenerator::Jump jump = bytecodeGenerator->jumpNotUndefined(); - expression(e->initializer).loadInAccumulator(); + Reference expr = expression(e->initializer); + if (hasError) + return; + expr.loadInAccumulator(); varToStore.storeConsumeAccumulator(); jump.link(); } else { baseRef.loadInAccumulator(); BytecodeGenerator::Jump jump = bytecodeGenerator->jumpNotUndefined(); - expression(e->initializer).loadInAccumulator(); + Reference expr = expression(e->initializer); + if (hasError) + return; + expr.loadInAccumulator(); jump.link(); varToStore.storeConsumeAccumulator(); } @@ -2033,6 +2042,7 @@ bool Codegen::visit(ObjectPattern *ast) if (!computedProperties.isEmpty()) { result = result.storeOnStack(); for (const auto &c : qAsConst(computedProperties)) { + // ### if RHS is an anonymous FunctionExpression, we need to set it's name to the computed name Reference element = Reference::fromSubscript(result, c.first); c.second.rvalue.loadInAccumulator(); element.storeConsumeAccumulator(); |