gpt4 book ai didi

net.sf.saxon.expr.XPathContextMajor.requestTailCall()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 19:49:40 26 4
gpt4 key购买 nike

本文整理了Java中net.sf.saxon.expr.XPathContextMajor.requestTailCall()方法的一些代码示例,展示了XPathContextMajor.requestTailCall()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XPathContextMajor.requestTailCall()方法的具体详情如下:
包路径:net.sf.saxon.expr.XPathContextMajor
类名称:XPathContextMajor
方法名:requestTailCall

XPathContextMajor.requestTailCall介绍

[英]Reset the local stack frame. This method is used when processing a tail-recursive function. Instead of the function being called recursively, the parameters are set to new values and the function body is evaluated repeatedly
[中]重置本地堆栈帧。此方法用于处理尾部递归函数。不是递归调用函数,而是将参数设置为新值,并重复计算函数体

代码示例

代码示例来源:origin: net.sourceforge.saxon/saxon

public TailCall processLeavingTail(XPathContext context) throws XPathException {
  if (context instanceof XPathContextMajor) {
    ((XPathContextMajor)context).requestTailCall(breakFunction, emptyArgs);
  }
  return null;
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

public void markContext(XPathContext context) {
  XPathContext c = context;
  while (!(c instanceof XPathContextMajor)) {
    c = c.getCaller();
  }
  ((XPathContextMajor) c).requestTailCall(this, null);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

public void markContext(XPathContext context) {
  XPathContext c = context;
  while (!(c instanceof XPathContextMajor)) {
    c = c.getCaller();
  }
  ((XPathContextMajor) c).requestTailCall(this, null);
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

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);
  }
}

代码示例来源:origin: net.sourceforge.saxon/saxon

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;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

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);
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

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;
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

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;
}

代码示例来源:origin: net.sf.saxon/Saxon-B

/**
 * 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);
  }
}

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
 * 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);
  }
}

代码示例来源:origin: org.opengis.cite.saxon/saxon9

/**
 * 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);
  }
}

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
 * 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);
  }
}

代码示例来源:origin: net.sf.saxon/Saxon-B

/**
 * 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);
  }
}

代码示例来源:origin: org.opengis.cite.saxon/saxon9

/**
 * 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);
  }
}

代码示例来源:origin: net.sourceforge.saxon/saxon

/**
 * 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;
    }
  }
}

代码示例来源:origin: net.sf.saxon/Saxon-B

/**
 * 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;
    }
  }
}

代码示例来源:origin: org.opengis.cite.saxon/saxon9

/**
 * 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;
    }
  }
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com