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

Side by Side Diff: lib/compiler/implementation/dart_backend/backend.dart

Issue 11090016: Change core lib, dart2js, and more for new optional parameters syntax (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class ElementAst { 5 class ElementAst {
6 final Node ast; 6 final Node ast;
7 final TreeElements treeElements; 7 final TreeElements treeElements;
8 8
9 ElementAst(this.ast, this.treeElements); 9 ElementAst(this.ast, this.treeElements);
10 10
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // As an idea: provide template as a Dart code---class C { C.name(); }--- 349 // As an idea: provide template as a Dart code---class C { C.name(); }---
350 // and then overwrite necessary parts. 350 // and then overwrite necessary parts.
351 SynthesizedConstructorElement constructor = 351 SynthesizedConstructorElement constructor =
352 new SynthesizedConstructorElement(classElement); 352 new SynthesizedConstructorElement(classElement);
353 constructor.type = new FunctionType( 353 constructor.type = new FunctionType(
354 compiler.types.voidType, const Link<DartType>(), 354 compiler.types.voidType, const Link<DartType>(),
355 constructor); 355 constructor);
356 constructor.cachedNode = new FunctionExpression( 356 constructor.cachedNode = new FunctionExpression(
357 new Send(receiver: classElement.parseNode(compiler).name, 357 new Send(receiver: classElement.parseNode(compiler).name,
358 selector: synthesizedIdentifier), 358 selector: synthesizedIdentifier),
359 new NodeList(beginToken: new StringToken(OPEN_PAREN_INFO, '(', -1), 359 new NodeList(new StringToken(OPEN_PAREN_INFO, '(', -1),
360 endToken: new StringToken(CLOSE_PAREN_INFO, ')', -1), 360 const Link<Node>(),
361 nodes: const Link<Node>()), 361 new StringToken(CLOSE_PAREN_INFO, ')', -1)),
362 new EmptyStatement(new StringToken(SEMICOLON_INFO, ';', -1)), 362 new EmptyStatement(new StringToken(SEMICOLON_INFO, ';', -1)),
363 null, Modifiers.EMPTY, null, null); 363 null, Modifiers.EMPTY, null, null);
364 364
365 classMembers[classElement].add(constructor); 365 classMembers[classElement].add(constructor);
366 elementAsts[constructor] = 366 elementAsts[constructor] =
367 new ElementAst(constructor.cachedNode, new TreeElementMapping()); 367 new ElementAst(constructor.cachedNode, new TreeElementMapping());
368 } 368 }
369 369
370 // Create all necessary placeholders. 370 // Create all necessary placeholders.
371 PlaceholderCollector collector = 371 PlaceholderCollector collector =
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 EmitterUnparser(this.renames); 462 EmitterUnparser(this.renames);
463 463
464 visit(Node node) { 464 visit(Node node) {
465 if (node !== null && renames.containsKey(node)) { 465 if (node !== null && renames.containsKey(node)) {
466 sb.add(renames[node]); 466 sb.add(renames[node]);
467 } else { 467 } else {
468 super.visit(node); 468 super.visit(node);
469 } 469 }
470 } 470 }
471 471
472 unparseSendReceiver(Send node, [bool spacesNeeded=false]) { 472 unparseSendReceiver(Send node, {bool spacesNeeded: false}) {
473 // TODO(smok): Remove ugly hack for library prefices. 473 // TODO(smok): Remove ugly hack for library prefices.
474 if (node.receiver !== null && renames[node.receiver] == '') return; 474 if (node.receiver !== null && renames[node.receiver] == '') return;
475 super.unparseSendReceiver(node, spacesNeeded); 475 super.unparseSendReceiver(node, spacesNeeded: spacesNeeded);
476 } 476 }
477 } 477 }
478 478
479 479
480 /** 480 /**
481 * Some elements are not recorded by resolver now, 481 * Some elements are not recorded by resolver now,
482 * for example, typedefs or classes which are only 482 * for example, typedefs or classes which are only
483 * used in signatures, as/is operators or in super clauses 483 * used in signatures, as/is operators or in super clauses
484 * (just to name a few). Retraverse AST to pick those up. 484 * (just to name a few). Retraverse AST to pick those up.
485 */ 485 */
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 536 }
537 537
538 compareElements(e0, e1) { 538 compareElements(e0, e1) {
539 int result = compareBy((e) => e.getLibrary().uri.toString())(e0, e1); 539 int result = compareBy((e) => e.getLibrary().uri.toString())(e0, e1);
540 if (result != 0) return result; 540 if (result != 0) return result;
541 return compareBy((e) => e.position().charOffset)(e0, e1); 541 return compareBy((e) => e.position().charOffset)(e0, e1);
542 } 542 }
543 543
544 List<Element> sortElements(Collection<Element> elements) => 544 List<Element> sortElements(Collection<Element> elements) =>
545 sorted(elements, compareElements); 545 sorted(elements, compareElements);
OLDNEW
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | lib/compiler/implementation/dart_backend/placeholder_collector.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698