summaryrefslogtreecommitdiff
path: root/src/runtime/c/gu/exn.c
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2014-10-09 13:44:26 +0000
committerkr.angelov <kr.angelov@gmail.com>2014-10-09 13:44:26 +0000
commit86e9acc7a7b714307e08ab25117ca03cecb00936 (patch)
tree38dd7904147567c4e97e1f62eca64739d3a516eb /src/runtime/c/gu/exn.c
parent8e3ed825a8dde13894a44169ddc09cc2c2be60b2 (diff)
throw away the long obsolete runtime type information in the C runtime
Diffstat (limited to 'src/runtime/c/gu/exn.c')
-rw-r--r--src/runtime/c/gu/exn.c38
1 files changed, 11 insertions, 27 deletions
diff --git a/src/runtime/c/gu/exn.c b/src/runtime/c/gu/exn.c
index 003a4357f..1b8b4f4a5 100644
--- a/src/runtime/c/gu/exn.c
+++ b/src/runtime/c/gu/exn.c
@@ -3,12 +3,10 @@
GuExn*
-gu_new_exn(GuExn* parent, GuKind* catch, GuPool* pool)
+gu_new_exn(GuPool* pool)
{
GuExn* exn = gu_new(GuExn, pool);
exn->state = GU_EXN_OK;
- exn->parent = parent;
- exn->catch = catch;
exn->caught = NULL;
exn->data.pool = pool;
exn->data.data = NULL;
@@ -20,6 +18,12 @@ gu_exn_is_raised(GuExn* err) {
return err && (err->state == GU_EXN_RAISED);
}
+bool
+gu_exn_caught_(GuExn* err, const char* type)
+{
+ return (err->caught && strcmp(err->caught, type) == 0);
+}
+
void
gu_exn_block(GuExn* err)
{
@@ -37,24 +41,11 @@ gu_exn_unblock(GuExn* err)
}
GuExnData*
-gu_exn_raise_debug_(GuExn* base, GuType* type,
- const char* filename, const char* func, int lineno)
+gu_exn_raise_debug_(GuExn* err, const char* type,
+ const char* filename, const char* func, int lineno)
{
gu_require(type);
- // TODO: log the error, once there's a system for dumping
- // error objects.
-
- GuExn* err = base;
-
- while (err && !(err->catch && gu_type_has_kind(type, err->catch))) {
- err->state = GU_EXN_RAISED;
- err = err->parent;
- }
- if (!err) {
- gu_abort_(GU_ASSERT_ASSERTION, filename, func, lineno,
- "Unexpected error raised");
- }
GuExnState old_state = err->state;
err->state = GU_EXN_RAISED;
if (old_state == GU_EXN_OK) {
@@ -63,23 +54,18 @@ gu_exn_raise_debug_(GuExn* base, GuType* type,
return &err->data;
}
}
+
// Exceptian had already been raised, possibly blocked, or no
// exception value is required.
return NULL;
}
GuExnData*
-gu_exn_raise_(GuExn* base, GuType* type)
+gu_exn_raise_(GuExn* base, const char* type)
{
return gu_exn_raise_debug_(base, type, NULL, NULL, -1);
}
-GuType*
-gu_exn_caught(GuExn* err)
-{
- return err->caught;
-}
-
void
gu_raise_errno(GuExn* err)
{
@@ -90,5 +76,3 @@ gu_raise_errno(GuExn* err)
err_data->data = gu_errno;
}
}
-
-GU_DEFINE_TYPE(GuErrno, signed, _);