OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 js_backend; | 5 part of js_backend; |
6 | 6 |
7 /// [ConstantCompilerTask] for compilation of constants for the JavaScript | 7 /// [ConstantCompilerTask] for compilation of constants for the JavaScript |
8 /// backend. | 8 /// backend. |
9 /// | 9 /// |
10 /// Since this task needs to distinguish between frontend and backend constants | 10 /// Since this task needs to distinguish between frontend and backend constants |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } | 238 } |
239 | 239 |
240 void forgetElement(Element element) { | 240 void forgetElement(Element element) { |
241 super.forgetElement(element); | 241 super.forgetElement(element); |
242 const ForgetConstantElementVisitor().visit(element, this); | 242 const ForgetConstantElementVisitor().visit(element, this); |
243 if (element is AstElement && element.hasNode) { | 243 if (element is AstElement && element.hasNode) { |
244 element.node.accept(new ForgetConstantNodeVisitor(this)); | 244 element.node.accept(new ForgetConstantNodeVisitor(this)); |
245 } | 245 } |
246 } | 246 } |
247 | 247 |
| 248 @override |
248 ConstantValue getConstantValue(ConstantExpression expression) { | 249 ConstantValue getConstantValue(ConstantExpression expression) { |
| 250 assert(invariant(CURRENT_ELEMENT_SPANNABLE, expression != null, |
| 251 message: "ConstantExpression is null in getConstantValue.")); |
| 252 evaluate(expression); |
249 ConstantValue value = super.getConstantValue(expression); | 253 ConstantValue value = super.getConstantValue(expression); |
250 if (value == null && | 254 if (value == null && |
251 expression != null && | 255 expression != null && |
252 expression.kind == ConstantExpressionKind.ERRONEOUS) { | 256 expression.kind == ConstantExpressionKind.ERRONEOUS) { |
253 // TODO(johnniwinther): When the Dart constant system sees a constant | 257 // TODO(johnniwinther): When the Dart constant system sees a constant |
254 // expression as erroneous but the JavaScript constant system finds it ok | 258 // expression as erroneous but the JavaScript constant system finds it ok |
255 // we have store a constant value for the erroneous constant expression. | 259 // we have store a constant value for the erroneous constant expression. |
256 // Ensure the computed constant expressions are always the same; that only | 260 // Ensure the computed constant expressions are always the same; that only |
257 // the constant values may be different. | 261 // the constant values may be different. |
258 value = new NullConstantValue(); | 262 value = new NullConstantValue(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 // TODO(ahe): This doesn't belong here. Rename this class and generalize. | 299 // TODO(ahe): This doesn't belong here. Rename this class and generalize. |
296 var closureClassMap = constants | 300 var closureClassMap = constants |
297 .compiler.closureToClassMapper.closureMappingCache | 301 .compiler.closureToClassMapper.closureMappingCache |
298 .remove(node); | 302 .remove(node); |
299 if (closureClassMap != null) { | 303 if (closureClassMap != null) { |
300 closureClassMap | 304 closureClassMap |
301 .removeMyselfFrom(constants.compiler.enqueuer.codegen.universe); | 305 .removeMyselfFrom(constants.compiler.enqueuer.codegen.universe); |
302 } | 306 } |
303 } | 307 } |
304 } | 308 } |
OLD | NEW |