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

Unified Diff: pkg/compiler/lib/src/compile_time_constants.dart

Issue 1166723002: Add StringLengthConstantExpression (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Update .fromEnvironment test expectations. Created 5 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 | « no previous file | pkg/compiler/lib/src/constants/expressions.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/compile_time_constants.dart
diff --git a/pkg/compiler/lib/src/compile_time_constants.dart b/pkg/compiler/lib/src/compile_time_constants.dart
index 00112af187231c75e4f2f69ef9c367d07e450872..b739ce5deb6ab38a1ee6e412c14e48d63354edd6 100644
--- a/pkg/compiler/lib/src/compile_time_constants.dart
+++ b/pkg/compiler/lib/src/compile_time_constants.dart
@@ -535,7 +535,8 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
StringConstantValue stringConstantValue = left.value;
DartString string = stringConstantValue.primitiveValue;
IntConstantValue length = constantSystem.createInt(string.length);
- result = new VariableConstantExpression(length, element);
+ result =
+ new StringLengthConstantExpression(length, left.expression);
}
}
// Fall through to error handling.
@@ -880,15 +881,20 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
AstConstant createEvaluatedConstant(ConstantValue value) {
ConstantExpression expression;
+ ConstantExpression name = concreteArguments[0].expression;
+ ConstantExpression defaultValue;
+ if (concreteArguments.length > 1) {
+ defaultValue = concreteArguments[1].expression;
+ }
if (constructor == compiler.intEnvironment) {
expression = new IntFromEnvironmentConstantExpression(
- value, name, normalizedArguments[1].expression);
+ value, name, defaultValue);
} else if (constructor == compiler.boolEnvironment) {
expression = new BoolFromEnvironmentConstantExpression(
- value, name, normalizedArguments[1].expression);
+ value, name, defaultValue);
} else if (constructor == compiler.stringEnvironment) {
expression = new StringFromEnvironmentConstantExpression(
- value, name, normalizedArguments[1].expression);
+ value, name, defaultValue);
}
return new AstConstant(context, node, expression);
}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/constants/expressions.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698