MCPcopy Create free account
hub / github.com/BaseXdb/basex / optPred

Method optPred

basex-core/src/main/java/org/basex/query/expr/Instance.java:105–114  ·  view source on GitHub ↗

Optimizes this expression as predicate. @param cc compilation context @return resulting expression @throws QueryException query exception

(final CompileContext cc)

Source from the content-addressed store, hash-verified

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) {

Callers 1

simplifyForMethod · 0.95

Calls 5

selfMethod · 0.95
getMethod · 0.95
getMethod · 0.95
seqTypeMethod · 0.65
kindMethod · 0.65

Tested by

no test coverage detected