doReturn method
void
doReturn(
- dynamic result
)
override
Implementation
@override
void doReturn(var result) {
// return address
programCounter = callStack.pop();
assert(programCounter> 0);
// result store address byte
// this may not be a byte if the Machine.STACK_MARKER
// is being used.
var resultAddrByte = callStack.pop();
//unwind locals and params length
callStack.stack.removeRange(0, callStack.peek() + 2);
//unwind game stack
while (stack.pop() != Engine.stackMarker) {}
//stack marker is used in the result byte to
//mark call routines that want to throw away the result
if (resultAddrByte == Engine.stackMarker) return;
writeVariable(resultAddrByte, result);
}