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

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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 return constant; 454 return constant;
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);
ahe 2013/01/03 14:09:26 To ease my mind, could you add this: } else if (s
ngeoffray 2013/01/08 14:36:11 This is not easing mine :) Where do you want to pu
ahe 2013/01/18 11:07:11 Right here, before the new code.
ngeoffray 2013/01/18 11:15:30 Done.
465 } else if (!Elements.isUnresolved(element)
466 && element.isVariable()
467 && element.modifiers.isConst()) {
468 Constant result = handler.compileConstant(element);
469 if (result != null) return result;
465 } 470 }
466 return signalNotCompileTimeConstant(send); 471 return signalNotCompileTimeConstant(send);
467 } else if (send.isCall) { 472 } else if (send.isCall) {
468 if (identical(element, compiler.identicalFunction) 473 if (identical(element, compiler.identicalFunction)
469 && send.argumentCount() == 2) { 474 && send.argumentCount() == 2) {
470 Constant left = evaluate(send.argumentsNode.nodes.head); 475 Constant left = evaluate(send.argumentsNode.nodes.head);
471 Constant right = evaluate(send.argumentsNode.nodes.tail.head); 476 Constant right = evaluate(send.argumentsNode.nodes.tail.head);
472 Constant result = constantSystem.identity.fold(left, right); 477 Constant result = constantSystem.identity.fold(left, right);
473 if (result != null) return result; 478 if (result != null) return result;
474 } else if (Elements.isClass(element) || Elements.isTypedef(element)) { 479 } 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. 875 // Use the default value.
871 fieldValue = handler.compileConstant(field); 876 fieldValue = handler.compileConstant(field);
872 } 877 }
873 jsNewArguments.add(fieldValue); 878 jsNewArguments.add(fieldValue);
874 }, 879 },
875 includeBackendMembers: true, 880 includeBackendMembers: true,
876 includeSuperMembers: true); 881 includeSuperMembers: true);
877 return jsNewArguments; 882 return jsNewArguments;
878 } 883 }
879 } 884 }
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