diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-05-21 15:10:45 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-05-21 18:03:47 +0200 |
commit | 3e716029ae61bf4c7bb33643ac331156e70e34f1 (patch) | |
tree | 2a2692dbaf49d87518c4b0da30078e177e8dd5c3 /src/qml/compiler/qv4codegen_p.h | |
parent | 9e919489c4e6b0c110281fda139fff84c1c71995 (diff) | |
download | qtdeclarative-3e716029ae61bf4c7bb33643ac331156e70e34f1.tar.gz |
Don't add local for anonymous function's "name"
Instead, populate their "name" property directly from the surrounding
object pattern if applicable, without adding locals. This fixes some
ecmascript tests where functions were assigned to the key "eval" in an
object. The JS engine then rejected that because you shouldn't use eval
in strict mode. That should be close enough to test for regressions.
Fixes: QTBUG-75880
Change-Id: Iacc45a3f7b0eb90cddc6ecf6d2bada616d2cf355
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen_p.h')
-rw-r--r-- | src/qml/compiler/qv4codegen_p.h | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h index ad86483132..958dd16816 100644 --- a/src/qml/compiler/qv4codegen_p.h +++ b/src/qml/compiler/qv4codegen_p.h @@ -196,8 +196,9 @@ public: codegen = cg; } - Reference() : + Reference(const QString &name = QString()) : constant(0), + name(name), isArgOrEval(false), isReadonly(false), isReferenceToConst(false), @@ -414,6 +415,11 @@ protected: bool _trueBlockFollowsCondition = false; public: + explicit Result(const QString &name) + : _result(name) + , _requested(ex) + {} + explicit Result(const Reference &lrvalue) : _result(lrvalue) , _requested(ex) @@ -472,6 +478,10 @@ protected: void setResult(Reference &&result) { _result = std::move(result); } + + void clearResultName() { + _result.name.clear(); + } }; void enterContext(AST::Node *node); @@ -519,12 +529,12 @@ protected: const BytecodeGenerator::Label *iffalse, bool trueBlockFollowsCondition); - inline Reference expression(AST::ExpressionNode *ast) + inline Reference expression(AST::ExpressionNode *ast, const QString &name = QString()) { if (!ast || hasError) return Reference(); - pushExpr(); + pushExpr(name); ast->accept(this); return popResult(); } @@ -712,6 +722,7 @@ protected: inline void setExprResult(const Reference &result) { m_expressions.back().setResult(result); } inline void setExprResult(Reference &&result) { m_expressions.back().setResult(std::move(result)); } inline Reference exprResult() const { return m_expressions.back().result(); } + inline void clearExprResultName() { m_expressions.back().clearResultName(); } inline bool exprAccept(Format f) { return m_expressions.back().accept(f); } @@ -719,7 +730,7 @@ protected: inline void pushExpr(Result &&expr) { m_expressions.push_back(std::move(expr)); } inline void pushExpr(const Result &expr) { m_expressions.push_back(expr); } - inline void pushExpr() { m_expressions.emplace_back(); } + inline void pushExpr(const QString &name = QString()) { m_expressions.emplace_back(name); } inline Result popExpr() { |