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

Side by Side Diff: tests/compiler/dart2js/backend_dart/sexpr_unstringifier.dart

Issue 810783002: Clean up FunctionDefinition in the IR S-expression representation. (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
« no previous file with comments | « tests/compiler/dart2js/backend_dart/opt_shrinking_test.dart ('k') | no next file » | 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 // SExpressionUnstringifier implements the inverse operation to 5 // SExpressionUnstringifier implements the inverse operation to
6 // [SExpressionStringifier]. 6 // [SExpressionStringifier].
7 7
8 library sexpr_unstringifier; 8 library sexpr_unstringifier;
9 9
10 import 'package:compiler/src/constants/expressions.dart' 10 import 'package:compiler/src/constants/expressions.dart'
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 tokens.consumeEnd(); 264 tokens.consumeEnd();
265 return prims; 265 return prims;
266 } 266 }
267 267
268 /// (FunctionDefinition name (args cont) body) 268 /// (FunctionDefinition name (args cont) body)
269 FunctionDefinition parseFunctionDefinition() { 269 FunctionDefinition parseFunctionDefinition() {
270 tokens.consumeStart(FUNCTION_DEFINITION); 270 tokens.consumeStart(FUNCTION_DEFINITION);
271 271
272 // name 272 // name
273 Element element = new DummyElement(""); 273 Element element = new DummyElement("");
274 if (tokens.current != '(' && tokens.current != '{') { 274 if (tokens.current != '(') {
275 // This is a named function. 275 // This is a named function.
276 element = new DummyElement(tokens.read()); 276 element = new DummyElement(tokens.read());
277 } 277 }
278 278
279 // [closure-vars] 279 // (parameters)
280 List<ClosureVariable> closureVariables = <ClosureVariable>[];
281 if (tokens.current == '{') {
282 tokens.read('{');
283 while (tokens.current != '}') {
284 String varName = tokens.read();
285 ClosureVariable variable =
286 new ClosureVariable(element, new DummyElement(varName));
287 closureVariables.add(variable);
288 name2variable[varName] = variable;
289 }
290 tokens.read('}');
291 }
292
293 // (args cont)
294 List<Definition> parameters = <Definition>[]; 280 List<Definition> parameters = <Definition>[];
295 tokens.consumeStart(); 281 tokens.consumeStart();
296 while (tokens.next != ")") { 282 while (tokens.current != ")") {
297 String paramName = tokens.read(); 283 String paramName = tokens.read();
298 if (name2variable.containsKey(paramName)) { 284 if (name2variable.containsKey(paramName)) {
299 parameters.add(name2variable[paramName]); 285 parameters.add(name2variable[paramName]);
300 } else { 286 } else {
301 Parameter param = new Parameter(new DummyElement(paramName)); 287 Parameter param = new Parameter(new DummyElement(paramName));
302 name2variable[paramName] = param; 288 name2variable[paramName] = param;
303 parameters.add(param); 289 parameters.add(param);
304 } 290 }
305 } 291 }
292 tokens.consumeEnd();
306 293
294 // continuation
307 String contName = tokens.read("return"); 295 String contName = tokens.read("return");
308 Continuation cont = name2variable[contName]; 296 Continuation cont = name2variable[contName];
309 assert(cont != null); 297 assert(cont != null);
298
299 // [closure-variables]
300 List<ClosureVariable> closureVariables = <ClosureVariable>[];
301 tokens.consumeStart();
302 while (tokens.current != ')') {
303 String varName = tokens.read();
304 ClosureVariable variable =
305 new ClosureVariable(element, new DummyElement(varName));
306 closureVariables.add(variable);
307 name2variable[varName] = variable;
308 }
310 tokens.consumeEnd(); 309 tokens.consumeEnd();
311 310
312 // body 311 // body
313 Expression body = parseExpression(); 312 Expression body = parseExpression();
314 313
315 tokens.consumeEnd(); 314 tokens.consumeEnd();
316 return new FunctionDefinition(element, cont, parameters, body, null, null, 315 return new FunctionDefinition(element, cont, parameters, body, null, null,
317 closureVariables); 316 closureVariables);
318 } 317 }
319 318
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 return new ReifyTypeVar(type); 702 return new ReifyTypeVar(type);
704 } 703 }
705 704
706 /// (This) 705 /// (This)
707 This parseThis() { 706 This parseThis() {
708 tokens.consumeStart(THIS); 707 tokens.consumeStart(THIS);
709 tokens.consumeEnd(); 708 tokens.consumeEnd();
710 return new This(); 709 return new This();
711 } 710 }
712 } 711 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/backend_dart/opt_shrinking_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698