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

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

Issue 2033383002: Handle use of fromEnvironment from serialized data. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fixes Created 4 years, 6 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/compiler.dart » ('j') | pkg/compiler/lib/src/elements/common.dart » ('J')
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 8e21f267166727d17735b13d090b6316b4a4787c..bbabcf9f9aaf521a67cad7c5d96b3117f4471026 100644
--- a/pkg/compiler/lib/src/compile_time_constants.dart
+++ b/pkg/compiler/lib/src/compile_time_constants.dart
@@ -927,10 +927,7 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
assert(normalizedArguments != null);
concreteArguments = normalizedArguments;
}
-
- if (constructor == compiler.intEnvironment ||
- constructor == compiler.boolEnvironment ||
- constructor == compiler.stringEnvironment) {
+ if (constructor.isFromEnvironmentConstructor) {
return createFromEnvironmentConstant(node, constructedType, constructor,
callStructure, normalizedArguments, concreteArguments);
} else {
@@ -974,7 +971,7 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
return null;
}
- if (constructor == compiler.intEnvironment &&
+ if (constructor.isIntFromEnvironmentConstructor &&
!(defaultValue.isNull || defaultValue.isInt)) {
DartType type = defaultValue.getType(coreTypes);
reporter.reportErrorMessage(
@@ -984,7 +981,7 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
return null;
}
- if (constructor == compiler.boolEnvironment &&
+ if (constructor.isBoolFromEnvironmentConstructor &&
!(defaultValue.isNull || defaultValue.isBool)) {
DartType type = defaultValue.getType(coreTypes);
reporter.reportErrorMessage(
@@ -994,7 +991,7 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
return null;
}
- if (constructor == compiler.stringEnvironment &&
+ if (constructor.isStringFromEnvironmentConstructor &&
!(defaultValue.isNull || defaultValue.isString)) {
DartType type = defaultValue.getType(coreTypes);
reporter.reportErrorMessage(
@@ -1014,13 +1011,13 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
if (concreteArguments.length > 1) {
defaultValue = concreteArguments[1].expression;
}
- if (constructor == compiler.intEnvironment) {
+ if (constructor.isIntFromEnvironmentConstructor) {
expression =
new IntFromEnvironmentConstantExpression(name, defaultValue);
- } else if (constructor == compiler.boolEnvironment) {
+ } else if (constructor.isBoolFromEnvironmentConstructor) {
expression =
new BoolFromEnvironmentConstantExpression(name, defaultValue);
- } else if (constructor == compiler.stringEnvironment) {
+ } else if (constructor.isStringFromEnvironmentConstructor) {
expression =
new StringFromEnvironmentConstantExpression(name, defaultValue);
}
@@ -1030,11 +1027,11 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
if (value == null) {
return createEvaluatedConstant(defaultValue);
- } else if (constructor == compiler.intEnvironment) {
+ } else if (constructor.isIntFromEnvironmentConstructor) {
int number = int.parse(value, onError: (_) => null);
return createEvaluatedConstant(
(number == null) ? defaultValue : constantSystem.createInt(number));
- } else if (constructor == compiler.boolEnvironment) {
+ } else if (constructor.isBoolFromEnvironmentConstructor) {
if (value == 'true') {
return createEvaluatedConstant(constantSystem.createBool(true));
} else if (value == 'false') {
@@ -1043,7 +1040,7 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
return createEvaluatedConstant(defaultValue);
}
} else {
- assert(constructor == compiler.stringEnvironment);
+ assert(constructor.isStringFromEnvironmentConstructor);
return createEvaluatedConstant(
constantSystem.createString(new DartString.literal(value)));
}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/compiler.dart » ('j') | pkg/compiler/lib/src/elements/common.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698