From e0c0e176d80692e7967f937fc0bcea4f1fc3ac72 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 24 Dec 2021 05:10:50 +0000 Subject: [PATCH] changed do_throw() to clear the class stack when the exception is empty --- hcl/lib/exec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hcl/lib/exec.c b/hcl/lib/exec.c index f649fb2..97811ca 100644 --- a/hcl/lib/exec.c +++ b/hcl/lib/exec.c @@ -2075,6 +2075,10 @@ static HCL_INLINE int do_throw (hcl_t* hcl, hcl_oop_t val, hcl_ooi_t ip) if (HCL_EXSTACK_ISEMPTY(hcl)) { + /* the exception stack is empty. + * clear the class stack if it is not empty */ + while (!HCL_CLSTACK_ISEMPTY(hcl)) HCL_CLSTACK_POP (hcl); + if (hcl->active_function->dbgi != hcl->_nil) { hcl_dbgi_t* dbgi; @@ -2087,13 +2091,14 @@ static HCL_INLINE int do_throw (hcl_t* hcl, hcl_oop_t val, hcl_ooi_t ip) HCL_LOG0 (hcl, HCL_LOG_IC | HCL_LOG_WARN, "Warning - exception not handled"); hcl_seterrbfmt (hcl, HCL_EEXCEPT, "exception not handled"); } - + /* exception not handled. terminate the active process */ /*terminate_process (hcl, hcl->processor->active); <- the vm cleanup code will do this */ return -1; } +/* TODO: unwind the nested class stack */ /* must rewind context */ HCL_EXSTACK_POP_TO(hcl, catch_ctx, catch_ip);