some code reformatting

This commit is contained in:
2025-09-05 01:16:24 +09:00
parent ad510b1436
commit 4d3172e552
5 changed files with 780 additions and 737 deletions

View File

@ -2368,20 +2368,24 @@ static HAK_INLINE int do_throw (hak_t* hak, hak_oop_t val, hak_ooi_t ip)
{
hak_oop_context_t catch_ctx;
hak_ooi_t catch_ip, clsp, sp;
hak_oop_context_t c;
if (HAK_EXSTACK_IS_EMPTY(hak))
{
hak_oop_function_t f;
/* the exception stack is empty.
* clear the class stack if it is not empty */
while (!HAK_CLSTACK_IS_EMPTY(hak)) HAK_CLSTACK_POP(hak);
if (hak->active_function->dbgi != hak->_nil)
f = hak->active_function;
if (f->dbgi != hak->_nil)
{
hak_dbgi_t* dbgi;
hak_loc_t loc;
dbgi = (hak_dbgi_t*)HAK_OBJ_GET_BYTE_SLOT(hak->active_function->dbgi);
HAK_LOG3 (hak, HAK_LOG_IC | HAK_LOG_WARN, "Warning - exception not handled %js:%zu - %O", (dbgi[ip].fname? dbgi[ip].fname: oocstr_dash), dbgi[ip].sline, val);
dbgi = (hak_dbgi_t*)HAK_OBJ_GET_BYTE_SLOT(f->dbgi);
HAK_LOG3(hak, HAK_LOG_IC | HAK_LOG_WARN, "Warning - exception not handled %js:%zu - %O\n", (dbgi[ip].fname? dbgi[ip].fname: oocstr_dash), dbgi[ip].sline, val);
HAK_MEMSET(&loc, 0, HAK_SIZEOF(loc));
loc.file = dbgi[ip].fname;
loc.line = dbgi[ip].sline;
@ -2394,9 +2398,34 @@ static HAK_INLINE int do_throw (hak_t* hak, hak_oop_t val, hak_ooi_t ip)
hak_seterrbfmt(hak, HAK_EEXCEPT, "exception not handled - %O", val);
}
/* output backtrace */
HAK_LOG0(hak, HAK_LOG_IC | HAK_LOG_INFO, "Backtrace\n");
c = hak->active_context;
while (c != hak->_nil) {
/*
hak_oop_class_t ow;
ow = c->owner;
if (ow != hak->_nil)
*/
f = c->base;
if (f->dbgi != hak->_nil)
{
hak_dbgi_t* dbgi;
hak_loc_t loc;
hak_ooi_t cip;
cip = HAK_OOP_TO_SMOOI(c->ip);
dbgi = (hak_dbgi_t*)HAK_OBJ_GET_BYTE_SLOT(f->dbgi);
HAK_MEMSET(&loc, 0, HAK_SIZEOF(loc));
loc.file = dbgi[cip].fname;
loc.line = dbgi[cip].sline;
HAK_LOG3(hak, HAK_LOG_IC | HAK_LOG_INFO, " %O (%js:%zu)\n", c->owner, (dbgi[cip].fname? dbgi[ip].fname: oocstr_dash), dbgi[cip].sline);
}
c = c->sender;
}
/* exception not handled. terminate the active process */
/*terminate_process (hak, hak->processor->active); <- the vm cleanup code will do this */
return -1;
}
@ -3927,6 +3956,7 @@ static int execute (hak_t* hak)
{
hak_oop_class_t c;
c = (hak_oop_class_t)HAK_OBJ_GET_CLASS(op);
/* TODO: use class to check? no more ibrand? */
switch (HAK_OOP_TO_SMOOI(c->ibrand))
{
case HAK_BRAND_FUNCTION:

View File

@ -141,13 +141,26 @@ class (#varying) Z: Object [ a b c ] {
self.a := 10
self.b := 20
self.c := 30
printf "Z:new called\n"
}
fun aaa() {
printf "%d %d %d\n" a b c
}
}
k := (Z:basicNew 10)
##k := (Z:new)
fun Z:abc() {
printf "%d %d %d\n" a b c ## this is not recognized as ....
}
fun k () {
k := (Z:basicNew 10) ## #varying is really required? what is the big deal even if you allow it regardless?
##k := (Z:new) ## no way to add extra fields.
k:basicAtPut 2 "hello"
k:basicAtPut 3 "world"
printf "----------------------------------------\n"
printf "%O\n" (k:basicAt 2)
printf "%O\n" (k:basicAt 20)
##k := (Z:new)
##k:aaa
}
(k)