Chromium Code Reviews| Index: lib/compiler/implementation/compile_time_constants.dart |
| diff --git a/lib/compiler/implementation/compile_time_constants.dart b/lib/compiler/implementation/compile_time_constants.dart |
| index 6fde51a2fe69b7596e76ba03acf3bfb4394d552f..12f5ad6056f37b36e272fe1afe525833566f8b74 100644 |
| --- a/lib/compiler/implementation/compile_time_constants.dart |
| +++ b/lib/compiler/implementation/compile_time_constants.dart |
| @@ -24,6 +24,8 @@ class Constant implements Hashable { |
| bool isNaN() => false; |
| + abstract DartType computeType(ConstantHandler handler); |
|
ngeoffray
2012/09/06 09:28:55
Please take a Compiler here instead of the Constan
Lasse Reichstein Nielsen
2012/09/06 12:03:36
Good point. I was trying to not make Constant depe
Lasse Reichstein Nielsen
2012/09/11 12:20:23
Done by someone else. Yey.
|
| + |
| abstract void _writeJsCode(CodeBuffer buffer, ConstantHandler handler); |
| /** |
| * Unless the constant can be emitted multiple times (as for numbers and |
| @@ -94,6 +96,9 @@ class NullConstant extends PrimitiveConstant { |
| const NullConstant._internal(); |
| bool isNull() => true; |
| get value => null; |
| + DartType computeType(ConstantHandler handler) { |
| + return handler.compiler.nullClass.computeType(handler.compiler); |
| + } |
| void _writeJsCode(CodeBuffer buffer, ConstantHandler handler) { |
| buffer.add(JsNull); |
| @@ -133,6 +138,10 @@ class IntConstant extends NumConstant { |
| const IntConstant._internal(this.value); |
| bool isInt() => true; |
| + DartType computeType(ConstantHandler handler) { |
| + return handler.compiler.intClass.computeType(handler.compiler); |
| + } |
| + |
| void _writeJsCode(CodeBuffer buffer, ConstantHandler handler) { |
| buffer.add("$value"); |
| } |
| @@ -172,6 +181,11 @@ class DoubleConstant extends NumConstant { |
| bool isDouble() => true; |
| bool isNaN() => value.isNaN(); |
| + DartType computeType(ConstantHandler handler) { |
| + return handler.compiler.doubleClass.computeType(handler.compiler); |
| + } |
| + |
| + |
| void _writeJsCode(CodeBuffer buffer, ConstantHandler handler) { |
| if (value.isNaN()) { |
| buffer.add("(0/0)"); |
| @@ -208,6 +222,10 @@ class BoolConstant extends PrimitiveConstant { |
| const BoolConstant._internal(); |
| bool isBool() => true; |
| + DartType computeType(ConstantHandler handler) { |
| + return handler.compiler.boolClass.computeType(handler.compiler); |
| + } |
| + |
| BoolConstant unaryFold(String op) { |
| if (op == "!") return new BoolConstant(!value); |
| return null; |
| @@ -269,6 +287,10 @@ class StringConstant extends PrimitiveConstant { |
| } |
| bool isString() => true; |
| + DartType computeType(ConstantHandler handler) { |
| + return handler.compiler.stringClass.computeType(handler.compiler); |
| + } |
| + |
| void _writeJsCode(CodeBuffer buffer, ConstantHandler handler) { |
| buffer.add("'"); |
| ConstantHandler.writeEscapedString(value, buffer, (reason) { |
| @@ -294,10 +316,10 @@ class ObjectConstant extends Constant { |
| ObjectConstant(this.type); |
| bool isObject() => true; |
| - // TODO(1603): The class should be marked as abstract, but the VM doesn't |
| - // currently allow this. |
| abstract int hashCode(); |
| + DartType computeType(ConstantHandler handler) => type; |
| + |
| void _writeCanonicalizedJsCode(CodeBuffer buffer, ConstantHandler handler) { |
| String name = handler.getNameForConstant(this); |
| buffer.add(handler.compiler.namer.isolatePropertiesAccessForConstant(name)); |