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 part of dart2js; | 5 part of dart2js; |
6 | 6 |
7 abstract class ConstantVisitor<R> { | 7 abstract class ConstantVisitor<R> { |
8 R visitSentinel(SentinelConstant constant); | 8 R visitSentinel(SentinelConstant constant); |
9 R visitFunction(FunctionConstant constant); | 9 R visitFunction(FunctionConstant constant); |
10 R visitNull(NullConstant constant); | 10 R visitNull(NullConstant constant); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 factory NullConstant() => const NullConstant._internal(); | 121 factory NullConstant() => const NullConstant._internal(); |
122 const NullConstant._internal(); | 122 const NullConstant._internal(); |
123 bool isNull() => true; | 123 bool isNull() => true; |
124 get value => null; | 124 get value => null; |
125 | 125 |
126 DartType computeType(Compiler compiler) { | 126 DartType computeType(Compiler compiler) { |
127 return compiler.nullClass.computeType(compiler); | 127 return compiler.nullClass.computeType(compiler); |
128 } | 128 } |
129 | 129 |
130 void _writeJsCode(CodeBuffer buffer, ConstantHandler handler) { | 130 void _writeJsCode(CodeBuffer buffer, ConstantHandler handler) { |
131 buffer.add(JsNull); | 131 buffer.write(JsNull); |
132 } | 132 } |
133 | 133 |
134 // The magic constant has no meaning. It is just a random value. | 134 // The magic constant has no meaning. It is just a random value. |
135 int get hashCode => 785965825; | 135 int get hashCode => 785965825; |
136 DartString toDartString() => const LiteralDartString("null"); | 136 DartString toDartString() => const LiteralDartString("null"); |
137 | 137 |
138 accept(ConstantVisitor visitor) => visitor.visitNull(this); | 138 accept(ConstantVisitor visitor) => visitor.visitNull(this); |
139 } | 139 } |
140 | 140 |
141 abstract class NumConstant extends PrimitiveConstant { | 141 abstract class NumConstant extends PrimitiveConstant { |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 for (int i = 0; i < fields.length; i++) { | 489 for (int i = 0; i < fields.length; i++) { |
490 if (fields[i] != other.fields[i]) return false; | 490 if (fields[i] != other.fields[i]) return false; |
491 } | 491 } |
492 return true; | 492 return true; |
493 } | 493 } |
494 | 494 |
495 List<Constant> getDependencies() => fields; | 495 List<Constant> getDependencies() => fields; |
496 | 496 |
497 accept(ConstantVisitor visitor) => visitor.visitConstructed(this); | 497 accept(ConstantVisitor visitor) => visitor.visitConstructed(this); |
498 } | 498 } |
OLD | NEW |