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

Unified Diff: pkg/compiler/lib/src/constants/expressions.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/constant_system.dart ('k') | pkg/compiler/lib/src/constants/values.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/constants/expressions.dart
diff --git a/pkg/compiler/lib/src/constants/expressions.dart b/pkg/compiler/lib/src/constants/expressions.dart
index 1577e5b2cbc001a2097ec8f98156170afda199c6..1b7079dfe4008ccfe02219d543a5ea33c6db1849 100644
--- a/pkg/compiler/lib/src/constants/expressions.dart
+++ b/pkg/compiler/lib/src/constants/expressions.dart
@@ -10,7 +10,6 @@ import '../common_elements.dart';
import '../elements/entities.dart';
import '../elements/operators.dart';
import '../elements/types.dart';
-import '../tree/dartstring.dart' show DartString;
import '../universe/call_structure.dart' show CallStructure;
import 'constructors.dart';
import 'evaluation.dart';
@@ -328,7 +327,7 @@ class StringConstantExpression extends PrimitiveConstantExpression {
@override
ConstantValue evaluate(
EvaluationEnvironment environment, ConstantSystem constantSystem) {
- return constantSystem.createString(new DartString.literal(primitiveValue));
+ return constantSystem.createString(primitiveValue);
}
@override
@@ -653,29 +652,19 @@ class ConcatenateConstantExpression extends ConstantExpression {
@override
ConstantValue evaluate(
EvaluationEnvironment environment, ConstantSystem constantSystem) {
- DartString accumulator;
+ StringBuffer sb = new StringBuffer();
for (ConstantExpression expression in expressions) {
ConstantValue value = expression.evaluate(environment, constantSystem);
- DartString valueString;
- if (value.isNum || value.isBool || value.isNull) {
- PrimitiveConstantValue primitive = value;
- valueString =
- new DartString.literal(primitive.primitiveValue.toString());
- } else if (value.isString) {
+ if (value.isPrimitive) {
PrimitiveConstantValue primitive = value;
- valueString = primitive.primitiveValue;
+ sb.write(primitive.primitiveValue);
} else {
// TODO(johnniwinther): Specialize message to indicated that the problem
// is not constness but the types of the const expressions.
return new NonConstantValue();
}
- if (accumulator == null) {
- accumulator = valueString;
- } else {
- accumulator = new DartString.concat(accumulator, valueString);
- }
}
- return constantSystem.createString(accumulator);
+ return constantSystem.createString(sb.toString());
}
@override
@@ -1433,8 +1422,8 @@ class BoolFromEnvironmentConstantExpression
return new NonConstantValue();
}
StringConstantValue nameStringConstantValue = nameConstantValue;
- String text = environment.readFromEnvironment(
- nameStringConstantValue.primitiveValue.slowToString());
+ String text =
+ environment.readFromEnvironment(nameStringConstantValue.primitiveValue);
if (text == 'true') {
return constantSystem.createBool(true);
} else if (text == 'false') {
@@ -1497,8 +1486,8 @@ class IntFromEnvironmentConstantExpression
return new NonConstantValue();
}
StringConstantValue nameStringConstantValue = nameConstantValue;
- String text = environment.readFromEnvironment(
- nameStringConstantValue.primitiveValue.slowToString());
+ String text =
+ environment.readFromEnvironment(nameStringConstantValue.primitiveValue);
int value;
if (text != null) {
value = int.parse(text, onError: (_) => null);
@@ -1563,12 +1552,12 @@ class StringFromEnvironmentConstantExpression
return new NonConstantValue();
}
StringConstantValue nameStringConstantValue = nameConstantValue;
- String text = environment.readFromEnvironment(
- nameStringConstantValue.primitiveValue.slowToString());
+ String text =
+ environment.readFromEnvironment(nameStringConstantValue.primitiveValue);
if (text == null) {
return defaultConstantValue;
} else {
- return constantSystem.createString(new DartString.literal(text));
+ return constantSystem.createString(text);
}
}
« no previous file with comments | « pkg/compiler/lib/src/constants/constant_system.dart ('k') | pkg/compiler/lib/src/constants/values.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698