public TailCall processLeavingTail(XPathContext context) throws XPathException { if (context instanceof XPathContextMajor) { ((XPathContextMajor)context).requestTailCall(breakFunction, emptyArgs); } return null; }
public void markContext(XPathContext context) { XPathContext c = context; while (!(c instanceof XPathContextMajor)) { c = c.getCaller(); } ((XPathContextMajor) c).requestTailCall(this, null); }
public void markContext(XPathContext context) { XPathContext c = context; while (!(c instanceof XPathContextMajor)) { c = c.getCaller(); } ((XPathContextMajor) c).requestTailCall(this, null); }
private void requestTailCall(XPathContext context, Sequence<?>[] actualArgs) { if (bindingSlot >= 0) { TailCallLoop.TailCallComponent info = new TailCallLoop.TailCallComponent(); Component target = getTargetComponent(context); info.component = target; info.function = (UserFunction) target.getActor(); ((XPathContextMajor) context).requestTailCall(info, actualArgs); } else { TailCallLoop.TailCallFunction info = new TailCallLoop.TailCallFunction(); info.function = function; ((XPathContextMajor) context).requestTailCall(info, actualArgs); } }
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; }
private void requestTailCall(XPathContext context, Sequence<?>[] actualArgs) { if (bindingSlot >= 0) { TailCallLoop.TailCallComponent info = new TailCallLoop.TailCallComponent(); Component target = getTargetComponent(context); info.component = target; info.function = (UserFunction) target.getActor(); ((XPathContextMajor) context).requestTailCall(info, actualArgs); } else { TailCallLoop.TailCallFunction info = new TailCallLoop.TailCallFunction(); info.function = function; ((XPathContextMajor) context).requestTailCall(info, actualArgs); } }
public TailCall processLeavingTail(XPathContext context) throws XPathException { XPathContext c = context; while (!(c instanceof XPathContextMajor)) { c = c.getCaller(); } XPathContextMajor cm = (XPathContextMajor)c; if (actualParams.length == 1) { cm.setLocalVariable(actualParams[0].getSlotNumber(), actualParams[0].getSelectValue(context)); } else { // we can't overwrite any of the parameters until we've evaluated all of them: test iterate012 Sequence[] oldVars = cm.getAllVariableValues(); Sequence[] newVars = Arrays.copyOf(oldVars, oldVars.length); for (WithParam wp : actualParams) { newVars[wp.getSlotNumber()] = wp.getSelectValue(context); } cm.resetAllVariableValues(newVars); } cm.requestTailCall(this, null); return null; }
public TailCall processLeavingTail(XPathContext context) throws XPathException { XPathContext c = context; while (!(c instanceof XPathContextMajor)) { c = c.getCaller(); } XPathContextMajor cm = (XPathContextMajor)c; if (actualParams.length == 1) { cm.setLocalVariable(actualParams[0].getSlotNumber(), actualParams[0].getSelectValue(context)); } else { // we can't overwrite any of the parameters until we've evaluated all of them: test iterate012 Sequence[] oldVars = cm.getAllVariableValues(); Sequence[] newVars = Arrays.copyOf(oldVars, oldVars.length); for (WithParam wp : actualParams) { newVars[wp.getSlotNumber()] = wp.getSelectValue(context); } cm.resetAllVariableValues(newVars); } cm.requestTailCall(this, null); return null; }
/** * Process the function call in push mode * @param context the XPath dynamic context * @throws XPathException */ public void process(XPathContext context) throws XPathException { ValueRepresentation[] actualArgs = evaluateArguments(context); if (tailCall) { ((XPathContextMajor)context).requestTailCall(function, actualArgs); } else { SequenceReceiver out = context.getReceiver(); XPathContextMajor c2 = context.newCleanContext(); c2.setReceiver(out); c2.setOrigin(this); function.process(actualArgs, c2); } }
/** * Process the function call in push mode * @param context the XPath dynamic context * @throws XPathException */ public void process(XPathContext context) throws XPathException { ValueRepresentation[] actualArgs = evaluateArguments(context); if (tailCall) { ((XPathContextMajor)context).requestTailCall(function, actualArgs); } else { SequenceReceiver out = context.getReceiver(); XPathContextMajor c2 = context.newCleanContext(); c2.setReceiver(out); c2.setOrigin(this); function.process(actualArgs, c2); } }
/** * Process the function call in push mode * @param context the XPath dynamic context * @throws XPathException */ public void process(XPathContext context) throws XPathException { ValueRepresentation[] actualArgs = evaluateArguments(context); if (tailCall) { ((XPathContextMajor)context).requestTailCall(function, actualArgs); } else { SequenceReceiver out = context.getReceiver(); XPathContextMajor c2 = context.newCleanContext(); c2.setReceiver(out); c2.setOrigin(this); function.process(actualArgs, c2); } }
/** * Process the function call in pull mode * @param context the XPath dynamic context * @throws XPathException */ public EventIterator iterateEvents(XPathContext context) throws XPathException { ValueRepresentation[] actualArgs = evaluateArguments(context); if (tailCall) { ((XPathContextMajor)context).requestTailCall(function, actualArgs); return EmptyEventIterator.getInstance(); } else { SequenceReceiver out = context.getReceiver(); XPathContextMajor c2 = context.newCleanContext(); c2.setReceiver(out); c2.setOrigin(this); return function.iterateEvents(actualArgs, c2); } }
/** * Process the function call in pull mode * @param context the XPath dynamic context * @throws XPathException */ public EventIterator iterateEvents(XPathContext context) throws XPathException { ValueRepresentation[] actualArgs = evaluateArguments(context); if (tailCall) { ((XPathContextMajor)context).requestTailCall(function, actualArgs); return EmptyEventIterator.getInstance(); } else { SequenceReceiver out = context.getReceiver(); XPathContextMajor c2 = context.newCleanContext(); c2.setReceiver(out); c2.setOrigin(this); return function.iterateEvents(actualArgs, c2); } }
/** * Process the function call in pull mode * @param context the XPath dynamic context * @throws XPathException */ public EventIterator iterateEvents(XPathContext context) throws XPathException { ValueRepresentation[] actualArgs = evaluateArguments(context); if (tailCall) { ((XPathContextMajor)context).requestTailCall(function, actualArgs); return EmptyEventIterator.getInstance(); } else { SequenceReceiver out = context.getReceiver(); XPathContextMajor c2 = context.newCleanContext(); c2.setReceiver(out); c2.setOrigin(this); return function.iterateEvents(actualArgs, c2); } }
/** * This is the method that actually does the function call * @param c the dynamic context * @return the result of the function * @throws XPathException if dynamic errors occur */ private ValueRepresentation callFunction(XPathContext c) throws XPathException { ValueRepresentation[] actualArgs = evaluateArguments(c); if (tailCall) { ((XPathContextMajor)c).requestTailCall(function, actualArgs); return EmptySequence.getInstance(); } XPathContextMajor c2 = c.newCleanContext(); c2.setOrigin(this); c2.setTemporaryOutputState(true); try { return function.call(actualArgs, c2); } catch (StackOverflowError err) { throw new XPathException("Too many nested function calls. May be due to infinite recursion.", this); } catch (NullPointerException err) { if (function == null) { throw new NullPointerException("Unbound function call " + function.getFunctionName().getDisplayName()); } else { throw err; } } }
/** * This is the method that actually does the function call * @param c the dynamic context * @return the result of the function * @throws XPathException if dynamic errors occur */ private ValueRepresentation callFunction(XPathContext c) throws XPathException { ValueRepresentation[] actualArgs = evaluateArguments(c); if (tailCall) { ((XPathContextMajor)c).requestTailCall(function, actualArgs); return EmptySequence.getInstance(); } XPathContextMajor c2 = c.newCleanContext(); c2.setOrigin(this); c2.setTemporaryOutputState(true); try { return function.call(actualArgs, c2); } catch (StackOverflowError err) { throw new XPathException("Too many nested function calls. May be due to infinite recursion.", this); } catch (NullPointerException err) { if (function == null) { throw new NullPointerException("Unbound function call " + function.getFunctionName().getDisplayName()); } else { throw err; } } }
/** * This is the method that actually does the function call * @param c the dynamic context * @return the result of the function * @throws XPathException if dynamic errors occur */ private ValueRepresentation callFunction(XPathContext c) throws XPathException { ValueRepresentation[] actualArgs = evaluateArguments(c); if (tailCall) { ((XPathContextMajor)c).requestTailCall(function, actualArgs); return EmptySequence.getInstance(); } XPathContextMajor c2 = c.newCleanContext(); c2.setOrigin(this); c2.setTemporaryOutputState(true); try { return function.call(actualArgs, c2); } catch (StackOverflowError err) { throw new XPathException("Too many nested function calls. May be due to infinite recursion.", this); } catch (NullPointerException err) { if (function == null) { throw new NullPointerException("Unbound function call " + function.getFunctionName().getDisplayName()); } else { throw err; } } }