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 #include "vm/flags.h" | 6 #include "vm/flags.h" |
7 | 7 |
8 #ifndef DART_PRECOMPILED_RUNTIME | 8 #ifndef DART_PRECOMPILED_RUNTIME |
9 | 9 |
10 #include "lib/invocation_mirror.h" | 10 #include "lib/invocation_mirror.h" |
(...skipping 6591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6602 LocalVariable* saved_stack_trace_var = | 6602 LocalVariable* saved_stack_trace_var = |
6603 try_scope->LocalLookupVariable(Symbols::SavedStackTraceVar()); | 6603 try_scope->LocalLookupVariable(Symbols::SavedStackTraceVar()); |
6604 SaveExceptionAndStackTrace(current_block_->statements, exception_var, | 6604 SaveExceptionAndStackTrace(current_block_->statements, exception_var, |
6605 stack_trace_var, saved_exception_var, | 6605 stack_trace_var, saved_exception_var, |
6606 saved_stack_trace_var); | 6606 saved_stack_trace_var); |
6607 | 6607 |
6608 // Catch block: add the error to the stream. | 6608 // Catch block: add the error to the stream. |
6609 // :controller.AddError(:exception, :stack_trace); | 6609 // :controller.AddError(:exception, :stack_trace); |
6610 // return; // The finally block will close the stream. | 6610 // return; // The finally block will close the stream. |
6611 LocalVariable* controller = | 6611 LocalVariable* controller = |
6612 current_block_->scope->LookupVariable(Symbols::Controller(), false); | 6612 current_block_->scope->LookupVariable(Symbols::ColonController(), false); |
6613 ASSERT(controller != NULL); | 6613 ASSERT(controller != NULL); |
6614 ArgumentListNode* args = new (Z) ArgumentListNode(TokenPosition::kNoSource); | 6614 ArgumentListNode* args = new (Z) ArgumentListNode(TokenPosition::kNoSource); |
6615 args->Add(new (Z) | 6615 args->Add(new (Z) |
6616 LoadLocalNode(TokenPosition::kNoSource, exception_param.var)); | 6616 LoadLocalNode(TokenPosition::kNoSource, exception_param.var)); |
6617 args->Add(new (Z) | 6617 args->Add(new (Z) |
6618 LoadLocalNode(TokenPosition::kNoSource, stack_trace_param.var)); | 6618 LoadLocalNode(TokenPosition::kNoSource, stack_trace_param.var)); |
6619 current_block_->statements->Add(new (Z) InstanceCallNode( | 6619 current_block_->statements->Add(new (Z) InstanceCallNode( |
6620 try_end_pos, new (Z) LoadLocalNode(TokenPosition::kNoSource, controller), | 6620 try_end_pos, new (Z) LoadLocalNode(TokenPosition::kNoSource, controller), |
6621 Symbols::AddError(), args)); | 6621 Symbols::AddError(), args)); |
6622 ReturnNode* return_node = new (Z) ReturnNode(TokenPosition::kNoSource); | 6622 ReturnNode* return_node = new (Z) ReturnNode(TokenPosition::kNoSource); |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7086 // are added. | 7086 // are added. |
7087 // var :async_op; | 7087 // var :async_op; |
7088 // var :async_then_callback; | 7088 // var :async_then_callback; |
7089 // var :async_catch_error_callback; | 7089 // var :async_catch_error_callback; |
7090 // var :async_stack_trace; | 7090 // var :async_stack_trace; |
7091 // var :controller_stream; | 7091 // var :controller_stream; |
7092 // These variables are used to store the async generator closure containing | 7092 // These variables are used to store the async generator closure containing |
7093 // the body of the async* function. They are used by the await operator. | 7093 // the body of the async* function. They are used by the await operator. |
7094 LocalVariable* controller_var = | 7094 LocalVariable* controller_var = |
7095 new (Z) LocalVariable(TokenPosition::kNoSource, TokenPosition::kNoSource, | 7095 new (Z) LocalVariable(TokenPosition::kNoSource, TokenPosition::kNoSource, |
7096 Symbols::Controller(), Object::dynamic_type()); | 7096 Symbols::ColonController(), Object::dynamic_type()); |
7097 current_block_->scope->AddVariable(controller_var); | 7097 current_block_->scope->AddVariable(controller_var); |
7098 LocalVariable* async_op_var = | 7098 LocalVariable* async_op_var = |
7099 new (Z) LocalVariable(TokenPosition::kNoSource, TokenPosition::kNoSource, | 7099 new (Z) LocalVariable(TokenPosition::kNoSource, TokenPosition::kNoSource, |
7100 Symbols::AsyncOperation(), Object::dynamic_type()); | 7100 Symbols::AsyncOperation(), Object::dynamic_type()); |
7101 current_block_->scope->AddVariable(async_op_var); | 7101 current_block_->scope->AddVariable(async_op_var); |
7102 LocalVariable* async_then_callback_var = new (Z) | 7102 LocalVariable* async_then_callback_var = new (Z) |
7103 LocalVariable(TokenPosition::kNoSource, TokenPosition::kNoSource, | 7103 LocalVariable(TokenPosition::kNoSource, TokenPosition::kNoSource, |
7104 Symbols::AsyncThenCallback(), Object::dynamic_type()); | 7104 Symbols::AsyncThenCallback(), Object::dynamic_type()); |
7105 current_block_->scope->AddVariable(async_then_callback_var); | 7105 current_block_->scope->AddVariable(async_then_callback_var); |
7106 LocalVariable* async_catch_error_callback_var = new (Z) | 7106 LocalVariable* async_catch_error_callback_var = new (Z) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7195 | 7195 |
7196 // Explicitly reference variables of the async genenerator function from the | 7196 // Explicitly reference variables of the async genenerator function from the |
7197 // closure body in order to mark them as captured. | 7197 // closure body in order to mark them as captured. |
7198 LocalVariable* existing_var = | 7198 LocalVariable* existing_var = |
7199 closure_body->scope()->LookupVariable(Symbols::AwaitJumpVar(), false); | 7199 closure_body->scope()->LookupVariable(Symbols::AwaitJumpVar(), false); |
7200 ASSERT((existing_var != NULL) && existing_var->is_captured()); | 7200 ASSERT((existing_var != NULL) && existing_var->is_captured()); |
7201 existing_var = | 7201 existing_var = |
7202 closure_body->scope()->LookupVariable(Symbols::AwaitContextVar(), false); | 7202 closure_body->scope()->LookupVariable(Symbols::AwaitContextVar(), false); |
7203 ASSERT((existing_var != NULL) && existing_var->is_captured()); | 7203 ASSERT((existing_var != NULL) && existing_var->is_captured()); |
7204 existing_var = | 7204 existing_var = |
7205 closure_body->scope()->LookupVariable(Symbols::Controller(), false); | 7205 closure_body->scope()->LookupVariable(Symbols::ColonController(), false); |
7206 ASSERT((existing_var != NULL) && existing_var->is_captured()); | 7206 ASSERT((existing_var != NULL) && existing_var->is_captured()); |
7207 existing_var = | 7207 existing_var = |
7208 closure_body->scope()->LookupVariable(Symbols::AsyncOperation(), false); | 7208 closure_body->scope()->LookupVariable(Symbols::AsyncOperation(), false); |
7209 ASSERT((existing_var != NULL) && existing_var->is_captured()); | 7209 ASSERT((existing_var != NULL) && existing_var->is_captured()); |
7210 existing_var = closure_body->scope()->LookupVariable( | 7210 existing_var = closure_body->scope()->LookupVariable( |
7211 Symbols::AsyncThenCallback(), false); | 7211 Symbols::AsyncThenCallback(), false); |
7212 ASSERT((existing_var != NULL) && existing_var->is_captured()); | 7212 ASSERT((existing_var != NULL) && existing_var->is_captured()); |
7213 existing_var = closure_body->scope()->LookupVariable( | 7213 existing_var = closure_body->scope()->LookupVariable( |
7214 Symbols::AsyncCatchErrorCallback(), false); | 7214 Symbols::AsyncCatchErrorCallback(), false); |
7215 ASSERT((existing_var != NULL) && existing_var->is_captured()); | 7215 ASSERT((existing_var != NULL) && existing_var->is_captured()); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7315 | 7315 |
7316 // :controller = new _AsyncStarStreamController(body_closure); | 7316 // :controller = new _AsyncStarStreamController(body_closure); |
7317 ArgumentListNode* arguments = | 7317 ArgumentListNode* arguments = |
7318 new (Z) ArgumentListNode(TokenPosition::kNoSource); | 7318 new (Z) ArgumentListNode(TokenPosition::kNoSource); |
7319 arguments->Add(new (Z) LoadLocalNode(TokenPosition::kNoSource, async_op_var)); | 7319 arguments->Add(new (Z) LoadLocalNode(TokenPosition::kNoSource, async_op_var)); |
7320 ConstructorCallNode* controller_constructor_call = | 7320 ConstructorCallNode* controller_constructor_call = |
7321 new (Z) ConstructorCallNode(TokenPosition::kNoSource, | 7321 new (Z) ConstructorCallNode(TokenPosition::kNoSource, |
7322 TypeArguments::ZoneHandle(Z), | 7322 TypeArguments::ZoneHandle(Z), |
7323 controller_constructor, arguments); | 7323 controller_constructor, arguments); |
7324 LocalVariable* controller_var = | 7324 LocalVariable* controller_var = |
7325 current_block_->scope->LookupVariable(Symbols::Controller(), false); | 7325 current_block_->scope->LookupVariable(Symbols::ColonController(), false); |
7326 StoreLocalNode* store_controller = new (Z) StoreLocalNode( | 7326 StoreLocalNode* store_controller = new (Z) StoreLocalNode( |
7327 TokenPosition::kNoSource, controller_var, controller_constructor_call); | 7327 TokenPosition::kNoSource, controller_var, controller_constructor_call); |
7328 current_block_->statements->Add(store_controller); | 7328 current_block_->statements->Add(store_controller); |
7329 | 7329 |
7330 // Grab :controller.stream | 7330 // Grab :controller.stream |
7331 InstanceGetterNode* controller_stream = new (Z) InstanceGetterNode( | 7331 InstanceGetterNode* controller_stream = new (Z) InstanceGetterNode( |
7332 TokenPosition::kNoSource, | 7332 TokenPosition::kNoSource, |
7333 new (Z) LoadLocalNode(TokenPosition::kNoSource, controller_var), | 7333 new (Z) LoadLocalNode(TokenPosition::kNoSource, controller_var), |
7334 Symbols::Stream()); | 7334 Symbols::Stream()); |
7335 | 7335 |
(...skipping 3062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10398 outer_async_saved_try_ctx))); | 10398 outer_async_saved_try_ctx))); |
10399 } | 10399 } |
10400 } else { | 10400 } else { |
10401 ASSERT(outer_saved_try_ctx == NULL); | 10401 ASSERT(outer_saved_try_ctx == NULL); |
10402 } | 10402 } |
10403 } else { | 10403 } else { |
10404 // yield statement in async* function. | 10404 // yield statement in async* function. |
10405 ASSERT(innermost_function().IsAsyncGenerator() || | 10405 ASSERT(innermost_function().IsAsyncGenerator() || |
10406 innermost_function().IsAsyncGenClosure()); | 10406 innermost_function().IsAsyncGenClosure()); |
10407 | 10407 |
10408 LocalVariable* controller_var = LookupLocalScope(Symbols::Controller()); | 10408 LocalVariable* controller_var = |
| 10409 LookupLocalScope(Symbols::ColonController()); |
10409 ASSERT(controller_var != NULL); | 10410 ASSERT(controller_var != NULL); |
10410 // :controller.add[Stream](expr); | 10411 // :controller.add[Stream](expr); |
10411 ArgumentListNode* add_args = new (Z) ArgumentListNode(yield_pos); | 10412 ArgumentListNode* add_args = new (Z) ArgumentListNode(yield_pos); |
10412 add_args->Add(expr); | 10413 add_args->Add(expr); |
10413 AstNode* add_call = new (Z) InstanceCallNode( | 10414 AstNode* add_call = new (Z) InstanceCallNode( |
10414 yield_pos, | 10415 yield_pos, |
10415 new (Z) LoadLocalNode(TokenPosition::kNoSource, controller_var), | 10416 new (Z) LoadLocalNode(TokenPosition::kNoSource, controller_var), |
10416 is_yield_each ? Symbols::AddStream() : Symbols::add(), add_args); | 10417 is_yield_each ? Symbols::AddStream() : Symbols::add(), add_args); |
10417 | 10418 |
10418 // if (:controller.add[Stream](expr)) { | 10419 // if (:controller.add[Stream](expr)) { |
(...skipping 4713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15132 const ArgumentListNode& function_args, | 15133 const ArgumentListNode& function_args, |
15133 const LocalVariable* temp_for_last_arg, | 15134 const LocalVariable* temp_for_last_arg, |
15134 bool is_super_invocation) { | 15135 bool is_super_invocation) { |
15135 UNREACHABLE(); | 15136 UNREACHABLE(); |
15136 return NULL; | 15137 return NULL; |
15137 } | 15138 } |
15138 | 15139 |
15139 } // namespace dart | 15140 } // namespace dart |
15140 | 15141 |
15141 #endif // DART_PRECOMPILED_RUNTIME | 15142 #endif // DART_PRECOMPILED_RUNTIME |
OLD | NEW |