(final CompileContext cc)
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public Expr optimize(final CompileContext cc) throws QueryException { |
| 42 | exprs = simplifyAll(Simplify.STRING, cc); |
| 43 | if(values(false, cc)) return cc.preEval(this); |
| 44 | |
| 45 | // swap operands |
| 46 | if(swap()) { |
| 47 | cc.info(OPTSWAP_X, this); |
| 48 | Collections.reverse(Arrays.asList(exprs)); |
| 49 | op = op.swap(); |
| 50 | } |
| 51 | |
| 52 | Expr expr = emptyExpr(); |
| 53 | if(expr == this) expr = toGeneral(cc, true); |
| 54 | if(expr == this) expr = opt(cc); |
| 55 | if(expr == this) { |
| 56 | // restrict type |
| 57 | final SeqType st1 = exprs[0].seqType(), st2 = exprs[1].seqType(); |
| 58 | if(st1.oneOrMore() && !st1.mayBeWrapped() && st2.oneOrMore() && !st2.mayBeWrapped()) { |
| 59 | exprType.assign(Occ.EXACTLY_ONE); |
| 60 | } |
| 61 | } |
| 62 | return cc.replaceWith(this, expr); |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public Expr simplifyFor(final Simplify mode, final CompileContext cc) throws QueryException { |
no test coverage detected