| 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 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 accumulator = new DartString.concat(accumulator, partString.value); | 832 accumulator = new DartString.concat(accumulator, partString.value); |
| 833 }; | 833 }; |
| 834 return new StringConstant(accumulator, node); | 834 return new StringConstant(accumulator, node); |
| 835 } | 835 } |
| 836 | 836 |
| 837 // TODO(floitsch): provide better error-messages. | 837 // TODO(floitsch): provide better error-messages. |
| 838 Constant visitSend(Send send) { | 838 Constant visitSend(Send send) { |
| 839 Element element = elements[send]; | 839 Element element = elements[send]; |
| 840 if (Elements.isStaticOrTopLevelField(element)) { | 840 if (Elements.isStaticOrTopLevelField(element)) { |
| 841 if (element.modifiers === null || | 841 if (element.modifiers === null || |
| 842 !element.modifiers.isFinal()) { | 842 // TODO(johnniwinther): This should eventually be [isConst]. |
| 843 !element.modifiers.isFinalOrConst()) { |
| 843 error(send); | 844 error(send); |
| 844 } | 845 } |
| 845 return compiler.compileVariable(element); | 846 return compiler.compileVariable(element); |
| 846 } else if (send.isPrefix) { | 847 } else if (send.isPrefix) { |
| 847 assert(send.isOperator); | 848 assert(send.isOperator); |
| 848 Constant receiverConstant = evaluate(send.receiver); | 849 Constant receiverConstant = evaluate(send.receiver); |
| 849 Operator op = send.selector; | 850 Operator op = send.selector; |
| 850 Constant folded; | 851 Constant folded; |
| 851 switch (op.source.stringValue) { | 852 switch (op.source.stringValue) { |
| 852 case "!": | 853 case "!": |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 Constant fieldValue = fieldValues[field]; | 1170 Constant fieldValue = fieldValues[field]; |
| 1170 if (fieldValue === null) { | 1171 if (fieldValue === null) { |
| 1171 // Use the default value. | 1172 // Use the default value. |
| 1172 fieldValue = compiler.compileVariable(field); | 1173 fieldValue = compiler.compileVariable(field); |
| 1173 } | 1174 } |
| 1174 jsNewArguments.add(fieldValue); | 1175 jsNewArguments.add(fieldValue); |
| 1175 }); | 1176 }); |
| 1176 return jsNewArguments; | 1177 return jsNewArguments; |
| 1177 } | 1178 } |
| 1178 } | 1179 } |
| OLD | NEW |