Пример #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);
  }
Пример #2
0
  /**
   * Returns the specified function.
   *
   * @param name name of the function
   * @param args optional arguments
   * @param ii input info
   * @return function instance
   */
  TypedFunc get(final QNm name, final Expr[] args, final InputInfo ii) {
    final int id = indexOf(name, args);
    if (id == -1) return null;

    // function has already been declared
    final UserFuncCall call = add(ii, funcs[id].name, id, args);
    final FuncType type = FuncType.get(funcs[id]);
    return new TypedFunc(call, type);
  }