|
Perl 6
Default SMOP Interpreter Implementation: Revision 1
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:
Node PrototypeThe Node prototype just declares an object that have a set of members.
This members can be passed to Node.new() as named arguments. Stack PrototypeThe 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.
Stack transformationsSome of the above methods transform the stack in interesting ways. Follows some ascii diagrams on how that works. push
Before
*
Current Frame 1 <- 2 <- 3 -> 4 -> 5
After
*
New Frame given node
|
Current Frame 1 <- 2 <- 3 -> 4 -> 5
next
* *
1 <- 2 -> 3 turns into 1 <- 2 <- 3
| |
and
*
1 <- 2 <- 3 turns into
| *
1 <- 2 1 <- 2
|