diff options
author | Erik Verbruggen <erik.verbruggen@me.com> | 2013-07-27 15:12:22 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-13 14:52:27 +0200 |
commit | fb74539d7d14c2444950474ad3f45a80443bfc73 (patch) | |
tree | 9cff8dec7d91213cf3a671a135ca2eee1add3f85 /src/qml/compiler/qv4codegen.cpp | |
parent | 6cd8b6830039aea7f748527882942752f900cefd (diff) |
Change post-increment/-decrement to not use a built-in.
Change-Id: I98af408db1e5d23e73a77d2614071bc998170f5e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 969b35831e..e0c77cfa94 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -1657,13 +1657,16 @@ bool Codegen::visit(PostDecrementExpression *ast) throwReferenceError(ast->base->lastSourceLocation(), "Invalid left-hand side expression in postfix operation"); throwSyntaxErrorOnEvalOrArgumentsInStrictMode(*expr, ast->decrementToken); - if (_expr.accept(nx)) { - move(*expr, binop(V4IR::OpSub, *expr, _block->CONST(V4IR::NumberType, 1))); - } else { - V4IR::ExprList *args = _function->New<V4IR::ExprList>(); - args->init(*expr); - _expr.code = call(_block->NAME(V4IR::Name::builtin_postdecrement, ast->lastSourceLocation().startLine, ast->lastSourceLocation().startColumn), args); - } + const unsigned oldValue = _block->newTemp(); + move(_block->TEMP(oldValue), unop(V4IR::OpUPlus, *expr)); + + const unsigned newValue = _block->newTemp(); + move(_block->TEMP(newValue), binop(V4IR::OpSub, _block->TEMP(oldValue), _block->CONST(V4IR::NumberType, 1))); + move(*expr, _block->TEMP(newValue)); + + if (!_expr.accept(nx)) + _expr.code = _block->TEMP(oldValue); + return false; } @@ -1674,13 +1677,16 @@ bool Codegen::visit(PostIncrementExpression *ast) throwReferenceError(ast->base->lastSourceLocation(), "Invalid left-hand side expression in postfix operation"); throwSyntaxErrorOnEvalOrArgumentsInStrictMode(*expr, ast->incrementToken); - if (_expr.accept(nx)) { - move(*expr, binop(V4IR::OpAdd, unop(V4IR::OpUPlus, *expr), _block->CONST(V4IR::NumberType, 1))); - } else { - V4IR::ExprList *args = _function->New<V4IR::ExprList>(); - args->init(*expr); - _expr.code = call(_block->NAME(V4IR::Name::builtin_postincrement, ast->lastSourceLocation().startLine, ast->lastSourceLocation().startColumn), args); - } + const unsigned oldValue = _block->newTemp(); + move(_block->TEMP(oldValue), unop(V4IR::OpUPlus, *expr)); + + const unsigned newValue = _block->newTemp(); + move(_block->TEMP(newValue), binop(V4IR::OpAdd, _block->TEMP(oldValue), _block->CONST(V4IR::NumberType, 1))); + move(*expr, _block->TEMP(newValue)); + + if (!_expr.accept(nx)) + _expr.code = _block->TEMP(oldValue); + return false; } |