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 7234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7245 // :await_jump_var = -1; | 7245 // :await_jump_var = -1; |
7246 LocalVariable* jump_var = | 7246 LocalVariable* jump_var = |
7247 current_block_->scope->LookupVariable(Symbols::AwaitJumpVar(), false); | 7247 current_block_->scope->LookupVariable(Symbols::AwaitJumpVar(), false); |
7248 LiteralNode* init_value = new (Z) | 7248 LiteralNode* init_value = new (Z) |
7249 LiteralNode(TokenPosition::kNoSource, Smi::ZoneHandle(Smi::New(-1))); | 7249 LiteralNode(TokenPosition::kNoSource, Smi::ZoneHandle(Smi::New(-1))); |
7250 current_block_->statements->Add( | 7250 current_block_->statements->Add( |
7251 new (Z) StoreLocalNode(TokenPosition::kNoSource, jump_var, init_value)); | 7251 new (Z) StoreLocalNode(TokenPosition::kNoSource, jump_var, init_value)); |
7252 | 7252 |
7253 TokenPosition token_pos = TokenPosition::kNoSource; | 7253 TokenPosition token_pos = TokenPosition::kNoSource; |
7254 | 7254 |
7255 | |
7256 // Add to AST: | |
7257 // :async_op = <closure>; (containing the original body) | |
7258 LocalVariable* async_op_var = | |
7259 current_block_->scope->LookupVariable(Symbols::AsyncOperation(), false); | |
7260 ClosureNode* closure_obj = new (Z) ClosureNode( | |
7261 TokenPosition::kNoSource, closure_func, NULL, closure_body->scope()); | |
7262 StoreLocalNode* store_async_op = new (Z) | |
7263 StoreLocalNode(TokenPosition::kNoSource, async_op_var, closure_obj); | |
7264 | |
7265 current_block_->statements->Add(store_async_op); | |
7266 | |
7255 if (FLAG_causal_async_stacks) { | 7267 if (FLAG_causal_async_stacks) { |
7256 // Add to AST: | 7268 // Add to AST: |
7257 // :async_stack_trace = _asyncStackTraceHelper(); | 7269 // :async_stack_trace = _asyncStackTraceHelper(); |
7258 const Function& async_stack_trace_helper = Function::ZoneHandle( | 7270 const Function& async_stack_trace_helper = Function::ZoneHandle( |
7259 Z, | 7271 Z, |
7260 async_lib.LookupFunctionAllowPrivate(Symbols::AsyncStackTraceHelper())); | 7272 async_lib.LookupFunctionAllowPrivate(Symbols::AsyncStackTraceHelper())); |
7261 ASSERT(!async_stack_trace_helper.IsNull()); | 7273 ASSERT(!async_stack_trace_helper.IsNull()); |
7262 ArgumentListNode* async_stack_trace_helper_args = | 7274 ArgumentListNode* async_stack_trace_helper_args = |
7263 new (Z) ArgumentListNode(TokenPosition::kNoSource); | 7275 new (Z) ArgumentListNode(TokenPosition::kNoSource); |
7276 async_stack_trace_helper_args->Add( | |
7277 new (Z) LoadLocalNode(TokenPosition::kNoSource, async_op_var)); | |
7264 StaticCallNode* async_stack_trace_helper_call = new (Z) StaticCallNode( | 7278 StaticCallNode* async_stack_trace_helper_call = new (Z) StaticCallNode( |
7265 token_pos, async_stack_trace_helper, async_stack_trace_helper_args); | 7279 token_pos, async_stack_trace_helper, async_stack_trace_helper_args); |
7266 LocalVariable* async_stack_trace_var = | 7280 LocalVariable* async_stack_trace_var = |
7267 current_block_->scope->LookupVariable(Symbols::AsyncStackTraceVar(), | 7281 current_block_->scope->LookupVariable(Symbols::AsyncStackTraceVar(), |
7268 false); | 7282 false); |
7269 StoreLocalNode* store_async_stack_trace = new (Z) StoreLocalNode( | 7283 StoreLocalNode* store_async_stack_trace = new (Z) StoreLocalNode( |
7270 token_pos, async_stack_trace_var, async_stack_trace_helper_call); | 7284 token_pos, async_stack_trace_var, async_stack_trace_helper_call); |
7271 current_block_->statements->Add(store_async_stack_trace); | 7285 current_block_->statements->Add(store_async_stack_trace); |
7272 } | 7286 } |
7273 | 7287 |
7274 | |
7275 // Add to AST: | |
7276 // :async_op = <closure>; (containing the original body) | |
7277 LocalVariable* async_op_var = | |
7278 current_block_->scope->LookupVariable(Symbols::AsyncOperation(), false); | |
7279 ClosureNode* closure_obj = new (Z) ClosureNode( | |
7280 TokenPosition::kNoSource, closure_func, NULL, closure_body->scope()); | |
7281 StoreLocalNode* store_async_op = new (Z) | |
7282 StoreLocalNode(TokenPosition::kNoSource, async_op_var, closure_obj); | |
7283 | |
7284 current_block_->statements->Add(store_async_op); | |
7285 | |
7286 // :async_then_callback = _asyncThenWrapperHelper(:async_op) | 7288 // :async_then_callback = _asyncThenWrapperHelper(:async_op) |
7287 const Function& async_then_wrapper_helper = Function::ZoneHandle( | 7289 const Function& async_then_wrapper_helper = Function::ZoneHandle( |
7288 Z, | 7290 Z, |
7289 async_lib.LookupFunctionAllowPrivate(Symbols::AsyncThenWrapperHelper())); | 7291 async_lib.LookupFunctionAllowPrivate(Symbols::AsyncThenWrapperHelper())); |
7290 ASSERT(!async_then_wrapper_helper.IsNull()); | 7292 ASSERT(!async_then_wrapper_helper.IsNull()); |
7291 ArgumentListNode* async_then_wrapper_helper_args = | 7293 ArgumentListNode* async_then_wrapper_helper_args = |
7292 new (Z) ArgumentListNode(TokenPosition::kNoSource); | 7294 new (Z) ArgumentListNode(TokenPosition::kNoSource); |
7293 async_then_wrapper_helper_args->Add( | 7295 async_then_wrapper_helper_args->Add( |
7294 new (Z) LoadLocalNode(TokenPosition::kNoSource, async_op_var)); | 7296 new (Z) LoadLocalNode(TokenPosition::kNoSource, async_op_var)); |
7295 StaticCallNode* then_wrapper_call = new (Z) | 7297 StaticCallNode* then_wrapper_call = new (Z) |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7488 | 7490 |
7489 if (FLAG_causal_async_stacks) { | 7491 if (FLAG_causal_async_stacks) { |
7490 // Add to AST: | 7492 // Add to AST: |
7491 // :async_stack_trace = _asyncStackTraceHelper(); | 7493 // :async_stack_trace = _asyncStackTraceHelper(); |
7492 const Function& async_stack_trace_helper = Function::ZoneHandle( | 7494 const Function& async_stack_trace_helper = Function::ZoneHandle( |
7493 Z, | 7495 Z, |
7494 async_lib.LookupFunctionAllowPrivate(Symbols::AsyncStackTraceHelper())); | 7496 async_lib.LookupFunctionAllowPrivate(Symbols::AsyncStackTraceHelper())); |
7495 ASSERT(!async_stack_trace_helper.IsNull()); | 7497 ASSERT(!async_stack_trace_helper.IsNull()); |
7496 ArgumentListNode* async_stack_trace_helper_args = | 7498 ArgumentListNode* async_stack_trace_helper_args = |
7497 new (Z) ArgumentListNode(token_pos); | 7499 new (Z) ArgumentListNode(token_pos); |
7500 async_stack_trace_helper_args->Add( | |
7501 new (Z) LoadLocalNode(token_pos, async_op_var)); | |
7498 StaticCallNode* async_stack_trace_helper_call = new (Z) StaticCallNode( | 7502 StaticCallNode* async_stack_trace_helper_call = new (Z) StaticCallNode( |
7499 token_pos, async_stack_trace_helper, async_stack_trace_helper_args); | 7503 token_pos, async_stack_trace_helper, async_stack_trace_helper_args); |
7500 LocalVariable* async_stack_trace_var = | 7504 LocalVariable* async_stack_trace_var = |
7501 current_block_->scope->LookupVariable(Symbols::AsyncStackTraceVar(), | 7505 current_block_->scope->LookupVariable(Symbols::AsyncStackTraceVar(), |
7502 false); | 7506 false); |
7503 StoreLocalNode* store_async_stack_trace = new (Z) StoreLocalNode( | 7507 StoreLocalNode* store_async_stack_trace = new (Z) StoreLocalNode( |
7504 token_pos, async_stack_trace_var, async_stack_trace_helper_call); | 7508 token_pos, async_stack_trace_var, async_stack_trace_helper_call); |
7505 current_block_->statements->Add(store_async_stack_trace); | 7509 current_block_->statements->Add(store_async_stack_trace); |
7506 } | 7510 } |
7507 | 7511 |
(...skipping 1710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9218 LocalVariable* async_saved_try_ctx; | 9222 LocalVariable* async_saved_try_ctx; |
9219 LocalVariable* outer_saved_try_ctx; | 9223 LocalVariable* outer_saved_try_ctx; |
9220 LocalVariable* outer_async_saved_try_ctx; | 9224 LocalVariable* outer_async_saved_try_ctx; |
9221 CheckAsyncOpInTryBlock(&saved_try_ctx, &async_saved_try_ctx, | 9225 CheckAsyncOpInTryBlock(&saved_try_ctx, &async_saved_try_ctx, |
9222 &outer_saved_try_ctx, &outer_async_saved_try_ctx); | 9226 &outer_saved_try_ctx, &outer_async_saved_try_ctx); |
9223 ArgumentListNode* no_args = new (Z) ArgumentListNode(stream_expr_pos); | 9227 ArgumentListNode* no_args = new (Z) ArgumentListNode(stream_expr_pos); |
9224 AstNode* iterator_moveNext = new (Z) InstanceCallNode( | 9228 AstNode* iterator_moveNext = new (Z) InstanceCallNode( |
9225 stream_expr_pos, new (Z) LoadLocalNode(stream_expr_pos, iterator_var), | 9229 stream_expr_pos, new (Z) LoadLocalNode(stream_expr_pos, iterator_var), |
9226 Symbols::MoveNext(), no_args); | 9230 Symbols::MoveNext(), no_args); |
9227 OpenBlock(); | 9231 OpenBlock(); |
9232 if (FLAG_support_debugger) { | |
9233 // Call '_asyncStarMoveNextHelper' so that the debugger can intercept and | |
9234 // handle single stepping into a async* generator. | |
9235 const Function& async_star_move_next_helper = Function::ZoneHandle( | |
9236 Z, isolate()->object_store()->async_star_move_next_helper()); | |
9237 ASSERT(!async_star_move_next_helper.IsNull()); | |
9238 ArgumentListNode* async_star_move_next_helper_args = | |
9239 new (Z) ArgumentListNode(stream_expr_pos); | |
9240 async_star_move_next_helper_args->Add( | |
9241 new (Z) LoadLocalNode(stream_expr_pos, stream_var)); | |
9242 StaticCallNode* async_star_move_next_helper_call = | |
9243 new (Z) StaticCallNode(stream_expr_pos, async_star_move_next_helper, | |
9244 async_star_move_next_helper_args); | |
9245 current_block_->statements->Add(async_star_move_next_helper_call); | |
9246 } | |
siva
2017/03/23 22:37:01
This call has to be added to the kernel side too r
Cutch
2017/03/24 14:55:39
Filed https://github.com/dart-lang/sdk/issues/2915
| |
9228 AstNode* await_moveNext = new (Z) AwaitNode( | 9247 AstNode* await_moveNext = new (Z) AwaitNode( |
9229 stream_expr_pos, iterator_moveNext, saved_try_ctx, async_saved_try_ctx, | 9248 stream_expr_pos, iterator_moveNext, saved_try_ctx, async_saved_try_ctx, |
9230 outer_saved_try_ctx, outer_async_saved_try_ctx, current_block_->scope); | 9249 outer_saved_try_ctx, outer_async_saved_try_ctx, current_block_->scope); |
9231 AwaitTransformer at(current_block_->statements, async_temp_scope_); | 9250 AwaitTransformer at(current_block_->statements, async_temp_scope_); |
9232 await_moveNext = at.Transform(await_moveNext); | 9251 await_moveNext = at.Transform(await_moveNext); |
9233 SequenceNode* await_preamble = CloseBlock(); | 9252 SequenceNode* await_preamble = CloseBlock(); |
9234 | 9253 |
9235 // Parse the for loop body. Ideally, we would use ParseNestedStatement() | 9254 // Parse the for loop body. Ideally, we would use ParseNestedStatement() |
9236 // here, but that does not work well because we have to insert an implicit | 9255 // here, but that does not work well because we have to insert an implicit |
9237 // variable assignment and potentially a variable declaration in the | 9256 // variable assignment and potentially a variable declaration in the |
(...skipping 5950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15188 const ArgumentListNode& function_args, | 15207 const ArgumentListNode& function_args, |
15189 const LocalVariable* temp_for_last_arg, | 15208 const LocalVariable* temp_for_last_arg, |
15190 bool is_super_invocation) { | 15209 bool is_super_invocation) { |
15191 UNREACHABLE(); | 15210 UNREACHABLE(); |
15192 return NULL; | 15211 return NULL; |
15193 } | 15212 } |
15194 | 15213 |
15195 } // namespace dart | 15214 } // namespace dart |
15196 | 15215 |
15197 #endif // DART_PRECOMPILED_RUNTIME | 15216 #endif // DART_PRECOMPILED_RUNTIME |
OLD | NEW |