diff options
| author | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-06-14 12:32:06 +0200 |
|---|---|---|
| committer | Lars Knoll <lars.knoll@qt.io> | 2017-06-20 09:50:48 +0000 |
| commit | 308224ccafdfdcc5748384de947ce96e83be9f26 (patch) | |
| tree | 60330e569973b522ad812591073af4360f2b1e89 /src/qml/compiler/qv4codegen.cpp | |
| parent | aeb754c5340e6a23daf9e57bd642c93c058c995d (diff) | |
Add inplace binary operators
Change-Id: Ia8d746e511dc03a3335b638d57ec169633fb3da8
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
| -rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index a0dcd5434f..e486a1efc2 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -1410,20 +1410,21 @@ bool Codegen::visit(BinaryExpression *ast) case QSOperator::InplaceXor: { // if (throwSyntaxErrorOnEvalOrArgumentsInStrictMode(left, ast->left->lastSourceLocation())) // return false; -// Result right = expression(ast->right); -// if (hasError) -// return false; -// if (!left->isLValue()) { -// throwSyntaxError(ast->operatorToken, QStringLiteral("left-hand side of inplace operator is not an lvalue")); -// return false; -// } -// TempScope scope(_function); -// const unsigned t = _block->newTemp(); -// move(_block->TEMP(t), *right); -// move(left, _block->TEMP(t), baseOp(ast->op)); -// if (!_expr.accept(nx)) -// _expr.code = left; + if (!left.isLValue()) { + throwSyntaxError(ast->operatorToken, QStringLiteral("left-hand side of inplace operator is not an lvalue")); + return false; + } + + Reference right = expression(ast->right); + + if (hasError) + return false; + + _expr.result = Reference::fromTemp(this, _block->newTemp()); + binopHelper(baseOp(ast->op), left.asRValue(), right.asRValue(), _expr.result.base); + left.store(_expr.result); + break; } |
