Example #1
0
  /**
   * Returns the specified function literal.
   *
   * @param name function name
   * @param arity number of arguments
   * @param dyn dynamic invocation flag
   * @param ctx query context
   * @param ii input info
   * @return literal function expression
   * @throws QueryException query exception
   */
  public static FItem get(
      final QNm name,
      final long arity,
      final boolean dyn,
      final QueryContext ctx,
      final InputInfo ii)
      throws QueryException {

    final Expr[] args = new Expr[(int) arity];
    final Var[] vars = new Var[args.length];
    for (int i = 0; i < args.length; i++) {
      vars[i] = ctx.uniqueVar(ii, null);
      args[i] = new VarRef(ii, vars[i]);
    }

    final TypedFunc f = get(name, args, dyn, ctx, ii);
    if (f == null) {
      if (!dyn) FUNCUNKNOWN.thrw(ii, name + "#" + arity);
      return null;
    }

    // compile the function if it hasn't been done statically
    if (dyn && f.fun instanceof UserFuncCall) {
      final UserFunc usf = ((UserFuncCall) f.fun).func();
      if (usf != null && usf.declared) usf.compile(ctx);
    }

    final FuncType ft = f.type;
    return new FuncItem(name, vars, f.fun, ft, false);
  }
Example #2
0
 @Override
 public String toString() {
   final StringBuilder sb = new StringBuilder();
   for (final UserFunc f : funcs) sb.append(f.toString());
   return sb.toString();
 }
Example #3
0
 /**
  * Checks if the function performs updates.
  *
  * @throws QueryException query exception
  */
 public void checkUp() throws QueryException {
   for (final UserFunc f : funcs) f.checkUp();
 }