/** * Static type checking for let expressions is delegated to the expression itself, * and is performed on the "action" expression, to allow further delegation to the branches * of a conditional * @param req the required type * @param backwardsCompatible true if backwards compatibility mode applies * @param role the role of the expression in relation to the required type * @param visitor an expression visitor * @return the expression after type checking (perhaps augmented with dynamic type checking code) * @throws XPathException if failures occur, for example if the static type of one branch of the conditional * is incompatible with the required type */ public Expression staticTypeCheck(SequenceType req, boolean backwardsCompatible, RoleLocator role, ExpressionVisitor visitor) throws XPathException { action = TypeChecker.staticTypeCheck(action, req, backwardsCompatible, role, visitor); return this; }
/** * Check the select expression against the required type. * @param visitor an expression visitor * @throws XPathException */ private void checkAgainstRequiredType(ExpressionVisitor visitor) throws XPathException { // Note, in some cases we are doing this twice. RoleLocator role = new RoleLocator(RoleLocator.VARIABLE, variableQName, 0); //role.setSourceLocator(this); SequenceType r = requiredType; if (r != null && select != null) { // check that the expression is consistent with the required type select = TypeChecker.staticTypeCheck(select, requiredType, false, role, visitor); } }
/** * Type-check the pattern. * Default implementation does nothing. This is only needed for patterns that contain * variable references or function calls. * @return the optimised Pattern */ public Pattern analyze(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { idExpression = visitor.typeCheck(idExpression, contextItemType); RoleLocator role = new RoleLocator(RoleLocator.FUNCTION, "id", 1); idExpression = TypeChecker.staticTypeCheck(idExpression, SequenceType.ATOMIC_SEQUENCE, false, role, visitor); return this; }
/** * Type-check the expression */ public Expression typeCheck(ExpressionVisitor visitor, final ItemType contextItemType) throws XPathException { operand0 = visitor.typeCheck(operand0, contextItemType); operand1 = visitor.typeCheck(operand1, contextItemType); final RoleLocator role0 = new RoleLocator(RoleLocator.BINARY_EXPR, Token.tokens[operator], 0); //role0.setSourceLocator(this); operand0 = TypeChecker.staticTypeCheck(operand0, SequenceType.NODE_SEQUENCE, false, role0, visitor); final RoleLocator role1 = new RoleLocator(RoleLocator.BINARY_EXPR, Token.tokens[operator], 1); //role1.setSourceLocator(this); operand1 = TypeChecker.staticTypeCheck(operand1, SequenceType.NODE_SEQUENCE, false, role1, visitor); return this; }
/** * Check the select expression against the required type. * @param visitor an expression visitor * @throws XPathException */ private void checkAgainstRequiredType(ExpressionVisitor visitor) throws XPathException { // Note, in some cases we are doing this twice. RoleLocator role = new RoleLocator(RoleLocator.VARIABLE, variableQName, 0, null); role.setSourceLocator(this); SequenceType r = requiredType; if (r != null && select != null) { // check that the expression is consistent with the required type select = TypeChecker.staticTypeCheck(select, requiredType, false, role, visitor); } }
public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { Expression oldop = operand; RoleLocator role = new RoleLocator(RoleLocator.UNARY_EXPR, "-", 0); operand = TypeChecker.staticTypeCheck(operand, SequenceType.OPTIONAL_NUMERIC, backwardsCompatible, role, visitor); operand = visitor.typeCheck(operand, contextItemType); if (operand != oldop) { adoptChildExpression(operand); } return this; }
public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { // always called from ArithmeticExpression.typeCheck, so the operand has already been checked. // Now need to ensure that it's numeric Expression oldop = operand; RoleLocator role = new RoleLocator(RoleLocator.UNARY_EXPR, "-", 0, null); role.setSourceLocator(this); operand = TypeChecker.staticTypeCheck(operand, SequenceType.OPTIONAL_NUMERIC, backwardsCompatible, role, visitor); if (operand != oldop) { adoptChildExpression(operand); } return this; }
/** * Type-check the expression */ public Expression typeCheck(ExpressionVisitor visitor, final ItemType contextItemType) throws XPathException { operand0 = visitor.typeCheck(operand0, contextItemType); operand1 = visitor.typeCheck(operand1, contextItemType); final RoleLocator role0 = new RoleLocator(RoleLocator.BINARY_EXPR, Token.tokens[operator], 0, null); role0.setSourceLocator(this); operand0 = TypeChecker.staticTypeCheck(operand0, SequenceType.NODE_SEQUENCE, false, role0, visitor); final RoleLocator role1 = new RoleLocator(RoleLocator.BINARY_EXPR, Token.tokens[operator], 1, null); role1.setSourceLocator(this); operand1 = TypeChecker.staticTypeCheck(operand1, SequenceType.NODE_SEQUENCE, false, role1, visitor); return this; }
/** * Type-check the expression */ public Expression typeCheck(ExpressionVisitor visitor, final ItemType contextItemType) throws XPathException { operand0 = visitor.typeCheck(operand0, contextItemType); operand1 = visitor.typeCheck(operand1, contextItemType); final RoleLocator role0 = new RoleLocator(RoleLocator.BINARY_EXPR, Token.tokens[operator], 0, null); role0.setSourceLocator(this); operand0 = TypeChecker.staticTypeCheck(operand0, SequenceType.NODE_SEQUENCE, false, role0, visitor); final RoleLocator role1 = new RoleLocator(RoleLocator.BINARY_EXPR, Token.tokens[operator], 1, null); role1.setSourceLocator(this); operand1 = TypeChecker.staticTypeCheck(operand1, SequenceType.NODE_SEQUENCE, false, role1, visitor); return this; }
/** * Type-check the pattern. * Default implementation does nothing. This is only needed for patterns that contain * variable references or function calls. * @return the optimised Pattern */ public Pattern analyze(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { idExpression = visitor.typeCheck(idExpression, contextItemType); RoleLocator role = new RoleLocator(RoleLocator.FUNCTION, "id", 1, visitor.getConfiguration().getNamePool()); idExpression = TypeChecker.staticTypeCheck(idExpression, SequenceType.ATOMIC_SEQUENCE, false, role, visitor); return this; }
/** * Type-check the expression */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { operand0 = visitor.typeCheck(operand0, contextItemType); operand1 = visitor.typeCheck(operand1, contextItemType); RoleLocator role0 = new RoleLocator(RoleLocator.BINARY_EXPR, "to", 0, null); role0.setSourceLocator(this); operand0 = TypeChecker.staticTypeCheck( operand0, SequenceType.OPTIONAL_INTEGER, false, role0, visitor); RoleLocator role1 = new RoleLocator(RoleLocator.BINARY_EXPR, "to", 1, null); role1.setSourceLocator(this); operand1 = TypeChecker.staticTypeCheck( operand1, SequenceType.OPTIONAL_INTEGER, false, role1, visitor); return makeConstantRange(); }
/** * Type-check the pattern. * Default implementation does nothing. This is only needed for patterns that contain * variable references or function calls. * @return the optimised Pattern */ public Pattern analyze(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { idExpression = visitor.typeCheck(idExpression, contextItemType); RoleLocator role = new RoleLocator(RoleLocator.FUNCTION, "id", 1, visitor.getConfiguration().getNamePool()); idExpression = TypeChecker.staticTypeCheck(idExpression, SequenceType.ATOMIC_SEQUENCE, false, role, visitor); return this; }
/** * Type-check the expression */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { operand0 = visitor.typeCheck(operand0, contextItemType); operand1 = visitor.typeCheck(operand1, contextItemType); boolean backCompat = visitor.getStaticContext().isInBackwardsCompatibleMode(); RoleLocator role0 = new RoleLocator(RoleLocator.BINARY_EXPR, "to", 0); //role0.setSourceLocator(this); operand0 = TypeChecker.staticTypeCheck( operand0, SequenceType.OPTIONAL_INTEGER, backCompat, role0, visitor); RoleLocator role1 = new RoleLocator(RoleLocator.BINARY_EXPR, "to", 1); //role1.setSourceLocator(this); operand1 = TypeChecker.staticTypeCheck( operand1, SequenceType.OPTIONAL_INTEGER, backCompat, role1, visitor); return makeConstantRange(); }
/** * Type-check the expression */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { operand0 = visitor.typeCheck(operand0, contextItemType); operand1 = visitor.typeCheck(operand1, contextItemType); RoleLocator role0 = new RoleLocator(RoleLocator.BINARY_EXPR, "to", 0, null); role0.setSourceLocator(this); operand0 = TypeChecker.staticTypeCheck( operand0, SequenceType.OPTIONAL_INTEGER, false, role0, visitor); RoleLocator role1 = new RoleLocator(RoleLocator.BINARY_EXPR, "to", 1, null); role1.setSourceLocator(this); operand1 = TypeChecker.staticTypeCheck( operand1, SequenceType.OPTIONAL_INTEGER, false, role1, visitor); return makeConstantRange(); }
/** * Type-check the pattern. This is needed for patterns that contain * variable references or function calls. * * @return the optimised Pattern */ public Pattern analyze(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { keyExpression = visitor.typeCheck(keyExpression, contextItemType); RoleLocator role = new RoleLocator(RoleLocator.FUNCTION, "key", 2); keyExpression = TypeChecker.staticTypeCheck(keyExpression, SequenceType.ATOMIC_SEQUENCE, false, role, visitor); keySet = visitor.getExecutable().getKeyManager().getKeyDefinitionSet(keyName); return this; }
/** * Type-check the pattern. This is needed for patterns that contain * variable references or function calls. * * @return the optimised Pattern */ public Pattern analyze(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { keyexp = visitor.typeCheck(keyexp, contextItemType); RoleLocator role = new RoleLocator(RoleLocator.FUNCTION, "key", 2, visitor.getConfiguration().getNamePool()); keyexp = TypeChecker.staticTypeCheck(keyexp, SequenceType.ATOMIC_SEQUENCE, false, role, visitor); keySet = visitor.getExecutable().getKeyManager().getKeyDefinitionSet(keyName); return this; }
/** * Type-check the pattern. This is needed for patterns that contain * variable references or function calls. * * @return the optimised Pattern */ public Pattern analyze(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { keyexp = visitor.typeCheck(keyexp, contextItemType); RoleLocator role = new RoleLocator(RoleLocator.FUNCTION, "key", 2, visitor.getConfiguration().getNamePool()); keyexp = TypeChecker.staticTypeCheck(keyexp, SequenceType.ATOMIC_SEQUENCE, false, role, visitor); keySet = visitor.getExecutable().getKeyManager().getKeyDefinitionSet(keyName); return this; }
/** * Perform static type checking on an argument to a function call, and add * type conversion logic where necessary. * @param arg argument number, zero-based * @param visitor an expression visitor */ private void checkArgument(int arg, ExpressionVisitor visitor) throws XPathException { RoleLocator role = new RoleLocator(RoleLocator.FUNCTION, getFunctionName(), arg); //role.setSourceLocator(this); role.setErrorCode(getErrorCodeForTypeErrors()); argument[arg] = TypeChecker.staticTypeCheck( argument[arg], getRequiredType(arg), visitor.getStaticContext().isInBackwardsCompatibleMode(), role, visitor); }
/** * Perform static type checking on an argument to a function call, and add * type conversion logic where necessary. * @param arg argument number, zero-based * @param visitor an expression visitor */ private void checkArgument(int arg, ExpressionVisitor visitor) throws XPathException { RoleLocator role = new RoleLocator(RoleLocator.FUNCTION, getFunctionName(), arg, visitor.getConfiguration().getNamePool()); role.setSourceLocator(this); role.setErrorCode(getErrorCodeForTypeErrors()); argument[arg] = TypeChecker.staticTypeCheck( argument[arg], getRequiredType(arg), visitor.getStaticContext().isInBackwardsCompatibleMode(), role, visitor); }
/** * Perform static type checking on an argument to a function call, and add * type conversion logic where necessary. * @param arg argument number, zero-based * @param visitor an expression visitor */ private void checkArgument(int arg, ExpressionVisitor visitor) throws XPathException { RoleLocator role = new RoleLocator(RoleLocator.FUNCTION, getFunctionName(), arg, visitor.getConfiguration().getNamePool()); role.setSourceLocator(this); role.setErrorCode(getErrorCodeForTypeErrors()); argument[arg] = TypeChecker.staticTypeCheck( argument[arg], getRequiredType(arg), visitor.getStaticContext().isInBackwardsCompatibleMode(), role, visitor); }