public void setEvaluator() { if (needsEagerEvaluation) { setEvaluator(ExpressionTool.eagerEvaluator(getSequence())); } else if (isIndexedVariable()) { setEvaluator(Evaluator.MAKE_INDEXED_VARIABLE); } else if (evaluator == null) { setEvaluator(ExpressionTool.lazyEvaluator(getSequence(), getNominalReferenceCount() > 1)); } }
/** * 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 XPathException */ private 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()) { Binding newBinding = ((VariableReference) seq).getBinding(); if (newBinding instanceof LetExpression) { ((LetExpression) newBinding).setIndexedVariable(); } } }
/** * 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 XPathException */ private 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()) { Binding newBinding = ((VariableReference) seq).getBinding(); if (newBinding instanceof LetExpression) { ((LetExpression) newBinding).setIndexedVariable(); } } }
replaceVariable(opt, seq); if (isIndexedVariable()) { if (seq instanceof VariableReference) { Binding newBinding = ((VariableReference) seq).getBinding();
public void setEvaluator() { if (needsEagerEvaluation) { setEvaluator(ExpressionTool.eagerEvaluator(getSequence())); } else if (isIndexedVariable()) { setEvaluator(Evaluator.MAKE_INDEXED_VARIABLE); } else if (evaluator == null) { setEvaluator(ExpressionTool.lazyEvaluator(getSequence(), getNominalReferenceCount() > 1)); } }
if (!isIndexedVariable()) { refCount = ExpressionTool.getReferenceCount(action, this, false); evaluationMode = (isIndexedVariable() ? ExpressionTool.MAKE_CLOSURE : ExpressionTool.lazyEvaluationMode(sequence));
if (!isIndexedVariable()) { refCount = ExpressionTool.getReferenceCount(action, this, false); evaluationMode = (isIndexedVariable() ? ExpressionTool.MAKE_CLOSURE : ExpressionTool.lazyEvaluationMode(sequence));
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. */ public void explain(ExpressionPresenter out) { out.startElement("let"); out.emitAttribute("variable", getVariableName()); out.emitAttribute("as", sequence.getItemType(out.getTypeHierarchy()).toString(out.getNamePool()) + Cardinality.getOccurrenceIndicator(sequence.getCardinality())); if (isIndexedVariable()) { out.emitAttribute("indexable", "true"); } out.startSubsidiaryElement("be"); sequence.explain(out); out.endSubsidiaryElement(); out.startSubsidiaryElement("return"); action.explain(out); out.endSubsidiaryElement(); out.endElement(); }
if (!isIndexedVariable()) { refCount = ExpressionTool.getReferenceCount(action, this, false); evaluationMode = (isIndexedVariable() ? ExpressionTool.MAKE_CLOSURE : ExpressionTool.lazyEvaluationMode(sequence));
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. */ public void export(ExpressionPresenter out) throws XPathException { out.startElement("let", this); out.emitAttribute("var", variableName); out.emitAttribute("as", getSequence().getStaticType().toExportString()); ExpressionPresenter.ExportOptions options = (ExpressionPresenter.ExportOptions) out.getOptions(); if (options.target.equals("JS") && options.targetVersion == 2) { out.emitAttribute("asJ", getSequence().getStaticType().toExportString2()); } if (isIndexedVariable()) { out.emitAttribute("indexable", "true"); } out.emitAttribute("slot", getLocalSlotNumber() + ""); if (evaluator == null) { setEvaluator(ExpressionTool.lazyEvaluator(getSequence(), getNominalReferenceCount() > 1)); } out.emitAttribute("eval", getEvaluator().getCode() + ""); getSequence().export(out); getAction().export(out); out.endElement(); }
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. */ public void explain(ExpressionPresenter out) { out.startElement("let"); out.emitAttribute("variable", getVariableName()); out.emitAttribute("as", sequence.getItemType(out.getTypeHierarchy()).toString(out.getNamePool()) + Cardinality.getOccurrenceIndicator(sequence.getCardinality())); if (isIndexedVariable()) { out.emitAttribute("indexable", "true"); } out.startSubsidiaryElement("be"); sequence.explain(out); out.endSubsidiaryElement(); out.startSubsidiaryElement("return"); action.explain(out); out.endSubsidiaryElement(); out.endElement(); }
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. */ public void explain(ExpressionPresenter out) { out.startElement("let"); out.emitAttribute("variable", getVariableName()); out.emitAttribute("as", sequence.getItemType(out.getTypeHierarchy()).toString(out.getNamePool()) + Cardinality.getOccurrenceIndicator(sequence.getCardinality())); if (isIndexedVariable()) { out.emitAttribute("indexable", "true"); } out.startSubsidiaryElement("be"); sequence.explain(out); out.endSubsidiaryElement(); out.startSubsidiaryElement("return"); action.explain(out); out.endSubsidiaryElement(); out.endElement(); }
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. */ public void export(ExpressionPresenter out) throws XPathException { out.startElement("let", this); out.emitAttribute("var", variableName); out.emitAttribute("as", getSequence().getStaticType().toExportString()); if (isIndexedVariable()) { out.emitAttribute("indexable", "true"); } out.emitAttribute("slot", getLocalSlotNumber() + ""); if (evaluator == null) { setEvaluator(ExpressionTool.lazyEvaluator(getSequence(), getNominalReferenceCount() > 1)); } out.emitAttribute("eval", getEvaluator().getCode() + ""); getSequence().export(out); getAction().export(out); out.endElement(); }