diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-02-02 22:54:42 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-02-02 22:56:14 +0000 |
| commit | 4fb0e6305743e265fec1b199210e77150b0216e1 (patch) | |
| tree | b7b6b8a380763733328f4bf9e4a7c1b6bdb921e8 /runtime/src/effects.c | |
| parent | 0fb465389d8d9e4455d4a57ce68f7744676ddb89 (diff) | |
Use runtime type tags as effect tags in effect handler
Diffstat (limited to 'runtime/src/effects.c')
| -rw-r--r-- | runtime/src/effects.c | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/runtime/src/effects.c b/runtime/src/effects.c index 17996768..ffc78030 100644 --- a/runtime/src/effects.c +++ b/runtime/src/effects.c @@ -6,7 +6,6 @@ struct ShedEffectHandler { struct ShedGcObjectHeader gc_object_header; - ShedEffectTag effect_tag; struct ShedEffectHandler* parent; ShedClosurePointer methods[]; }; @@ -23,26 +22,12 @@ void shed__runtime__effects_set_handler(ShedEffectHandler* effect_handler) { shed__runtime__current_effect_handler = effect_handler; } -ShedEffectHandler* shed__runtime__effects_push_handler( - ShedEffectTag effect_tag, - ShedEffectMethodIndex method_count +void shed__runtime__effects_push_handler( + ShedEffectHandler* effect_handler ) { - ShedEffectHandler* handler = shed__runtime__gc_alloc( - sizeof(ShedEffectHandler) + sizeof(ShedClosurePointer) * method_count, - // TODO: in principle, treating this as a scalar is a bug. However, in - // practice, any methods will also be GC roots (since we only pop GC - // roots at the end of blocks, and effect handlers are not first-class - // values and therefore cannot live longer than the block they're - // defined in). We should definitely fix this though, probably by - // generating the code to alloc the handler. - 0 - ); - handler->effect_tag = effect_tag; - handler->parent = shed__runtime__current_effect_handler; - - shed__runtime__current_effect_handler = handler; + effect_handler->parent = shed__runtime__current_effect_handler; - return handler; + shed__runtime__current_effect_handler = effect_handler; } void shed__runtime__effects_set_handler_method( @@ -63,7 +48,7 @@ ShedClosurePointer shed__runtime__effects_find_handler_method( ) { ShedEffectHandler* handler = shed__runtime__current_effect_handler; while (handler != NULL) { - if (handler->effect_tag == effect_tag) { + if (handler->gc_object_header.runtime_type_tag == effect_tag) { return handler->methods[method_index]; } handler = handler->parent; |
