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; }
/** * Call the function dynamically. For this to be possible, the static arguments of the function call * must have been set up as SuppliedParameterReference objects. The actual arguments are placed on the * callee's stack, and the type conversion takes place "in situ". * @param suppliedArguments the values to be used for the arguments of the function * @param context the dynamic evaluation context * @return the result of evaluating the function */ public ValueRepresentation dynamicCall(ValueRepresentation[] suppliedArguments, XPathContext context) throws XPathException { ValueRepresentation[] convertedArgs = new ValueRepresentation[suppliedArguments.length]; XPathContextMajor c2 = context.newCleanContext(); c2.setOrigin(this); c2.setCaller(context); c2.openStackFrame(suppliedArguments.length); for (int i=0; i<suppliedArguments.length; i++) { c2.setLocalVariable(i, suppliedArguments[i]); convertedArgs[i] = ExpressionTool.lazyEvaluate(argument[i], c2, 10); } XPathContextMajor c3 = c2.newCleanContext(); c3.setOrigin(this); return function.call(convertedArgs, c3); }
/** * Call the function dynamically. For this to be possible, the static arguments of the function call * must have been set up as SuppliedParameterReference objects. The actual arguments are placed on the * callee's stack, and the type conversion takes place "in situ". * @param suppliedArguments the values to be used for the arguments of the function * @param context the dynamic evaluation context * @return the result of evaluating the function */ public ValueRepresentation dynamicCall(ValueRepresentation[] suppliedArguments, XPathContext context) throws XPathException { ValueRepresentation[] convertedArgs = new ValueRepresentation[suppliedArguments.length]; XPathContextMajor c2 = context.newCleanContext(); c2.setOrigin(this); c2.setCaller(context); c2.openStackFrame(suppliedArguments.length); for (int i=0; i<suppliedArguments.length; i++) { c2.setLocalVariable(i, suppliedArguments[i]); convertedArgs[i] = ExpressionTool.lazyEvaluate(argument[i], c2, 10); } XPathContextMajor c3 = c2.newCleanContext(); c3.setOrigin(this); return function.call(convertedArgs, c3); }
/** * Call the function dynamically. For this to be possible, the static arguments of the function call * must have been set up as SuppliedParameterReference objects. The actual arguments are placed on the * callee's stack, and the type conversion takes place "in situ". * @param suppliedArguments the values to be used for the arguments of the function * @param context the dynamic evaluation context * @return the result of evaluating the function */ public ValueRepresentation dynamicCall(ValueRepresentation[] suppliedArguments, XPathContext context) throws XPathException { ValueRepresentation[] convertedArgs = new ValueRepresentation[suppliedArguments.length]; XPathContextMajor c2 = context.newCleanContext(); c2.setOrigin(this); c2.setCaller(context); c2.openStackFrame(suppliedArguments.length); for (int i=0; i<suppliedArguments.length; i++) { c2.setLocalVariable(i, suppliedArguments[i]); convertedArgs[i] = ExpressionTool.lazyEvaluate(argument[i], c2, 10); } XPathContextMajor c3 = c2.newCleanContext(); c3.setOrigin(this); return function.call(convertedArgs, c3); }
/** * Apply an accumulator rule * * @param rule the rule to apply * @param node the node that was matched * @param isPostDescent false for the pre-descent visit to a node, true for the post-descent visit * @param value the value of the accumulator before applying the rule * @param context the dynamic evaluation context * @return the value of the accumulator after applying the rule * @throws XPathException if a dynamic error occurs during the evaluation */ private Sequence<?> processRule(Rule rule, NodeInfo node, boolean isPostDescent, Sequence<?> value, XPathContext context) throws XPathException { AccumulatorRule target = (AccumulatorRule) rule.getAction(); Expression delta = target.getNewValueExpression(); XPathContextMajor c2 = context.newCleanContext(); final Controller controller = c2.getController(); assert controller != null; ManualIterator<NodeInfo> initialNode = new ManualIterator<>(node); c2.setCurrentIterator(initialNode); c2.openStackFrame(target.getStackFrameMap()); c2.setLocalVariable(0, value); c2.setCurrentComponent(accumulator.getDeclaringComponent()); c2.setTemporaryOutputState(StandardNames.XSL_ACCUMULATOR_RULE); value = Evaluator.EAGER_SEQUENCE.evaluate(delta, c2); //System.err.println("Node " + ((TinyNodeImpl) node).getNodeNumber() + " : " + value); values.add(new DataPoint(new Visit(node, isPostDescent), value)); return value; }
contextObject.setLocalVariable(variable.getLocalSlotNumber(), value);
/** * Apply an accumulator rule * * @param rule the rule to apply * @param node the node that was matched * @param isPostDescent false for the pre-descent visit to a node, true for the post-descent visit * @param value the value of the accumulator before applying the rule * @param context the dynamic evaluation context * @return the value of the accumulator after applying the rule * @throws XPathException if a dynamic error occurs during the evaluation */ private Sequence<?> processRule(Rule rule, NodeInfo node, boolean isPostDescent, Sequence<?> value, XPathContext context) throws XPathException { AccumulatorRule target = (AccumulatorRule) rule.getAction(); Expression delta = target.getNewValueExpression(); XPathContextMajor c2 = context.newCleanContext(); final Controller controller = c2.getController(); assert controller != null; ManualIterator<NodeInfo> initialNode = new ManualIterator<>(node); c2.setCurrentIterator(initialNode); c2.openStackFrame(target.getStackFrameMap()); c2.setLocalVariable(0, value); c2.setCurrentComponent(accumulator.getDeclaringComponent()); c2.setTemporaryOutputState(StandardNames.XSL_ACCUMULATOR_RULE); value = Evaluator.EAGER_SEQUENCE.evaluate(delta, c2); //System.err.println("Node " + ((TinyNodeImpl) node).getNodeNumber() + " : " + value); values.add(new DataPoint(new Visit(node, isPostDescent), value)); return value; }
"Supplied XPathVariable is bound to the wrong slot: perhaps it was created using a different static context"); contextObject.setLocalVariable(slot, value);
/** * Iterate over the results of the function */ public SequenceIterator iterate(XPathContext c) throws XPathException { PreparedExpression pexpr = prepareExpression(c); if (operation == EXPRESSION) { return SingletonIterator.makeIterator(new ObjectValue(pexpr)); } else { XPathContextMajor c2 = c.newCleanContext(); c2.setOrigin(details); c2.openStackFrame(pexpr.stackFrameMap); c2.setCurrentIterator(c.getCurrentIterator()); for (int i=1; i<argument.length; i++) { int slot = pexpr.variables[i-1].getLocalSlotNumber(); c2.setLocalVariable(slot, ExpressionTool.eagerEvaluate(argument[i],c)); } return Value.getIterator( ExpressionTool.lazyEvaluate(pexpr.expression, c2, 1)); } }
/** * Iterate over the results of the function */ public SequenceIterator iterate(XPathContext c) throws XPathException { PreparedExpression pexpr = prepareExpression(c); if (operation == EXPRESSION) { return SingletonIterator.makeIterator(new ObjectValue(pexpr)); } else { XPathContextMajor c2 = c.newCleanContext(); c2.setOrigin(details); c2.openStackFrame(pexpr.stackFrameMap); c2.setCurrentIterator(c.getCurrentIterator()); for (int i=1; i<argument.length; i++) { int slot = pexpr.variables[i-1].getLocalSlotNumber(); c2.setLocalVariable(slot, ExpressionTool.eagerEvaluate(argument[i],c)); } return Value.getIterator( ExpressionTool.lazyEvaluate(pexpr.expression, c2, 1)); } }
/** * Iterate over the results of the function */ public SequenceIterator iterate(XPathContext c) throws XPathException { PreparedExpression pexpr = prepareExpression(c); if (operation == EXPRESSION) { return SingletonIterator.makeIterator(new ObjectValue(pexpr)); } else { XPathContextMajor c2 = c.newCleanContext(); c2.setOrigin(details); c2.openStackFrame(pexpr.stackFrameMap); c2.setCurrentIterator(c.getCurrentIterator()); for (int i=1; i<argument.length; i++) { int slot = pexpr.variables[i-1].getLocalSlotNumber(); c2.setLocalVariable(slot, ExpressionTool.eagerEvaluate(argument[i],c)); } return Value.getIterator( ExpressionTool.lazyEvaluate(pexpr.expression, c2, 1)); } }
"Supplied XPathVariable is bound to the wrong slot: perhaps it was created using a different static context"); contextObject.setLocalVariable(slot, value);
"Supplied XPathVariable is bound to the wrong slot: perhaps it was created using a different static context"); contextObject.setLocalVariable(slot, value);
/** * Evaluate in a general context */ public Item evaluateItem(XPathContext c) throws XPathException { if (operation == EXPRESSION) { PreparedExpression pexpr = prepareExpression(c); return new ObjectValue(pexpr); } else if (operation == EVALUATE_NODE) { XPathContextMajor c2 = c.newCleanContext(); PreparedExpression pexpr = prepareExpression(c2); c2.setOrigin(details); c2.openStackFrame(pexpr.stackFrameMap); return pexpr.expression.evaluateItem(c2); } else { XPathContextMajor c2 = c.newCleanContext(); PreparedExpression pexpr = prepareExpression(c2); for (int i=1; i<argument.length; i++) { int slot = pexpr.variables[i-1].getLocalSlotNumber(); c2.setLocalVariable(slot, ExpressionTool.eagerEvaluate(argument[i],c)); } c2.setOrigin(details); c2.openStackFrame(pexpr.stackFrameMap); c2.setCurrentIterator(c.getCurrentIterator()); return pexpr.expression.evaluateItem(c2); } }
/** * Evaluate in a general context */ public Item evaluateItem(XPathContext c) throws XPathException { if (operation == EXPRESSION) { PreparedExpression pexpr = prepareExpression(c); return new ObjectValue(pexpr); } else if (operation == EVALUATE_NODE) { XPathContextMajor c2 = c.newCleanContext(); PreparedExpression pexpr = prepareExpression(c2); c2.setOrigin(details); c2.openStackFrame(pexpr.stackFrameMap); return pexpr.expression.evaluateItem(c2); } else { XPathContextMajor c2 = c.newCleanContext(); PreparedExpression pexpr = prepareExpression(c2); for (int i=1; i<argument.length; i++) { int slot = pexpr.variables[i-1].getLocalSlotNumber(); c2.setLocalVariable(slot, ExpressionTool.eagerEvaluate(argument[i],c)); } c2.setOrigin(details); c2.openStackFrame(pexpr.stackFrameMap); c2.setCurrentIterator(c.getCurrentIterator()); return pexpr.expression.evaluateItem(c2); } }
/** * Evaluate in a general context */ public Item evaluateItem(XPathContext c) throws XPathException { if (operation == EXPRESSION) { PreparedExpression pexpr = prepareExpression(c); return new ObjectValue(pexpr); } else if (operation == EVALUATE_NODE) { XPathContextMajor c2 = c.newCleanContext(); PreparedExpression pexpr = prepareExpression(c2); c2.setOrigin(details); c2.openStackFrame(pexpr.stackFrameMap); return pexpr.expression.evaluateItem(c2); } else { XPathContextMajor c2 = c.newCleanContext(); PreparedExpression pexpr = prepareExpression(c2); for (int i=1; i<argument.length; i++) { int slot = pexpr.variables[i-1].getLocalSlotNumber(); c2.setLocalVariable(slot, ExpressionTool.eagerEvaluate(argument[i],c)); } c2.setOrigin(details); c2.openStackFrame(pexpr.stackFrameMap); c2.setCurrentIterator(c.getCurrentIterator()); return pexpr.expression.evaluateItem(c2); } }