| 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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 parsed_function->function().Owner())), | 354 parsed_function->function().Owner())), |
| 355 library_(Library::Handle(zone(), Class::Handle( | 355 library_(Library::Handle(zone(), Class::Handle( |
| 356 zone(), | 356 zone(), |
| 357 parsed_function->function().origin()).library())), | 357 parsed_function->function().origin()).library())), |
| 358 try_blocks_list_(NULL), | 358 try_blocks_list_(NULL), |
| 359 last_used_try_index_(0), | 359 last_used_try_index_(0), |
| 360 unregister_pending_function_(false), | 360 unregister_pending_function_(false), |
| 361 async_temp_scope_(NULL) { | 361 async_temp_scope_(NULL) { |
| 362 ASSERT(tokens_iterator_.IsValid()); | 362 ASSERT(tokens_iterator_.IsValid()); |
| 363 ASSERT(!current_function().IsNull()); | 363 ASSERT(!current_function().IsNull()); |
| 364 if (FLAG_enable_type_checks) { | 364 EnsureExpressionTemp(); |
| 365 EnsureExpressionTemp(); | |
| 366 } | |
| 367 } | 365 } |
| 368 | 366 |
| 369 | 367 |
| 370 Parser::~Parser() { | 368 Parser::~Parser() { |
| 371 if (unregister_pending_function_) { | 369 if (unregister_pending_function_) { |
| 372 const GrowableObjectArray& pending_functions = | 370 const GrowableObjectArray& pending_functions = |
| 373 GrowableObjectArray::Handle(I->object_store()->pending_functions()); | 371 GrowableObjectArray::Handle(I->object_store()->pending_functions()); |
| 374 ASSERT(pending_functions.Length() > 0); | 372 ASSERT(pending_functions.Length() > 0); |
| 375 ASSERT(pending_functions.At(pending_functions.Length()-1) == | 373 ASSERT(pending_functions.At(pending_functions.Length()-1) == |
| 376 current_function().raw()); | 374 current_function().raw()); |
| (...skipping 7209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7586 // while (await :for-in-iter.moveNext()) | 7584 // while (await :for-in-iter.moveNext()) |
| 7587 ArgumentListNode* no_args = new(Z) ArgumentListNode(stream_pos); | 7585 ArgumentListNode* no_args = new(Z) ArgumentListNode(stream_pos); |
| 7588 AstNode* iterator_moveNext = new(Z) InstanceCallNode( | 7586 AstNode* iterator_moveNext = new(Z) InstanceCallNode( |
| 7589 stream_pos, | 7587 stream_pos, |
| 7590 new(Z) LoadLocalNode(stream_pos, iterator_var), | 7588 new(Z) LoadLocalNode(stream_pos, iterator_var), |
| 7591 Symbols::MoveNext(), | 7589 Symbols::MoveNext(), |
| 7592 no_args); | 7590 no_args); |
| 7593 AstNode* await_moveNext = new (Z) AwaitNode(stream_pos, iterator_moveNext); | 7591 AstNode* await_moveNext = new (Z) AwaitNode(stream_pos, iterator_moveNext); |
| 7594 OpenBlock(); | 7592 OpenBlock(); |
| 7595 AwaitTransformer at(current_block_->statements, | 7593 AwaitTransformer at(current_block_->statements, |
| 7596 parsed_function(), | 7594 *parsed_function(), |
| 7597 async_temp_scope_); | 7595 async_temp_scope_); |
| 7598 AstNode* transformed_await = at.Transform(await_moveNext); | 7596 AstNode* transformed_await = at.Transform(await_moveNext); |
| 7599 SequenceNode* await_preamble = CloseBlock(); | 7597 SequenceNode* await_preamble = CloseBlock(); |
| 7600 | 7598 |
| 7601 // Parse the for loop body. Ideally, we would use ParseNestedStatement() | 7599 // Parse the for loop body. Ideally, we would use ParseNestedStatement() |
| 7602 // here, but that does not work well because we have to insert an implicit | 7600 // here, but that does not work well because we have to insert an implicit |
| 7603 // variable assignment and potentially a variable declaration in the | 7601 // variable assignment and potentially a variable declaration in the |
| 7604 // loop body. | 7602 // loop body. |
| 7605 OpenLoopBlock(); | 7603 OpenLoopBlock(); |
| 7606 SourceLabel* label = | 7604 SourceLabel* label = |
| (...skipping 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9280 TRACE_PARSER("ParseAwaitableExpr"); | 9278 TRACE_PARSER("ParseAwaitableExpr"); |
| 9281 BoolScope saved_seen_await(&parsed_function()->have_seen_await_expr_, false); | 9279 BoolScope saved_seen_await(&parsed_function()->have_seen_await_expr_, false); |
| 9282 AstNode* expr = ParseExpr(require_compiletime_const, consume_cascades); | 9280 AstNode* expr = ParseExpr(require_compiletime_const, consume_cascades); |
| 9283 if (parsed_function()->have_seen_await()) { | 9281 if (parsed_function()->have_seen_await()) { |
| 9284 // Make sure we do not reuse the scope to avoid creating contexts that we | 9282 // Make sure we do not reuse the scope to avoid creating contexts that we |
| 9285 // are unaware of, i.e, creating contexts that have already been covered. | 9283 // are unaware of, i.e, creating contexts that have already been covered. |
| 9286 // See FlowGraphBuilder::VisitSequenceNode() for details on when contexts | 9284 // See FlowGraphBuilder::VisitSequenceNode() for details on when contexts |
| 9287 // are created. | 9285 // are created. |
| 9288 OpenBlock(); | 9286 OpenBlock(); |
| 9289 AwaitTransformer at(current_block_->statements, | 9287 AwaitTransformer at(current_block_->statements, |
| 9290 parsed_function(), | 9288 *parsed_function(), |
| 9291 async_temp_scope_); | 9289 async_temp_scope_); |
| 9292 AstNode* result = at.Transform(expr); | 9290 AstNode* result = at.Transform(expr); |
| 9293 SequenceNode* preamble = CloseBlock(); | 9291 SequenceNode* preamble = CloseBlock(); |
| 9294 if (await_preamble == NULL) { | 9292 if (await_preamble == NULL) { |
| 9295 current_block_->statements->Add(preamble); | 9293 current_block_->statements->Add(preamble); |
| 9296 } else { | 9294 } else { |
| 9297 *await_preamble = preamble; | 9295 *await_preamble = preamble; |
| 9298 } | 9296 } |
| 9299 return result; | 9297 return result; |
| 9300 } | 9298 } |
| (...skipping 2925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12226 void Parser::SkipQualIdent() { | 12224 void Parser::SkipQualIdent() { |
| 12227 ASSERT(IsIdentifier()); | 12225 ASSERT(IsIdentifier()); |
| 12228 ConsumeToken(); | 12226 ConsumeToken(); |
| 12229 if (CurrentToken() == Token::kPERIOD) { | 12227 if (CurrentToken() == Token::kPERIOD) { |
| 12230 ConsumeToken(); // Consume the kPERIOD token. | 12228 ConsumeToken(); // Consume the kPERIOD token. |
| 12231 ExpectIdentifier("identifier expected after '.'"); | 12229 ExpectIdentifier("identifier expected after '.'"); |
| 12232 } | 12230 } |
| 12233 } | 12231 } |
| 12234 | 12232 |
| 12235 } // namespace dart | 12233 } // namespace dart |
| OLD | NEW |