| 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 visitFunction(FunctionConstant constant); | 8 R visitFunction(FunctionConstant constant); |
| 9 R visitNull(NullConstant constant); | 9 R visitNull(NullConstant constant); |
| 10 R visitInt(IntConstant constant); | 10 R visitInt(IntConstant constant); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 get value => null; | 116 get value => null; |
| 117 | 117 |
| 118 DartType computeType(Compiler compiler) { | 118 DartType computeType(Compiler compiler) { |
| 119 return compiler.nullClass.computeType(compiler); | 119 return compiler.nullClass.computeType(compiler); |
| 120 } | 120 } |
| 121 | 121 |
| 122 ti.TypeMask computeMask(Compiler compiler) { | 122 ti.TypeMask computeMask(Compiler compiler) { |
| 123 return compiler.typesTask.nullType; | 123 return compiler.typesTask.nullType; |
| 124 } | 124 } |
| 125 | 125 |
| 126 void _writeJsCode(CodeBuffer buffer, ConstantHandler handler) { | |
| 127 buffer.write(JsNull); | |
| 128 } | |
| 129 | |
| 130 // The magic constant has no meaning. It is just a random value. | 126 // The magic constant has no meaning. It is just a random value. |
| 131 int get hashCode => 785965825; | 127 int get hashCode => 785965825; |
| 132 DartString toDartString() => const LiteralDartString("null"); | 128 DartString toDartString() => const LiteralDartString("null"); |
| 133 | 129 |
| 134 accept(ConstantVisitor visitor) => visitor.visitNull(this); | 130 accept(ConstantVisitor visitor) => visitor.visitNull(this); |
| 135 } | 131 } |
| 136 | 132 |
| 137 abstract class NumConstant extends PrimitiveConstant { | 133 abstract class NumConstant extends PrimitiveConstant { |
| 138 num get value; | 134 num get value; |
| 139 const NumConstant(); | 135 const NumConstant(); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 326 |
| 331 String toString() { | 327 String toString() { |
| 332 return 'StringConstant(${Error.safeToString(value.slowToString())})'; | 328 return 'StringConstant(${Error.safeToString(value.slowToString())})'; |
| 333 } | 329 } |
| 334 } | 330 } |
| 335 | 331 |
| 336 abstract class ObjectConstant extends Constant { | 332 abstract class ObjectConstant extends Constant { |
| 337 final DartType type; | 333 final DartType type; |
| 338 | 334 |
| 339 ObjectConstant(this.type); | 335 ObjectConstant(this.type); |
| 336 |
| 340 bool isObject() => true; | 337 bool isObject() => true; |
| 341 | 338 |
| 342 DartType computeType(Compiler compiler) => type; | 339 DartType computeType(Compiler compiler) => type; |
| 343 } | 340 } |
| 344 | 341 |
| 345 class TypeConstant extends ObjectConstant { | 342 class TypeConstant extends ObjectConstant { |
| 346 /// The user type that this constant represents. | 343 /// The user type that this constant represents. |
| 347 final DartType representedType; | 344 final DartType representedType; |
| 348 | 345 |
| 349 TypeConstant(this.representedType, type) : super(type); | 346 TypeConstant(this.representedType, type) : super(type); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 if (i > 0) sb.write(','); | 604 if (i > 0) sb.write(','); |
| 608 sb.write(Error.safeToString(field.name)); | 605 sb.write(Error.safeToString(field.name)); |
| 609 sb.write('='); | 606 sb.write('='); |
| 610 sb.write(Error.safeToString(value)); | 607 sb.write(Error.safeToString(value)); |
| 611 i++; | 608 i++; |
| 612 }); | 609 }); |
| 613 sb.write('))'); | 610 sb.write('))'); |
| 614 return sb.toString(); | 611 return sb.toString(); |
| 615 } | 612 } |
| 616 } | 613 } |
| OLD | NEW |