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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 13467021: Register type for literal list/map. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 part of resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 Element get currentElement; 8 Element get currentElement;
9 Set<Node> get superUses; 9 Set<Node> get superUses;
10 10
(...skipping 2600 matching lines...) Expand 10 before | Expand all | Expand 10 after
2611 error(nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); 2611 error(nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT);
2612 resolveTypeRequired(nodes.head); 2612 resolveTypeRequired(nodes.head);
2613 } 2613 }
2614 } 2614 }
2615 } 2615 }
2616 DartType listType; 2616 DartType listType;
2617 if (typeArgument != null) { 2617 if (typeArgument != null) {
2618 listType = new InterfaceType(compiler.listClass, 2618 listType = new InterfaceType(compiler.listClass,
2619 new Link<DartType>.fromList([typeArgument])); 2619 new Link<DartType>.fromList([typeArgument]));
2620 } else { 2620 } else {
2621 compiler.listClass.computeType(compiler);
2621 listType = compiler.listClass.rawType; 2622 listType = compiler.listClass.rawType;
2622 } 2623 }
2624 mapping.setType(node, listType);
2623 world.registerInstantiatedType(listType, mapping); 2625 world.registerInstantiatedType(listType, mapping);
2624 visit(node.elements); 2626 visit(node.elements);
2625 } 2627 }
2626 2628
2627 visitConditional(Conditional node) { 2629 visitConditional(Conditional node) {
2628 node.visitChildren(this); 2630 node.visitChildren(this);
2629 } 2631 }
2630 2632
2631 visitStringInterpolation(StringInterpolation node) { 2633 visitStringInterpolation(StringInterpolation node) {
2632 world.registerInstantiatedClass(compiler.stringClass, mapping); 2634 world.registerInstantiatedClass(compiler.stringClass, mapping);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2768 } 2770 }
2769 }); 2771 });
2770 if (!targetElement.isTarget && identical(mapping[body], targetElement)) { 2772 if (!targetElement.isTarget && identical(mapping[body], targetElement)) {
2771 // If the body is itself a break or continue for another target, it 2773 // If the body is itself a break or continue for another target, it
2772 // might have updated its mapping to the target it actually does target. 2774 // might have updated its mapping to the target it actually does target.
2773 mapping.remove(body); 2775 mapping.remove(body);
2774 } 2776 }
2775 } 2777 }
2776 2778
2777 visitLiteralMap(LiteralMap node) { 2779 visitLiteralMap(LiteralMap node) {
2780 NodeList arguments = node.typeArguments;
2781 DartType keyTypeArgument;
2782 DartType valueTypeArgument;
2783 if (arguments != null) {
2784 Link<Node> nodes = arguments.nodes;
2785 if (nodes.isEmpty) {
2786 error(arguments, MessageKind.MISSING_TYPE_ARGUMENT);
2787 } else {
2788 keyTypeArgument = resolveTypeRequired(nodes.head);
2789 nodes = nodes.tail;
2790 if (nodes.isEmpty) {
2791 error(arguments, MessageKind.MISSING_TYPE_ARGUMENT);
2792 } else {
2793 valueTypeArgument = resolveTypeRequired(nodes.head);
2794 for (nodes = nodes.tail; !nodes.isEmpty; nodes = nodes.tail) {
2795 error(nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT);
2796 resolveTypeRequired(nodes.head);
2797 }
2798 }
2799 }
2800 }
2801 DartType mapType;
2802 if (valueTypeArgument != null) {
2803 mapType = new InterfaceType(compiler.mapClass,
2804 new Link<DartType>.fromList([keyTypeArgument, valueTypeArgument]));
2805 } else {
2806 compiler.mapClass.computeType(compiler);
2807 mapType = compiler.mapClass.rawType;
2808 }
2809 mapping.setType(node, mapType);
2778 world.registerInstantiatedClass(compiler.mapClass, mapping); 2810 world.registerInstantiatedClass(compiler.mapClass, mapping);
2779 if (node.isConst()) { 2811 if (node.isConst()) {
2780 compiler.backend.registerConstantMap(mapping); 2812 compiler.backend.registerConstantMap(mapping);
2781 } 2813 }
2782 node.visitChildren(this); 2814 node.visitChildren(this);
2783 } 2815 }
2784 2816
2785 visitLiteralMapEntry(LiteralMapEntry node) { 2817 visitLiteralMapEntry(LiteralMapEntry node) {
2786 node.visitChildren(this); 2818 node.visitChildren(this);
2787 } 2819 }
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
3842 return e; 3874 return e;
3843 } 3875 }
3844 3876
3845 /// Assumed to be called by [resolveRedirectingFactory]. 3877 /// Assumed to be called by [resolveRedirectingFactory].
3846 Element visitReturn(Return node) { 3878 Element visitReturn(Return node) {
3847 Node expression = node.expression; 3879 Node expression = node.expression;
3848 return finishConstructorReference(visit(expression), 3880 return finishConstructorReference(visit(expression),
3849 expression, expression); 3881 expression, expression);
3850 } 3882 }
3851 } 3883 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698