(final CompileContext cc)
| 30 | } |
| 31 | |
| 32 | @Override |
| 33 | public Expr optimize(final CompileContext cc) throws QueryException { |
| 34 | super.optimize(cc); |
| 35 | if((ZERO_OR_ONE.is(expr) || EXACTLY_ONE.is(expr) || ONE_OR_MORE.is(expr)) && |
| 36 | seqType.occ.instanceOf(expr.seqType().occ)) expr = expr.arg(0); |
| 37 | |
| 38 | final SeqType st = castType(); |
| 39 | exprType.assign(st); |
| 40 | |
| 41 | final Boolean test = castable(st); |
| 42 | if(test == Boolean.FALSE) throw typeError(expr, seqType, info); |
| 43 | if(test == Boolean.TRUE) return cc.replaceWith(this, expr); |
| 44 | |
| 45 | final Expr arg = simplify(st, cc); |
| 46 | if(arg != null) return new Cast(info, arg, seqType).optimize(cc); |
| 47 | |
| 48 | return expr instanceof Value ? cc.preEval(this) : this; |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public Value value(final QueryContext qc) throws QueryException { |
nothing calls this directly
no test coverage detected