protected void loadModule(Environment env) { if (!module.isLoaded()) { synchronized (env.scope) { if (!module.isLoaded()) { env.scope.loadModule(module); env.scope.addUserModule(module); } } } }
public ModuleEntity fetchModule(String name) { if (library == null) { throw new CriticalException("Standalone library is not loaded"); } ModuleEntity entity = _fetch(name, library.getModules()); if (entity != null) { loadModule(entity); scope.loadModule(entity, false); scope.addUserModule(entity); } return entity; }
public ModuleEntity importCompiledModule(Context context, boolean debugInformation) throws Throwable { String moduleName = context.getModuleName(); ModuleEntity module = moduleName == null ? null : scope.findUserModule(moduleName); if (module == null) { ModuleDumper moduleDumper = new ModuleDumper(context, this, debugInformation); module = moduleDumper.load(context.getInputStream(getDefaultCharset())); synchronized (scope) { scope.loadModule(module); } } registerModule(module); scope.addUserModule(module); return module; }
public void registerModule(ModuleEntity module) { addUserModule(module); for(ClassEntity entity : module.getClasses()) { if (entity.isStatic()){ if (classMap.put(entity.getLowerName(), entity) != null) { throw new CriticalException(Messages.ERR_CANNOT_REDECLARE_CLASS.fetch(entity.getName())); } } } for(FunctionEntity entity : module.getFunctions()) { if (entity.isStatic()) { if (functionMap.put(entity.getLowerName(), entity) != null) { throw new CriticalException(Messages.ERR_CANNOT_REDECLARE_FUNCTION.fetch(entity.getName())); } } } for(ConstantEntity entity : module.getConstants()) { if (constantMap.put(entity.getLowerName(), entity) != null) { throw new CriticalException(Messages.ERR_CANNOT_REDECLARE_CONSTANT.fetch(entity.getName())); } } }
scope.addUserModule(module);
environment.getScope().addUserModule(module); environment.registerModule(module); environment.getModuleManager().addModule(context.getFileName(), module);