//function are in a different order to the arguments supplied to the defined
//function
//Thus we will build the list of arguments used to expand the inner function
//manually
List<Var> defArgs = def.getArgList();
ExprList subArgs = new ExprList();
for (int i = 0; i < args.size(); i++) {
Expr arg = args.get(i);
String var = arg.getVarName();
if (var == null) {
//Non-variable args may be passed as-is
subArgs.add(arg);
} else {
//Variable args must be checked to ensure they are within the number of
//arguments of the invoked function
//We then use the arg as-is to substitute
if (i > defArgs.size()) throw new ExprBuildException("Unable to expand function dependency, the function <" + def.getUri() + "> is called but uses an argument ?" + var + " which is not an argument to the outer function");
subArgs.add(arg);
}
}
//Expand the function
uFunc.build(def.getUri(), subArgs);