| 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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 result = compiler.compileVariable(element); | 398 result = compiler.compileVariable(element); |
| 399 } | 399 } |
| 400 } | 400 } |
| 401 if (result == null) return signalNotCompileTimeConstant(send); | 401 if (result == null) return signalNotCompileTimeConstant(send); |
| 402 return result; | 402 return result; |
| 403 } else if (Elements.isStaticOrTopLevelFunction(element) | 403 } else if (Elements.isStaticOrTopLevelFunction(element) |
| 404 && send.isPropertyAccess) { | 404 && send.isPropertyAccess) { |
| 405 compiler.codegenWorld.staticFunctionsNeedingGetter.add(element); | 405 compiler.codegenWorld.staticFunctionsNeedingGetter.add(element); |
| 406 Constant constant = new FunctionConstant(element); | 406 Constant constant = new FunctionConstant(element); |
| 407 compiler.constantHandler.registerCompileTimeConstant(constant); | 407 compiler.constantHandler.registerCompileTimeConstant(constant); |
| 408 compiler.enqueuer.codegen.registerStaticUse(element); |
| 408 return constant; | 409 return constant; |
| 409 } else if (send.isPrefix) { | 410 } else if (send.isPrefix) { |
| 410 assert(send.isOperator); | 411 assert(send.isOperator); |
| 411 Constant receiverConstant = evaluate(send.receiver); | 412 Constant receiverConstant = evaluate(send.receiver); |
| 412 if (receiverConstant == null) return null; | 413 if (receiverConstant == null) return null; |
| 413 Operator op = send.selector; | 414 Operator op = send.selector; |
| 414 Constant folded; | 415 Constant folded; |
| 415 switch (op.source.stringValue) { | 416 switch (op.source.stringValue) { |
| 416 case "!": | 417 case "!": |
| 417 folded = constantSystem.not.fold(receiverConstant); | 418 folded = constantSystem.not.fold(receiverConstant); |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 Constant fieldValue = fieldValues[field]; | 778 Constant fieldValue = fieldValues[field]; |
| 778 if (fieldValue === null) { | 779 if (fieldValue === null) { |
| 779 // Use the default value. | 780 // Use the default value. |
| 780 fieldValue = compiler.compileConstant(field); | 781 fieldValue = compiler.compileConstant(field); |
| 781 } | 782 } |
| 782 jsNewArguments.add(fieldValue); | 783 jsNewArguments.add(fieldValue); |
| 783 }); | 784 }); |
| 784 return jsNewArguments; | 785 return jsNewArguments; |
| 785 } | 786 } |
| 786 } | 787 } |
| OLD | NEW |