Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/constants.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/constants.dart b/sdk/lib/_internal/compiler/implementation/constants.dart |
| index cc7d11dcc84136039425005edd85c8b562194ca7..b16c90033b844ba7ec0ae5287ba94f5e659b8b71 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/constants.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/constants.dart |
| @@ -105,10 +105,14 @@ abstract class PrimitiveConstant extends Constant { |
| int get hashCode => throw new UnsupportedError('PrimitiveConstant.hashCode'); |
| - String toString() => value.toString(); |
| + String toString() => toSyntax(); |
| // Primitive constants don't have dependencies. |
| List<Constant> getDependencies() => const <Constant>[]; |
| DartString toDartString(); |
| + |
| + /// This value in Dart syntax. |
| + // TODO(johnniwinther): Move this to [Constant]. |
| + String toSyntax() => value.toString(); |
|
sigurdm
2014/09/17 10:29:41
maybe call it `unparse` or something similar. `toS
Johnni Winther
2014/09/17 12:20:39
Done.
|
| } |
| class NullConstant extends PrimitiveConstant { |
| @@ -341,8 +345,11 @@ class StringConstant extends PrimitiveConstant { |
| accept(ConstantVisitor visitor) => visitor.visitString(this); |
| + // TODO(johnniwinther): Ensure correct escaping. |
| + String toSyntax() => '"${value.slowToString()}"'; |
| + |
| String toString() { |
| - return 'StringConstant("${value.slowToString()}")'; |
| + return 'StringConstant(${toSyntax()})'; |
| } |
| } |
| @@ -569,17 +576,14 @@ class ConstructedConstant extends ObjectConstant { |
| final List<Constant> fields; |
| final int hashCode; |
| - ConstructedConstant(DartType type, List<Constant> fields, |
| - {this.isLiteralSymbol: false}) |
| + ConstructedConstant(DartType type, List<Constant> fields) |
| : this.fields = fields, |
| hashCode = computeHash(type, fields), |
| super(type) { |
| assert(type != null); |
| } |
| - bool get isConstructedObject => true; |
| - /// True if this constant is constructed as a literal symbol. |
| - final bool isLiteralSymbol; |
| + bool get isConstructedObject => true; |
| static int computeHash(DartType type, List<Constant> fields) { |
| // TODO(floitsch): create a better hash. |