Bytecodes in NewtonScript virtual machine.
Bytecodes |
Pop | Pop the top element from the stack (discard the value). |
PushSelf | Push the current message context on the interpreter stack. |
Push <X> | Push the nonimmediate value <X> on the top of the stack. |
PushConstant <X> | Push the immediate value described by <X> on the stack. |
FindVar <X> | Look for the variable <X> using both the inherited lexical context and the current message context (self), including _proto and _parent inheritance, and push it on the stack. |
GetVar <X> | Get the parameter or local <X> (which is located at a particular offset in the current lexical scope) and push it on the stack. |
MakeFrame <N> | Frame constructor. Using the frame map (an array of symbols) found on the top of the stack, make a frame using the next <N> elements of the stack (in bottom-up order) to fill the frame slots. That frame is pushed on the stack. |
MakeArray <N> | Array constructor. Make an array of the class of the top element of the stack, using the next <N> elements of the stack (in bottom-up order) to populate the array. The resulting array is pushed on the stack. |
GetPath <N> | Look for the slot on the top of the stack in the frame that's second on the stack, using _proto inheritance only. |
SetPath <N> | Take the value on the top of the stack; assign it to the slot that's second on the stack in the frame that's third on the stack. |
SetVar <N> [<X>] | Assign the value on the top of the stack to the local or parameter that's at offset <N> in the current lexical scope. <X> is the name of this variable or parameter. |
SetFindVar <X> | Inherited variable assignment. Assign the value on the top of the stack to the variable that's second on the stack, using FindVar (see above) to locate that variable. |
SetLexScope | Set the lexical scope (inherited locals and params) of the thing on the top of the stack to the currently executing function. |
Return | Return from the function. Top of stack contains result of function. |
Branch <I> | Goto the instruction at <I> . |
BranchT <I> | If the top of the stack is non-nil, jump to instruction <I> . |
BranchF<I> | If the top of the stack is nil, jump to instruction <I> . |
IncrVar <N> | Increment the loop variable found at offset <N> into the current lexical scope by the amount at the top of the stack, pushing the result. This one's weird in that it doesn't pop the top of the stack (the increment) when using it. |
BranchIfLoopNotDone <I> | Using the top three elements of the stack as the current loop variable, the loop limit, and the loop increment, determine if the loop is complete. If not, branch to <I> . |
NewHandlers <N> | Register the top <N> pairs of elements on the stack as exception handlers for the currently executing function. Within each pair of items, the second (lower) is the exception symbol, and the first (higher) is the instruction number to jump to in order to process that exception. |
PopHandlers | Pop one set of exception handlers (see NewHandlers <N> ). |
IterNext | Increment array/frame iterator. |
IterDone | Test to see if an array/frame iterator is complete; push result of test on the stack. |
Call <N> | Execute global function (symbol for which is on top of stack), passing <N> elements below that on the stack as arguments. |
Invoke <N> | Execute a function on the top of the stack using its message context, passing the next <N> stack elements as arguments. |
Send <N> | Send the message on the top of the stack to the receiver that's second on the stack, passing the next <N> elements of the stack as arguments. |
SendIfDefined <N> | Like Send <N> , but it is not an error if the function can't be found. |
Resend <N> | inherited: Send the message on the top of the stack to the current message context, but start looking for the actual function to invoke after the implementor of the function currently executing. Pass the next <N> things on the stack as arguments. |
ResendIfDefined <N> | inherited:? Works like Resend<N> , but it is not an error if the function can't be found. |