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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/compile_time_constants.dart

Issue 11740019: Fix issue 7677: recognize const declarations inside methods. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/language_dart2js.status » ('j') | 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) 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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 } else if (Elements.isStaticOrTopLevelField(element)) { 455 } else if (Elements.isStaticOrTopLevelField(element)) {
456 Constant result; 456 Constant result;
457 if (element.modifiers.isConst()) { 457 if (element.modifiers.isConst()) {
458 result = handler.compileConstant(element); 458 result = handler.compileConstant(element);
459 } else if (element.modifiers.isFinal() && !isEvaluatingConstant) { 459 } else if (element.modifiers.isFinal() && !isEvaluatingConstant) {
460 result = handler.compileVariable(element); 460 result = handler.compileVariable(element);
461 } 461 }
462 if (result != null) return result; 462 if (result != null) return result;
463 } else if (Elements.isClass(element) || Elements.isTypedef(element)) { 463 } else if (Elements.isClass(element) || Elements.isTypedef(element)) {
464 return makeTypeConstant(element); 464 return makeTypeConstant(element);
465 } else if (send.receiver != null) {
466 // Fall through to error handling.
467 } else if (!Elements.isUnresolved(element)
468 && element.isVariable()
469 && element.modifiers.isConst()) {
470 Constant result = handler.compileConstant(element);
471 if (result != null) return result;
465 } 472 }
466 return signalNotCompileTimeConstant(send); 473 return signalNotCompileTimeConstant(send);
467 } else if (send.isCall) { 474 } else if (send.isCall) {
468 if (identical(element, compiler.identicalFunction) 475 if (identical(element, compiler.identicalFunction)
469 && send.argumentCount() == 2) { 476 && send.argumentCount() == 2) {
470 Constant left = evaluate(send.argumentsNode.nodes.head); 477 Constant left = evaluate(send.argumentsNode.nodes.head);
471 Constant right = evaluate(send.argumentsNode.nodes.tail.head); 478 Constant right = evaluate(send.argumentsNode.nodes.tail.head);
472 Constant result = constantSystem.identity.fold(left, right); 479 Constant result = constantSystem.identity.fold(left, right);
473 if (result != null) return result; 480 if (result != null) return result;
474 } else if (Elements.isClass(element) || Elements.isTypedef(element)) { 481 } else if (Elements.isClass(element) || Elements.isTypedef(element)) {
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 // Use the default value. 877 // Use the default value.
871 fieldValue = handler.compileConstant(field); 878 fieldValue = handler.compileConstant(field);
872 } 879 }
873 jsNewArguments.add(fieldValue); 880 jsNewArguments.add(fieldValue);
874 }, 881 },
875 includeBackendMembers: true, 882 includeBackendMembers: true,
876 includeSuperMembers: true); 883 includeSuperMembers: true);
877 return jsNewArguments; 884 return jsNewArguments;
878 } 885 }
879 } 886 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/language_dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698