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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/cps_ir/cps_ir_nodes.dart

Issue 658103003: Support map and list literals in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use LiteralMapEntry to ensure build order Created 6 years, 1 month 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // IrNodes are kept in a separate library to have precise control over their 5 // IrNodes are kept in a separate library to have precise control over their
6 // dependencies on other parts of the system. 6 // dependencies on other parts of the system.
7 library dart2js.ir_nodes; 7 library dart2js.ir_nodes;
8 8
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../constants/values.dart' as values show ConstantValue; 10 import '../constants/values.dart' as values show ConstantValue;
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 values.ConstantValue get constant => null; 474 values.ConstantValue get constant => null;
475 475
476 accept(Visitor visitor) => visitor.visitReifyTypeVar(this); 476 accept(Visitor visitor) => visitor.visitReifyTypeVar(this);
477 } 477 }
478 478
479 class LiteralList extends Primitive { 479 class LiteralList extends Primitive {
480 /// The List type being created; this is not the type argument. 480 /// The List type being created; this is not the type argument.
481 final GenericType type; 481 final GenericType type;
482 final List<Reference> values; 482 final List<Reference> values;
483 483
484 LiteralList(this.type, List<Primitive> values) 484 LiteralList(this.type, Iterable<Primitive> values)
485 : this.values = _referenceList(values); 485 : this.values = _referenceList(values);
486 486
487 accept(Visitor visitor) => visitor.visitLiteralList(this); 487 accept(Visitor visitor) => visitor.visitLiteralList(this);
488 } 488 }
489 489
490 class LiteralMapEntry {
491 final Reference key;
492 final Reference value;
493
494 LiteralMapEntry(Primitive key, Primitive value)
495 : this.key = new Reference(key),
496 this.value = new Reference(value);
497 }
498
490 class LiteralMap extends Primitive { 499 class LiteralMap extends Primitive {
491 final GenericType type; 500 final GenericType type;
492 final List<Reference> keys; 501 final List<LiteralMapEntry> entries;
493 final List<Reference> values;
494 502
495 LiteralMap(this.type, List<Primitive> keys, List<Primitive> values) 503 LiteralMap(this.type, this.entries);
496 : this.keys = _referenceList(keys),
497 this.values = _referenceList(values);
498 504
499 accept(Visitor visitor) => visitor.visitLiteralMap(this); 505 accept(Visitor visitor) => visitor.visitLiteralMap(this);
500 } 506 }
501 507
502 /// Create a non-recursive function. 508 /// Create a non-recursive function.
503 class CreateFunction extends Primitive { 509 class CreateFunction extends Primitive {
504 final FunctionDefinition definition; 510 final FunctionDefinition definition;
505 511
506 CreateFunction(this.definition); 512 CreateFunction(this.definition);
507 513
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 565
560 accept(Visitor visitor) => visitor.visitFunctionDefinition(this); 566 accept(Visitor visitor) => visitor.visitFunctionDefinition(this);
561 567
562 /// Returns `true` if this function is abstract. 568 /// Returns `true` if this function is abstract.
563 /// 569 ///
564 /// If `true`, [body] and [returnContinuation] are `null` and [localConstants] 570 /// If `true`, [body] and [returnContinuation] are `null` and [localConstants]
565 /// is empty. 571 /// is empty.
566 bool get isAbstract => body == null; 572 bool get isAbstract => body == null;
567 } 573 }
568 574
569 List<Reference> _referenceList(List<Definition> definitions) { 575 List<Reference> _referenceList(Iterable<Definition> definitions) {
570 return definitions.map((e) => new Reference(e)).toList(); 576 return definitions.map((e) => new Reference(e)).toList();
571 } 577 }
572 578
573 abstract class Visitor<T> { 579 abstract class Visitor<T> {
574 T visit(Node node) => node.accept(this); 580 T visit(Node node) => node.accept(this);
575 // Abstract classes. 581 // Abstract classes.
576 T visitNode(Node node) => null; 582 T visitNode(Node node) => null;
577 T visitExpression(Expression node) => visitNode(node); 583 T visitExpression(Expression node) => visitNode(node);
578 T visitDefinition(Definition node) => visitNode(node); 584 T visitDefinition(Definition node) => visitNode(node);
579 T visitPrimitive(Primitive node) => visitDefinition(node); 585 T visitPrimitive(Primitive node) => visitDefinition(node);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 730
725 processLiteralList(LiteralList node) {} 731 processLiteralList(LiteralList node) {}
726 visitLiteralList(LiteralList node) { 732 visitLiteralList(LiteralList node) {
727 processLiteralList(node); 733 processLiteralList(node);
728 node.values.forEach(processReference); 734 node.values.forEach(processReference);
729 } 735 }
730 736
731 processLiteralMap(LiteralMap node) {} 737 processLiteralMap(LiteralMap node) {}
732 visitLiteralMap(LiteralMap node) { 738 visitLiteralMap(LiteralMap node) {
733 processLiteralMap(node); 739 processLiteralMap(node);
734 for (int i = 0; i < node.keys.length; i++) { 740 for (LiteralMapEntry entry in node.entries) {
735 processReference(node.keys[i]); 741 processReference(entry.key);
736 processReference(node.values[i]); 742 processReference(entry.value);
737 } 743 }
738 } 744 }
739 745
740 processConstant(Constant node) {} 746 processConstant(Constant node) {}
741 visitConstant(Constant node) => processConstant(node); 747 visitConstant(Constant node) => processConstant(node);
742 748
743 processThis(This node) {} 749 processThis(This node) {}
744 visitThis(This node) => processThis(node); 750 visitThis(This node) => processThis(node);
745 751
746 processReifyTypeVar(ReifyTypeVar node) {} 752 processReifyTypeVar(ReifyTypeVar node) {}
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 885
880 void visitBranch(Branch node) { 886 void visitBranch(Branch node) {
881 visit(node.condition); 887 visit(node.condition);
882 } 888 }
883 889
884 void visitLiteralList(LiteralList node) { 890 void visitLiteralList(LiteralList node) {
885 node.values.forEach(visitReference); 891 node.values.forEach(visitReference);
886 } 892 }
887 893
888 void visitLiteralMap(LiteralMap node) { 894 void visitLiteralMap(LiteralMap node) {
889 for (int i = 0; i < node.keys.length; ++i) { 895 for (LiteralMapEntry entry in node.entries) {
890 visitReference(node.keys[i]); 896 visitReference(entry.key);
891 visitReference(node.values[i]); 897 visitReference(entry.value);
892 } 898 }
893 } 899 }
894 900
895 void visitTypeOperator(TypeOperator node) { 901 void visitTypeOperator(TypeOperator node) {
896 visitReference(node.receiver); 902 visitReference(node.receiver);
897 } 903 }
898 904
899 void visitConstant(Constant node) { 905 void visitConstant(Constant node) {
900 } 906 }
901 907
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 release(node.parameters[i]); 942 release(node.parameters[i]);
937 } 943 }
938 } 944 }
939 945
940 void visitIsTrue(IsTrue node) { 946 void visitIsTrue(IsTrue node) {
941 visitReference(node.value); 947 visitReference(node.value);
942 } 948 }
943 949
944 } 950 }
945 951
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698