Default SMOP Interpreter Implementation: Revision 3
The default SMOP Interpreter Implementation is a mixture of a stack-based and a stackless machine, as it does support pushing new frames, but it also supports continuation passing style inside itself. This implementation is based on three elements:
The Node prototype just declares an object that have a set of members.
This members can be passed to Node.new() as named arguments.
The Stack prototype defines the implementation in itself, it's the one with the "eval" method. It simply have a reference to the currently selected Node, and have the following methods.
Some of the above methods transform the stack in interesting ways. Follows some ascii diagrams on how that works, where:
Before * Current Frame 1 <- 2 <- 3 -> 4 -> 5 After * New Frame given node | Current Frame 1 <- 2 <- 3 -> 4 -> 5
* * 1 <- 2 -> 3 turns into 1 <- 2 <- 3 | | and * 1 <- 2 <- 3 turns into | * 1 <- 2 1 <- 2
Before * Current Frame 1 <- 2 <- 3 -> 4 -> 5 After * Current Frame 1 <- 2 <- 3 -> given node -> 4 -> 5