Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: pkg/compiler/lib/src/js_backend/constant_handler_javascript.dart

Issue 1927533002: Handle discrepancy Dart and JS constant expressions. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698