MCPcopy Index your code
hub / github.com/bazelbuild/bazel / execLoad

Method execLoad

src/main/java/net/starlark/java/eval/Eval.java:244–275  ·  view source on GitHub ↗
(StarlarkThread.Frame fr, LoadStatement node)

Source from the content-addressed store, hash-verified

242 }
243
244 private static void execLoad(StarlarkThread.Frame fr, LoadStatement node) throws EvalException {
245 // Has the application defined a behavior for load statements in this thread?
246 StarlarkThread.Loader loader = fr.thread.getLoader();
247 if (loader == null) {
248 fr.setErrorLocation(node.getStartLocation());
249 throw Starlark.errorf("load statements may not be executed in this thread");
250 }
251
252 // Load module.
253 String moduleName = node.getImport().getValue();
254 Module module = loader.load(moduleName);
255 if (module == null) {
256 fr.setErrorLocation(node.getStartLocation());
257 throw Starlark.errorf("module '%s' not found", moduleName);
258 }
259
260 for (LoadStatement.Binding binding : node.getBindings()) {
261 // Extract symbol.
262 Identifier orig = binding.getOriginalName();
263 Object value = module.getGlobal(orig.getName());
264 if (value == null) {
265 fr.setErrorLocation(orig.getStartLocation());
266 throw Starlark.errorf(
267 "file '%s' does not contain symbol '%s'%s",
268 moduleName,
269 orig.getName(),
270 SpellChecker.didYouMean(orig.getName(), module.getGlobals().keySet()));
271 }
272
273 assignIdentifier(fr, binding.getLocalName(), value);
274 }
275 }
276
277 private static TokenKind execReturn(StarlarkThread.Frame fr, ReturnStatement node)
278 throws EvalException, InterruptedException {

Callers 1

execMethod · 0.95

Calls 15

errorfMethod · 0.95
getGlobalMethod · 0.95
getNameMethod · 0.95
didYouMeanMethod · 0.95
getGlobalsMethod · 0.95
assignIdentifierMethod · 0.95
getLoaderMethod · 0.80
setErrorLocationMethod · 0.80
getImportMethod · 0.80
getBindingsMethod · 0.80
getLocalNameMethod · 0.80
getValueMethod · 0.65

Tested by

no test coverage detected