Chromium Code Reviews| Index: pkg/compiler/lib/src/constants/values.dart |
| diff --git a/pkg/compiler/lib/src/constants/values.dart b/pkg/compiler/lib/src/constants/values.dart |
| index c49239eaec6f0dffacc653fb681450b852343e6c..8f797d90f5131c0def407aa10f99b96c8336a192 100644 |
| --- a/pkg/compiler/lib/src/constants/values.dart |
| +++ b/pkg/compiler/lib/src/constants/values.dart |
| @@ -8,7 +8,6 @@ import '../common.dart'; |
| import '../common_elements.dart'; |
| import '../elements/entities.dart'; |
| import '../elements/types.dart'; |
| -import '../tree/dartstring.dart'; |
| import '../util/util.dart' show Hashing; |
| enum ConstantValueKind { |
| @@ -126,10 +125,6 @@ class FunctionConstantValue extends ConstantValue { |
| List<ConstantValue> getDependencies() => const <ConstantValue>[]; |
| - DartString toDartString() { |
| - return new DartString.literal(element.name); |
| - } |
| - |
| DartType getType(CommonElements types) => type; |
| int get hashCode => (17 * element.hashCode) & 0x7fffffff; |
| @@ -170,7 +165,8 @@ abstract class PrimitiveConstantValue extends ConstantValue { |
| // Primitive constants don't have dependencies. |
| List<ConstantValue> getDependencies() => const <ConstantValue>[]; |
| - DartString toDartString(); |
| + /// Returns the constant value as its string representation. |
| + String toDartString() => primitiveValue.toString(); |
| /// This value in Dart syntax. |
| String toDartText() => primitiveValue.toString(); |
| @@ -193,8 +189,6 @@ class NullConstantValue extends PrimitiveConstantValue { |
| // The magic constant has no meaning. It is just a random value. |
| int get hashCode => 785965825; |
| - DartString toDartString() => const LiteralDartString("null"); |
| - |
| accept(ConstantValueVisitor visitor, arg) => visitor.visitNull(this, arg); |
| ConstantValueKind get kind => ConstantValueKind.NULL; |
| @@ -274,10 +268,6 @@ class IntConstantValue extends NumConstantValue { |
| int get hashCode => primitiveValue & Hashing.SMI_MASK; |
| - DartString toDartString() { |
| - return new DartString.literal(primitiveValue.toString()); |
| - } |
| - |
| accept(ConstantValueVisitor visitor, arg) => visitor.visitInt(this, arg); |
| ConstantValueKind get kind => ConstantValueKind.INT; |
| @@ -338,10 +328,6 @@ class DoubleConstantValue extends NumConstantValue { |
| int get hashCode => primitiveValue.hashCode; |
| - DartString toDartString() { |
| - return new DartString.literal(primitiveValue.toString()); |
| - } |
| - |
| accept(ConstantValueVisitor visitor, arg) => visitor.visitDouble(this, arg); |
| ConstantValueKind get kind => ConstantValueKind.DOUBLE; |
| @@ -385,8 +371,6 @@ class TrueConstantValue extends BoolConstantValue { |
| // The magic constant is just a random value. It does not have any |
| // significance. |
| int get hashCode => 499; |
| - |
| - DartString toDartString() => const LiteralDartString("true"); |
| } |
| class FalseConstantValue extends BoolConstantValue { |
| @@ -405,24 +389,17 @@ class FalseConstantValue extends BoolConstantValue { |
| // The magic constant is just a random value. It does not have any |
| // significance. |
| int get hashCode => 536555975; |
| - |
| - DartString toDartString() => const LiteralDartString("false"); |
| } |
| class StringConstantValue extends PrimitiveConstantValue { |
| - final DartString primitiveValue; |
| + final String primitiveValue; |
| final int hashCode; |
| // TODO(floitsch): cache StringConstants. |
| - // TODO(floitsch): compute hashcode without calling toString() on the |
| - // DartString. |
| - StringConstantValue(DartString value) |
| + StringConstantValue(String value) |
| : this.primitiveValue = value, |
| - this.hashCode = value.slowToString().hashCode; |
| - |
| - StringConstantValue.fromString(String value) |
| - : this(new DartString.literal(value)); |
| + this.hashCode = value.hashCode; |
| bool get isString => true; |
| @@ -436,7 +413,7 @@ class StringConstantValue extends PrimitiveConstantValue { |
| primitiveValue == otherString.primitiveValue; |
| } |
| - DartString toDartString() => primitiveValue; |
| + String toDartString() => primitiveValue; |
|
Siggi Cherem (dart-lang)
2017/05/08 22:24:04
we could also get rid of the 'toDartString' entire
Johnni Winther
2017/05/09 08:18:13
Done.
|
| int get length => primitiveValue.length; |
| @@ -445,7 +422,7 @@ class StringConstantValue extends PrimitiveConstantValue { |
| ConstantValueKind get kind => ConstantValueKind.STRING; |
| // TODO(johnniwinther): Ensure correct escaping. |
| - String toDartText() => '"${primitiveValue.slowToString()}"'; |
| + String toDartText() => '"${primitiveValue}"'; |
| String toStructuredText() => 'StringConstant(${toDartText()})'; |
| } |