| 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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |