Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 } |
| OLD | NEW |