Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: runtime/vm/ast_transformer.cc

Issue 1875643002: Dart VM: Simplify token positions in the translation of await. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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/ast_transformer.h" 5 #include "vm/ast_transformer.h"
6 6
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 #include "vm/parser.h" 8 #include "vm/parser.h"
9 #include "vm/thread.h" 9 #include "vm/thread.h"
10 10
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 LocalVariable* async_catch_error_callback = GetVariableInScope( 139 LocalVariable* async_catch_error_callback = GetVariableInScope(
140 preamble_->scope(), Symbols::AsyncCatchErrorCallback()); 140 preamble_->scope(), Symbols::AsyncCatchErrorCallback());
141 LocalVariable* result_param = GetVariableInScope( 141 LocalVariable* result_param = GetVariableInScope(
142 preamble_->scope(), Symbols::AsyncOperationParam()); 142 preamble_->scope(), Symbols::AsyncOperationParam());
143 LocalVariable* error_param = GetVariableInScope( 143 LocalVariable* error_param = GetVariableInScope(
144 preamble_->scope(), Symbols::AsyncOperationErrorParam()); 144 preamble_->scope(), Symbols::AsyncOperationErrorParam());
145 LocalVariable* stack_trace_param = GetVariableInScope( 145 LocalVariable* stack_trace_param = GetVariableInScope(
146 preamble_->scope(), Symbols::AsyncOperationStackTraceParam()); 146 preamble_->scope(), Symbols::AsyncOperationStackTraceParam());
147 147
148 AstNode* transformed_expr = Transform(node->expr()); 148 AstNode* transformed_expr = Transform(node->expr());
149 LocalVariable* await_temp = AddNewTempVarToPreamble(transformed_expr, 149 LocalVariable* await_temp =
150 ST(node->token_pos())); 150 AddNewTempVarToPreamble(transformed_expr, token_pos);
hausner 2016/04/08 16:43:36 Nit: indentation should be 4 spaces.
151 151
152 AwaitMarkerNode* await_marker = 152 AwaitMarkerNode* await_marker =
153 new(Z) AwaitMarkerNode(async_temp_scope_, node->scope(), token_pos); 153 new(Z) AwaitMarkerNode(async_temp_scope_, node->scope(), token_pos);
154 preamble_->Add(await_marker); 154 preamble_->Add(await_marker);
155 155
156 // :result_param = _awaitHelper( 156 // :result_param = _awaitHelper(
157 // :await_temp, :async_then_callback, :async_catch_error_callback) 157 // :await_temp, :async_then_callback, :async_catch_error_callback)
158 const Library& async_lib = Library::Handle(Library::AsyncLibrary()); 158 const Library& async_lib = Library::Handle(Library::AsyncLibrary());
159 const Function& async_await_helper = Function::ZoneHandle( 159 const Function& async_await_helper = Function::ZoneHandle(
160 Z, async_lib.LookupFunctionAllowPrivate(Symbols::AsyncAwaitHelper())); 160 Z, async_lib.LookupFunctionAllowPrivate(Symbols::AsyncAwaitHelper()));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 error_ne_null_branch->Add(new(Z) ThrowNode( 213 error_ne_null_branch->Add(new(Z) ThrowNode(
214 token_pos, 214 token_pos,
215 load_error_param, 215 load_error_param,
216 load_stack_trace_param)); 216 load_stack_trace_param));
217 preamble_->Add(new(Z) IfNode( 217 preamble_->Add(new(Z) IfNode(
218 token_pos, 218 token_pos,
219 new(Z) ComparisonNode( 219 new(Z) ComparisonNode(
220 token_pos, 220 token_pos,
221 Token::kNE, 221 Token::kNE,
222 load_error_param, 222 load_error_param,
223 new(Z) LiteralNode(token_pos, 223 new(Z) LiteralNode(token_pos, Object::null_instance())),
224 Object::null_instance())),
225 error_ne_null_branch, 224 error_ne_null_branch,
226 NULL)); 225 NULL));
227 226
228 LocalVariable* result = AddNewTempVarToPreamble(new(Z) LoadLocalNode( 227 result_ = MakeName(result_param);
hausner 2016/04/08 16:43:36 How does this work? result_param is a LocalVariabl
229 token_pos, result_param), ST(node->token_pos()));
230 result_ = new(Z) LoadLocalNode(token_pos, result);
231 } 228 }
232 229
233 230
234 // Transforms boolean expressions into a sequence of evaluatons that only lazily 231 // Transforms boolean expressions into a sequence of evaluatons that only lazily
235 // evaluate subexpressions. 232 // evaluate subexpressions.
236 // 233 //
237 // Example: 234 // Example:
238 // 235 //
239 // (a || b) only evaluates b if a is false 236 // (a || b) only evaluates b if a is false
240 // 237 //
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 568
572 569
573 void AwaitTransformer::VisitThrowNode(ThrowNode* node) { 570 void AwaitTransformer::VisitThrowNode(ThrowNode* node) {
574 AstNode* new_exception = Transform(node->exception()); 571 AstNode* new_exception = Transform(node->exception());
575 result_ = MakeName(new(Z) ThrowNode(node->token_pos(), 572 result_ = MakeName(new(Z) ThrowNode(node->token_pos(),
576 new_exception, 573 new_exception,
577 node->stacktrace())); 574 node->stacktrace()));
578 } 575 }
579 576
580 } // namespace dart 577 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698