Пример #1
0
  @Override
  public Expr inline(final QueryContext qc, final VarScope scp, final Var var, final Expr ex)
      throws QueryException {

    boolean change = false;
    try {
      final Expr sub = expr.inline(qc, scp, var, ex);
      if (sub != null) {
        if (sub.isValue()) return optPre(sub, qc);
        expr = sub;
        change = true;
      }
    } catch (final QueryException qe) {
      if (!qe.isCatchable()) throw qe;
      for (final Catch c : catches) {
        if (c.matches(qe)) {
          // found a matching clause, inline variable and error message
          final Catch nw = c.inline(qc, scp, var, ex);
          return optPre((nw == null ? c : nw).asExpr(qe, qc, scp), qc);
        }
      }
      throw qe;
    }

    for (final Catch c : catches) change |= c.inline(qc, scp, var, ex) != null;
    return change ? this : null;
  }
Пример #2
0
 @Override
 public Expr optimize(final QueryContext qc, final VarScope scp) throws QueryException {
   seqType = expr.seqType();
   for (final Catch c : catches) {
     if (!c.expr.isFunction(Function.ERROR)) seqType = seqType.union(c.seqType());
   }
   return this;
 }
Пример #3
0
 @Override
 public Value value(final QueryContext qc) throws QueryException {
   // don't catch errors from error handlers
   try {
     return qc.value(expr);
   } catch (final QueryException ex) {
     if (!ex.isCatchable()) throw ex;
     for (final Catch c : catches) if (c.matches(ex)) return c.value(qc, ex);
     throw ex;
   }
 }
Пример #4
0
  @Override
  public Expr compile(final QueryContext qc, final VarScope scp) throws QueryException {
    try {
      super.compile(qc, scp);
      if (expr.isValue()) return optPre(expr, qc);
    } catch (final QueryException ex) {
      if (!ex.isCatchable()) throw ex;
      for (final Catch c : catches) {
        if (c.matches(ex)) {
          // found a matching clause, compile and inline error message
          return optPre(c.compile(qc, scp).asExpr(ex, qc, scp), qc);
        }
      }
      throw ex;
    }

    for (final Catch c : catches) c.compile(qc, scp);
    return optimize(qc, scp);
  }
Пример #5
0
 @Override
 public void markTailCalls(final QueryContext qc) {
   for (final Catch c : catches) c.markTailCalls(qc);
 }
Пример #6
0
 @Override
 public boolean removable(final Var var) {
   for (final Catch c : catches) if (!c.removable(var)) return false;
   return super.removable(var);
 }
Пример #7
0
 @Override
 public boolean has(final Flag flag) {
   for (final Catch c : catches) if (c.has(flag)) return true;
   return super.has(flag);
 }