コード例 #1
0
ファイル: UserFuncs.java プロジェクト: wakamoto/basex
 /**
  * Registers and returns a new function call.
  *
  * @param ii input info
  * @param nm function name
  * @param id function id
  * @param arg arguments
  * @return new function call
  */
 private UserFuncCall add(final InputInfo ii, final QNm nm, final int id, final Expr[] arg) {
   final UserFuncCall call = new BaseFuncCall(ii, nm, arg);
   // for dynamic calls
   if (func[id].declared) call.init(func[id]);
   calls[id] = Array.add(calls[id], call);
   return call;
 }
コード例 #2
0
ファイル: UserFuncs.java プロジェクト: danielberry/basex
  /**
   * Checks if all functions have been correctly declared, and initializes all function calls.
   *
   * @throws QueryException query exception
   */
  public void check() throws QueryException {
    // initialize function calls
    for (int i = 0; i < funcs.length; ++i) {
      for (final UserFuncCall c : calls[i]) c.init(funcs[i]);
    }

    for (final UserFunc f : funcs) {
      if (f.expr == null) EXTERNALFUNC.thrw(f.info, f.name.string());
      if (!f.declared) {
        // function has not been declared yet
        for (final UserFunc uf : funcs) {
          // check if another function with same name exists
          if (f != uf && f.name.eq(uf.name)) FUNCTYPE.thrw(f.info, uf.name.string());
        }
        // if not, indicate that function is unknown
        FUNCUNKNOWN.thrw(f.info, f.name.string());
      }
    }
  }