@Override public Item item(final QueryContext ctx, final InputInfo ii) throws QueryException { final Item a = expr[0].item(ctx, info); if (a == null) return null; final Item b = expr[1].item(ctx, info); if (b == null) return null; return calc.ev(info, a, b); }
@Override public Expr optimize(final QueryContext ctx, final VarScope scp) throws QueryException { final SeqType s0 = expr[0].type(); final SeqType s1 = expr[1].type(); final Type t0 = s0.type; final Type t1 = s1.type; if (t0.isNumberOrUntyped() && t1.isNumberOrUntyped()) { final Occ occ = s0.one() && s1.one() ? Occ.ONE : Occ.ZERO_ONE; type = SeqType.get(Calc.type(t0, t1), occ); } else if (s0.one() && s1.one()) { type = SeqType.ITEM; } return optPre(oneIsEmpty() ? null : allAreValues() ? item(ctx, info) : this, ctx); }