| 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 "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 9 #include "vm/bootstrap.h" | 9 #include "vm/bootstrap.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 6978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6989 statement = ParseJump(label_name); | 6989 statement = ParseJump(label_name); |
| 6990 AddNodeForFinallyInlining(statement); | 6990 AddNodeForFinallyInlining(statement); |
| 6991 ExpectSemicolon(); | 6991 ExpectSemicolon(); |
| 6992 } else if (CurrentToken() == Token::kCONTINUE) { | 6992 } else if (CurrentToken() == Token::kCONTINUE) { |
| 6993 statement = ParseJump(label_name); | 6993 statement = ParseJump(label_name); |
| 6994 AddNodeForFinallyInlining(statement); | 6994 AddNodeForFinallyInlining(statement); |
| 6995 ExpectSemicolon(); | 6995 ExpectSemicolon(); |
| 6996 } else if (CurrentToken() == Token::kSEMICOLON) { | 6996 } else if (CurrentToken() == Token::kSEMICOLON) { |
| 6997 // Empty statement, nothing to do. | 6997 // Empty statement, nothing to do. |
| 6998 ConsumeToken(); | 6998 ConsumeToken(); |
| 6999 } else if ((CurrentToken() == Token::kRETHROW) || | 6999 } else if (CurrentToken() == Token::kRETHROW) { |
| 7000 ((CurrentToken() == Token::kTHROW) && | 7000 // Rethrow of current exception. |
| 7001 (LookaheadToken(1) == Token::kSEMICOLON))) { | |
| 7002 // Rethrow of current exception. Throwing of an exception object | |
| 7003 // is an expression and is handled in ParseExpr(). | |
| 7004 // TODO(hausner): remove support for 'throw;'. | |
| 7005 ConsumeToken(); | 7001 ConsumeToken(); |
| 7006 ExpectSemicolon(); | 7002 ExpectSemicolon(); |
| 7007 // Check if it is ok to do a rethrow. | 7003 // Check if it is ok to do a rethrow. |
| 7008 SourceLabel* label = current_block_->scope->LookupInnermostCatchLabel(); | 7004 SourceLabel* label = current_block_->scope->LookupInnermostCatchLabel(); |
| 7009 if (label == NULL || | 7005 if (label == NULL || |
| 7010 label->FunctionLevel() != current_block_->scope->function_level()) { | 7006 label->FunctionLevel() != current_block_->scope->function_level()) { |
| 7011 ErrorMsg(statement_pos, "rethrow of an exception is not valid here"); | 7007 ErrorMsg(statement_pos, "rethrow of an exception is not valid here"); |
| 7012 } | 7008 } |
| 7013 ASSERT(label->owner() != NULL); | 7009 ASSERT(label->owner() != NULL); |
| 7014 LocalScope* scope = label->owner()->parent(); | 7010 LocalScope* scope = label->owner()->parent(); |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7740 | 7736 |
| 7741 AstNode* Parser::ParseExpr(bool require_compiletime_const, | 7737 AstNode* Parser::ParseExpr(bool require_compiletime_const, |
| 7742 bool consume_cascades) { | 7738 bool consume_cascades) { |
| 7743 TRACE_PARSER("ParseExpr"); | 7739 TRACE_PARSER("ParseExpr"); |
| 7744 String* expr_ident = | 7740 String* expr_ident = |
| 7745 Token::IsIdentifier(CurrentToken()) ? CurrentLiteral() : NULL; | 7741 Token::IsIdentifier(CurrentToken()) ? CurrentLiteral() : NULL; |
| 7746 const intptr_t expr_pos = TokenPos(); | 7742 const intptr_t expr_pos = TokenPos(); |
| 7747 | 7743 |
| 7748 if (CurrentToken() == Token::kTHROW) { | 7744 if (CurrentToken() == Token::kTHROW) { |
| 7749 ConsumeToken(); | 7745 ConsumeToken(); |
| 7750 ASSERT(CurrentToken() != Token::kSEMICOLON); | 7746 if (CurrentToken() == Token::kSEMICOLON) { |
| 7747 ErrorMsg("expression expected after throw"); |
| 7748 } |
| 7751 AstNode* expr = ParseExpr(require_compiletime_const, consume_cascades); | 7749 AstNode* expr = ParseExpr(require_compiletime_const, consume_cascades); |
| 7752 return new ThrowNode(expr_pos, expr, NULL); | 7750 return new ThrowNode(expr_pos, expr, NULL); |
| 7753 } | 7751 } |
| 7754 AstNode* expr = ParseConditionalExpr(); | 7752 AstNode* expr = ParseConditionalExpr(); |
| 7755 if (!Token::IsAssignmentOperator(CurrentToken())) { | 7753 if (!Token::IsAssignmentOperator(CurrentToken())) { |
| 7756 if ((CurrentToken() == Token::kCASCADE) && consume_cascades) { | 7754 if ((CurrentToken() == Token::kCASCADE) && consume_cascades) { |
| 7757 return ParseCascades(expr); | 7755 return ParseCascades(expr); |
| 7758 } | 7756 } |
| 7759 if (require_compiletime_const) { | 7757 if (require_compiletime_const) { |
| 7760 expr = FoldConstExpr(expr_pos, expr); | 7758 expr = FoldConstExpr(expr_pos, expr); |
| (...skipping 2787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10548 void Parser::SkipQualIdent() { | 10546 void Parser::SkipQualIdent() { |
| 10549 ASSERT(IsIdentifier()); | 10547 ASSERT(IsIdentifier()); |
| 10550 ConsumeToken(); | 10548 ConsumeToken(); |
| 10551 if (CurrentToken() == Token::kPERIOD) { | 10549 if (CurrentToken() == Token::kPERIOD) { |
| 10552 ConsumeToken(); // Consume the kPERIOD token. | 10550 ConsumeToken(); // Consume the kPERIOD token. |
| 10553 ExpectIdentifier("identifier expected after '.'"); | 10551 ExpectIdentifier("identifier expected after '.'"); |
| 10554 } | 10552 } |
| 10555 } | 10553 } |
| 10556 | 10554 |
| 10557 } // namespace dart | 10555 } // namespace dart |
| OLD | NEW |