doReturn method

void doReturn(
  1. dynamic result
)

Implementation

void doReturn(final result) {
  // return address
  programCounter = callStack.pop();
  assert(programCounter> 0);

  // result store address byte
  final resultAddrByte = callStack.pop();

  //unwind locals and params length
  callStack.stack.removeRange(0, callStack.pop() + 1);

  //unwind game stack
  while (stack.pop() != stackMarker) {}

  writeVariable(resultAddrByte, result);
}