| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 3645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3656 } | 3656 } |
| 3657 return if_node; | 3657 return if_node; |
| 3658 } | 3658 } |
| 3659 | 3659 |
| 3660 | 3660 |
| 3661 CaseNode* Parser::ParseCaseClause(LocalVariable* switch_expr_value, | 3661 CaseNode* Parser::ParseCaseClause(LocalVariable* switch_expr_value, |
| 3662 SourceLabel* case_label) { | 3662 SourceLabel* case_label) { |
| 3663 TRACE_PARSER("ParseCaseStatement"); | 3663 TRACE_PARSER("ParseCaseStatement"); |
| 3664 bool default_seen = false; | 3664 bool default_seen = false; |
| 3665 intptr_t case_pos = token_index_; | 3665 intptr_t case_pos = token_index_; |
| 3666 intptr_t expr_pos = 0; | |
| 3667 SequenceNode* case_expressions = | 3666 SequenceNode* case_expressions = |
| 3668 new SequenceNode(case_pos, current_block_->scope); | 3667 new SequenceNode(case_pos, current_block_->scope); |
| 3669 while (CurrentToken() == Token::kCASE || CurrentToken() == Token::kDEFAULT) { | 3668 while (CurrentToken() == Token::kCASE || CurrentToken() == Token::kDEFAULT) { |
| 3670 if (CurrentToken() == Token::kCASE) { | 3669 if (CurrentToken() == Token::kCASE) { |
| 3671 if (default_seen) { | 3670 if (default_seen) { |
| 3672 ErrorMsg("default clause must be last case"); | 3671 ErrorMsg("default clause must be last case"); |
| 3673 } | 3672 } |
| 3674 ConsumeToken(); // Keyword case. | 3673 ConsumeToken(); // Keyword case. |
| 3675 expr_pos = token_index_; | 3674 intptr_t expr_pos = token_index_; |
| 3676 AstNode* expr = ParseExpr(kAllowConst); | 3675 AstNode* expr = ParseExpr(kAllowConst); |
| 3677 AstNode* switch_expr_load = new LoadLocalNode(case_pos, | 3676 AstNode* switch_expr_load = new LoadLocalNode(case_pos, |
| 3678 *switch_expr_value); | 3677 *switch_expr_value); |
| 3679 AstNode* case_comparison = new ComparisonNode(case_pos, | 3678 AstNode* case_comparison = new ComparisonNode(expr_pos, |
| 3680 Token::kEQ, | 3679 Token::kEQ, |
| 3681 expr, | 3680 expr, |
| 3682 switch_expr_load); | 3681 switch_expr_load); |
| 3683 case_expressions->Add(case_comparison); | 3682 case_expressions->Add(case_comparison); |
| 3684 } else { | 3683 } else { |
| 3685 if (default_seen) { | 3684 if (default_seen) { |
| 3686 ErrorMsg("only one default clause is allowed"); | 3685 ErrorMsg("only one default clause is allowed"); |
| 3687 } | 3686 } |
| 3688 ConsumeToken(); // Keyword default. | 3687 ConsumeToken(); // Keyword default. |
| 3689 expr_pos = token_index_; | |
| 3690 default_seen = true; | 3688 default_seen = true; |
| 3691 // The default case always succeeds. | 3689 // The default case always succeeds. |
| 3692 } | 3690 } |
| 3693 ExpectToken(Token::kCOLON); | 3691 ExpectToken(Token::kCOLON); |
| 3694 } | 3692 } |
| 3695 | 3693 |
| 3696 OpenBlock(); | 3694 OpenBlock(); |
| 3697 bool abrupt_completing_seen = false; | 3695 bool abrupt_completing_seen = false; |
| 3698 while (true) { | 3696 while (true) { |
| 3699 // Check whether the next statement still belongs to the current case | 3697 // Check whether the next statement still belongs to the current case |
| (...skipping 3191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6891 } | 6889 } |
| 6892 | 6890 |
| 6893 | 6891 |
| 6894 void Parser::SkipNestedExpr() { | 6892 void Parser::SkipNestedExpr() { |
| 6895 const bool saved_mode = SetAllowFunctionLiterals(true); | 6893 const bool saved_mode = SetAllowFunctionLiterals(true); |
| 6896 SkipExpr(); | 6894 SkipExpr(); |
| 6897 SetAllowFunctionLiterals(saved_mode); | 6895 SetAllowFunctionLiterals(saved_mode); |
| 6898 } | 6896 } |
| 6899 | 6897 |
| 6900 } // namespace dart | 6898 } // namespace dart |
| OLD | NEW |