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

Method optimize

basex-core/src/main/java/org/basex/query/expr/Unary.java:36–55  ·  view source on GitHub ↗
(final CompileContext cc)

Source from the content-addressed store, hash-verified

34 }
35
36 @Override
37 public Expr optimize(final CompileContext cc) throws QueryException {
38 expr = expr.simplifyFor(Simplify.NUMBER, cc);
39
40 // no negation, numeric value: return operand
41 final SeqType st = expr.seqType();
42 final Type type = st.type.isUntyped() ? BasicType.DOUBLE :
43 st.type.instanceOf(BasicType.INTEGER) ? BasicType.INTEGER : st.type;
44 final Occ occ = st.oneOrMore() && !st.mayBeWrapped() ? Occ.EXACTLY_ONE : Occ.ZERO_OR_ONE;
45 exprType.assign(type, occ);
46
47 // --123 → 123
48 // --$byte → xs:byte($byte)
49 if(!minus && st.instanceOf(Types.NUMERIC_ZO)) {
50 final Expr cast = new Cast(info, expr, SeqType.get(type, st.occ)).optimize(cc);
51 return cc.replaceWith(this, cast);
52 }
53
54 return super.optimize(cc);
55 }
56
57 @Override
58 public Item item(final QueryContext qc, final InputInfo ii) throws QueryException {

Callers

nothing calls this directly

Calls 10

oneOrMoreMethod · 0.95
mayBeWrappedMethod · 0.95
instanceOfMethod · 0.95
getMethod · 0.95
replaceWithMethod · 0.80
seqTypeMethod · 0.65
isUntypedMethod · 0.65
instanceOfMethod · 0.65
simplifyForMethod · 0.45
assignMethod · 0.45

Tested by

no test coverage detected