public class TypeChecker10 extends TypeChecker
Constructor and Description |
---|
TypeChecker10() |
Modifier and Type | Method and Description |
---|---|
Expression |
makeArithmeticExpression(Expression lhs,
int operator,
Expression rhs) |
Expression |
makeGeneralComparison(Expression lhs,
int operator,
Expression rhs) |
Expression |
processValueOf(Expression select,
Configuration config) |
Expression |
staticTypeCheck(Expression supplied,
SequenceType req,
RoleDiagnostic role,
ExpressionVisitor visitor)
Check an expression against a required type, modifying it if necessary.
|
ebvError, strictTypeCheck, testConformance
public Expression staticTypeCheck(Expression supplied, SequenceType req, RoleDiagnostic role, ExpressionVisitor visitor) throws XPathException
TypeChecker
This method takes the supplied expression and checks to see whether it is known statically to conform to the specified type. There are three possible outcomes. If the static type of the expression is a subtype of the required type, the method returns the expression unchanged. If the static type of the expression is incompatible with the required type (for example, if the supplied type is integer and the required type is string) the method throws an exception (this results in a compile-time type error being reported). If the static type is a supertype of the required type, then a new expression is constructed that evaluates the original expression and checks the dynamic type of the result; this new expression is returned as the result of the method.
The rules applied are those for function calling in XPath, that is, the rules that the argument of a function call must obey in relation to the signature of the function. Some contexts require slightly different rules (for example, operands of polymorphic operators such as "+"). In such cases this method cannot be used.
Note that this method does not do recursive type-checking of the sub-expressions.
staticTypeCheck
in class TypeChecker
supplied
- The expression to be type-checkedreq
- The required type for the context in which the expression is usedrole
- Information about the role of the subexpression within the
containing expression, used to provide useful error messagesvisitor
- An expression visitorXPathException
- if the supplied type is statically inconsistent with the
required type (that is, if they have no common subtype)public Expression makeArithmeticExpression(Expression lhs, int operator, Expression rhs)
makeArithmeticExpression
in class TypeChecker
public Expression makeGeneralComparison(Expression lhs, int operator, Expression rhs)
makeGeneralComparison
in class TypeChecker
public Expression processValueOf(Expression select, Configuration config)
processValueOf
in class TypeChecker
Copyright (c) 2004-2018 Saxonica Limited. All rights reserved.