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

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

Issue 1542003003: Revert "dart2js: Initial implementation of inlining." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart ('k') | pkg/compiler/lib/src/cps_ir/inline.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) 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 30 matching lines...) Expand all
41 return namer.nameParameter(node); 41 return namer.nameParameter(node);
42 } 42 }
43 43
44 String visitMutableVariable(MutableVariable node) { 44 String visitMutableVariable(MutableVariable node) {
45 return namer.nameMutableVariable(node); 45 return namer.nameMutableVariable(node);
46 } 46 }
47 47
48 /// Main entry point for creating a [String] from a [Node]. All recursive 48 /// Main entry point for creating a [String] from a [Node]. All recursive
49 /// calls must go through this method. 49 /// calls must go through this method.
50 String visit(Node node) { 50 String visit(Node node) {
51 if (node == null) return '**** NULL ****';
52 String s = node.accept(this); 51 String s = node.accept(this);
53 return decorator(node, s); 52 return decorator(node, s);
54 } 53 }
55 54
56 String formatThisParameter(Parameter thisParameter) { 55 String formatThisParameter(Parameter thisParameter) {
57 return thisParameter == null ? '()' : '(${visit(thisParameter)})'; 56 return thisParameter == null ? '()' : '(${visit(thisParameter)})';
58 } 57 }
59 58
60 String visitFunctionDefinition(FunctionDefinition node) { 59 String visitFunctionDefinition(FunctionDefinition node) {
61 String name = node.element.name; 60 String name = node.element.name;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 105 }
107 106
108 String visitLetMutable(LetMutable node) { 107 String visitLetMutable(LetMutable node) {
109 String name = visit(node.variable); 108 String name = visit(node.variable);
110 String value = access(node.value); 109 String value = access(node.value);
111 String body = indentBlock(() => visit(node.body)); 110 String body = indentBlock(() => visit(node.body));
112 return '$indentation(LetMutable ($name $value)\n$body)'; 111 return '$indentation(LetMutable ($name $value)\n$body)';
113 } 112 }
114 113
115 String formatArguments(CallStructure call, 114 String formatArguments(CallStructure call,
116 List<Reference<Primitive>> arguments, 115 List<Reference<Primitive>> arguments,
117 [CallingConvention callingConvention = CallingConvention.Normal]) { 116 [CallingConvention callingConvention = CallingConvention.Normal]) {
118 int positionalArgumentCount = call.positionalArgumentCount; 117 int positionalArgumentCount = call.positionalArgumentCount;
119 if (callingConvention == CallingConvention.Intercepted || 118 if (callingConvention == CallingConvention.Intercepted) {
120 callingConvention == CallingConvention.dummyIntercepted) {
121 ++positionalArgumentCount; 119 ++positionalArgumentCount;
122 } 120 }
123 List<String> args = 121 List<String> args =
124 arguments.take(positionalArgumentCount).map(access).toList(); 122 arguments.getRange(0, positionalArgumentCount).map(access).toList();
125 List<String> argumentNames = call.getOrderedNamedArguments(); 123 List<String> argumentNames = call.getOrderedNamedArguments();
126 for (int i = 0; i < argumentNames.length; ++i) { 124 for (int i = 0; i < argumentNames.length; ++i) {
127 String name = argumentNames[i]; 125 String name = argumentNames[i];
128 String arg = access(arguments[positionalArgumentCount + i]); 126 String arg = access(arguments[positionalArgumentCount + i]);
129 args.add("($name: $arg)"); 127 args.add("($name: $arg)");
130 } 128 }
131 // Constructors can have type parameter after the named arguments.
132 args.addAll(
133 arguments.skip(positionalArgumentCount + argumentNames.length)
134 .map(access));
135 return '(${args.join(' ')})'; 129 return '(${args.join(' ')})';
136 } 130 }
137 131
138 String visitInvokeStatic(InvokeStatic node) { 132 String visitInvokeStatic(InvokeStatic node) {
139 String name = node.target.name; 133 String name = node.target.name;
140 String args = formatArguments(node.selector.callStructure, node.arguments); 134 String args = formatArguments(node.selector.callStructure, node.arguments);
141 return '(InvokeStatic $name $args)'; 135 return '(InvokeStatic $name $args)';
142 } 136 }
143 137
144 String visitInvokeMethod(InvokeMethod node) { 138 String visitInvokeMethod(InvokeMethod node) {
(...skipping 24 matching lines...) Expand all
169 name = '${name}.${node.target.name}'; 163 name = '${name}.${node.target.name}';
170 } 164 }
171 String args = formatArguments(node.selector.callStructure, node.arguments); 165 String args = formatArguments(node.selector.callStructure, node.arguments);
172 return '(InvokeConstructor $name $args)'; 166 return '(InvokeConstructor $name $args)';
173 } 167 }
174 168
175 String visitInvokeContinuation(InvokeContinuation node) { 169 String visitInvokeContinuation(InvokeContinuation node) {
176 String name = access(node.continuation); 170 String name = access(node.continuation);
177 if (node.isRecursive) name = 'rec $name'; 171 if (node.isRecursive) name = 'rec $name';
178 String args = node.arguments.map(access).join(' '); 172 String args = node.arguments.map(access).join(' ');
179 String escaping = node.isEscapingTry ? ' escape' : ''; 173 return '$indentation(InvokeContinuation $name ($args))';
180 return '$indentation(InvokeContinuation $name ($args)$escaping)';
181 } 174 }
182 175
183 String visitThrow(Throw node) { 176 String visitThrow(Throw node) {
184 String value = access(node.value); 177 String value = access(node.value);
185 return '$indentation(Throw $value)'; 178 return '$indentation(Throw $value)';
186 } 179 }
187 180
188 String visitRethrow(Rethrow node) { 181 String visitRethrow(Rethrow node) {
189 return '$indentation(Rethrow)'; 182 return '$indentation(Rethrow)';
190 } 183 }
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 void setReturnContinuation(Continuation node) { 484 void setReturnContinuation(Continuation node) {
492 assert(!_names.containsKey(node) || _names[node] == 'return'); 485 assert(!_names.containsKey(node) || _names[node] == 'return');
493 _names[node] = 'return'; 486 _names[node] = 'return';
494 } 487 }
495 488
496 String getName(Node node) { 489 String getName(Node node) {
497 if (!_names.containsKey(node)) return 'MISSING_NAME'; 490 if (!_names.containsKey(node)) return 'MISSING_NAME';
498 return _names[node]; 491 return _names[node];
499 } 492 }
500 } 493 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart ('k') | pkg/compiler/lib/src/cps_ir/inline.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698