Optimizes this expression as predicate. @param cc compilation context @return resulting expression @throws QueryException query exception
(final CompileContext cc)
| 103 | * @throws QueryException query exception |
| 104 | */ |
| 105 | private Expr optPred(final CompileContext cc) throws QueryException { |
| 106 | if(expr instanceof ContextValue && expr.seqType().type instanceof NodeType && |
| 107 | seqType.type instanceof final NodeType nt) { |
| 108 | // E[. instance of element(a)] → E[self::a] |
| 109 | final Test test = nt.test; |
| 110 | final Expr step = Step.self(cc, null, info, test != null ? test : NodeTest.get(nt.kind())); |
| 111 | return step != Empty.VALUE ? Path.get(cc, info, null, step) : Bln.FALSE; |
| 112 | } |
| 113 | return this; |
| 114 | } |
| 115 | |
| 116 | @Override |
| 117 | public Instance copy(final CompileContext cc, final IntObjectMap<Var> vm) { |