| 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 return constant; | 237 return constant; |
| 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 |
| 248 ConstantValue getConstantValue(ConstantExpression expression) { |
| 249 ConstantValue value = super.getConstantValue(expression); |
| 250 if (value == null && |
| 251 expression != null && |
| 252 expression.kind == ConstantExpressionKind.ERRONEOUS) { |
| 253 // TODO(johnniwinther): When the Dart constant system sees a constant |
| 254 // expression as erroneous but the JavaScript constant system finds it ok |
| 255 // we have store a constant value for the erroneous constant expression. |
| 256 // Ensure the computed constant expressions are always the same; that only |
| 257 // the constant values may be different. |
| 258 value = new NullConstantValue(); |
| 259 } |
| 260 return value; |
| 261 } |
| 247 } | 262 } |
| 248 | 263 |
| 249 class ForgetConstantElementVisitor | 264 class ForgetConstantElementVisitor |
| 250 extends BaseElementVisitor<dynamic, JavaScriptConstantCompiler> { | 265 extends BaseElementVisitor<dynamic, JavaScriptConstantCompiler> { |
| 251 const ForgetConstantElementVisitor(); | 266 const ForgetConstantElementVisitor(); |
| 252 | 267 |
| 253 void visitElement(Element e, JavaScriptConstantCompiler constants) { | 268 void visitElement(Element e, JavaScriptConstantCompiler constants) { |
| 254 for (MetadataAnnotation data in e.implementation.metadata) { | 269 for (MetadataAnnotation data in e.implementation.metadata) { |
| 255 constants.metadataConstantMap.remove(data); | 270 constants.metadataConstantMap.remove(data); |
| 256 if (data.hasNode) { | 271 if (data.hasNode) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 280 // TODO(ahe): This doesn't belong here. Rename this class and generalize. | 295 // TODO(ahe): This doesn't belong here. Rename this class and generalize. |
| 281 var closureClassMap = constants | 296 var closureClassMap = constants |
| 282 .compiler.closureToClassMapper.closureMappingCache | 297 .compiler.closureToClassMapper.closureMappingCache |
| 283 .remove(node); | 298 .remove(node); |
| 284 if (closureClassMap != null) { | 299 if (closureClassMap != null) { |
| 285 closureClassMap | 300 closureClassMap |
| 286 .removeMyselfFrom(constants.compiler.enqueuer.codegen.universe); | 301 .removeMyselfFrom(constants.compiler.enqueuer.codegen.universe); |
| 287 } | 302 } |
| 288 } | 303 } |
| 289 } | 304 } |
| OLD | NEW |