public Operand getLhs() { return getOperand(); }
public Operand getLhs() { return getOperand(); }
/** * Perform optimisation of an expression and its subexpressions. This is the third and final * phase of static optimization. * <p>This method is called after all references to functions and variables have been resolved * to the declaration of the function or variable, and after all type checking has been done.</p> * * @param visitor the expression visitor * @param contextInfo the static type of "." at the point where this expression is invoked. * The parameter is set to null if it is known statically that the context item will be undefined. * If the type of the context item is not known statically, the argument is set to * {@link net.sf.saxon.type.Type#ITEM_TYPE} * @return the original expression, rewritten if appropriate to optimize execution * @throws XPathException if an error is discovered during this phase * (typically a type error) */ /*@NotNull*/ public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getOperand().optimize(visitor, contextInfo); if (getLhsExpression() instanceof Literal) { return Literal.makeLiteral(BooleanValue.get(effectiveBooleanValue(null)), this); } return this; }
/** * Perform optimisation of an expression and its subexpressions. This is the third and final * phase of static optimization. * <p>This method is called after all references to functions and variables have been resolved * to the declaration of the function or variable, and after all type checking has been done.</p> * * @param visitor the expression visitor * @param contextInfo the static type of "." at the point where this expression is invoked. * The parameter is set to null if it is known statically that the context item will be undefined. * If the type of the context item is not known statically, the argument is set to * {@link net.sf.saxon.type.Type#ITEM_TYPE} * @return the original expression, rewritten if appropriate to optimize execution * @throws XPathException if an error is discovered during this phase * (typically a type error) */ /*@NotNull*/ public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getOperand().optimize(visitor, contextInfo); if (getLhsExpression() instanceof Literal) { return Literal.makeLiteral(BooleanValue.get(effectiveBooleanValue(null)), this); } return this; }
public AbstractExpression exprFor (CompareToIntegerConstant comp) { Operator op = operatorFor (comp.getComparisonOperator()); long num = comp.getComparand(); return new BinaryOperation (exprFor (comp.getOperand()), op, new LiteralExpression (num)); }