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

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

Issue 11358141: Do not always error-out when evaluating a map that is not a compile time constant. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
« no previous file with comments | « no previous file | tests/language/lazy_map_test.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 part of dart2js; 5 part of dart2js;
6 6
7 /** 7 /**
8 * The [ConstantHandler] keeps track of compile-time constants, 8 * The [ConstantHandler] keeps track of compile-time constants,
9 * initializations of global and static fields, and default values of 9 * initializations of global and static fields, and default values of
10 * optional parameters. 10 * optional parameters.
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 } 294 }
295 // TODO(floitsch): get type parameters. 295 // TODO(floitsch): get type parameters.
296 DartType type = new InterfaceType(compiler.listClass); 296 DartType type = new InterfaceType(compiler.listClass);
297 Constant constant = new ListConstant(type, arguments); 297 Constant constant = new ListConstant(type, arguments);
298 compiler.constantHandler.registerCompileTimeConstant(constant); 298 compiler.constantHandler.registerCompileTimeConstant(constant);
299 return constant; 299 return constant;
300 } 300 }
301 301
302 Constant visitLiteralMap(LiteralMap node) { 302 Constant visitLiteralMap(LiteralMap node) {
303 if (!node.isConst()) { 303 if (!node.isConst()) {
304 signalNotCompileTimeConstant(node); 304 return signalNotCompileTimeConstant(node);
305 error(node);
306 } 305 }
307 List<StringConstant> keys = <StringConstant>[]; 306 List<StringConstant> keys = <StringConstant>[];
308 Map<StringConstant, Constant> map = new Map<StringConstant, Constant>(); 307 Map<StringConstant, Constant> map = new Map<StringConstant, Constant>();
309 for (Link<Node> link = node.entries.nodes; 308 for (Link<Node> link = node.entries.nodes;
310 !link.isEmpty; 309 !link.isEmpty;
311 link = link.tail) { 310 link = link.tail) {
312 LiteralMapEntry entry = link.head; 311 LiteralMapEntry entry = link.head;
313 Constant key = evaluateConstant(entry.key); 312 Constant key = evaluateConstant(entry.key);
314 if (!key.isString() || entry.key.asStringNode() == null) { 313 if (!key.isString() || entry.key.asStringNode() == null) {
315 MessageKind kind = MessageKind.KEY_NOT_A_STRING_LITERAL; 314 MessageKind kind = MessageKind.KEY_NOT_A_STRING_LITERAL;
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 // Use the default value. 809 // Use the default value.
811 fieldValue = compiler.compileConstant(field); 810 fieldValue = compiler.compileConstant(field);
812 } 811 }
813 jsNewArguments.add(fieldValue); 812 jsNewArguments.add(fieldValue);
814 }, 813 },
815 includeBackendMembers: true, 814 includeBackendMembers: true,
816 includeSuperMembers: true); 815 includeSuperMembers: true);
817 return jsNewArguments; 816 return jsNewArguments;
818 } 817 }
819 } 818 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/lazy_map_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698