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)); } }
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)); } }
/** * Evaluate the variable. * * @param context the dynamic evaluation context * @return the result of evaluating the expression that is bound to the variable */ public Sequence<?> eval(XPathContext context) throws XPathException { if (evaluator == null) { setEvaluator(ExpressionTool.lazyEvaluator(getSequence(), getNominalReferenceCount() > 1)); } try { int savedOutputState = context.getTemporaryOutputState(); context.setTemporaryOutputState(StandardNames.XSL_VARIABLE); Sequence<?> result = evaluator.evaluate(getSequence(), context); context.setTemporaryOutputState(savedOutputState); return result; } catch (ClassCastException e) { // Probably the evaluation mode is wrong, as a result of an expression rewrite. Try again. assert false; int savedOutputState = context.getTemporaryOutputState(); context.setTemporaryOutputState(StandardNames.XSL_VARIABLE); Sequence<?> result = Evaluator.EAGER_SEQUENCE.evaluate(getSequence(), context); context.setTemporaryOutputState(savedOutputState); return result; } }
/** * Evaluate the variable. * * @param context the dynamic evaluation context * @return the result of evaluating the expression that is bound to the variable */ public Sequence<?> eval(XPathContext context) throws XPathException { if (evaluator == null) { setEvaluator(ExpressionTool.lazyEvaluator(getSequence(), getNominalReferenceCount() > 1)); } try { int savedOutputState = context.getTemporaryOutputState(); context.setTemporaryOutputState(StandardNames.XSL_VARIABLE); Sequence<?> result = evaluator.evaluate(getSequence(), context); context.setTemporaryOutputState(savedOutputState); return result; } catch (ClassCastException e) { // Probably the evaluation mode is wrong, as a result of an expression rewrite. Try again. assert false; int savedOutputState = context.getTemporaryOutputState(); context.setTemporaryOutputState(StandardNames.XSL_VARIABLE); Sequence<?> result = Evaluator.EAGER_SEQUENCE.evaluate(getSequence(), context); context.setTemporaryOutputState(savedOutputState); return result; } }
/** * 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 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(); }