public static boolean function_exists(Environment env, String name) { FunctionEntity function = env.fetchFunction(name); return function != null; }
public FunctionEntity fetchFunction(String name) { return fetchFunction(name, name.toLowerCase()); }
public FunctionEntity fetchFunction(String name, String nameL) { FunctionEntity r = functionMap.get(nameL); if (r == null) { r = scope.findUserFunction(name); } if (r == null && !name.isEmpty() && name.charAt(0) == '\\') { return fetchFunction(name.substring(1), nameL.substring(1)); } return r; }
public static FunctionInvoker valueOf(Environment env, TraceInfo trace, String name){ FunctionEntity functionEntity = env.fetchFunction(name); if (functionEntity == null){ if (trace == null) return null; env.error(trace, Messages.ERR_CALL_TO_UNDEFINED_FUNCTION.fetch(name)); } return new FunctionInvoker(env, trace, functionEntity); }
public static Memory call(Environment env, TraceInfo trace, String sign, String originName, Memory[] args, FunctionCallCache callCache, int cacheIndex) throws Throwable { FunctionEntity function = null; if (callCache != null) function = callCache.get(env, cacheIndex); if (function == null) { function = env.fetchFunction(originName, sign); if (function != null && callCache != null) { callCache.put(env, cacheIndex, function); } } if (function == null) { if (!sign.isEmpty() && sign.charAt(0) != Information.NAMESPACE_SEP_CHAR) { // for global style invoke int p = sign.lastIndexOf(Information.NAMESPACE_SEP_CHAR); if (p > -1) function = env.fetchFunction(originName.substring(p + 1), sign.substring(p + 1)); } if (function == null) { env.error(trace, Messages.ERR_CALL_TO_UNDEFINED_FUNCTION.fetch(originName)); return Memory.NULL; } if (callCache != null) { callCache.put(env, cacheIndex, function); } } return call(env, trace, function, args); }
@Signature(@Arg("functionName")) public Memory importFunction(Environment env, Memory... args){ FunctionEntity functionEntity = env.fetchFunction(args[0].toString()); if (functionEntity == null) { env.exception(Messages.ERR_FUNCTION_NOT_FOUND.fetch(args[0])); return Memory.NULL; } environment.registerFunction(functionEntity); return Memory.NULL; }
@Signature(@Arg("functionName")) public Memory exportFunction(Environment env, Memory... args){ FunctionEntity functionEntity = environment.fetchFunction(args[0].toString()); if (functionEntity == null) { env.exception(Messages.ERR_FUNCTION_NOT_FOUND.fetch(args[0])); return Memory.NULL; } env.registerFunction(functionEntity); return Memory.NULL; }
@FastMethod @Signature({ @Arg("funcName") }) public static Memory functionModule(Environment env, Memory... args) { FunctionEntity entity = env.fetchFunction(args[0].toString()); if (entity != null && entity.getModule() != null) { return ObjectMemory.valueOf(new WrapModule(env, entity.getModule())); } return Memory.NULL; }
@Signature(@Arg(value = "name")) public Memory __construct(Environment env, Memory... args){ Memory name = args[0].toValue(); if (name.isClosure()){ closure = (Closure)name.toValue(ObjectMemory.class).value; closureEntity = (ClosureEntity)closure.getReflection(); } else { functionEntity = env.fetchFunction(name.toString()); if (functionEntity == null) exception(env, "Function %s does not exist", name.toString()); setFunctionEntity(functionEntity); } return Memory.NULL; }
FunctionEntity tmp = env.fetchFunction(name); functionEntity = tmp; if (tmp == null) {
&& compiler.getEnvironment().fetchFunction(realName) == null && compiler.findFunction(realName) == null) { String tryName = ((FulledNameToken) name).getLastName().getName();