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

Side by Side Diff: lib/transformations/async.dart

Issue 2502943002: Fix parent pointer issue in async rewriter. (Closed)
Patch Set: Created 4 years, 1 month 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 | « lib/ast.dart ('k') | lib/transformations/continuation.dart » ('j') | 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library kernel.transformations.async; 5 library kernel.transformations.async;
6 6
7 import '../kernel.dart'; 7 import '../kernel.dart';
8 import 'continuation.dart'; 8 import 'continuation.dart';
9 9
10 /// A transformer that introduces temporary variables for all subexpressions 10 /// A transformer that introduces temporary variables for all subexpressions
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 // if (t) { 314 // if (t) {
315 // t = [right] == true; 315 // t = [right] == true;
316 // } 316 // }
317 317
318 // Recall that statements are emitted in reverse order, so first emit the if 318 // Recall that statements are emitted in reverse order, so first emit the if
319 // statement, then the assignment of [left] == true, and then translate left 319 // statement, then the assignment of [left] == true, and then translate left
320 // so any statements it emits occur after in the accumulated list (that is, 320 // so any statements it emits occur after in the accumulated list (that is,
321 // so they occur before in the corresponding block). 321 // so they occur before in the corresponding block).
322 var rightBody = blockOf(rightStatements); 322 var rightBody = blockOf(rightStatements);
323 var result = allocateTemporary(nameIndex); 323 var result = allocateTemporary(nameIndex);
324 rightBody.statements.add(new ExpressionStatement( 324 rightBody.addStatement(new ExpressionStatement(
325 new VariableSet( 325 new VariableSet(
326 result, 326 result,
327 new MethodInvocation( 327 new MethodInvocation(
328 expr.right, 328 expr.right,
329 new Name('=='), 329 new Name('=='),
330 new Arguments(<Expression>[new BoolLiteral(true)]))))); 330 new Arguments(<Expression>[new BoolLiteral(true)])))));
331 var then, otherwise; 331 var then, otherwise;
332 if (expr.operator == '&&') { 332 if (expr.operator == '&&') {
333 then = rightBody; 333 then = rightBody;
334 otherwise = null; 334 otherwise = null;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 // and emit: 384 // and emit:
385 // 385 //
386 // if ([condition]) { 386 // if ([condition]) {
387 // t = [left]; 387 // t = [left];
388 // } else { 388 // } else {
389 // t = [right]; 389 // t = [right];
390 // } 390 // }
391 var result = allocateTemporary(nameIndex); 391 var result = allocateTemporary(nameIndex);
392 var thenBody = blockOf(thenStatements); 392 var thenBody = blockOf(thenStatements);
393 var otherwiseBody = blockOf(otherwiseStatements); 393 var otherwiseBody = blockOf(otherwiseStatements);
394 thenBody.statements.add( 394 thenBody.addStatement(
395 new ExpressionStatement(new VariableSet(result, expr.then))); 395 new ExpressionStatement(new VariableSet(result, expr.then)));
396 otherwiseBody.statements.add( 396 otherwiseBody.addStatement(
397 new ExpressionStatement(new VariableSet(result, expr.otherwise))); 397 new ExpressionStatement(new VariableSet(result, expr.otherwise)));
398 var branch = new IfStatement(expr.condition, thenBody, otherwiseBody); 398 var branch = new IfStatement(expr.condition, thenBody, otherwiseBody);
399 statements.add(branch); 399 statements.add(branch);
400 400
401 seenAwait = false; 401 seenAwait = false;
402 branch.condition = branch.condition.accept(this)..parent = branch; 402 branch.condition = branch.condition.accept(this)..parent = branch;
403 403
404 ++nameIndex; 404 ++nameIndex;
405 seenAwait = seenAwait || thenAwait || otherwiseAwait; 405 seenAwait = seenAwait || thenAwait || otherwiseAwait;
406 return new VariableGet(result); 406 return new VariableGet(result);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 }); 480 });
481 } 481 }
482 } 482 }
483 483
484 visitFunctionNode(FunctionNode node) { 484 visitFunctionNode(FunctionNode node) {
485 var nestedRewriter = new RecursiveContinuationRewriter( 485 var nestedRewriter = new RecursiveContinuationRewriter(
486 continuationRewriter.helper); 486 continuationRewriter.helper);
487 return node.accept(nestedRewriter); 487 return node.accept(nestedRewriter);
488 } 488 }
489 } 489 }
OLDNEW
« no previous file with comments | « lib/ast.dart ('k') | lib/transformations/continuation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698