diff options
Diffstat (limited to 'unwind.h')
-rw-r--r-- | unwind.h | 33 |
1 files changed, 27 insertions, 6 deletions
@@ -27,7 +27,7 @@ typedef union uw_frame uw_frame_t; typedef enum uw_frtype uw_frtype_t; -enum uw_frtype { UW_BLOCK }; +enum uw_frtype { UW_BLOCK, UW_ENV }; struct uw_common { uw_frame_t *up; @@ -42,25 +42,46 @@ struct uw_block { jmp_buf jb; }; +struct uw_dynamic_env { + uw_frame_t *up; + uw_frtype_t type; + obj_t *func_bindings; +}; + union uw_frame { struct uw_common uw; struct uw_block bl; + struct uw_dynamic_env ev; }; +void uw_init(void); void uw_push_block(uw_frame_t *, obj_t *tag); +void uw_push_env(uw_frame_t *); +obj_t *uw_get_func(obj_t *sym); +obj_t *uw_set_func(obj_t *sym, obj_t *value); obj_t *uw_block_return(obj_t *tag, obj_t *result); void uw_pop_frame(uw_frame_t *); + #define uw_block_begin(TAG, RESULTVAR) \ obj_t *RESULTVAR = nil; \ { \ - uw_frame_t uw_fr; \ - uw_push_block(&uw_fr, TAG); \ - if (setjmp(uw_fr.bl.jb)) { \ - RESULTVAR = uw_fr.bl.result; \ + uw_frame_t uw_blk; \ + uw_push_block(&uw_blk, TAG); \ + if (setjmp(uw_blk.bl.jb)) { \ + RESULTVAR = uw_blk.bl.result; \ } else { #define uw_block_end \ } \ - uw_pop_frame(&uw_fr); \ + uw_pop_frame(&uw_blk); \ + } + +#define uw_env_begin \ + { \ + uw_frame_t uw_env; \ + uw_push_env(&uw_env) + +#define uw_env_end \ + uw_pop_frame(&uw_env); \ } |