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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 && value != null | 198 && value != null |
199 && element.isField()) { | 199 && element.isField()) { |
200 DartType elementType = element.computeType(compiler); | 200 DartType elementType = element.computeType(compiler); |
201 DartType constantType = value.computeType(compiler); | 201 DartType constantType = value.computeType(compiler); |
202 if (!constantSystem.isSubtype(compiler, constantType, elementType)) { | 202 if (!constantSystem.isSubtype(compiler, constantType, elementType)) { |
203 if (isConst) { | 203 if (isConst) { |
204 compiler.reportFatalError( | 204 compiler.reportFatalError( |
205 node, MessageKind.NOT_ASSIGNABLE.error, | 205 node, MessageKind.NOT_ASSIGNABLE.error, |
206 {'fromType': constantType, 'toType': elementType}); | 206 {'fromType': constantType, 'toType': elementType}); |
207 } else { | 207 } else { |
208 // If the field can be lazily initialized, we will throw | 208 // If the field cannot be lazily initialized, we will throw |
209 // the exception at runtime. | 209 // the exception at runtime. |
210 value = null; | 210 value = null; |
211 } | 211 } |
212 } | 212 } |
213 } | 213 } |
214 } | 214 } |
215 if (value != null) { | 215 if (value != null) { |
216 initialVariableValues[element] = value; | 216 initialVariableValues[element] = value; |
217 } else { | 217 } else { |
218 assert(!isConst); | 218 assert(!isConst); |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 if (fieldValue == null) { | 962 if (fieldValue == null) { |
963 // Use the default value. | 963 // Use the default value. |
964 fieldValue = handler.compileConstant(field); | 964 fieldValue = handler.compileConstant(field); |
965 } | 965 } |
966 jsNewArguments.add(fieldValue); | 966 jsNewArguments.add(fieldValue); |
967 }, | 967 }, |
968 includeSuperAndInjectedMembers: true); | 968 includeSuperAndInjectedMembers: true); |
969 return jsNewArguments; | 969 return jsNewArguments; |
970 } | 970 } |
971 } | 971 } |
OLD | NEW |