public ModuleEntity findModule(TraceInfo traceInfo) { if (traceInfo == null || traceInfo == TraceInfo.UNKNOWN) { return null; } return findModule(traceInfo.getFileName()); }
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; }
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; }
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; }