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

Side by Side Diff: lib/compiler/implementation/compile_time_constants.dart

Issue 9976004: Allow all different string-literals in map literals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add description. Created 8 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
« no previous file with comments | « no previous file | lib/compiler/implementation/scanner/listener.dart » ('j') | 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) 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 Constant implements Hashable { 5 class Constant implements Hashable {
6 const Constant(); 6 const Constant();
7 7
8 bool isNull() => false; 8 bool isNull() => false;
9 bool isBool() => false; 9 bool isBool() => false;
10 bool isTrue() => false; 10 bool isTrue() => false;
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 732
733 Constant visitLiteralMap(LiteralMap node) { 733 Constant visitLiteralMap(LiteralMap node) {
734 if (!node.isConst()) error(node); 734 if (!node.isConst()) error(node);
735 List<StringConstant> keys = <StringConstant>[]; 735 List<StringConstant> keys = <StringConstant>[];
736 Map<StringConstant, Constant> map = new Map<StringConstant, Constant>(); 736 Map<StringConstant, Constant> map = new Map<StringConstant, Constant>();
737 for (Link<Node> link = node.entries.nodes; 737 for (Link<Node> link = node.entries.nodes;
738 !link.isEmpty(); 738 !link.isEmpty();
739 link = link.tail) { 739 link = link.tail) {
740 LiteralMapEntry entry = link.head; 740 LiteralMapEntry entry = link.head;
741 Constant key = evaluate(entry.key); 741 Constant key = evaluate(entry.key);
742 if (!key.isString() || entry.key.asLiteralString() === null) { 742 if (!key.isString() || entry.key.asStringNode() === null) {
743 MessageKind kind = MessageKind.KEY_NOT_A_STRING_LITERAL; 743 MessageKind kind = MessageKind.KEY_NOT_A_STRING_LITERAL;
744 compiler.reportError(entry.key, new ResolutionError(kind, const [])); 744 compiler.reportError(entry.key, new ResolutionError(kind, const []));
745 } 745 }
746 StringConstant keyConstant = key; 746 StringConstant keyConstant = key;
747 if (!map.containsKey(key)) keys.add(key); 747 if (!map.containsKey(key)) keys.add(key);
748 map[key] = evaluate(entry.value); 748 map[key] = evaluate(entry.value);
749 } 749 }
750 List<Constant> values = <Constant>[]; 750 List<Constant> values = <Constant>[];
751 Constant protoValue = null; 751 Constant protoValue = null;
752 for (StringConstant key in keys) { 752 for (StringConstant key in keys) {
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 Constant fieldValue = fieldValues[field]; 1125 Constant fieldValue = fieldValues[field];
1126 if (fieldValue === null) { 1126 if (fieldValue === null) {
1127 // Use the default value. 1127 // Use the default value.
1128 fieldValue = compiler.compileVariable(field); 1128 fieldValue = compiler.compileVariable(field);
1129 } 1129 }
1130 jsNewArguments.add(fieldValue); 1130 jsNewArguments.add(fieldValue);
1131 }); 1131 });
1132 return jsNewArguments; 1132 return jsNewArguments;
1133 } 1133 }
1134 } 1134 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/scanner/listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698