| 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 /** | 5 /** |
| 6 * The [ConstantHandler] keeps track of compile-time constants, | 6 * The [ConstantHandler] keeps track of compile-time constants, |
| 7 * initializations of global and static fields, and default values of | 7 * initializations of global and static fields, and default values of |
| 8 * optional parameters. | 8 * optional parameters. |
| 9 */ | 9 */ |
| 10 class ConstantHandler extends CompilerTask { | 10 class ConstantHandler extends CompilerTask { |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 Element element = elements[send]; | 391 Element element = elements[send]; |
| 392 if (send.isPropertyAccess) { | 392 if (send.isPropertyAccess) { |
| 393 if (Elements.isStaticOrTopLevelFunction(element)) { | 393 if (Elements.isStaticOrTopLevelFunction(element)) { |
| 394 compiler.codegenWorld.staticFunctionsNeedingGetter.add(element); | 394 compiler.codegenWorld.staticFunctionsNeedingGetter.add(element); |
| 395 Constant constant = new FunctionConstant(element); | 395 Constant constant = new FunctionConstant(element); |
| 396 compiler.constantHandler.registerCompileTimeConstant(constant); | 396 compiler.constantHandler.registerCompileTimeConstant(constant); |
| 397 compiler.enqueuer.codegen.registerStaticUse(element); | 397 compiler.enqueuer.codegen.registerStaticUse(element); |
| 398 return constant; | 398 return constant; |
| 399 } else if (Elements.isStaticOrTopLevelField(element)) { | 399 } else if (Elements.isStaticOrTopLevelField(element)) { |
| 400 Constant result; | 400 Constant result; |
| 401 if (element.modifiers !== null) { | 401 if (element.modifiers.isConst()) { |
| 402 if (element.modifiers.isConst()) { | 402 result = compiler.compileConstant(element); |
| 403 result = compiler.compileConstant(element); | 403 } else if (element.modifiers.isFinal() && !isEvaluatingConstant) { |
| 404 } else if (element.modifiers.isFinal() && !isEvaluatingConstant) { | 404 result = compiler.compileVariable(element); |
| 405 result = compiler.compileVariable(element); | |
| 406 } | |
| 407 } | 405 } |
| 408 if (result !== null) return result; | 406 if (result !== null) return result; |
| 409 } | 407 } |
| 410 return signalNotCompileTimeConstant(send); | 408 return signalNotCompileTimeConstant(send); |
| 411 } else if (send.isCall) { | 409 } else if (send.isCall) { |
| 412 if (element === compiler.identicalFunction && send.argumentCount() == 2) { | 410 if (element === compiler.identicalFunction && send.argumentCount() == 2) { |
| 413 Constant left = evaluate(send.argumentsNode.nodes.head); | 411 Constant left = evaluate(send.argumentsNode.nodes.head); |
| 414 Constant right = evaluate(send.argumentsNode.nodes.tail.head); | 412 Constant right = evaluate(send.argumentsNode.nodes.tail.head); |
| 415 Constant result = constantSystem.identity.fold(left, right); | 413 Constant result = constantSystem.identity.fold(left, right); |
| 416 if (result !== null) return result; | 414 if (result !== null) return result; |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 Constant fieldValue = fieldValues[field]; | 806 Constant fieldValue = fieldValues[field]; |
| 809 if (fieldValue === null) { | 807 if (fieldValue === null) { |
| 810 // Use the default value. | 808 // Use the default value. |
| 811 fieldValue = compiler.compileConstant(field); | 809 fieldValue = compiler.compileConstant(field); |
| 812 } | 810 } |
| 813 jsNewArguments.add(fieldValue); | 811 jsNewArguments.add(fieldValue); |
| 814 }); | 812 }); |
| 815 return jsNewArguments; | 813 return jsNewArguments; |
| 816 } | 814 } |
| 817 } | 815 } |
| OLD | NEW |