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

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

Issue 787603003: Generative constructors in the new dart backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 '../util/util.dart'; 7 import '../util/util.dart';
8 import 'cps_ir_nodes.dart'; 8 import 'cps_ir_nodes.dart';
9 9
10 /// A [Decorator] is a function used by [SExpressionStringifier] to augment the 10 /// A [Decorator] is a function used by [SExpressionStringifier] to augment the
(...skipping 22 matching lines...) Expand all
33 33
34 /// Main entry point for creating a [String] from a [Node]. All recursive 34 /// Main entry point for creating a [String] from a [Node]. All recursive
35 /// calls must go through this method. 35 /// calls must go through this method.
36 String visit(Node node) { 36 String visit(Node node) {
37 String s = super.visit(node); 37 String s = super.visit(node);
38 return (decorator == null) ? s : decorator(node, s); 38 return (decorator == null) ? s : decorator(node, s);
39 } 39 }
40 40
41 String visitFunctionDefinition(FunctionDefinition node) { 41 String visitFunctionDefinition(FunctionDefinition node) {
42 String name = node.element.name; 42 String name = node.element.name;
43 namer.useReturnName(node.returnContinuation); 43 namer.useReturnName(node.body.returnContinuation);
44 String closureVariables = node.closureVariables.isEmpty 44 String closureVariables = node.closureVariables.isEmpty
45 ? '' 45 ? ''
46 : '{${node.closureVariables.map(namer.defineClosureName).join(' ')}} '; 46 : '{${node.closureVariables.map(namer.defineClosureName).join(' ')}} ';
47 String parameters = node.parameters.map(visit).join(' '); 47 String parameters = node.parameters.map(visit).join(' ');
48 String body = indentBlock(() => visit(node.body)); 48 String body = indentBlock(() => visit(node.body));
49 return '$indentation(FunctionDefinition $name $closureVariables' 49 return '$indentation(FunctionDefinition $name $closureVariables'
50 '($parameters return)\n$body)'; 50 '($parameters return)\n$body)';
51 } 51 }
52 52
53 String visitFieldDefinition(FieldDefinition node) { 53 String visitFieldDefinition(FieldDefinition node) {
54 String name = node.element.name; 54 String name = node.element.name;
55 if (node.hasInitializer) { 55 if (node.hasInitializer) {
56 namer.useReturnName(node.returnContinuation); 56 namer.useReturnName(node.body.returnContinuation);
57 String body = indentBlock(() => visit(node.body)); 57 String body = indentBlock(() => visit(node.body));
58 return '$indentation(FieldDefinition $name (return)\n' 58 return '$indentation(FieldDefinition $name (return)\n'
59 '$body)'; 59 '$body)';
60 } else { 60 } else {
61 return '$indentation(FieldDefinition $name)'; 61 return '$indentation(FieldDefinition $name)';
62 } 62 }
63 } 63 }
64 64
65 String visitLetPrim(LetPrim node) { 65 String visitLetPrim(LetPrim node) {
66 String name = newValueName(node.primitive); 66 String name = newValueName(node.primitive);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 String useReturnName(Continuation node) { 253 String useReturnName(Continuation node) {
254 assert(!_names.containsKey(node) || _names[node] == 'return'); 254 assert(!_names.containsKey(node) || _names[node] == 'return');
255 return _names[node] = 'return'; 255 return _names[node] = 'return';
256 } 256 }
257 257
258 String getName(Node node) { 258 String getName(Node node) {
259 assert(_names.containsKey(node)); 259 assert(_names.containsKey(node));
260 return _names[node]; 260 return _names[node];
261 } 261 }
262 } 262 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698