/** * Type-check the expression. Default implementation for unary operators that accept * any kind of operand */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { operand = visitor.typeCheck(operand, contextItemType); // if the operand value is known, pre-evaluate the expression try { if (operand instanceof Literal) { return Literal.makeLiteral(Value.asValue( SequenceExtent.makeSequenceExtent( iterate(visitor.getStaticContext().makeEarlyEvaluationContext())))); } //return (Value)ExpressionTool.eagerEvaluate(this, env.makeEarlyEvaluationContext()); } catch (XPathException err) { // if early evaluation fails, suppress the error: the value might // not be needed at run-time } return this; }
/** * Type-check the expression. Default implementation for unary operators that accept * any kind of operand */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { operand = visitor.typeCheck(operand, contextItemType); // if the operand value is known, pre-evaluate the expression try { if (operand instanceof Literal) { return Literal.makeLiteral(Value.asValue( SequenceExtent.makeSequenceExtent( iterate(visitor.getStaticContext().makeEarlyEvaluationContext())))); } //return (Value)ExpressionTool.eagerEvaluate(this, env.makeEarlyEvaluationContext()); } catch (XPathException err) { // if early evaluation fails, suppress the error: the value might // not be needed at run-time } return this; }
/** * 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 { operand.optimize(visitor, contextInfo); // if the operand value is known, pre-evaluate the expression Expression base = getBaseExpression(); try { if (base instanceof Literal) { return Literal.makeLiteral( iterate(visitor.getStaticContext().makeEarlyEvaluationContext()).materialize(), this); } } catch (XPathException err) { // if early evaluation fails, suppress the error: the value might // not be needed at run-time } return this; }
/** * Perform optimisation of an expression and its subexpressions. * <p/> * <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 contextItemType 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) */ public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { operand = visitor.optimize(operand, contextItemType); // if the operand value is known, pre-evaluate the expression try { if (operand instanceof Literal) { return Literal.makeLiteral(Value.asValue( SequenceExtent.makeSequenceExtent( iterate(visitor.getStaticContext().makeEarlyEvaluationContext())))); } } catch (XPathException err) { // if early evaluation fails, suppress the error: the value might // not be needed at run-time } return this; }
/** * Type-check the expression. Default implementation for unary operators that accept * any kind of operand */ /*@NotNull*/ public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { operand.typeCheck(visitor, contextInfo); // if the operand value is known, pre-evaluate the expression try { if (getBaseExpression() instanceof Literal) { Expression e2 = Literal.makeLiteral( iterate(visitor.getStaticContext().makeEarlyEvaluationContext()).materialize(), this); ExpressionTool.copyLocationInfo(this, e2); return e2; } //return (Value)ExpressionTool.eagerEvaluate(this, env.makeEarlyEvaluationContext()); } catch (Exception err) { // if early evaluation fails, suppress the error: the value might // not be needed at run-time } return this; }
/** * Perform optimisation of an expression and its subexpressions. * <p/> * <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 contextItemType 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) */ public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { operand = visitor.optimize(operand, contextItemType); // if the operand value is known, pre-evaluate the expression try { if (operand instanceof Literal) { return Literal.makeLiteral(Value.asValue( SequenceExtent.makeSequenceExtent( iterate(visitor.getStaticContext().makeEarlyEvaluationContext())))); } } catch (XPathException err) { // if early evaluation fails, suppress the error: the value might // not be needed at run-time } return this; }
/** * Type-check the expression. Default implementation for unary operators that accept * any kind of operand */ /*@NotNull*/ public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { operand.typeCheck(visitor, contextInfo); // if the operand value is known, pre-evaluate the expression try { if (getBaseExpression() instanceof Literal) { Expression e2 = Literal.makeLiteral( iterate(visitor.getStaticContext().makeEarlyEvaluationContext()).materialize(), this); ExpressionTool.copyLocationInfo(this, e2); return e2; } //return (Value)ExpressionTool.eagerEvaluate(this, env.makeEarlyEvaluationContext()); } catch (Exception err) { // if early evaluation fails, suppress the error: the value might // not be needed at run-time } return this; }
/** * 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 { operand.optimize(visitor, contextInfo); // if the operand value is known, pre-evaluate the expression Expression base = getBaseExpression(); try { if (base instanceof Literal) { return Literal.makeLiteral( iterate(visitor.getStaticContext().makeEarlyEvaluationContext()).materialize(), this); } } catch (XPathException err) { // if early evaluation fails, suppress the error: the value might // not be needed at run-time } return this; }