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

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

Issue 1585503002: dart2js: CPS translation of switches with continue to their labels. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update test expectations. Created 4 years, 11 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 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 import '../universe/call_structure.dart' show 10 import '../universe/call_structure.dart' show
(...skipping 12 matching lines...) Expand all
23 String newContinuationName(Continuation node) => namer.nameContinuation(node); 23 String newContinuationName(Continuation node) => namer.nameContinuation(node);
24 Decorator decorator; 24 Decorator decorator;
25 25
26 SExpressionStringifier([this.decorator]) { 26 SExpressionStringifier([this.decorator]) {
27 if (this.decorator == null) { 27 if (this.decorator == null) {
28 this.decorator = (node, String s) => s; 28 this.decorator = (node, String s) => s;
29 } 29 }
30 } 30 }
31 31
32 String access(Reference<Definition> r) { 32 String access(Reference<Definition> r) {
33 if (r == null) return '**** NULL ****';
33 return decorator(r, namer.getName(r.definition)); 34 return decorator(r, namer.getName(r.definition));
34 } 35 }
35 36
36 String optionalAccess(Reference<Definition> reference) { 37 String optionalAccess(Reference<Definition> reference) {
37 return reference == null ? '()' : '(${access(reference)})'; 38 return reference == null ? '()' : '(${access(reference)})';
38 } 39 }
39 40
40 String visitParameter(Parameter node) { 41 String visitParameter(Parameter node) {
41 return namer.nameParameter(node); 42 return namer.nameParameter(node);
42 } 43 }
43 44
44 String visitMutableVariable(MutableVariable node) { 45 String visitMutableVariable(MutableVariable node) {
45 return namer.nameMutableVariable(node); 46 return namer.nameMutableVariable(node);
46 } 47 }
47 48
48 /// Main entry point for creating a [String] from a [Node]. All recursive 49 /// Main entry point for creating a [String] from a [Node]. All recursive
49 /// calls must go through this method. 50 /// calls must go through this method.
50 String visit(Node node) { 51 String visit(Node node) {
51 if (node == null) return '**** NULL ****'; 52 if (node == null) {
53 return node is Expression
asgerf 2016/01/19 22:45:24 Dead code, null is not an expression.
Kevin Millikin (Google) 2016/01/25 12:46:37 Done.
54 ? '$indentation**** NULL ****'
55 : '**** NULL ****';
56 }
52 String s = node.accept(this); 57 String s = node.accept(this);
53 return decorator(node, s); 58 return decorator(node, s);
54 } 59 }
55 60
56 String formatThisParameter(Parameter thisParameter) { 61 String formatThisParameter(Parameter thisParameter) {
57 return thisParameter == null ? '()' : '(${visit(thisParameter)})'; 62 return thisParameter == null ? '()' : '(${visit(thisParameter)})';
58 } 63 }
59 64
60 String visitFunctionDefinition(FunctionDefinition node) { 65 String visitFunctionDefinition(FunctionDefinition node) {
61 String name = node.element.name; 66 String name = node.element.name;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 if (!node.target.name.isEmpty) { 190 if (!node.target.name.isEmpty) {
186 name = '${name}.${node.target.name}'; 191 name = '${name}.${node.target.name}';
187 } 192 }
188 String args = formatArguments(node.selector.callStructure, node.arguments); 193 String args = formatArguments(node.selector.callStructure, node.arguments);
189 return '(InvokeConstructor $name $args)'; 194 return '(InvokeConstructor $name $args)';
190 } 195 }
191 196
192 String visitInvokeContinuation(InvokeContinuation node) { 197 String visitInvokeContinuation(InvokeContinuation node) {
193 String name = access(node.continuation); 198 String name = access(node.continuation);
194 if (node.isRecursive) name = 'rec $name'; 199 if (node.isRecursive) name = 'rec $name';
195 String args = node.arguments.map(access).join(' '); 200 String args = node.arguments == null
201 ? '**** NULL ****'
202 » : node.arguments.map(access).join(' ');
196 String escaping = node.isEscapingTry ? ' escape' : ''; 203 String escaping = node.isEscapingTry ? ' escape' : '';
197 return '$indentation(InvokeContinuation $name ($args)$escaping)'; 204 return '$indentation(InvokeContinuation $name ($args)$escaping)';
198 } 205 }
199 206
200 String visitThrow(Throw node) { 207 String visitThrow(Throw node) {
201 String value = access(node.value); 208 String value = access(node.value);
202 return '$indentation(Throw $value)'; 209 return '$indentation(Throw $value)';
203 } 210 }
204 211
205 String visitRethrow(Rethrow node) { 212 String visitRethrow(Rethrow node) {
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 void setReturnContinuation(Continuation node) { 525 void setReturnContinuation(Continuation node) {
519 assert(!_names.containsKey(node) || _names[node] == 'return'); 526 assert(!_names.containsKey(node) || _names[node] == 'return');
520 _names[node] = 'return'; 527 _names[node] = 'return';
521 } 528 }
522 529
523 String getName(Node node) { 530 String getName(Node node) {
524 if (!_names.containsKey(node)) return 'MISSING_NAME'; 531 if (!_names.containsKey(node)) return 'MISSING_NAME';
525 return _names[node]; 532 return _names[node];
526 } 533 }
527 } 534 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698