/** * Make a tail call on a different function. This reuses the context object and the stack frame array * where possible, but it does consume some Java stack space. It's still worth it, because we don't use * as much stack as we would if we didn't return down to the TailCallLoop level. * @param fn the function to be called * @param cm the dynamic context * @return the result of calling the other function * @throws XPathException if the called function fails */ private ValueRepresentation tailCallDifferentFunction(UserFunction fn, XPathContextMajor cm) throws XPathException { cm.resetStackFrameMap(fn.getStackFrameMap(), fn.getNumberOfArguments()); try { return ExpressionTool.evaluate(fn.getBody(), fn.getEvaluationMode(), cm, 1); } catch (XPathException err) { err.maybeSetLocation(this); err.maybeSetContext(cm); throw err; } }
/** * Make a tail call on a different function. This reuses the context object and the stack frame array * where possible, but it does consume some Java stack space. It's still worth it, because we don't use * as much stack as we would if we didn't return down to the TailCallLoop level. * @param fn the function to be called * @param cm the dynamic context * @return the result of calling the other function * @throws XPathException if the called function fails */ private ValueRepresentation tailCallDifferentFunction(UserFunction fn, XPathContextMajor cm) throws XPathException { cm.resetStackFrameMap(fn.getStackFrameMap(), fn.getNumberOfArguments()); try { return ExpressionTool.evaluate(fn.getBody(), fn.getEvaluationMode(), cm, 1); } catch (XPathException err) { err.maybeSetLocation(this); err.maybeSetContext(cm); throw err; } }
/** * Make a tail call on a different function. This reuses the context object and the stack frame array * where possible, but it does consume some Java stack space. It's still worth it, because we don't use * as much stack as we would if we didn't return down to the TailCallLoop level. * * @param userFunction the function to be called * @param cm the dynamic context * @return the result of calling the other function * @throws XPathException if the called function fails */ /*@Nullable*/ private Sequence<?> tailCallDifferentFunction(UserFunction userFunction, XPathContextMajor cm) throws XPathException { cm.resetStackFrameMap(userFunction.getStackFrameMap(), userFunction.getArity()); try { return userFunction.getEvaluator().evaluate(userFunction.getBody(), cm); } catch (XPathException err) { err.maybeSetLocation(getLocation()); err.maybeSetContext(cm); throw err; } }
/** * Make a tail call on a different function. This reuses the context object and the stack frame array * where possible, but it does consume some Java stack space. It's still worth it, because we don't use * as much stack as we would if we didn't return down to the TailCallLoop level. * * @param userFunction the function to be called * @param cm the dynamic context * @return the result of calling the other function * @throws XPathException if the called function fails */ /*@Nullable*/ private Sequence<?> tailCallDifferentFunction(UserFunction userFunction, XPathContextMajor cm) throws XPathException { cm.resetStackFrameMap(userFunction.getStackFrameMap(), userFunction.getArity()); try { return userFunction.getEvaluator().evaluate(userFunction.getBody(), cm); } catch (XPathException err) { err.maybeSetLocation(getLocation()); err.maybeSetContext(cm); throw err; } }