(final CompileContext cc)
| 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 { |
nothing calls this directly
no test coverage detected