| 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 class Constant implements Hashable { | 5 class Constant implements Hashable { |
| 6 const Constant(); | 6 const Constant(); |
| 7 | 7 |
| 8 bool isNull() => false; | 8 bool isNull() => false; |
| 9 bool isBool() => false; | 9 bool isBool() => false; |
| 10 bool isTrue() => false; | 10 bool isTrue() => false; |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 } | 762 } |
| 763 | 763 |
| 764 Constant visitLiteralNull(LiteralNull node) { | 764 Constant visitLiteralNull(LiteralNull node) { |
| 765 return new NullConstant(); | 765 return new NullConstant(); |
| 766 } | 766 } |
| 767 | 767 |
| 768 Constant visitLiteralString(LiteralString node) { | 768 Constant visitLiteralString(LiteralString node) { |
| 769 return new StringConstant(node.dartString); | 769 return new StringConstant(node.dartString); |
| 770 } | 770 } |
| 771 | 771 |
| 772 Constant visitStringJuxtaposition(StringJuxtaposition node) { |
| 773 if (!node.isInterpolation) { |
| 774 return new StringConstant(node.dartString); |
| 775 } |
| 776 return super.visitStringJuxtaposition(node); |
| 777 } |
| 778 |
| 772 // TODO(floitsch): provide better error-messages. | 779 // TODO(floitsch): provide better error-messages. |
| 773 Constant visitSend(Send send) { | 780 Constant visitSend(Send send) { |
| 774 Element element = elements[send]; | 781 Element element = elements[send]; |
| 775 if (Elements.isStaticOrTopLevelField(element)) { | 782 if (Elements.isStaticOrTopLevelField(element)) { |
| 776 if (element.modifiers === null || | 783 if (element.modifiers === null || |
| 777 !element.modifiers.isFinal()) { | 784 !element.modifiers.isFinal()) { |
| 778 error(send); | 785 error(send); |
| 779 } | 786 } |
| 780 return constantHandler.compileVariable(element); | 787 return constantHandler.compileVariable(element); |
| 781 } else if (send.isPrefix) { | 788 } else if (send.isPrefix) { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 initializerEvaluator, | 1010 initializerEvaluator, |
| 1004 constructorElements, | 1011 constructorElements, |
| 1005 constructorDefinitions, | 1012 constructorDefinitions, |
| 1006 fieldValues); | 1013 fieldValues); |
| 1007 } | 1014 } |
| 1008 List<Constant> jsNewArguments = | 1015 List<Constant> jsNewArguments = |
| 1009 buildJsNewArguments(classElement, fieldValues); | 1016 buildJsNewArguments(classElement, fieldValues); |
| 1010 | 1017 |
| 1011 compiler.registerInstantiatedClass(classElement); | 1018 compiler.registerInstantiatedClass(classElement); |
| 1012 // TODO(floitsch): take generic types into account. | 1019 // TODO(floitsch): take generic types into account. |
| 1013 Type type = classElement.computeType(compiler); | 1020 Type type = classElement.computeType(compiler); |
| 1014 Constant constant = new ConstructedConstant(type, jsNewArguments); | 1021 Constant constant = new ConstructedConstant(type, jsNewArguments); |
| 1015 constantHandler.registerCompileTimeConstant(constant); | 1022 constantHandler.registerCompileTimeConstant(constant); |
| 1016 return constant; | 1023 return constant; |
| 1017 } | 1024 } |
| 1018 | 1025 |
| 1019 error(Node node) { | 1026 error(Node node) { |
| 1020 // TODO(floitsch): get the list of constants that are currently compiled | 1027 // TODO(floitsch): get the list of constants that are currently compiled |
| 1021 // and present some kind of stack-trace. | 1028 // and present some kind of stack-trace. |
| 1022 MessageKind kind = MessageKind.NOT_A_COMPILE_TIME_CONSTANT; | 1029 MessageKind kind = MessageKind.NOT_A_COMPILE_TIME_CONSTANT; |
| 1023 compiler.reportError(node, new CompileTimeConstantError(kind, const [])); | 1030 compiler.reportError(node, new CompileTimeConstantError(kind, const [])); |
| 1024 } | 1031 } |
| 1025 } | 1032 } |
| OLD | NEW |