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

Side by Side Diff: pkg/compiler/lib/src/tree_ir/tree_ir_tracer.dart

Issue 1253333002: dart2js cps: Support async/await by rewriting the JavaScript AST. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add issue number to status file. Created 5 years, 4 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
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 library tree_ir_tracer; 5 library tree_ir_tracer;
6 6
7 import 'dart:async' show EventSink; 7 import 'dart:async' show EventSink;
8 import '../tracer.dart'; 8 import '../tracer.dart';
9 import 'tree_ir_nodes.dart'; 9 import 'tree_ir_nodes.dart';
10 10
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 return 'GetIndex($object, $index)'; 548 return 'GetIndex($object, $index)';
549 } 549 }
550 550
551 @override 551 @override
552 String visitSetIndex(SetIndex node) { 552 String visitSetIndex(SetIndex node) {
553 String object = visitExpression(node.object); 553 String object = visitExpression(node.object);
554 String index = visitExpression(node.index); 554 String index = visitExpression(node.index);
555 String value = visitExpression(node.value); 555 String value = visitExpression(node.value);
556 return 'SetIndex($object, $index, $value)'; 556 return 'SetIndex($object, $index, $value)';
557 } 557 }
558
559 @override
560 String visitAwait(Await node) {
561 String value = visitExpression(node.input);
562 return 'Await($value)';
563 }
558 } 564 }
559 565
560 /** 566 /**
561 * Invents (and remembers) names for Variables that do not have an associated 567 * Invents (and remembers) names for Variables that do not have an associated
562 * identifier. 568 * identifier.
563 * 569 *
564 * In case a variable is named v0, v1, etc, it may be assigned a different 570 * In case a variable is named v0, v1, etc, it may be assigned a different
565 * name to avoid clashing with a previously synthesized variable name. 571 * name to avoid clashing with a previously synthesized variable name.
566 */ 572 */
567 class Names { 573 class Names {
568 final Map<Variable, String> _names = {}; 574 final Map<Variable, String> _names = {};
569 final Set<String> _usedNames = new Set(); 575 final Set<String> _usedNames = new Set();
570 int _counter = 0; 576 int _counter = 0;
571 577
572 String varName(Variable v) { 578 String varName(Variable v) {
573 String name = _names[v]; 579 String name = _names[v];
574 if (name == null) { 580 if (name == null) {
575 String prefix = v.element == null ? 'v' : '${v.element.name}_'; 581 String prefix = v.element == null ? 'v' : '${v.element.name}_';
576 while (name == null || _usedNames.contains(name)) { 582 while (name == null || _usedNames.contains(name)) {
577 name = "$prefix${_counter++}"; 583 name = "$prefix${_counter++}";
578 } 584 }
579 _names[v] = name; 585 _names[v] = name;
580 _usedNames.add(name); 586 _usedNames.add(name);
581 } 587 }
582 return name; 588 return name;
583 } 589 }
584 } 590 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698