| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/parser.h" | 5 #include "vm/parser.h" |
| 6 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
| (...skipping 6135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6146 } else { | 6146 } else { |
| 6147 expr = UnaryOpNode::UnaryOpOrLiteral(op_pos, unary_op, expr); | 6147 expr = UnaryOpNode::UnaryOpOrLiteral(op_pos, unary_op, expr); |
| 6148 } | 6148 } |
| 6149 } else if (IsIncrementOperator(CurrentToken())) { | 6149 } else if (IsIncrementOperator(CurrentToken())) { |
| 6150 Token::Kind incr_op = CurrentToken(); | 6150 Token::Kind incr_op = CurrentToken(); |
| 6151 ConsumeToken(); | 6151 ConsumeToken(); |
| 6152 expr = ParseUnaryExpr(); | 6152 expr = ParseUnaryExpr(); |
| 6153 if (!IsAssignableExpr(expr)) { | 6153 if (!IsAssignableExpr(expr)) { |
| 6154 ErrorMsg("expression is not assignable"); | 6154 ErrorMsg("expression is not assignable"); |
| 6155 } | 6155 } |
| 6156 // TODO(srdjan): Implement transformation for all. | 6156 // Is prefix. |
| 6157 if (expr->IsLoadStaticFieldNode() || expr->IsStaticGetterNode()) { | 6157 AstNode* left_expr = PrepareCompoundAssignmentNodes(&expr); |
| 6158 Token::Kind binary_op = | 6158 Token::Kind binary_op = |
| 6159 (incr_op == Token::kINCR) ? Token::kADD : Token::kSUB; | 6159 (incr_op == Token::kINCR) ? Token::kADD : Token::kSUB; |
| 6160 BinaryOpNode* add = new BinaryOpNode( | 6160 BinaryOpNode* add = new BinaryOpNode( |
| 6161 op_pos, | 6161 op_pos, |
| 6162 binary_op, | 6162 binary_op, |
| 6163 expr, | 6163 expr, |
| 6164 new LiteralNode(op_pos, Smi::ZoneHandle(Smi::New(1)))); | 6164 new LiteralNode(op_pos, Smi::ZoneHandle(Smi::New(1)))); |
| 6165 AstNode* store = expr->MakeAssignmentNode(add); | 6165 AstNode* store = left_expr->MakeAssignmentNode(add); |
| 6166 expr = store; | 6166 expr = store; |
| 6167 } else { | |
| 6168 // is_prefix. | |
| 6169 AstNode* incr_op_node = expr->MakeIncrOpNode(op_pos, incr_op, true); | |
| 6170 if (incr_op_node == NULL) { | |
| 6171 Unimplemented("incr operation not implemented"); | |
| 6172 } | |
| 6173 expr = incr_op_node; | |
| 6174 } | |
| 6175 } else { | 6167 } else { |
| 6176 expr = ParsePostfixExpr(); | 6168 expr = ParsePostfixExpr(); |
| 6177 } | 6169 } |
| 6178 return expr; | 6170 return expr; |
| 6179 } | 6171 } |
| 6180 | 6172 |
| 6181 | 6173 |
| 6182 ArgumentListNode* Parser::ParseActualParameters( | 6174 ArgumentListNode* Parser::ParseActualParameters( |
| 6183 ArgumentListNode* implicit_arguments, | 6175 ArgumentListNode* implicit_arguments, |
| 6184 bool require_const) { | 6176 bool require_const) { |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6640 postfix_expr = selector; | 6632 postfix_expr = selector; |
| 6641 } | 6633 } |
| 6642 if (IsIncrementOperator(CurrentToken())) { | 6634 if (IsIncrementOperator(CurrentToken())) { |
| 6643 TRACE_PARSER("IncrementOperator"); | 6635 TRACE_PARSER("IncrementOperator"); |
| 6644 Token::Kind incr_op = CurrentToken(); | 6636 Token::Kind incr_op = CurrentToken(); |
| 6645 if (!IsAssignableExpr(postfix_expr)) { | 6637 if (!IsAssignableExpr(postfix_expr)) { |
| 6646 ErrorMsg("expression is not assignable"); | 6638 ErrorMsg("expression is not assignable"); |
| 6647 } | 6639 } |
| 6648 ConsumeToken(); | 6640 ConsumeToken(); |
| 6649 // Not prefix. | 6641 // Not prefix. |
| 6650 if (postfix_expr->IsLoadStaticFieldNode() || | 6642 AstNode* left_expr = PrepareCompoundAssignmentNodes(&postfix_expr); |
| 6651 postfix_expr->IsStaticGetterNode() || | 6643 const LocalVariable& temp = GetIncrementTempLocal(); |
| 6652 postfix_expr->IsLoadLocalNode()) { | 6644 AstNode* save = |
| 6653 const LocalVariable& temp = GetIncrementTempLocal(); | 6645 new StoreLocalNode(postfix_expr_pos, temp, postfix_expr); |
| 6654 AstNode* save = | 6646 Token::Kind binary_op = |
| 6655 new StoreLocalNode(postfix_expr_pos, temp, postfix_expr); | 6647 (incr_op == Token::kINCR) ? Token::kADD : Token::kSUB; |
| 6656 Token::Kind binary_op = | 6648 BinaryOpNode* add = new BinaryOpNode( |
| 6657 (incr_op == Token::kINCR) ? Token::kADD : Token::kSUB; | 6649 postfix_expr_pos, |
| 6658 BinaryOpNode* add = new BinaryOpNode( | 6650 binary_op, |
| 6659 postfix_expr_pos, | 6651 save, |
| 6660 binary_op, | 6652 new LiteralNode(postfix_expr_pos, Smi::ZoneHandle(Smi::New(1)))); |
| 6661 save, | 6653 AstNode* store = left_expr->MakeAssignmentNode(add); |
| 6662 new LiteralNode(postfix_expr_pos, Smi::ZoneHandle(Smi::New(1)))); | 6654 LoadLocalNode* load_res = |
| 6663 AstNode* store = postfix_expr->MakeAssignmentNode(add); | 6655 new LoadLocalNode(postfix_expr_pos, temp, store); |
| 6664 LoadLocalNode* load_res = | 6656 return load_res; |
| 6665 new LoadLocalNode(postfix_expr_pos, temp, store); | |
| 6666 return load_res; | |
| 6667 } else { | |
| 6668 AstNode* incr_op_node = | |
| 6669 postfix_expr->MakeIncrOpNode(postfix_expr_pos, incr_op, false); | |
| 6670 if (incr_op_node == NULL) { | |
| 6671 Unimplemented("incr op not implemented"); | |
| 6672 } | |
| 6673 postfix_expr = incr_op_node; | |
| 6674 } | |
| 6675 } | 6657 } |
| 6676 return postfix_expr; | 6658 return postfix_expr; |
| 6677 } | 6659 } |
| 6678 | 6660 |
| 6679 | 6661 |
| 6680 // Resolve the given type and its type arguments from the given scope class | 6662 // Resolve the given type and its type arguments from the given scope class |
| 6681 // according to the given type finalization mode. | 6663 // according to the given type finalization mode. |
| 6682 // If the given scope class is null, use the current library, but do not try to | 6664 // If the given scope class is null, use the current library, but do not try to |
| 6683 // resolve type parameters. | 6665 // resolve type parameters. |
| 6684 // Not all involved type classes may get resolved yet, but at least the type | 6666 // Not all involved type classes may get resolved yet, but at least the type |
| (...skipping 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8448 void Parser::SkipQualIdent() { | 8430 void Parser::SkipQualIdent() { |
| 8449 ASSERT(IsIdentifier()); | 8431 ASSERT(IsIdentifier()); |
| 8450 ConsumeToken(); | 8432 ConsumeToken(); |
| 8451 if (CurrentToken() == Token::kPERIOD) { | 8433 if (CurrentToken() == Token::kPERIOD) { |
| 8452 ConsumeToken(); // Consume the kPERIOD token. | 8434 ConsumeToken(); // Consume the kPERIOD token. |
| 8453 ExpectIdentifier("identifier expected after '.'"); | 8435 ExpectIdentifier("identifier expected after '.'"); |
| 8454 } | 8436 } |
| 8455 } | 8437 } |
| 8456 | 8438 |
| 8457 } // namespace dart | 8439 } // namespace dart |
| OLD | NEW |