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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 95 } |
96 | 96 |
97 abstract class PrimitiveConstant extends Constant { | 97 abstract class PrimitiveConstant extends Constant { |
98 get value; | 98 get value; |
99 const PrimitiveConstant(); | 99 const PrimitiveConstant(); |
100 bool isPrimitive() => true; | 100 bool isPrimitive() => true; |
101 | 101 |
102 bool operator ==(var other) { | 102 bool operator ==(var other) { |
103 if (other is !PrimitiveConstant) return false; | 103 if (other is !PrimitiveConstant) return false; |
104 PrimitiveConstant otherPrimitive = other; | 104 PrimitiveConstant otherPrimitive = other; |
105 // We use == instead of === so that DartStrings compare correctly. | 105 // We use == instead of 'identical' so that DartStrings compare correctly. |
106 return value == otherPrimitive.value; | 106 return value == otherPrimitive.value; |
107 } | 107 } |
108 | 108 |
109 String toString() => value.toString(); | 109 String toString() => value.toString(); |
110 // Primitive constants don't have dependencies. | 110 // Primitive constants don't have dependencies. |
111 List<Constant> getDependencies() => const <Constant>[]; | 111 List<Constant> getDependencies() => const <Constant>[]; |
112 DartString toDartString(); | 112 DartString toDartString(); |
113 } | 113 } |
114 | 114 |
115 class NullConstant extends PrimitiveConstant { | 115 class NullConstant extends PrimitiveConstant { |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 for (int i = 0; i < fields.length; i++) { | 464 for (int i = 0; i < fields.length; i++) { |
465 if (fields[i] != other.fields[i]) return false; | 465 if (fields[i] != other.fields[i]) return false; |
466 } | 466 } |
467 return true; | 467 return true; |
468 } | 468 } |
469 | 469 |
470 List<Constant> getDependencies() => fields; | 470 List<Constant> getDependencies() => fields; |
471 | 471 |
472 accept(ConstantVisitor visitor) => visitor.visitConstructed(this); | 472 accept(ConstantVisitor visitor) => visitor.visitConstructed(this); |
473 } | 473 } |
OLD | NEW |