OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |