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 20 matching lines...) Expand all Loading... |
31 | 31 |
32 ConstantHandler(Compiler compiler, this.constantSystem) | 32 ConstantHandler(Compiler compiler, this.constantSystem) |
33 : initialVariableValues = new Map<VariableElement, dynamic>(), | 33 : initialVariableValues = new Map<VariableElement, dynamic>(), |
34 compiledConstants = new Set<Constant>(), | 34 compiledConstants = new Set<Constant>(), |
35 pendingVariables = new Set<VariableElement>(), | 35 pendingVariables = new Set<VariableElement>(), |
36 lazyStatics = new Set<VariableElement>(), | 36 lazyStatics = new Set<VariableElement>(), |
37 super(compiler); | 37 super(compiler); |
38 String get name => 'ConstantHandler'; | 38 String get name => 'ConstantHandler'; |
39 | 39 |
40 void registerCompileTimeConstant(Constant constant) { | 40 void registerCompileTimeConstant(Constant constant) { |
| 41 compiler.enqueuer.codegen.registerInstantiatedClass( |
| 42 constant.computeType(compiler).element); |
41 compiledConstants.add(constant); | 43 compiledConstants.add(constant); |
42 } | 44 } |
43 | 45 |
44 /** | 46 /** |
45 * Compiles the initial value of the given field and stores it in an internal | 47 * Compiles the initial value of the given field and stores it in an internal |
46 * map. Returns the initial value (a constant) if it can be computed | 48 * map. Returns the initial value (a constant) if it can be computed |
47 * statically. Returns [:null:] if the variable must be initialized lazily. | 49 * statically. Returns [:null:] if the variable must be initialized lazily. |
48 * | 50 * |
49 * [WorkItem] must contain a [VariableElement] refering to a global or | 51 * [WorkItem] must contain a [VariableElement] refering to a global or |
50 * static field. | 52 * static field. |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 // Use the default value. | 823 // Use the default value. |
822 fieldValue = compiler.compileConstant(field); | 824 fieldValue = compiler.compileConstant(field); |
823 } | 825 } |
824 jsNewArguments.add(fieldValue); | 826 jsNewArguments.add(fieldValue); |
825 }, | 827 }, |
826 includeBackendMembers: true, | 828 includeBackendMembers: true, |
827 includeSuperMembers: true); | 829 includeSuperMembers: true); |
828 return jsNewArguments; | 830 return jsNewArguments; |
829 } | 831 } |
830 } | 832 } |
OLD | NEW |