| 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 4411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4422 | 4422 |
| 4423 | 4423 |
| 4424 void Parser::ParseStatementSequence() { | 4424 void Parser::ParseStatementSequence() { |
| 4425 TRACE_PARSER("ParseStatementSequence"); | 4425 TRACE_PARSER("ParseStatementSequence"); |
| 4426 const bool dead_code_allowed = true; | 4426 const bool dead_code_allowed = true; |
| 4427 bool abrupt_completing_seen = false; | 4427 bool abrupt_completing_seen = false; |
| 4428 while (CurrentToken() != Token::kRBRACE) { | 4428 while (CurrentToken() != Token::kRBRACE) { |
| 4429 const intptr_t statement_pos = token_index_; | 4429 const intptr_t statement_pos = token_index_; |
| 4430 AstNode* statement = ParseStatement(); | 4430 AstNode* statement = ParseStatement(); |
| 4431 // Do not add statements with no effect (e.g., LoadLocalNode). | 4431 // Do not add statements with no effect (e.g., LoadLocalNode). |
| 4432 if (statement != NULL && !statement->IsLoadLocalNode()) { | 4432 if ((statement != NULL) && statement->IsLoadLocalNode()) { |
| 4433 // Skip load local. |
| 4434 statement = statement->AsLoadLocalNode()->pseudo(); |
| 4435 } |
| 4436 if (statement != NULL) { |
| 4433 if (!dead_code_allowed && abrupt_completing_seen) { | 4437 if (!dead_code_allowed && abrupt_completing_seen) { |
| 4434 ErrorMsg(statement_pos, "dead code after abrupt completing statement"); | 4438 ErrorMsg(statement_pos, "dead code after abrupt completing statement"); |
| 4435 } | 4439 } |
| 4436 current_block_->statements->Add(statement); | 4440 current_block_->statements->Add(statement); |
| 4437 abrupt_completing_seen |= IsAbruptCompleting(statement); | 4441 abrupt_completing_seen |= IsAbruptCompleting(statement); |
| 4438 } | 4442 } |
| 4439 } | 4443 } |
| 4440 } | 4444 } |
| 4441 | 4445 |
| 4442 | 4446 |
| (...skipping 2177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6620 ErrorMsg("expression is not assignable"); | 6624 ErrorMsg("expression is not assignable"); |
| 6621 } | 6625 } |
| 6622 ConsumeToken(); | 6626 ConsumeToken(); |
| 6623 // Not prefix. | 6627 // Not prefix. |
| 6624 if (postfix_expr->IsLoadStaticFieldNode() || | 6628 if (postfix_expr->IsLoadStaticFieldNode() || |
| 6625 postfix_expr->IsStaticGetterNode()) { | 6629 postfix_expr->IsStaticGetterNode()) { |
| 6626 LocalVariable* temp = CreateTempConstVariable( | 6630 LocalVariable* temp = CreateTempConstVariable( |
| 6627 postfix_expr_pos, postfix_expr->id(), "incoplix"); | 6631 postfix_expr_pos, postfix_expr->id(), "incoplix"); |
| 6628 AstNode* save = | 6632 AstNode* save = |
| 6629 new StoreLocalNode(postfix_expr_pos, *temp, postfix_expr); | 6633 new StoreLocalNode(postfix_expr_pos, *temp, postfix_expr); |
| 6630 current_block_->statements->Add(save); | |
| 6631 LoadLocalNode* load = new LoadLocalNode(postfix_expr_pos, *temp); | |
| 6632 Token::Kind binary_op = | 6634 Token::Kind binary_op = |
| 6633 (incr_op == Token::kINCR) ? Token::kADD : Token::kSUB; | 6635 (incr_op == Token::kINCR) ? Token::kADD : Token::kSUB; |
| 6634 BinaryOpNode* add = new BinaryOpNode( | 6636 BinaryOpNode* add = new BinaryOpNode( |
| 6635 postfix_expr_pos, | 6637 postfix_expr_pos, |
| 6636 binary_op, | 6638 binary_op, |
| 6637 load, | 6639 save, |
| 6638 new LiteralNode(postfix_expr_pos, Smi::ZoneHandle(Smi::New(1)))); | 6640 new LiteralNode(postfix_expr_pos, Smi::ZoneHandle(Smi::New(1)))); |
| 6639 AstNode* store = postfix_expr->MakeAssignmentNode(add); | 6641 AstNode* store = postfix_expr->MakeAssignmentNode(add); |
| 6640 current_block_->statements->Add(store); | 6642 LoadLocalNode* load_res = |
| 6641 LoadLocalNode* load_res = new LoadLocalNode(postfix_expr_pos, *temp); | 6643 new LoadLocalNode(postfix_expr_pos, *temp, store); |
| 6642 return load_res; | 6644 return load_res; |
| 6643 } else { | 6645 } else { |
| 6644 AstNode* incr_op_node = | 6646 AstNode* incr_op_node = |
| 6645 postfix_expr->MakeIncrOpNode(postfix_expr_pos, incr_op, false); | 6647 postfix_expr->MakeIncrOpNode(postfix_expr_pos, incr_op, false); |
| 6646 if (incr_op_node == NULL) { | 6648 if (incr_op_node == NULL) { |
| 6647 Unimplemented("incr op not implemented"); | 6649 Unimplemented("incr op not implemented"); |
| 6648 } | 6650 } |
| 6649 postfix_expr = incr_op_node; | 6651 postfix_expr = incr_op_node; |
| 6650 } | 6652 } |
| 6651 } | 6653 } |
| (...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8424 void Parser::SkipQualIdent() { | 8426 void Parser::SkipQualIdent() { |
| 8425 ASSERT(IsIdentifier()); | 8427 ASSERT(IsIdentifier()); |
| 8426 ConsumeToken(); | 8428 ConsumeToken(); |
| 8427 if (CurrentToken() == Token::kPERIOD) { | 8429 if (CurrentToken() == Token::kPERIOD) { |
| 8428 ConsumeToken(); // Consume the kPERIOD token. | 8430 ConsumeToken(); // Consume the kPERIOD token. |
| 8429 ExpectIdentifier("identifier expected after '.'"); | 8431 ExpectIdentifier("identifier expected after '.'"); |
| 8430 } | 8432 } |
| 8431 } | 8433 } |
| 8432 | 8434 |
| 8433 } // namespace dart | 8435 } // namespace dart |
| OLD | NEW |