aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/effects.c
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2024-02-11 21:29:15 +0000
committerMichael Williamson <mike@zwobble.org>2024-02-11 21:29:15 +0000
commita01ee103f9bc0c6defe9ce8cd85651f19f7127bd (patch)
tree8634fd33dde74b4aab1519e1b61bc3343d99606f /runtime/src/effects.c
parent3d4e3f4a54d128a2a280b5adc921f3d95fb963bb (diff)
Create separate lib for patio runtime
Diffstat (limited to 'runtime/src/effects.c')
-rw-r--r--runtime/src/effects.c51
1 files changed, 0 insertions, 51 deletions
diff --git a/runtime/src/effects.c b/runtime/src/effects.c
deleted file mode 100644
index 39dabe56..00000000
--- a/runtime/src/effects.c
+++ /dev/null
@@ -1,51 +0,0 @@
-#include <stddef.h>
-#include "./std/unistd.h"
-#include "./gc.h"
-#include "./closures.h"
-#include "./effects.h"
-
-struct ShedEffectHandler {
- struct ShedGcObjectHeader gc_object_header;
- struct ShedEffectHandler* parent;
- ShedClosurePointer methods[];
-};
-
-typedef struct ShedEffectHandler ShedEffectHandler;
-
-struct ShedEffectHandler* shed__runtime__current_effect_handler = NULL;
-
-ShedEffectHandler* shed__runtime__effects_get_handler() {
- return shed__runtime__current_effect_handler;
-}
-
-void shed__runtime__effects_set_handler(ShedEffectHandler* effect_handler) {
- shed__runtime__current_effect_handler = effect_handler;
-}
-
-void shed__runtime__effects_push_handler(
- ShedEffectHandler* effect_handler
-) {
- effect_handler->parent = shed__runtime__current_effect_handler;
-
- shed__runtime__current_effect_handler = effect_handler;
-}
-
-void shed__runtime__effects_pop_handler() {
- shed__runtime__current_effect_handler = shed__runtime__current_effect_handler->parent;
-}
-
-ShedClosurePointer shed__runtime__effects_find_handler_method(
- ShedEffectTag effect_tag,
- ShedEffectMethodIndex method_index
-) {
- ShedEffectHandler* handler = shed__runtime__current_effect_handler;
- while (handler != NULL) {
- if (handler->gc_object_header.runtime_type_tag == effect_tag) {
- return handler->methods[method_index];
- }
- handler = handler->parent;
- }
-
- // TODO: more informative error
- return NULL;
-}