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 7243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7254 // :await_jump_var = -1; | 7254 // :await_jump_var = -1; |
7255 LocalVariable* jump_var = | 7255 LocalVariable* jump_var = |
7256 current_block_->scope->LookupVariable(Symbols::AwaitJumpVar(), false); | 7256 current_block_->scope->LookupVariable(Symbols::AwaitJumpVar(), false); |
7257 LiteralNode* init_value = new (Z) | 7257 LiteralNode* init_value = new (Z) |
7258 LiteralNode(TokenPosition::kNoSource, Smi::ZoneHandle(Smi::New(-1))); | 7258 LiteralNode(TokenPosition::kNoSource, Smi::ZoneHandle(Smi::New(-1))); |
7259 current_block_->statements->Add( | 7259 current_block_->statements->Add( |
7260 new (Z) StoreLocalNode(TokenPosition::kNoSource, jump_var, init_value)); | 7260 new (Z) StoreLocalNode(TokenPosition::kNoSource, jump_var, init_value)); |
7261 | 7261 |
7262 TokenPosition token_pos = TokenPosition::kNoSource; | 7262 TokenPosition token_pos = TokenPosition::kNoSource; |
7263 | 7263 |
7264 | |
7265 // Add to AST: | |
7266 // :async_op = <closure>; (containing the original body) | |
7267 LocalVariable* async_op_var = | |
7268 current_block_->scope->LookupVariable(Symbols::AsyncOperation(), false); | |
7269 ClosureNode* closure_obj = new (Z) ClosureNode( | |
7270 TokenPosition::kNoSource, closure_func, NULL, closure_body->scope()); | |
7271 StoreLocalNode* store_async_op = new (Z) | |
7272 StoreLocalNode(TokenPosition::kNoSource, async_op_var, closure_obj); | |
7273 | |
7274 current_block_->statements->Add(store_async_op); | |
7275 | |
7264 if (FLAG_causal_async_stacks) { | 7276 if (FLAG_causal_async_stacks) { |
7265 // Add to AST: | 7277 // Add to AST: |
7266 // :async_stack_trace = _asyncStackTraceHelper(); | 7278 // :async_stack_trace = _asyncStackTraceHelper(); |
7267 const Function& async_stack_trace_helper = Function::ZoneHandle( | 7279 const Function& async_stack_trace_helper = Function::ZoneHandle( |
7268 Z, | 7280 Z, |
7269 async_lib.LookupFunctionAllowPrivate(Symbols::AsyncStackTraceHelper())); | 7281 async_lib.LookupFunctionAllowPrivate(Symbols::AsyncStackTraceHelper())); |
7270 ASSERT(!async_stack_trace_helper.IsNull()); | 7282 ASSERT(!async_stack_trace_helper.IsNull()); |
7271 ArgumentListNode* async_stack_trace_helper_args = | 7283 ArgumentListNode* async_stack_trace_helper_args = |
7272 new (Z) ArgumentListNode(TokenPosition::kNoSource); | 7284 new (Z) ArgumentListNode(TokenPosition::kNoSource); |
7285 async_stack_trace_helper_args->Add( | |
7286 new (Z) LoadLocalNode(TokenPosition::kNoSource, async_op_var)); | |
7273 StaticCallNode* async_stack_trace_helper_call = new (Z) StaticCallNode( | 7287 StaticCallNode* async_stack_trace_helper_call = new (Z) StaticCallNode( |
7274 token_pos, async_stack_trace_helper, async_stack_trace_helper_args); | 7288 token_pos, async_stack_trace_helper, async_stack_trace_helper_args); |
7275 LocalVariable* async_stack_trace_var = | 7289 LocalVariable* async_stack_trace_var = |
7276 current_block_->scope->LookupVariable(Symbols::AsyncStackTraceVar(), | 7290 current_block_->scope->LookupVariable(Symbols::AsyncStackTraceVar(), |
7277 false); | 7291 false); |
7278 StoreLocalNode* store_async_stack_trace = new (Z) StoreLocalNode( | 7292 StoreLocalNode* store_async_stack_trace = new (Z) StoreLocalNode( |
7279 token_pos, async_stack_trace_var, async_stack_trace_helper_call); | 7293 token_pos, async_stack_trace_var, async_stack_trace_helper_call); |
7280 current_block_->statements->Add(store_async_stack_trace); | 7294 current_block_->statements->Add(store_async_stack_trace); |
7281 } | 7295 } |
7282 | 7296 |
7283 | |
7284 // Add to AST: | |
7285 // :async_op = <closure>; (containing the original body) | |
7286 LocalVariable* async_op_var = | |
7287 current_block_->scope->LookupVariable(Symbols::AsyncOperation(), false); | |
7288 ClosureNode* closure_obj = new (Z) ClosureNode( | |
7289 TokenPosition::kNoSource, closure_func, NULL, closure_body->scope()); | |
7290 StoreLocalNode* store_async_op = new (Z) | |
7291 StoreLocalNode(TokenPosition::kNoSource, async_op_var, closure_obj); | |
7292 | |
7293 current_block_->statements->Add(store_async_op); | |
7294 | |
7295 // :async_then_callback = _asyncThenWrapperHelper(:async_op) | 7297 // :async_then_callback = _asyncThenWrapperHelper(:async_op) |
7296 const Function& async_then_wrapper_helper = Function::ZoneHandle( | 7298 const Function& async_then_wrapper_helper = Function::ZoneHandle( |
7297 Z, | 7299 Z, |
7298 async_lib.LookupFunctionAllowPrivate(Symbols::AsyncThenWrapperHelper())); | 7300 async_lib.LookupFunctionAllowPrivate(Symbols::AsyncThenWrapperHelper())); |
7299 ASSERT(!async_then_wrapper_helper.IsNull()); | 7301 ASSERT(!async_then_wrapper_helper.IsNull()); |
7300 ArgumentListNode* async_then_wrapper_helper_args = | 7302 ArgumentListNode* async_then_wrapper_helper_args = |
7301 new (Z) ArgumentListNode(TokenPosition::kNoSource); | 7303 new (Z) ArgumentListNode(TokenPosition::kNoSource); |
7302 async_then_wrapper_helper_args->Add( | 7304 async_then_wrapper_helper_args->Add( |
7303 new (Z) LoadLocalNode(TokenPosition::kNoSource, async_op_var)); | 7305 new (Z) LoadLocalNode(TokenPosition::kNoSource, async_op_var)); |
7304 StaticCallNode* then_wrapper_call = new (Z) | 7306 StaticCallNode* then_wrapper_call = new (Z) |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7497 | 7499 |
7498 if (FLAG_causal_async_stacks) { | 7500 if (FLAG_causal_async_stacks) { |
7499 // Add to AST: | 7501 // Add to AST: |
7500 // :async_stack_trace = _asyncStackTraceHelper(); | 7502 // :async_stack_trace = _asyncStackTraceHelper(); |
7501 const Function& async_stack_trace_helper = Function::ZoneHandle( | 7503 const Function& async_stack_trace_helper = Function::ZoneHandle( |
7502 Z, | 7504 Z, |
7503 async_lib.LookupFunctionAllowPrivate(Symbols::AsyncStackTraceHelper())); | 7505 async_lib.LookupFunctionAllowPrivate(Symbols::AsyncStackTraceHelper())); |
7504 ASSERT(!async_stack_trace_helper.IsNull()); | 7506 ASSERT(!async_stack_trace_helper.IsNull()); |
7505 ArgumentListNode* async_stack_trace_helper_args = | 7507 ArgumentListNode* async_stack_trace_helper_args = |
7506 new (Z) ArgumentListNode(token_pos); | 7508 new (Z) ArgumentListNode(token_pos); |
7509 async_stack_trace_helper_args->Add( | |
7510 new (Z) LoadLocalNode(token_pos, async_op_var)); | |
7507 StaticCallNode* async_stack_trace_helper_call = new (Z) StaticCallNode( | 7511 StaticCallNode* async_stack_trace_helper_call = new (Z) StaticCallNode( |
7508 token_pos, async_stack_trace_helper, async_stack_trace_helper_args); | 7512 token_pos, async_stack_trace_helper, async_stack_trace_helper_args); |
7509 LocalVariable* async_stack_trace_var = | 7513 LocalVariable* async_stack_trace_var = |
7510 current_block_->scope->LookupVariable(Symbols::AsyncStackTraceVar(), | 7514 current_block_->scope->LookupVariable(Symbols::AsyncStackTraceVar(), |
7511 false); | 7515 false); |
7512 StoreLocalNode* store_async_stack_trace = new (Z) StoreLocalNode( | 7516 StoreLocalNode* store_async_stack_trace = new (Z) StoreLocalNode( |
7513 token_pos, async_stack_trace_var, async_stack_trace_helper_call); | 7517 token_pos, async_stack_trace_var, async_stack_trace_helper_call); |
7514 current_block_->statements->Add(store_async_stack_trace); | 7518 current_block_->statements->Add(store_async_stack_trace); |
7515 } | 7519 } |
7516 | 7520 |
(...skipping 1710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9227 LocalVariable* async_saved_try_ctx; | 9231 LocalVariable* async_saved_try_ctx; |
9228 LocalVariable* outer_saved_try_ctx; | 9232 LocalVariable* outer_saved_try_ctx; |
9229 LocalVariable* outer_async_saved_try_ctx; | 9233 LocalVariable* outer_async_saved_try_ctx; |
9230 CheckAsyncOpInTryBlock(&saved_try_ctx, &async_saved_try_ctx, | 9234 CheckAsyncOpInTryBlock(&saved_try_ctx, &async_saved_try_ctx, |
9231 &outer_saved_try_ctx, &outer_async_saved_try_ctx); | 9235 &outer_saved_try_ctx, &outer_async_saved_try_ctx); |
9232 ArgumentListNode* no_args = new (Z) ArgumentListNode(stream_expr_pos); | 9236 ArgumentListNode* no_args = new (Z) ArgumentListNode(stream_expr_pos); |
9233 AstNode* iterator_moveNext = new (Z) InstanceCallNode( | 9237 AstNode* iterator_moveNext = new (Z) InstanceCallNode( |
9234 stream_expr_pos, new (Z) LoadLocalNode(stream_expr_pos, iterator_var), | 9238 stream_expr_pos, new (Z) LoadLocalNode(stream_expr_pos, iterator_var), |
9235 Symbols::MoveNext(), no_args); | 9239 Symbols::MoveNext(), no_args); |
9236 OpenBlock(); | 9240 OpenBlock(); |
9241 // Call '_asyncStarMoveNextHelper' so that the debugger can intercept and | |
rmacnak
2017/03/23 20:20:18
if (FLAG_support_debugger) {
Cutch
2017/03/23 21:24:51
Done.
| |
9242 // handle single stepping into a async* generator. | |
9243 const Function& async_star_move_next_helper = Function::ZoneHandle( | |
9244 Z, isolate()->object_store()->async_star_move_next_helper()); | |
9245 ASSERT(!async_star_move_next_helper.IsNull()); | |
9246 ArgumentListNode* async_star_move_next_helper_args = | |
9247 new (Z) ArgumentListNode(stream_expr_pos); | |
9248 async_star_move_next_helper_args->Add( | |
9249 new (Z) LoadLocalNode(stream_expr_pos, stream_var)); | |
9250 StaticCallNode* async_star_move_next_helper_call = | |
9251 new (Z) StaticCallNode(stream_expr_pos, async_star_move_next_helper, | |
9252 async_star_move_next_helper_args); | |
9253 current_block_->statements->Add(async_star_move_next_helper_call); | |
9237 AstNode* await_moveNext = new (Z) AwaitNode( | 9254 AstNode* await_moveNext = new (Z) AwaitNode( |
9238 stream_expr_pos, iterator_moveNext, saved_try_ctx, async_saved_try_ctx, | 9255 stream_expr_pos, iterator_moveNext, saved_try_ctx, async_saved_try_ctx, |
9239 outer_saved_try_ctx, outer_async_saved_try_ctx, current_block_->scope); | 9256 outer_saved_try_ctx, outer_async_saved_try_ctx, current_block_->scope); |
9240 AwaitTransformer at(current_block_->statements, async_temp_scope_); | 9257 AwaitTransformer at(current_block_->statements, async_temp_scope_); |
9241 await_moveNext = at.Transform(await_moveNext); | 9258 await_moveNext = at.Transform(await_moveNext); |
9242 SequenceNode* await_preamble = CloseBlock(); | 9259 SequenceNode* await_preamble = CloseBlock(); |
9243 | 9260 |
9244 // Parse the for loop body. Ideally, we would use ParseNestedStatement() | 9261 // Parse the for loop body. Ideally, we would use ParseNestedStatement() |
9245 // here, but that does not work well because we have to insert an implicit | 9262 // here, but that does not work well because we have to insert an implicit |
9246 // variable assignment and potentially a variable declaration in the | 9263 // variable assignment and potentially a variable declaration in the |
(...skipping 5950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15197 const ArgumentListNode& function_args, | 15214 const ArgumentListNode& function_args, |
15198 const LocalVariable* temp_for_last_arg, | 15215 const LocalVariable* temp_for_last_arg, |
15199 bool is_super_invocation) { | 15216 bool is_super_invocation) { |
15200 UNREACHABLE(); | 15217 UNREACHABLE(); |
15201 return NULL; | 15218 return NULL; |
15202 } | 15219 } |
15203 | 15220 |
15204 } // namespace dart | 15221 } // namespace dart |
15205 | 15222 |
15206 #endif // DART_PRECOMPILED_RUNTIME | 15223 #endif // DART_PRECOMPILED_RUNTIME |
OLD | NEW |