All -- Dan asked me to remove the swap op, since what he really wants is rotate. So, I implemented an initial version of rotate. Here's the log entry: * core.ops: Replaced 'swap()' by 'rotate(i|ic)'. * stacks.c and stacks.h: Removed swap-related functions from my prior commit, replacing them with stack_depth(), stack_entry() and rotate_entries(). NOTE: The stack_depth() and rotate_entries() routines could be made more efficient through the caching of the sum of chunk 'used' members from lower chunks in a field in the upper chunks. Also, if the interpreter's stack_base was changed to hold the pointer to the *top* chunk (since we usually come at the stack from the top down) instead of the *bottom* chunk. The code here at least works, and we can decide about bigger changes separately. For now, rotate only handles rotates in one direction and of magnituded one. A fully general rotate would do handle rotates in both directions and of arbitrary amounts. Again, this implementation is sufficient for current applications, and a feature-complete version can be developed if this turns out to be otherwise the right type of implementation. This change includes a new exception for ERROR_STACK_SHALLOW, meaning "not-empty-yet-not-deep-enough-for-what-you-asked". * jakoc: Changed the calling convention to use rotate instead of swap (of course). Also changed the convention for return value passing to use the stack as well.
Regards, -- Gregor