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

Unified Diff: tools/testing/dart/status_expression.dart

Issue 2914893003: Revert "Replace the configuration map with a typed object." (Closed)
Patch Set: 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 | « tools/testing/dart/runtime_configuration.dart ('k') | tools/testing/dart/status_file.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/status_expression.dart
diff --git a/tools/testing/dart/status_expression.dart b/tools/testing/dart/status_expression.dart
index 10b30953096af0f6f634f6f8c94c6e36e9b3c645..c0e35c2017d050fe45c419e60f34b796df9d8d6f 100644
--- a/tools/testing/dart/status_expression.dart
+++ b/tools/testing/dart/status_expression.dart
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'environment.dart';
-
/// A parsed Boolean expression AST.
abstract class Expression {
/// Parses Boolean expressions in a .status file for Dart.
@@ -22,17 +20,9 @@ abstract class Expression {
static Expression parse(String expression) =>
new _ExpressionParser(expression).parse();
- /// Validates that this expression does not contain any invalid uses of
- /// variables.
- ///
- /// Ensures that any variable names are known and that any literal values are
- /// allowed for their corresponding variable. If an invalid variable or value
- /// is found, adds appropriate error messages to [errors].
- void validate(List<String> errors);
-
/// Evaluates the expression where all variables are defined by the given
/// [environment].
- bool evaluate(Environment environment);
+ bool evaluate(Map<String, dynamic> environment);
}
/// Keyword token strings.
@@ -52,8 +42,8 @@ class _Variable {
_Variable(this.name);
- String lookup(Environment environment) {
- var value = environment.lookUp(name);
+ String lookup(Map<String, dynamic> environment) {
+ var value = environment[name];
if (value == null) {
throw new Exception("Could not find '$name' in environment "
"while evaluating status file expression.");
@@ -79,11 +69,7 @@ class _ComparisonExpression implements Expression {
_ComparisonExpression(this.left, this.right, this.negate);
- void validate(List<String> errors) {
- Environment.validate(left.name, right, errors);
- }
-
- bool evaluate(Environment environment) {
+ bool evaluate(Map<String, dynamic> environment) {
return negate != (left.lookup(environment) == right);
}
@@ -99,12 +85,7 @@ class _VariableExpression implements Expression {
_VariableExpression(this.variable);
- void validate(List<String> errors) {
- // It must be a Boolean, so it should allow either Boolean value.
- Environment.validate(variable.name, "true", errors);
- }
-
- bool evaluate(Environment environment) =>
+ bool evaluate(Map<String, dynamic> environment) =>
variable.lookup(environment) == "true";
String toString() => "(bool \$${variable.name})";
@@ -120,12 +101,7 @@ class _LogicExpression implements Expression {
_LogicExpression(this.op, this.left, this.right);
- void validate(List<String> errors) {
- left.validate(errors);
- right.validate(errors);
- }
-
- bool evaluate(Environment environment) => (op == _Token.and)
+ bool evaluate(Map<String, dynamic> environment) => (op == _Token.and)
? left.evaluate(environment) && right.evaluate(environment)
: left.evaluate(environment) || right.evaluate(environment);
« no previous file with comments | « tools/testing/dart/runtime_configuration.dart ('k') | tools/testing/dart/status_file.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698