/** * Copy an expression. This makes a deep copy. * @return the copy of the original expression */ public Expression copy() { LetExpression let = new LetExpression(); let.setVariableQName(variableName); let.setRequiredType(requiredType); let.setSequence(sequence.copy()); Expression newAction = action.copy(); let.setAction(newAction); ExpressionTool.rebindVariableReferences(newAction, this, let); return let; }
/** * Copy an expression. This makes a deep copy. * @return the copy of the original expression */ public Expression copy() { LetExpression let = new LetExpression(); let.setVariableQName(variableName); let.setRequiredType(requiredType); let.setSequence(sequence.copy()); Expression newAction = action.copy(); let.setAction(newAction); ExpressionTool.rebindVariableReferences(newAction, this, let); return let; }
/** * Copy an expression. This makes a deep copy. * @return the copy of the original expression */ public Expression copy() { LetExpression let = new LetExpression(); let.setVariableQName(variableName); let.setRequiredType(requiredType); let.setSequence(sequence.copy()); Expression newAction = action.copy(); let.setAction(newAction); ExpressionTool.rebindVariableReferences(newAction, this, let); return let; }
/** * Resolve calls to the XSLT current() function within an expression * @param exp the expression within which calls to current() should be resolved * @param config the Saxon configuration * @return the expression after resolving calls to current() */ public static Expression resolveCallsToCurrentFunction(Expression exp, Configuration config) throws XPathException { if (callsFunction(exp, Current.FN_CURRENT)) { LetExpression let = new LetExpression(); let.setVariableQName( new StructuredQName("saxon", NamespaceConstant.SAXON, "current" + exp.hashCode())); let.setRequiredType(SequenceType.SINGLE_ITEM); let.setSequence(new CurrentItemExpression()); PromotionOffer offer = new PromotionOffer(config.getOptimizer()); offer.action = PromotionOffer.REPLACE_CURRENT; offer.containingExpression = let; exp = exp.promote(offer); let.setAction(exp); return let; } else { return exp; } }
/** * Resolve calls to the XSLT current() function within an expression * @param exp the expression within which calls to current() should be resolved * @param config the Saxon configuration * @return the expression after resolving calls to current() */ public static Expression resolveCallsToCurrentFunction(Expression exp, Configuration config) throws XPathException { if (callsFunction(exp, Current.FN_CURRENT)) { LetExpression let = new LetExpression(); let.setVariableQName( new StructuredQName("saxon", NamespaceConstant.SAXON, "current" + exp.hashCode())); let.setRequiredType(SequenceType.SINGLE_ITEM); let.setSequence(new CurrentItemExpression()); PromotionOffer offer = new PromotionOffer(config.getOptimizer()); offer.action = PromotionOffer.REPLACE_CURRENT; offer.containingExpression = let; exp = exp.promote(offer); let.setAction(exp); return let; } else { return exp; } }
private Expression parseTypeswitchReturnClause(StructuredQName varQName, LetExpression outerLet) throws XPathException { Expression action; // t.treatCurrentAsOperator(); // expect(Token.RETURN); // nextToken(); LetExpression innerLet = makeLetExpression(); innerLet.setRequiredType(SequenceType.ANY_SEQUENCE); innerLet.setVariableQName(varQName); innerLet.setSequence(new LocalVariableReference(outerLet)); declareRangeVariable(innerLet); action = parseExprSingle(); undeclareRangeVariable(); innerLet.setAction(action); return innerLet; // if (Literal.isEmptySequence(action)) { // // The purpose of simplifying this now is that () is allowed in a branch even in XQuery Update when // // other branches of the typeswitch are updating. // return action; // } else { // return innerLet; // } }
private Expression parseTypeswitchReturnClause(StructuredQName varQName, LetExpression outerLet) throws XPathException { Expression action; // t.treatCurrentAsOperator(); // expect(Token.RETURN); // nextToken(); LetExpression innerLet = makeLetExpression(); innerLet.setRequiredType(SequenceType.ANY_SEQUENCE); innerLet.setVariableQName(varQName); innerLet.setSequence(new LocalVariableReference(outerLet)); declareRangeVariable(innerLet); action = parseExprSingle(); undeclareRangeVariable(); innerLet.setAction(action); return innerLet; // if (Literal.isEmptySequence(action)) { // // The purpose of simplifying this now is that () is allowed in a branch even in XQuery Update when // // other branches of the typeswitch are updating. // return action; // } else { // return innerLet; // } }
private Expression parseTypeswitchReturnClause(StructuredQName varQName, LetExpression outerLet) throws XPathException { Expression action; t.treatCurrentAsOperator(); expect(Token.RETURN); nextToken(); LetExpression innerLet = makeLetExpression(); innerLet.setRequiredType(SequenceType.ANY_SEQUENCE); innerLet.setVariableQName(varQName); innerLet.setSequence(new LocalVariableReference(outerLet)); declareRangeVariable(innerLet); action = parseExprSingle(); undeclareRangeVariable(); innerLet.setAction(action); action = innerLet; return action; }
private Expression parseTypeswitchReturnClause(StructuredQName varQName, LetExpression outerLet) throws XPathException { Expression action; t.treatCurrentAsOperator(); expect(Token.RETURN); nextToken(); LetExpression innerLet = makeLetExpression(); innerLet.setRequiredType(SequenceType.ANY_SEQUENCE); innerLet.setVariableQName(varQName); innerLet.setSequence(new LocalVariableReference(outerLet)); declareRangeVariable(innerLet); action = parseExprSingle(); undeclareRangeVariable(); innerLet.setAction(action); return innerLet; // if (Literal.isEmptySequence(action)) { // // The purpose of simplifying this now is that () is allowed in a branch even in XQuery Update when // // other branches of the typeswitch are updating. // return action; // } else { // return innerLet; // } }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression * @param rebindings variables whose binding needs to change */ /*@NotNull*/ public Expression copy(RebindingMap rebindings) { LetExpression let = new LetExpression(); ExpressionTool.copyLocationInfo(this, let); let.isIndexedVariable = isIndexedVariable; let.hasLoopingReference = hasLoopingReference; let.setNeedsEagerEvaluation(needsEagerEvaluation); let.setNeedsLazyEvaluation(needsLazyEvaluation); let.setVariableQName(variableName); let.setRequiredType(requiredType); let.setSequence(getSequence().copy(rebindings)); let.setInstruction(isInstruction()); Expression newAction = getAction().copy(rebindings); let.setAction(newAction); ExpressionTool.rebindVariableReferences(newAction, this, let); return let; }
let.setRequiredType(type); ExpressionTool.copyLocationInfo(child, let); let.setSequence(child); let.setNeedsLazyEvaluation(true); let.setEvaluationMode(Cardinality.allowsMany(child.getCardinality()) ? ExpressionTool.MAKE_MEMO_CLOSURE : ExpressionTool.MAKE_SINGLETON_CLOSURE);
new StructuredQName("vv", NamespaceConstant.SAXON_GENERATED_VARIABLE, "current" + exp.hashCode())); let.setRequiredType(SequenceType.SINGLE_ITEM); let.setSequence(new CurrentItemExpression()); replaceCallsToCurrent(exp, let); let.setAction(exp);
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression * @param rebindings variables whose binding needs to change */ /*@NotNull*/ public Expression copy(RebindingMap rebindings) { LetExpression let = new LetExpression(); ExpressionTool.copyLocationInfo(this, let); let.isIndexedVariable = isIndexedVariable; let.hasLoopingReference = hasLoopingReference; let.setNeedsEagerEvaluation(needsEagerEvaluation); let.setNeedsLazyEvaluation(needsLazyEvaluation); let.setVariableQName(variableName); let.setRequiredType(requiredType); let.setSequence(getSequence().copy(rebindings)); let.setInstruction(isInstruction()); Expression newAction = getAction().copy(rebindings); let.setAction(newAction); ExpressionTool.rebindVariableReferences(newAction, this, let); return let; }
let.setRequiredType(type); ExpressionTool.copyLocationInfo(containingExpression, let); let.setSequence(LazyExpression.makeLazyExpression(child)); let.setAction(containingExpression); let.adoptChildExpression(containingExpression);
let.setRequiredType(type); ExpressionTool.copyLocationInfo(containingExpression, let); let.setSequence(LazyExpression.makeLazyExpression(child)); let.setAction(containingExpression); let.adoptChildExpression(containingExpression);
let.setRequiredType(type); ExpressionTool.copyLocationInfo(containingExpression, let); let.setSequence(LazyExpression.makeLazyExpression(child)); let.setAction(containingExpression); let.adoptChildExpression(containingExpression);
new StructuredQName("saxon", NamespaceConstant.SAXON, "dot" + exp.hashCode())); let.setRequiredType(SequenceType.makeSequenceType(contextItemType, StaticProperty.EXACTLY_ONE)); let.setSequence(new ContextItemExpression()); let.setAction(exp); boolean changed = factorOutDot(exp, let);
new StructuredQName("vv", NamespaceConstant.SAXON_GENERATED_VARIABLE, "current" + exp.hashCode())); let.setRequiredType(SequenceType.SINGLE_ITEM); let.setSequence(new CurrentItemExpression()); replaceCallsToCurrent(exp, let); let.setAction(exp);
/** * Type-check the expression. This also has the side-effect of counting the number of references * to the variable (treating references that occur within a loop specially) */ /*@NotNull*/ public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { // The order of events is critical here. First we ensure that the type of the // sequence expression is established. This is used to establish the type of the variable, // which in turn is required when type-checking the action part. getSequenceOp().typeCheck(visitor, contextInfo); RoleDiagnostic role = new RoleDiagnostic(RoleDiagnostic.VARIABLE, getVariableQName().getDisplayName(), 0); //role.setSourceLocator(this); setSequence(TypeChecker.strictTypeCheck( getSequence(), requiredType, role, visitor.getStaticContext())); final ItemType actualItemType = getSequence().getItemType(); refineTypeInformation(actualItemType, getSequence().getCardinality(), getSequence() instanceof Literal ? ((Literal) getSequence()).getValue() : null, getSequence().getSpecialProperties(), this); getActionOp().typeCheck(visitor, contextInfo); return this; }
/** * Type-check the expression. This also has the side-effect of counting the number of references * to the variable (treating references that occur within a loop specially) */ /*@NotNull*/ public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { // The order of events is critical here. First we ensure that the type of the // sequence expression is established. This is used to establish the type of the variable, // which in turn is required when type-checking the action part. getSequenceOp().typeCheck(visitor, contextInfo); RoleDiagnostic role = new RoleDiagnostic(RoleDiagnostic.VARIABLE, getVariableQName().getDisplayName(), 0); //role.setSourceLocator(this); setSequence(TypeChecker.strictTypeCheck( getSequence(), requiredType, role, visitor.getStaticContext())); final ItemType actualItemType = getSequence().getItemType(); refineTypeInformation(actualItemType, getSequence().getCardinality(), getSequence() instanceof Literal ? ((Literal) getSequence()).getValue() : null, getSequence().getSpecialProperties(), this); getActionOp().typeCheck(visitor, contextInfo); return this; }