*: Replace did_throw checks with current_exception checks

Removes obsolete did_throw after that.
This commit is contained in:
ZyX
2018-03-25 15:13:05 +03:00
parent 79b4b6fc86
commit 201a4ef11c
5 changed files with 209 additions and 246 deletions

View File

@@ -56,7 +56,6 @@ void try_enter(TryState *const tstate)
.private_msg_list = NULL,
.trylevel = trylevel,
.got_int = got_int,
.did_throw = did_throw,
.need_rethrow = need_rethrow,
.did_emsg = did_emsg,
};
@@ -64,7 +63,6 @@ void try_enter(TryState *const tstate)
current_exception = NULL;
trylevel = 1;
got_int = false;
did_throw = false;
need_rethrow = false;
did_emsg = false;
}
@@ -85,7 +83,6 @@ bool try_leave(const TryState *const tstate, Error *const err)
assert(trylevel == 0);
assert(!need_rethrow);
assert(!got_int);
assert(!did_throw);
assert(!did_emsg);
assert(msg_list == &tstate->private_msg_list);
assert(*msg_list == NULL);
@@ -94,7 +91,6 @@ bool try_leave(const TryState *const tstate, Error *const err)
current_exception = tstate->current_exception;
trylevel = tstate->trylevel;
got_int = tstate->got_int;
did_throw = tstate->did_throw;
need_rethrow = tstate->need_rethrow;
did_emsg = tstate->did_emsg;
return ret;
@@ -130,7 +126,7 @@ bool try_end(Error *err)
did_emsg = false;
if (got_int) {
if (did_throw) {
if (current_exception) {
// If we got an interrupt, discard the current exception
discard_current_exception();
}
@@ -149,7 +145,7 @@ bool try_end(Error *err)
if (should_free) {
xfree(msg);
}
} else if (did_throw) {
} else if (current_exception) {
api_set_error(err, kErrorTypeException, "%s", current_exception->value);
discard_current_exception();
}

View File

@@ -93,7 +93,6 @@ typedef struct {
const struct msglist *const *msg_list;
int trylevel;
int got_int;
int did_throw;
int need_rethrow;
int did_emsg;
} TryState;