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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart

Issue 1001793002: dart2js: Add support for do/while loops to the CPS backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
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 dart2js.ir_nodes_sexpr; 5 library dart2js.ir_nodes_sexpr;
6 6
7 import '../constants/values.dart'; 7 import '../constants/values.dart';
8 import '../util/util.dart'; 8 import '../util/util.dart';
9 import 'cps_ir_nodes.dart'; 9 import 'cps_ir_nodes.dart';
10 10
11 /// A [Decorator] is a function used by [SExpressionStringifier] to augment the 11 /// A [Decorator] is a function used by [SExpressionStringifier] to augment the
12 /// output produced for a node. It can be provided to the constructor. 12 /// output produced for a node or reference. It can be provided to the
13 typedef String Decorator(Node node, String s); 13 /// constructor.
14 typedef String Decorator(node, String s);
14 15
15 /// Generate a Lisp-like S-expression representation of an IR node as a string. 16 /// Generate a Lisp-like S-expression representation of an IR node as a string.
16 class SExpressionStringifier extends Indentation implements Visitor<String> { 17 class SExpressionStringifier extends Indentation implements Visitor<String> {
17 final _Namer namer = new _Namer(); 18 final _Namer namer = new _Namer();
18 19
19 String newValueName(Primitive node) => namer.nameValue(node); 20 String newValueName(Primitive node) => namer.nameValue(node);
20 String newContinuationName(Continuation node) => namer.nameContinuation(node); 21 String newContinuationName(Continuation node) => namer.nameContinuation(node);
21 Decorator decorator; 22 Decorator decorator;
22 23
23 SExpressionStringifier([this.decorator]) { 24 SExpressionStringifier([this.decorator]) {
24 if (this.decorator == null) { 25 if (this.decorator == null) {
25 this.decorator = (Node node, String s) => s; 26 this.decorator = (node, String s) => s;
26 } 27 }
27 } 28 }
28 29
29 String access(Reference<Definition> r) { 30 String access(Reference<Definition> r) {
30 return decorator(r.definition, namer.getName(r.definition)); 31 return decorator(r, namer.getName(r.definition));
31 } 32 }
32 33
33 String visitParameter(Parameter node) { 34 String visitParameter(Parameter node) {
34 return namer.nameParameter(node); 35 return namer.nameParameter(node);
35 } 36 }
36 37
37 String visitMutableVariable(MutableVariable node) { 38 String visitMutableVariable(MutableVariable node) {
38 return namer.nameMutableVariable(node); 39 return namer.nameMutableVariable(node);
39 } 40 }
40 41
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 void setReturnContinuation(Continuation node) { 440 void setReturnContinuation(Continuation node) {
440 assert(!_names.containsKey(node) || _names[node] == 'return'); 441 assert(!_names.containsKey(node) || _names[node] == 'return');
441 _names[node] = 'return'; 442 _names[node] = 'return';
442 } 443 }
443 444
444 String getName(Node node) { 445 String getName(Node node) {
445 assert(_names.containsKey(node)); 446 assert(_names.containsKey(node));
446 return _names[node]; 447 return _names[node];
447 } 448 }
448 } 449 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698