Beispiel #1
0
  /**
   * Adds and returns a user-defined function that has not been defined yet.
   *
   * @param name name of the function
   * @param args optional arguments
   * @param ii input info
   * @return function instance
   * @throws QueryException query exception
   */
  TypedFunc add(final QNm name, final Expr[] args, final InputInfo ii) throws QueryException {

    // add function call for function that has not been declared yet
    final int al = args.length;
    final UserFunc uf = new UserFunc(ii, name, new Var[al], null, null, false);
    final UserFuncCall call = add(ii, name, add(uf, ii), args);
    final FuncType type = FuncType.arity(al);
    return new TypedFunc(call, type);
  }
Beispiel #2
0
 /**
  * Creates a function literal for a function that was not yet encountered while parsing.
  *
  * @param nm function name
  * @param ar function arity
  * @param ctx query context
  * @param ii input info
  * @return function literal
  * @throws QueryException query exception
  */
 public static FuncLit unknown(
     final QNm nm, final long ar, final QueryContext ctx, final InputInfo ii)
     throws QueryException {
   final VarScope scp = new VarScope();
   final FuncType temp = FuncType.arity((int) ar);
   final Var[] arg = new Var[(int) ar];
   final Expr[] refs = temp.args(arg, ctx, scp, ii);
   final TypedFunc call = ctx.funcs.getFuncRef(nm, refs, ctx.sc, ii);
   return new FuncLit(nm, arg, call.fun, null, scp, ctx.sc, ii);
 }
Beispiel #3
0
 /**
  * Constructor.
  *
  * @param nm function name
  * @param arg formal parameters
  * @param fn function body
  * @param ft function type
  * @param scp variable scope
  * @param sctx static context
  * @param ii input info
  */
 public FuncLit(
     final QNm nm,
     final Var[] arg,
     final Expr fn,
     final FuncType ft,
     final VarScope scp,
     final StaticContext sctx,
     final InputInfo ii) {
   super(ii, fn);
   name = nm;
   args = arg;
   check = ft == null;
   type = (ft == null ? FuncType.arity(args.length) : ft).seqType();
   scope = scp;
   sc = sctx;
 }