| 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); | |
| 9 R visitFunction(FunctionConstant constant); | 8 R visitFunction(FunctionConstant constant); |
| 10 R visitNull(NullConstant constant); | 9 R visitNull(NullConstant constant); |
| 11 R visitInt(IntConstant constant); | 10 R visitInt(IntConstant constant); |
| 12 R visitDouble(DoubleConstant constant); | 11 R visitDouble(DoubleConstant constant); |
| 13 R visitTrue(TrueConstant constant); | 12 R visitTrue(TrueConstant constant); |
| 14 R visitFalse(FalseConstant constant); | 13 R visitFalse(FalseConstant constant); |
| 15 R visitString(StringConstant constant); | 14 R visitString(StringConstant constant); |
| 16 R visitList(ListConstant constant); | 15 R visitList(ListConstant constant); |
| 17 R visitMap(MapConstant constant); | 16 R visitMap(MapConstant constant); |
| 18 R visitConstructed(ConstructedConstant constant); | 17 R visitConstructed(ConstructedConstant constant); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 46 bool isNaN() => false; | 45 bool isNaN() => false; |
| 47 bool isMinusZero() => false; | 46 bool isMinusZero() => false; |
| 48 | 47 |
| 49 DartType computeType(Compiler compiler); | 48 DartType computeType(Compiler compiler); |
| 50 | 49 |
| 51 List<Constant> getDependencies(); | 50 List<Constant> getDependencies(); |
| 52 | 51 |
| 53 accept(ConstantVisitor visitor); | 52 accept(ConstantVisitor visitor); |
| 54 } | 53 } |
| 55 | 54 |
| 56 class SentinelConstant extends Constant { | |
| 57 const SentinelConstant(); | |
| 58 static final SENTINEL = const SentinelConstant(); | |
| 59 | |
| 60 List<Constant> getDependencies() => const <Constant>[]; | |
| 61 | |
| 62 // Just use a random value. | |
| 63 int get hashCode => 24297418; | |
| 64 | |
| 65 bool isSentinel() => true; | |
| 66 | |
| 67 accept(ConstantVisitor visitor) => visitor.visitSentinel(this); | |
| 68 | |
| 69 DartType computeType(Compiler compiler) => compiler.types.dynamicType; | |
| 70 } | |
| 71 | |
| 72 class FunctionConstant extends Constant { | 55 class FunctionConstant extends Constant { |
| 73 Element element; | 56 Element element; |
| 74 | 57 |
| 75 FunctionConstant(this.element); | 58 FunctionConstant(this.element); |
| 76 | 59 |
| 77 bool isFunction() => true; | 60 bool isFunction() => true; |
| 78 | 61 |
| 79 bool operator ==(var other) { | 62 bool operator ==(var other) { |
| 80 if (other is !FunctionConstant) return false; | 63 if (other is !FunctionConstant) return false; |
| 81 return identical(other.element, element); | 64 return identical(other.element, element); |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 for (int i = 0; i < fields.length; i++) { | 477 for (int i = 0; i < fields.length; i++) { |
| 495 if (fields[i] != other.fields[i]) return false; | 478 if (fields[i] != other.fields[i]) return false; |
| 496 } | 479 } |
| 497 return true; | 480 return true; |
| 498 } | 481 } |
| 499 | 482 |
| 500 List<Constant> getDependencies() => fields; | 483 List<Constant> getDependencies() => fields; |
| 501 | 484 |
| 502 accept(ConstantVisitor visitor) => visitor.visitConstructed(this); | 485 accept(ConstantVisitor visitor) => visitor.visitConstructed(this); |
| 503 } | 486 } |
| OLD | NEW |