(StarlarkThread.Frame fr, LoadStatement node)
| 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 { |
no test coverage detected