| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 const PrimitiveConstant(); | 101 const PrimitiveConstant(); |
| 102 bool isPrimitive() => true; | 102 bool isPrimitive() => true; |
| 103 | 103 |
| 104 bool operator ==(var other) { | 104 bool operator ==(var other) { |
| 105 if (other is !PrimitiveConstant) return false; | 105 if (other is !PrimitiveConstant) return false; |
| 106 PrimitiveConstant otherPrimitive = other; | 106 PrimitiveConstant otherPrimitive = other; |
| 107 // We use == instead of 'identical' so that DartStrings compare correctly. | 107 // We use == instead of 'identical' so that DartStrings compare correctly. |
| 108 return value == otherPrimitive.value; | 108 return value == otherPrimitive.value; |
| 109 } | 109 } |
| 110 | 110 |
| 111 int get hashCode => throw new UnsupportedError('PrimitiveConstant.hashCode'); |
| 112 |
| 111 String toString() => value.toString(); | 113 String toString() => value.toString(); |
| 112 // Primitive constants don't have dependencies. | 114 // Primitive constants don't have dependencies. |
| 113 List<Constant> getDependencies() => const <Constant>[]; | 115 List<Constant> getDependencies() => const <Constant>[]; |
| 114 DartString toDartString(); | 116 DartString toDartString(); |
| 115 } | 117 } |
| 116 | 118 |
| 117 class NullConstant extends PrimitiveConstant { | 119 class NullConstant extends PrimitiveConstant { |
| 118 /** The value a Dart null is compiled to in JavaScript. */ | 120 /** The value a Dart null is compiled to in JavaScript. */ |
| 119 static const String JsNull = "null"; | 121 static const String JsNull = "null"; |
| 120 | 122 |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 for (int i = 0; i < fields.length; i++) { | 496 for (int i = 0; i < fields.length; i++) { |
| 495 if (fields[i] != other.fields[i]) return false; | 497 if (fields[i] != other.fields[i]) return false; |
| 496 } | 498 } |
| 497 return true; | 499 return true; |
| 498 } | 500 } |
| 499 | 501 |
| 500 List<Constant> getDependencies() => fields; | 502 List<Constant> getDependencies() => fields; |
| 501 | 503 |
| 502 accept(ConstantVisitor visitor) => visitor.visitConstructed(this); | 504 accept(ConstantVisitor visitor) => visitor.visitConstructed(this); |
| 503 } | 505 } |
| OLD | NEW |