$throw method
void
$throw(
- dynamic exception
Throw an exception from the VM. This will unwind the stack until a catch block is found.
Implementation
void $throw(dynamic exception) {
List<int> catchFrame;
while (true) {
catchFrame = catchStack.last;
if (catchFrame.isNotEmpty) {
break;
}
stack.removeLast();
if (stack.isNotEmpty) {
frame = stack.last;
frameOffset = frameOffsetStack.removeLast();
}
catchStack.removeLast();
if (callStack.removeLast() == -1) {
throw exception is WrappedException
? exception
: WrappedException(exception);
}
}
var catchOffset = catchFrame.removeLast();
if (catchOffset < 0) {
rethrowException = exception;
catchOffset = -catchOffset;
} else {
inCatch = true;
}
frameOffset = frameOffsetStack.last;
returnValue =
exception is WrappedException ? exception.exception : exception;
_prOffset = catchOffset;
}