05.08.2014 Views

here - Stefan-Marr.de

here - Stefan-Marr.de

here - Stefan-Marr.de

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4.2. SOM: Simple Object Machine<br />

HALT return from the interpreter loop, without changing the interpreter’s<br />

state.<br />

DUP duplicates the element at the top of the operand stack.<br />

POP removes the element from the top of the operand stack.<br />

RETURN_LOCAL performs a return from the current method. The top of the<br />

current frame’s operand stack is saved as return value, the current stack<br />

frame is removed from the interpreter’s stack, and the return value is<br />

then pushed onto the operand stack of the calling method.<br />

RETURN_NON_LOCAL performs a return from a block activation. The top of the<br />

current frame’s operand stack is saved as return value, then all stack<br />

frames from the interpreter’s stack are removed until the end of the<br />

context frame chain is reached, named the target frame; the target frame is<br />

removed, too, and the return value is then pushed onto the top frame’s<br />

operand stack.<br />

PUSH_LOCAL and POP_LOCAL either push or pop the value of a local variable<br />

onto or from the operand stack.<br />

PUSH_ARGUMENT and POP_ARGUMENT either push or pop the value of a method<br />

argument onto or from the operand stack.<br />

PUSH_FIELD and POP_FIELD either push or pop the value of an object’s field<br />

onto or from the operand stack.<br />

PUSH_BLOCK pushes a new block object onto the operand stack. The block<br />

object is initialized to point to the stack frame of the currently-executing<br />

method, so that the block method can access its arguments and locals.<br />

PUSH_CONSTANT pushes a constant value object onto the operand stack.<br />

PUSH_GLOBAL pushes the value of an entry from the global symbol table onto<br />

the operand stack.<br />

SEND and SUPER_SEND send a message to the class or superclass of an object.<br />

The name of the message specifies how many arguments are consumed<br />

from the operand stack. For example, the #ifNil:ifNotNil: message<br />

uses 3 elements: the receiver object and two explicit arguments. Each<br />

send leads to the creation of a new frame, which takes the arguments<br />

and is used for the execution of the corresponding method. Arguments<br />

are popped from the operand stack of the original frame.<br />

99

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!