/** * Perform optimisation of an expression and its subexpressions. * <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 an 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 { getLhs().optimize(visitor, contextInfo); getRhs().optimize(visitor, contextInfo); return makeConstantRange(); }
/** * Type-check the expression */ /*@NotNull*/ public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getLhs().typeCheck(visitor, contextInfo); getRhs().typeCheck(visitor, contextInfo); boolean backCompat = visitor.getStaticContext().isInBackwardsCompatibleMode(); TypeChecker tc = visitor.getConfiguration().getTypeChecker(backCompat); RoleDiagnostic role0 = new RoleDiagnostic(RoleDiagnostic.BINARY_EXPR, "to", 0); setLhsExpression(tc.staticTypeCheck( getLhsExpression(), SequenceType.OPTIONAL_INTEGER, role0, visitor)); RoleDiagnostic role1 = new RoleDiagnostic(RoleDiagnostic.BINARY_EXPR, "to", 1); setRhsExpression(tc.staticTypeCheck( getRhsExpression(), SequenceType.OPTIONAL_INTEGER, role1, visitor)); return makeConstantRange(); }
/** * Type-check the expression */ /*@NotNull*/ public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getLhs().typeCheck(visitor, contextInfo); getRhs().typeCheck(visitor, contextInfo); boolean backCompat = visitor.getStaticContext().isInBackwardsCompatibleMode(); TypeChecker tc = visitor.getConfiguration().getTypeChecker(backCompat); RoleDiagnostic role0 = new RoleDiagnostic(RoleDiagnostic.BINARY_EXPR, "to", 0); setLhsExpression(tc.staticTypeCheck( getLhsExpression(), SequenceType.OPTIONAL_INTEGER, role0, visitor)); RoleDiagnostic role1 = new RoleDiagnostic(RoleDiagnostic.BINARY_EXPR, "to", 1); setRhsExpression(tc.staticTypeCheck( getRhsExpression(), SequenceType.OPTIONAL_INTEGER, role1, visitor)); return makeConstantRange(); }
/** * Perform optimisation of an expression and its subexpressions. * <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 an 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 { getLhs().optimize(visitor, contextInfo); getRhs().optimize(visitor, contextInfo); return makeConstantRange(); }