| 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.instruct; |
| 9 | |
| 10 | import net.sf.saxon.trans.XPathException; |
| 11 | |
| 12 | |
| 13 | /** |
| 14 | * Interface representing a Tail Call. This is a package of information passed back by a called |
| 15 | * instruction to its caller, representing a call (and its arguments) that needs to be made |
| 16 | * by the caller. This saves stack space by unwinding the stack before making the call. |
| 17 | */ |
| 18 | |
| 19 | public interface TailCall { |
| 20 | |
| 21 | /** |
| 22 | * Process this TailCall (that is, executed the template call that is packaged in this |
| 23 | * object). This may return a further TailCall, which should also be processed: this |
| 24 | * is the mechanism by which a nested set of recursive calls is converted into an iteration. |
| 25 | * |
| 26 | * @return a further TailCall, if the recursion continues, or null, indicating that the |
| 27 | * recursion has terminated. |
| 28 | * @throws net.sf.saxon.trans.XPathException |
| 29 | * if any error occurs processing the tail call |
| 30 | */ |
| 31 | |
| 32 | public TailCall processLeavingTail() throws XPathException; |
| 33 | |
| 34 | } |
| 35 |