protected ModuleEntity fetchClass(Environment env, String fileName, boolean compiled) throws Throwable { return env.getModuleManager().fetchTemporaryModule("res://" + fileName, compiled); } }
public ModuleEntity loadFrom(String file) throws Throwable { return environment.getModuleManager().fetchModule(file); }
private ModuleEntity compileFile(File path, File destinationDirectory, File destinationResDirectory) { try { ModuleEntity entity = env.getModuleManager().fetchModule(path.getPath()); saveModuleClasses(entity, destinationDirectory, destinationResDirectory); return entity; } catch (Throwable throwable) { throw new RuntimeException(throwable); } }
public ModuleEntity module() { if (callStackTop <= 0) { return null; } return env.getModuleManager().findModule(peekCall(0).trace); }
public ModuleEntity module(int depth) { CallStackItem stackItem = peekCall(depth); if (stackItem != null) { return env.getModuleManager().findModule(stackItem.trace); } return null; }
public static Memory get_included_files(Environment env){ return ArrayMemory.ofStringCollection(env.getModuleManager().getCachedPaths()); }
private static Memory typeHintArg(Environment env, TraceInfo trace, ParameterEntity param, Memory arg, int i, String originClassName, String originMethodName, String staticClassName) { if (!param.checkTypeHinting(env, arg, staticClassName)) { ModuleEntity module = env.getModuleManager().findModule(trace); Memory memory = param.applyTypeHinting(env, arg, module != null && module.isStrictTypes()); if (memory != null) { return memory; } else { invalidType(env, trace, param, i + 1, arg, originClassName, originMethodName); } } return arg; }
@Signature(@Arg("path")) public Memory findModule(Environment env, Memory... args) throws Throwable { ModuleManager moduleManager = this.environment.getModuleManager(); boolean hasModule = moduleManager.hasModule(args[0].toString()); if (hasModule) { return ObjectMemory.valueOf(new WrapModule(env, moduleManager.fetchModule(args[0].toString()))); } return Memory.NULL; }
ModuleEntity fetchModule = environment.getModuleManager().fetchModule(include);
public static Memory checkReturnType(Environment env, TraceInfo trace, Memory result, Function<String> callName, TypeChecker typeChecker, boolean nullable) { if (typeChecker == null) { return result; } if (!typeChecker.check(env, result, nullable, null)) { ModuleEntity module = env.getModuleManager().findModule(trace); Memory newReturn = typeChecker.apply( env, result, nullable, module != null && module.isStrictTypes() ); if (newReturn == null) { String given = result.isObject() ? result.toValue(ObjectMemory.class).getReflection().getName() : result.getRealType().toString(); env.exception( trace, BaseTypeError.class, Messages.ERR_RETURN_TYPE_INVALID.fetch(callName.call(), typeChecker.getHumanString(), given) ); return null; } else { return newReturn; } } return result; }
environment.getScope().addUserModule(module); environment.registerModule(module); environment.getModuleManager().addModule(context.getFileName(), module);