Allow evaluation from String
Lift the Evaluation code from the test files AbstractParserTestCase and
AbstractEvaluationTestCase into new files EvaluationContext.
Remove this code's dependency on FsApparatus (and thus to InMemoryFS),
by making the Lexer accept null as filename.
Also remove dependency on EventCollectionApparatus;
parameterized by an EventHandler.
Have the SkylarkSignatureProcessor use this Evaluation for defaultValue-s.
While refactoring evaluation, have SkylarkShell use it,
which fixes its ValidationEnvironment issues.
TODO: refactor the tests to use this new infrastructure.
--
MOS_MIGRATED_REVID=90824736
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Environment.java b/src/main/java/com/google/devtools/build/lib/syntax/Environment.java
index 456007f..bd59512 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Environment.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Environment.java
@@ -135,14 +135,18 @@
this.eventHandler = Preconditions.checkNotNull(eventHandler);
}
+ public EventHandler getEventHandler() {
+ return eventHandler;
+ }
+
// Sets up the global environment
private void setupGlobal() {
// In Python 2.x, True and False are global values and can be redefined by the user.
// In Python 3.x, they are keywords. We implement them as values, for the sake of
// simplicity. We define them as Boolean objects.
- env.put("False", FALSE);
- env.put("True", TRUE);
- env.put("None", NONE);
+ update("False", FALSE);
+ update("True", TRUE);
+ update("None", NONE);
}
public boolean isSkylarkEnabled() {