public TailCall processLeavingTail(XPathContext context) throws XPathException { XPathContextMajor cm = (XPathContextMajor)context; ParameterSet params = assembleParams(context, actualParams); cm.setLocalParameters(params); cm.requestTailCall(continueFunction, emptyArgs); return null; }
/** * Process the template call encapsulated by this package. * @return another TailCall. This will never be the original call, but it may be the next * recursive call. For example, if A calls B which calls C which calls D, then B may return * a TailCall to A representing the call from B to C; when this is processed, the result may be * a TailCall representing the call from C to D. * @throws XPathException if a dynamic error occurs */ public TailCall processLeavingTail() throws XPathException { // TODO: the idea of tail call optimization is to reuse the caller's stack frame rather than // creating a new one. We're doing this for the Java stack, but not for the context stack where // local variables are held. It should be possible to avoid creating a new context, and instead // to update the existing one in situ. XPathContextMajor c2 = evaluationContext.newContext(); c2.setOrigin(CallTemplate.this); c2.setLocalParameters(params); c2.setTunnelParameters(tunnelParams); c2.openStackFrame(target.getStackFrameMap()); // System.err.println("Tail call on template"); return target.expand(c2); } }
/** * Process the template call encapsulated by this package. * @return another TailCall. This will never be the original call, but it may be the next * recursive call. For example, if A calls B which calls C which calls D, then B may return * a TailCall to A representing the call from B to C; when this is processed, the result may be * a TailCall representing the call from C to D. * @throws XPathException if a dynamic error occurs */ public TailCall processLeavingTail() throws XPathException { // TODO: the idea of tail call optimization is to reuse the caller's stack frame rather than // creating a new one. We're doing this for the Java stack, but not for the context stack where // local variables are held. It should be possible to avoid creating a new context, and instead // to update the existing one in situ. XPathContextMajor c2 = evaluationContext.newContext(); c2.setOrigin(instruction); c2.setLocalParameters(params); c2.setTunnelParameters(tunnelParams); c2.openStackFrame(target.getStackFrameMap()); // System.err.println("Tail call on template"); return target.expand(c2); } }
/** * Process the template call encapsulated by this package. * @return another TailCall. This will never be the original call, but it may be the next * recursive call. For example, if A calls B which calls C which calls D, then B may return * a TailCall to A representing the call from B to C; when this is processed, the result may be * a TailCall representing the call from C to D. * @throws XPathException if a dynamic error occurs */ public TailCall processLeavingTail() throws XPathException { Template nh = (Template)rule.getAction(); XPathContextMajor c2 = evaluationContext.newContext(); c2.setOrigin(NextMatch.this); c2.setLocalParameters(params); c2.setTunnelParameters(tunnelParams); c2.openStackFrame(nh.getStackFrameMap()); // System.err.println("Tail call on template"); return nh.applyLeavingTail(c2, rule); } }
/** * Process the template call encapsulated by this package. * * @return another TailCall. This will never be the original call, but it may be the next * recursive call. For example, if A calls B which calls C which calls D, then B may return * a TailCall to A representing the call from B to C; when this is processed, the result may be * a TailCall representing the call from C to D. * @throws XPathException if a dynamic error occurs */ public TailCall processLeavingTail() throws XPathException { // TODO: the idea of tail call optimization is to reuse the caller's stack frame rather than // creating a new one. We're doing this for the Java stack, but not for the context stack where // local variables are held. It should be possible to avoid creating a new context, and instead // to update the existing one in situ. NamedTemplate template = (NamedTemplate)targetComponent.getActor(); XPathContextMajor c2 = evaluationContext.newContext(); c2.setCurrentComponent(targetComponent); c2.setOrigin(instruction); c2.setLocalParameters(params); c2.setTunnelParameters(tunnelParams); c2.openStackFrame(template.getStackFrameMap()); // System.err.println("Tail call on template"); return template.expand(c2); } }
/** * Process the template call encapsulated by this package. * * @return another TailCall. This will never be the original call, but it may be the next * recursive call. For example, if A calls B which calls C which calls D, then B may return * a TailCall to A representing the call from B to C; when this is processed, the result may be * a TailCall representing the call from C to D. * @throws XPathException if a dynamic error occurs */ public TailCall processLeavingTail() throws XPathException { // TODO: the idea of tail call optimization is to reuse the caller's stack frame rather than // creating a new one. We're doing this for the Java stack, but not for the context stack where // local variables are held. It should be possible to avoid creating a new context, and instead // to update the existing one in situ. NamedTemplate template = (NamedTemplate)targetComponent.getActor(); XPathContextMajor c2 = evaluationContext.newContext(); c2.setCurrentComponent(targetComponent); c2.setOrigin(instruction); c2.setLocalParameters(params); c2.setTunnelParameters(tunnelParams); c2.openStackFrame(template.getStackFrameMap()); // System.err.println("Tail call on template"); return template.expand(c2); } }
/** * Process the template call encapsulated by this package. * * @return another TailCall. This will never be the original call, but it may be the next * recursive call. For example, if A calls B which calls C which calls D, then B may return * a TailCall to A representing the call from B to C; when this is processed, the result may be * a TailCall representing the call from C to D. * @throws XPathException if a dynamic error occurs */ public TailCall processLeavingTail() throws XPathException { TemplateRule nh = (TemplateRule) rule.getAction(); nh.initialize(); XPathContextMajor c2 = evaluationContext.newContext(); c2.setOrigin(NextMatch.this); //c2.setOriginatingConstructType(LocationKind.TEMPLATE); c2.setLocalParameters(params); c2.setTunnelParameters(tunnelParams); c2.openStackFrame(nh.getStackFrameMap()); c2.setCurrentTemplateRule(rule); c2.setCurrentComponent(evaluationContext.getCurrentComponent()); // System.err.println("Tail call on template"); return nh.applyLeavingTail(c2); } }
/** * Process the template call encapsulated by this package. * * @return another TailCall. This will never be the original call, but it may be the next * recursive call. For example, if A calls B which calls C which calls D, then B may return * a TailCall to A representing the call from B to C; when this is processed, the result may be * a TailCall representing the call from C to D. * @throws XPathException if a dynamic error occurs */ public TailCall processLeavingTail() throws XPathException { TemplateRule nh = (TemplateRule) rule.getAction(); nh.initialize(); XPathContextMajor c2 = evaluationContext.newContext(); c2.setOrigin(NextMatch.this); //c2.setOriginatingConstructType(LocationKind.TEMPLATE); c2.setLocalParameters(params); c2.setTunnelParameters(tunnelParams); c2.openStackFrame(nh.getStackFrameMap()); c2.setCurrentTemplateRule(rule); c2.setCurrentComponent(evaluationContext.getCurrentComponent()); // System.err.println("Tail call on template"); return nh.applyLeavingTail(c2); } }
/** * Process this instruction, without leaving any tail calls. * @param context the dynamic context for this transformation * @throws XPathException if a dynamic error occurs */ public void process(XPathContext context) throws XPathException { Template t = getTargetTemplate(context); XPathContextMajor c2 = context.newContext(); c2.setOrigin(this); c2.openStackFrame(t.getStackFrameMap()); c2.setLocalParameters(assembleParams(context, actualParams)); c2.setTunnelParameters(assembleTunnelParams(context, tunnelParams)); try { TailCall tc = t.expand(c2); while (tc != null) { tc = tc.processLeavingTail(); } } catch (StackOverflowError e) { XPathException err = new XPathException("Too many nested template or function calls. The stylesheet may be looping."); err.setLocator(this); err.setXPathContext(context); throw err; } }
/** * Process this instruction, without leaving any tail calls. * @param context the dynamic context for this transformation * @throws XPathException if a dynamic error occurs */ public void process(XPathContext context) throws XPathException { Template t = getTargetTemplate(context); XPathContextMajor c2 = context.newContext(); c2.setOrigin(this); c2.openStackFrame(t.getStackFrameMap()); c2.setLocalParameters(assembleParams(context, actualParams)); c2.setTunnelParameters(assembleTunnelParams(context, tunnelParams)); try { TailCall tc = t.expand(c2); while (tc != null) { tc = tc.processLeavingTail(); } } catch (StackOverflowError e) { XPathException err = new XPathException("Too many nested template or function calls. The stylesheet may be looping."); err.setLocator(this); err.setXPathContext(context); throw err; } }
c2.setLocalParameters(params); c2.setTunnelParameters(tunnels); c2.setCurrentTemplateRule(rule);
c2.setLocalParameters(params); c2.setTunnelParameters(tunnels); c2.setCurrentTemplateRule(rule);
c2.setOrigin(this); c2.setLocalParameters(params); c2.setTunnelParameters(tunnels); c2.openStackFrame(nh.getStackFrameMap());
c2.setOrigin(this); c2.setLocalParameters(params); c2.setTunnelParameters(tunnels); c2.openStackFrame(nh.getStackFrameMap());
c2.setOrigin(this); c2.openStackFrame(t.getStackFrameMap()); c2.setLocalParameters(assembleParams(context, actualParams)); c2.setTunnelParameters(assembleTunnelParams(context, tunnelParams)); if (isWithinDeclaredStreamableConstruct) {
c2.setOrigin(this); c2.openStackFrame(t.getStackFrameMap()); c2.setLocalParameters(assembleParams(context, actualParams)); c2.setTunnelParameters(assembleTunnelParams(context, tunnelParams)); if (isWithinDeclaredStreamableConstruct) {
c2.setOrigin(this); c2.openStackFrame(nh.getStackFrameMap()); c2.setLocalParameters(params); c2.setTunnelParameters(tunnels); nh.apply(c2, rule);
c2.setOrigin(this); c2.openStackFrame(nh.getStackFrameMap()); c2.setLocalParameters(params); c2.setTunnelParameters(tunnels); nh.apply(c2, rule);
c2.setCurrentComponent(initialComponent); c2.openStackFrame(t.getStackFrameMap()); c2.setLocalParameters(ordinaryParams); c2.setTunnelParameters(tunnelParams);
Template nh = (Template)rule.getAction(); c2.setOrigin(this); c2.setLocalParameters(params); c2.setTunnelParameters(tunnels); c2.openStackFrame(nh.getStackFrameMap());