From 2141768b6f9bb991debaaff7e99be79dd3f619f6 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 18 Jun 2021 19:07:36 +0000 Subject: [PATCH] changed compile_return() to cater for exception handling --- lib/comp.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/comp.c b/lib/comp.c index 43b38c9..887ae46 100644 --- a/lib/comp.c +++ b/lib/comp.c @@ -2177,6 +2177,7 @@ static int compile_return (hcl_t* hcl, hcl_cnode_t* src, int ret_from_home) hcl_cnode_t* obj, * val; hcl_cframe_t* cf; hcl_fnblk_info_t* fbi; + hcl_ooi_t i; HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(src)); HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_RETURN) || @@ -2185,6 +2186,22 @@ static int compile_return (hcl_t* hcl, hcl_cnode_t* src, int ret_from_home) fbi = &hcl->c->fnblk.info[hcl->c->fnblk.depth]; obj = HCL_CNODE_CONS_CDR(src); + for (i = hcl->c->cblk.depth; i > hcl->c->fnblk.info[hcl->c->fnblk.depth].cblk_base; --i) + { + switch (hcl->c->cblk.info[i]._type) + { + case HCL_CBLK_TYPE_TRY: + if (emit_byte_instruction(hcl, HCL_CODE_TRY_EXIT, HCL_CNODE_GET_LOC(src)) <= -1) return -1; + break; + +#if 0 + case HCL_CBLK_TYPE_CLASS: + if (emit_byte_instruction(hcl, HCL_CODE_TRY_CLASS, HCL_CNODE_GET_LOC(src)) <= -1) return -1; + break; +#endif + } + } + if (fbi->tmpr_nrvars > 0) { hcl_cnode_t* tmp = HCL_CNODE_CONS_CAR(src);