Exemple #1
0
 /**
  * Replace all references to the variable bound by this let expression, that occur within the
  * action expression, with the given expression
  *
  * @param opt The optimizer
  * @param seq the expression
  * @throws net.sf.saxon.trans.XPathException
  */
 public void replaceVariable(Optimizer opt, Expression seq) throws XPathException {
   PromotionOffer offer2 = new PromotionOffer(opt);
   offer2.action = PromotionOffer.INLINE_VARIABLE_REFERENCES;
   offer2.bindingList = new Binding[] {this};
   offer2.containingExpression = seq;
   action = doPromotion(action, offer2);
   if (offer2.accepted) {
     // there might be further references to the variable
     offer2.accepted = false;
     replaceVariable(opt, seq);
   }
   if (isIndexedVariable() && seq instanceof VariableReference) {
     Binding newBinding = ((VariableReference) seq).getBinding();
     if (newBinding instanceof Assignation) {
       ((Assignation) newBinding).setIndexedVariable();
     }
   }
 }
Exemple #2
0
 /** Promote this expression if possible */
 public Expression promote(PromotionOffer offer) throws XPathException {
   Expression exp = offer.accept(this);
   if (exp != null) {
     return exp;
   } else {
     if (offer.action != PromotionOffer.UNORDERED) {
       // we can't push the UNORDERED property down to the operand, because order is significant
       operand = doPromotion(operand, offer);
     }
     return this;
   }
 }
 /** Promote this expression if possible */
 public Expression promote(PromotionOffer offer, Expression parent) throws XPathException {
   Expression exp = offer.accept(parent, this);
   if (exp != null) {
     return exp;
   } else {
     if (offer.action != PromotionOffer.UNORDERED) {
       operand0 = doPromotion(this, operand0, offer);
       operand1 = doPromotion(this, operand1, offer);
     }
     return this;
   }
 }
Exemple #4
0
 /** Promote this expression if possible */
 public Expression promote(PromotionOffer offer, Expression parent) throws XPathException {
   Expression exp = offer.accept(parent, this);
   if (exp != null) {
     return exp;
   } else {
     sequence = doPromotion(sequence, offer);
     if (offer.action == PromotionOffer.INLINE_VARIABLE_REFERENCES
         || offer.action == PromotionOffer.UNORDERED
         || offer.action == PromotionOffer.REPLACE_CURRENT) {
       action = doPromotion(action, offer);
     } else if (offer.action == PromotionOffer.RANGE_INDEPENDENT
         || offer.action == PromotionOffer.FOCUS_INDEPENDENT) {
       // Pass the offer to the action expression only if the action isn't dependent on the
       // variable bound by this assignation
       Binding[] savedBindingList = offer.bindingList;
       offer.bindingList = extendBindingList(offer.bindingList);
       action = doPromotion(action, offer);
       offer.bindingList = savedBindingList;
     }
     return this;
   }
 }