Create SkylarkCallable.useContext and use it instead of Environment.BazelInfo
This makes the Starlark interpreter pass a StarlarkContext object to methods, which, for Bazel, should be a stand-in replacement for the previous BazelInfo object.
In a future cleanup, we can move Mutability to context, and then turn down useEnvironment. Environment is a bit too powerful an object to be passing around.
RELNOTES: None.
PiperOrigin-RevId: 224216211
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java
index e7f3861..04f20d8 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java
@@ -35,6 +35,7 @@
import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
import com.google.devtools.build.lib.skylarkinterface.SkylarkSignature;
import com.google.devtools.build.lib.skylarkinterface.SkylarkValue;
+import com.google.devtools.build.lib.skylarkinterface.StarlarkContext;
import com.google.devtools.build.lib.syntax.SkylarkList.MutableList;
import com.google.devtools.build.lib.syntax.SkylarkSemantics.FlagIdentifier;
import com.google.devtools.build.lib.testutil.TestMode;
@@ -308,15 +309,19 @@
}
@SkylarkCallable(
- name = "with_extra",
- documented = false,
- useLocation = true,
- useAst = true,
- useEnvironment = true,
- useSkylarkSemantics = true
- )
+ name = "with_extra",
+ documented = false,
+ useLocation = true,
+ useAst = true,
+ useEnvironment = true,
+ useSkylarkSemantics = true,
+ useContext = true)
public String withExtraInterpreterParams(
- Location location, FuncallExpression func, Environment env, SkylarkSemantics sem) {
+ Location location,
+ FuncallExpression func,
+ Environment env,
+ SkylarkSemantics sem,
+ StarlarkContext context) {
return "with_extra("
+ location.getStartLine()
+ ", "
@@ -325,6 +330,8 @@
+ env.isGlobal()
+ ", "
+ (sem != null)
+ + ", "
+ + (context != null)
+ ")";
}
@@ -1304,7 +1311,7 @@
new SkylarkTest()
.update("mock", new Mock())
.setUp("v = mock.with_extra()")
- .testLookup("v", "with_extra(1, 0, true, true)");
+ .testLookup("v", "with_extra(1, 0, true, true, true)");
}
@Test