| 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 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 this.compiler, | 686 this.compiler, |
| 687 this.definitions); | 687 this.definitions); |
| 688 | 688 |
| 689 bool insideConstructor() => definitions !== null; | 689 bool insideConstructor() => definitions !== null; |
| 690 | 690 |
| 691 Constant evaluate(Node node) { | 691 Constant evaluate(Node node) { |
| 692 return node.accept(this); | 692 return node.accept(this); |
| 693 } | 693 } |
| 694 | 694 |
| 695 visitNode(Node node) { | 695 visitNode(Node node) { |
| 696 compiler.unimplemented("CompileTimeConstantEvaluator", node: node); | 696 error(node); |
| 697 } | 697 } |
| 698 | 698 |
| 699 Constant visitLiteralBool(LiteralBool node) { | 699 Constant visitLiteralBool(LiteralBool node) { |
| 700 // TODO(floitsch): make BoolConstant a factory and cache the two values | 700 // TODO(floitsch): make BoolConstant a factory and cache the two values |
| 701 // there. | 701 // there. |
| 702 return new BoolConstant(node.value); | 702 return new BoolConstant(node.value); |
| 703 } | 703 } |
| 704 | 704 |
| 705 Constant visitLiteralDouble(LiteralDouble node) { | 705 Constant visitLiteralDouble(LiteralDouble node) { |
| 706 return new DoubleConstant(node.value); | 706 return new DoubleConstant(node.value); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 | 1049 |
| 1050 | 1050 |
| 1051 compiler.registerInstantiatedClass(classElement); | 1051 compiler.registerInstantiatedClass(classElement); |
| 1052 // TODO(floitsch): take generic types into account. | 1052 // TODO(floitsch): take generic types into account. |
| 1053 Type type = classElement.computeType(compiler); | 1053 Type type = classElement.computeType(compiler); |
| 1054 Constant constant = new ConstructedConstant(type, jsNewArguments); | 1054 Constant constant = new ConstructedConstant(type, jsNewArguments); |
| 1055 constantHandler.registerCompileTimeConstant(constant); | 1055 constantHandler.registerCompileTimeConstant(constant); |
| 1056 return constant; | 1056 return constant; |
| 1057 } | 1057 } |
| 1058 | 1058 |
| 1059 Constant visitParenthesizedExpression(ParenthesizedExpression node) { |
| 1060 return node.expression.accept(this); |
| 1061 } |
| 1062 |
| 1059 error(Node node) { | 1063 error(Node node) { |
| 1060 // TODO(floitsch): get the list of constants that are currently compiled | 1064 // TODO(floitsch): get the list of constants that are currently compiled |
| 1061 // and present some kind of stack-trace. | 1065 // and present some kind of stack-trace. |
| 1062 MessageKind kind = MessageKind.NOT_A_COMPILE_TIME_CONSTANT; | 1066 MessageKind kind = MessageKind.NOT_A_COMPILE_TIME_CONSTANT; |
| 1063 compiler.reportError(node, new CompileTimeConstantError(kind, const [])); | 1067 compiler.reportError(node, new CompileTimeConstantError(kind, const [])); |
| 1064 } | 1068 } |
| 1065 } | 1069 } |
| OLD | NEW |