// We only copy the local variables if the expression has dependencies on local variables.
// It would be even smarter to copy only those variables that we need; but that gives
// diminishing returns.
if ((instruction.getDependencies() & StaticProperty.DEPENDS_ON_LOCAL_VARIABLES) != 0) {
StackFrame localStackFrame = context.getStackFrame();
ValueRepresentation[] local = localStackFrame.getStackFrameValues();
if (local != null) {
ValueRepresentation[] savedStackFrame = new ValueRepresentation[local.length];
System.arraycopy(local, 0, savedStackFrame, 0, local.length);
savedXPathContext.setStackFrame(localStackFrame.getStackFrameMap(), savedStackFrame);
}
}
// Make a copy of the context item
SequenceIterator currentIterator = context.getCurrentIterator();