| 1 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2 | // Copyright (c) 2018 Saxonica Limited. |
| 3 | // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. |
| 4 | // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. |
| 6 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 7 | |
| 8 | package net.sf.saxon.expr; |
| 9 | |
| 10 | import net.sf.saxon.expr.parser.ContextItemStaticInfo; |
| 11 | import net.sf.saxon.expr.parser.ExpressionTool; |
| 12 | import net.sf.saxon.expr.parser.ExpressionVisitor; |
| 13 | import net.sf.saxon.trans.XPathException; |
| 14 | |
| 15 | /** |
| 16 | * An EagerLetExpression is the same as a LetExpression except that the variable is evaluated using |
| 17 | * eager evaluation rather than lazy evaluation. This is used when performing diagnostic tracing. |
| 18 | */ |
| 19 | |
| 20 | public class EagerLetExpression extends LetExpression { |
| 21 | |
| 22 | public EagerLetExpression() { |
| 23 | } |
| 24 | |
| 25 | /*@NotNull*/ |
| 26 | public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { |
| 27 | Expression e = super.optimize(visitor, contextItemType); |
| 28 | if (e == this) { |
| 29 | setEvaluator(ExpressionTool.eagerEvaluator(getSequence())); |
| 30 | } |
| 31 | return e; |
| 32 | } |
| 33 | |
| 34 | } |
| 35 | |
| 36 |