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

Side by Side Diff: pkg/compiler/lib/src/js/template.dart

Issue 750323003: Remove js.ArrayElement. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add parsing and testing of array holes, make lists non-growable 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 part of js; 5 part of js;
6 6
7 class TemplateManager { 7 class TemplateManager {
8 Map<String, Template> expressionTemplates = new Map<String, Template>(); 8 Map<String, Template> expressionTemplates = new Map<String, Template>();
9 Map<String, Template> statementTemplates = new Map<String, Template>(); 9 Map<String, Template> statementTemplates = new Map<String, Template>();
10 10
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 Instantiator visitLiteralString(LiteralString node) => 605 Instantiator visitLiteralString(LiteralString node) =>
606 (arguments) => new LiteralString(node.value); 606 (arguments) => new LiteralString(node.value);
607 607
608 Instantiator visitLiteralNumber(LiteralNumber node) => 608 Instantiator visitLiteralNumber(LiteralNumber node) =>
609 (arguments) => new LiteralNumber(node.value); 609 (arguments) => new LiteralNumber(node.value);
610 610
611 Instantiator visitLiteralNull(LiteralNull node) => 611 Instantiator visitLiteralNull(LiteralNull node) =>
612 (arguments) => new LiteralNull(); 612 (arguments) => new LiteralNull();
613 613
614 Instantiator visitArrayInitializer(ArrayInitializer node) { 614 Instantiator visitArrayInitializer(ArrayInitializer node) {
615 // Assume array has no missing elements.
616 // TODO(sra): Implement splicing? 615 // TODO(sra): Implement splicing?
617 List<Instantiator> elementMakers = node.elements 616 List<Instantiator> elementMakers = node.elements
618 .map((ArrayElement element) => visit(element.value)) 617 .map((Expression element) => visit(element))
floitsch 2014/12/01 13:03:29 .map(visit)
sigurdm 2014/12/02 09:27:31 Done.
619 .toList(); 618 .toList(growable: false);
620 return (arguments) { 619 return (arguments) {
621 List<ArrayElement> elements = <ArrayElement>[]; 620 List<Expression> elements = elementMakers.map(
floitsch 2014/12/01 13:03:29 move the ".map(" into the next line (hoping that i
sigurdm 2014/12/02 09:27:31 Done.
622 void add(Expression value) { 621 (Instantiator instantiator) => instantiator(arguments))
623 elements.add(new ArrayElement(elements.length, value)); 622 .toList(growable: false);
624 } 623 return new ArrayInitializer(elements);
625 for (Instantiator instantiator in elementMakers) {
626 var result = instantiator(arguments);
627 add(result);
628 }
629 return new ArrayInitializer(elements.length, elements);
630 }; 624 };
631 } 625 }
632 626
633 Instantiator visitArrayElement(ArrayElement node) { 627 Instantiator visitArrayHole(ArrayHole node) {
634 throw 'Should not get here'; // Handled in visitArrayInitializer. 628 return (arguments) => new ArrayHole();
635 } 629 }
636 630
637 Instantiator visitObjectInitializer(ObjectInitializer node) { 631 Instantiator visitObjectInitializer(ObjectInitializer node) {
638 List<Instantiator> propertyMakers = 632 List<Instantiator> propertyMakers =
639 node.properties.map(visitSplayable).toList(); 633 node.properties.map(visitSplayable).toList();
640 bool isOneLiner = node.isOneLiner; 634 bool isOneLiner = node.isOneLiner;
641 return (arguments) { 635 return (arguments) {
642 List<Property> properties = <Property>[]; 636 List<Property> properties = <Property>[];
643 for (Instantiator instantiator in propertyMakers) { 637 for (Instantiator instantiator in propertyMakers) {
644 var result = instantiator(arguments); 638 var result = instantiator(arguments);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 return null; 685 return null;
692 } 686 }
693 687
694 visitInterpolatedNode(InterpolatedNode node) { 688 visitInterpolatedNode(InterpolatedNode node) {
695 interpolatedNodes.add(node); 689 interpolatedNodes.add(node);
696 containsInterpolatedNode.add(node); 690 containsInterpolatedNode.add(node);
697 if (node.isNamed) holeNames.add(node.nameOrPosition); 691 if (node.isNamed) holeNames.add(node.nameOrPosition);
698 ++count; 692 ++count;
699 } 693 }
700 } 694 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698