| 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 "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/ast_transformer.h" | 9 #include "vm/ast_transformer.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 9076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9087 Symbols::SavedStackTraceVar(), | 9087 Symbols::SavedStackTraceVar(), |
| 9088 dynamic_type); | 9088 dynamic_type); |
| 9089 try_scope->AddVariable(*saved_stack_trace_var); | 9089 try_scope->AddVariable(*saved_stack_trace_var); |
| 9090 } | 9090 } |
| 9091 } | 9091 } |
| 9092 } | 9092 } |
| 9093 | 9093 |
| 9094 | 9094 |
| 9095 AstNode* Parser::ParseTryStatement(String* label_name) { | 9095 AstNode* Parser::ParseTryStatement(String* label_name) { |
| 9096 TRACE_PARSER("ParseTryStatement"); | 9096 TRACE_PARSER("ParseTryStatement"); |
| 9097 |
| 9098 const intptr_t try_pos = TokenPos(); |
| 9099 SourceLabel* try_label = NULL; |
| 9100 if (label_name != NULL) { |
| 9101 try_label = SourceLabel::New(try_pos, label_name, SourceLabel::kStatement); |
| 9102 OpenBlock(); |
| 9103 current_block_->scope->AddLabel(try_label); |
| 9104 } |
| 9105 |
| 9097 const bool is_async = innermost_function().IsAsyncClosure() || | 9106 const bool is_async = innermost_function().IsAsyncClosure() || |
| 9098 innermost_function().IsAsyncFunction() || | 9107 innermost_function().IsAsyncFunction() || |
| 9099 innermost_function().IsSyncGenClosure() || | 9108 innermost_function().IsSyncGenClosure() || |
| 9100 innermost_function().IsSyncGenerator() || | 9109 innermost_function().IsSyncGenerator() || |
| 9101 innermost_function().IsAsyncGenClosure() || | 9110 innermost_function().IsAsyncGenClosure() || |
| 9102 innermost_function().IsAsyncGenerator(); | 9111 innermost_function().IsAsyncGenerator(); |
| 9103 LocalVariable* context_var = NULL; | 9112 LocalVariable* context_var = NULL; |
| 9104 LocalVariable* exception_var = NULL; | 9113 LocalVariable* exception_var = NULL; |
| 9105 LocalVariable* stack_trace_var = NULL; | 9114 LocalVariable* stack_trace_var = NULL; |
| 9106 LocalVariable* saved_exception_var = NULL; | 9115 LocalVariable* saved_exception_var = NULL; |
| 9107 LocalVariable* saved_stack_trace_var = NULL; | 9116 LocalVariable* saved_stack_trace_var = NULL; |
| 9108 SetupExceptionVariables(current_block_->scope, | 9117 SetupExceptionVariables(current_block_->scope, |
| 9109 is_async, | 9118 is_async, |
| 9110 &context_var, | 9119 &context_var, |
| 9111 &exception_var, | 9120 &exception_var, |
| 9112 &stack_trace_var, | 9121 &stack_trace_var, |
| 9113 &saved_exception_var, | 9122 &saved_exception_var, |
| 9114 &saved_stack_trace_var); | 9123 &saved_stack_trace_var); |
| 9115 | 9124 |
| 9116 const intptr_t try_pos = TokenPos(); | |
| 9117 ConsumeToken(); // Consume the 'try'. | 9125 ConsumeToken(); // Consume the 'try'. |
| 9118 | 9126 |
| 9119 SourceLabel* try_label = NULL; | |
| 9120 if (label_name != NULL) { | |
| 9121 try_label = SourceLabel::New(try_pos, label_name, SourceLabel::kStatement); | |
| 9122 OpenBlock(); | |
| 9123 current_block_->scope->AddLabel(try_label); | |
| 9124 } | |
| 9125 | |
| 9126 // Now parse the 'try' block. | 9127 // Now parse the 'try' block. |
| 9127 OpenBlock(); | 9128 OpenBlock(); |
| 9128 PushTryBlock(current_block_); | 9129 PushTryBlock(current_block_); |
| 9129 ExpectToken(Token::kLBRACE); | 9130 ExpectToken(Token::kLBRACE); |
| 9130 | 9131 |
| 9131 if (is_async) { | 9132 if (is_async) { |
| 9132 SetupSavedTryContext(context_var); | 9133 SetupSavedTryContext(context_var); |
| 9133 } | 9134 } |
| 9134 | 9135 |
| 9135 ParseStatementSequence(); | 9136 ParseStatementSequence(); |
| (...skipping 4063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13199 void Parser::SkipQualIdent() { | 13200 void Parser::SkipQualIdent() { |
| 13200 ASSERT(IsIdentifier()); | 13201 ASSERT(IsIdentifier()); |
| 13201 ConsumeToken(); | 13202 ConsumeToken(); |
| 13202 if (CurrentToken() == Token::kPERIOD) { | 13203 if (CurrentToken() == Token::kPERIOD) { |
| 13203 ConsumeToken(); // Consume the kPERIOD token. | 13204 ConsumeToken(); // Consume the kPERIOD token. |
| 13204 ExpectIdentifier("identifier expected after '.'"); | 13205 ExpectIdentifier("identifier expected after '.'"); |
| 13205 } | 13206 } |
| 13206 } | 13207 } |
| 13207 | 13208 |
| 13208 } // namespace dart | 13209 } // namespace dart |
| OLD | NEW |