// now simply extend the current module
eval.getCurrentModuleEnvironment().extend(other); //heap.getModule(name));
}
public static ModuleEnvironment loadModule(ISourceLocation x, String name, IEvaluator<Result<IValue>> eval) {
GlobalEnvironment heap = eval.getHeap();
ModuleEnvironment env = heap.getModule(name);
if (env == null) {
env = new ModuleEnvironment(name, heap);
heap.addModule(env);
}
try {
Module module = buildModule(name, env, eval);
if (isDeprecated(module)) {
eval.getStdErr().println("WARNING: deprecated module " + name + ":" + getDeprecatedMessage(module));
}
if (module != null) {
String internalName = org.rascalmpl.semantics.dynamic.Module.getModuleName(module);
if (!internalName.equals(name)) {
throw new ModuleNameMismatch(internalName, name, x);
}
heap.setModuleURI(name, module.getLocation().getURI());
module.interpret(eval);
return env;
}
} catch (StaticError e) {
heap.removeModule(env);
throw e;
} catch (Throw e) {
heap.removeModule(env);
throw e;
} catch (IOException e) {
heap.removeModule(env);
throw new ModuleImport(name, e.getMessage(), x);
}
heap.removeModule(env);
throw new ImplementationError("Unexpected error while parsing module " + name + " and building an AST for it ", x);
}