mirror of
https://github.com/CPunch/Cosmo.git
synced 2025-11-17 04:30:05 +00:00
cosmoV_throw() now resets the vm stack as well
also a minor GC bug in cosmoO_newError was fixed. i'm going to try to phase out cosmoM_freezeGC & friends since that would cause hell with this new error handling solution. the only thing still using it is the GC.
This commit is contained in:
@@ -118,11 +118,14 @@ void cosmoV_throw(CState *state)
|
||||
StkPtr temp = cosmoV_getTop(state, 0);
|
||||
CObjError *error = cosmoO_newError(state, *temp);
|
||||
|
||||
// replace the value on the stack with the error
|
||||
*temp = cosmoV_newRef((CObj *)cosmoO_newError(state, *temp));
|
||||
CValue val = cosmoV_newRef((CObj *)cosmoO_newError(state, *temp));
|
||||
if (state->panic) {
|
||||
state->top = state->panic->top;
|
||||
state->frameCount = state->panic->frameCount;
|
||||
cosmoV_pushValue(state, val);
|
||||
longjmp(state->panic->jmp, 1);
|
||||
} else {
|
||||
cosmoV_pushValue(state, val);
|
||||
fprintf(stderr, "Unhandled panic! ");
|
||||
cosmoV_printError(state, error);
|
||||
exit(1);
|
||||
|
||||
Reference in New Issue
Block a user