diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-07-31 17:32:19 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-07-31 17:37:25 -0700 |
commit | 2f5e7a5b96039b7a00543b4056bab7ec85c8db4b (patch) | |
tree | f6aeb8eb6cb4ee3fad726348fdd27ae2e43ec885 /unwind.h | |
parent | c7edf3a752bc2522589246ff64f5a00fb96315d6 (diff) | |
download | txr-2f5e7a5b96039b7a00543b4056bab7ec85c8db4b.tar.gz txr-2f5e7a5b96039b7a00543b4056bab7ec85c8db4b.tar.bz2 txr-2f5e7a5b96039b7a00543b4056bab7ec85c8db4b.zip |
txr-014 2009-10-05txr-014
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); \ } |