Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1151)

Unified Diff: pkg/compiler/lib/src/constants/values.dart

Issue 2864363002: Remove DartString from constants. (Closed)
Patch Set: Remove toDartString Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/constants/expressions.dart ('k') | pkg/compiler/lib/src/deferred_load.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0818f91885b7bf962385ea9b69204e3e46594dbb 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,8 +165,6 @@ abstract class PrimitiveConstantValue extends ConstantValue {
// Primitive constants don't have dependencies.
List<ConstantValue> getDependencies() => const <ConstantValue>[];
- DartString toDartString();
-
/// This value in Dart syntax.
String toDartText() => primitiveValue.toString();
}
@@ -193,8 +186,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 +265,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 +325,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 +368,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 +386,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 +410,7 @@ class StringConstantValue extends PrimitiveConstantValue {
primitiveValue == otherString.primitiveValue;
}
- DartString toDartString() => primitiveValue;
+ String toDartString() => primitiveValue;
int get length => primitiveValue.length;
@@ -445,7 +419,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()})';
}
« no previous file with comments | « pkg/compiler/lib/src/constants/expressions.dart ('k') | pkg/compiler/lib/src/deferred_load.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698