removed unneeded code

uniformize the naming of locptr, dbgl to dbgi
This commit is contained in:
hyung-hwan 2021-02-01 03:32:09 +00:00
parent 7d6436a4de
commit 65c23a3ff5
8 changed files with 29 additions and 315 deletions

View File

@ -843,7 +843,7 @@ static int handle_dbgopt (hcl_t* hcl, const hcl_bch_t* str)
cm = hcl_find_bchar_in_bcstr(flt, ','); cm = hcl_find_bchar_in_bcstr(flt, ',');
len = cm? (cm - flt): hcl_count_bcstr(flt); len = cm? (cm - flt): hcl_count_bcstr(flt);
if (hcl_comp_bchars_bcstr (flt, len, "gc") == 0) dbgopt |= HCL_TRAIT_DEBUG_GC; if (hcl_comp_bchars_bcstr (flt, len, "gc") == 0) dbgopt |= HCL_TRAIT_DEBUG_GC;
else if (hcl_comp_bchars_bcstr (flt, len, "bigint") == 0) dbgopt |= HCL_DEBUG_BIGINT; else if (hcl_comp_bchars_bcstr (flt, len, "bigint") == 0) dbgopt |= HCL_TRAIT_DEBUG_BIGINT;
else else
{ {
fprintf (stderr, "ERROR: unknown debug option value - %.*s\n", (int)len, flt); fprintf (stderr, "ERROR: unknown debug option value - %.*s\n", (int)len, flt);

View File

@ -277,13 +277,13 @@ static int emit_byte_instruction (hcl_t* hcl, hcl_oob_t bc, const hcl_ioloc_t* s
{ {
hcl_oow_t newcapa; hcl_oow_t newcapa;
hcl_oob_t* tmp; hcl_oob_t* tmp;
hcl_dbgl_t* tmp2; hcl_dbgi_t* tmp2;
newcapa = HCL_ALIGN(hcl->code.bc.capa + 1, HCL_BC_BUFFER_ALIGN); newcapa = HCL_ALIGN(hcl->code.bc.capa + 1, HCL_BC_BUFFER_ALIGN);
tmp = (hcl_oob_t*)hcl_reallocmem(hcl, hcl->code.bc.ptr, HCL_SIZEOF(*tmp) * newcapa); tmp = (hcl_oob_t*)hcl_reallocmem(hcl, hcl->code.bc.ptr, HCL_SIZEOF(*tmp) * newcapa);
if (HCL_UNLIKELY(!tmp)) return -1; if (HCL_UNLIKELY(!tmp)) return -1;
tmp2 = (hcl_dbgl_t*)hcl_reallocmem(hcl, hcl->code.locptr, HCL_SIZEOF(*tmp2) * newcapa); tmp2 = (hcl_dbgi_t*)hcl_reallocmem(hcl, hcl->code.dbgi, HCL_SIZEOF(*tmp2) * newcapa);
if (HCL_UNLIKELY(!tmp2)) if (HCL_UNLIKELY(!tmp2))
{ {
hcl_freemem (hcl, tmp); hcl_freemem (hcl, tmp);
@ -293,15 +293,15 @@ static int emit_byte_instruction (hcl_t* hcl, hcl_oob_t bc, const hcl_ioloc_t* s
hcl->code.bc.ptr = tmp; hcl->code.bc.ptr = tmp;
hcl->code.bc.capa = newcapa; hcl->code.bc.capa = newcapa;
hcl->code.locptr = tmp2; hcl->code.dbgi = tmp2;
} }
hcl->code.bc.ptr[hcl->code.bc.len] = bc; hcl->code.bc.ptr[hcl->code.bc.len] = bc;
if (srcloc) if (srcloc)
{ {
hcl->code.locptr[hcl->code.bc.len].fname = srcloc->file; hcl->code.dbgi[hcl->code.bc.len].fname = srcloc->file;
hcl->code.locptr[hcl->code.bc.len].sline = srcloc->line; hcl->code.dbgi[hcl->code.bc.len].sline = srcloc->line;
} }
hcl->code.bc.len++; hcl->code.bc.len++;

View File

@ -70,199 +70,3 @@ void hcl_dumpdic (hcl_t* hcl, hcl_oop_dic_t dic, const hcl_bch_t* title)
/* TODO: hcl_loaddbgifromimage() -> load debug information from compiled image?
hcl_storedbgitoimage()? -> store debug information to compiled image?
hcl_compactdbgi()? -> compact debug information by scaning dbgi data. find class and method. if not found, drop the portion.
*/
int hcl_initdbgi (hcl_t* hcl, hcl_oow_t capa)
{
hcl_dbgi_t* tmp;
if (capa < HCL_SIZEOF(*tmp)) capa = HCL_SIZEOF(*tmp);
tmp = (hcl_dbgi_t*)hcl_callocmem(hcl, capa);
if (!tmp) return -1;
tmp->_capa = capa;
tmp->_len = HCL_SIZEOF(*tmp);
/* tmp->_last_file = 0;
tmp->_last_class = 0;
tmp->_last_text = 0;
tmp->_last_method = 0; */
hcl->dbgi = tmp;
return 0;
}
void hcl_finidbgi (hcl_t* hcl)
{
if (hcl->dbgi)
{
hcl_freemem (hcl, hcl->dbgi);
hcl->dbgi = HCL_NULL;
}
}
static HCL_INLINE hcl_uint8_t* secure_dbgi_space (hcl_t* hcl, hcl_oow_t req_bytes)
{
if (hcl->dbgi->_capa - hcl->dbgi->_len < req_bytes)
{
hcl_dbgi_t* tmp;
hcl_oow_t newcapa;
newcapa = hcl->dbgi->_len + req_bytes;
newcapa = HCL_ALIGN_POW2(newcapa, 65536); /* TODO: make the align value configurable */
tmp = hcl_reallocmem(hcl, hcl->dbgi, newcapa);
if (!tmp) return HCL_NULL;
hcl->dbgi = tmp;
hcl->dbgi->_capa = newcapa;
}
return &((hcl_uint8_t*)hcl->dbgi)[hcl->dbgi->_len];
}
int hcl_addfiletodbgi (hcl_t* hcl, const hcl_ooch_t* file_name, hcl_oow_t* start_offset)
{
hcl_oow_t name_len, name_bytes, name_bytes_aligned, req_bytes;
hcl_dbgi_file_t* di;
if (!hcl->dbgi)
{
if (start_offset) *start_offset = 0;
return 0; /* debug information is disabled*/
}
if (hcl->dbgi->_last_file > 0)
{
/* TODO: avoid linear search. need indexing for speed up */
hcl_oow_t offset = hcl->dbgi->_last_file;
do
{
di = (hcl_dbgi_file_t*)&((hcl_uint8_t*)hcl->dbgi)[offset];
if (hcl_comp_oocstr((hcl_ooch_t*)(di + 1), file_name) == 0)
{
if (start_offset) *start_offset = offset;
return 0;
}
offset = di->_next;
}
while (offset > 0);
}
name_len = hcl_count_oocstr(file_name);
name_bytes = (name_len + 1) * HCL_SIZEOF(*file_name);
name_bytes_aligned = HCL_ALIGN_POW2(name_bytes, HCL_SIZEOF_OOW_T);
req_bytes = HCL_SIZEOF(hcl_dbgi_file_t) + name_bytes_aligned;
di = (hcl_dbgi_file_t*)secure_dbgi_space(hcl, req_bytes);
if (!di) return -1;
di->_type = HCL_DBGI_MAKE_TYPE(HCL_DBGI_TYPE_CODE_FILE, 0);
di->_len = req_bytes;
di->_next = hcl->dbgi->_last_file;
hcl_copy_oocstr ((hcl_ooch_t*)(di + 1), name_len + 1, file_name);
hcl->dbgi->_last_file = hcl->dbgi->_len;
hcl->dbgi->_len += req_bytes;
if (start_offset) *start_offset = hcl->dbgi->_last_file;
return 0;
}
int hcl_addclasstodbgi (hcl_t* hcl, const hcl_ooch_t* class_name, hcl_oow_t file_offset, hcl_oow_t file_line, hcl_oow_t* start_offset)
{
hcl_oow_t name_len, name_bytes, name_bytes_aligned, req_bytes;
hcl_dbgi_class_t* di;
if (!hcl->dbgi) return 0; /* debug information is disabled*/
if (hcl->dbgi->_last_class > 0)
{
/* TODO: avoid linear search. need indexing for speed up */
hcl_oow_t offset = hcl->dbgi->_last_class;
do
{
di = (hcl_dbgi_class_t*)&((hcl_uint8_t*)hcl->dbgi)[offset];
if (hcl_comp_oocstr((hcl_ooch_t*)(di + 1), class_name) == 0 && di->_file == file_offset && di->_line == file_line)
{
if (start_offset) *start_offset = offset;
return 0;
}
offset = di->_next;
}
while (offset > 0);
}
name_len = hcl_count_oocstr(class_name);
name_bytes = (name_len + 1) * HCL_SIZEOF(*class_name);
name_bytes_aligned = HCL_ALIGN_POW2(name_bytes, HCL_SIZEOF_OOW_T);
req_bytes = HCL_SIZEOF(hcl_dbgi_class_t) + name_bytes_aligned;
di = (hcl_dbgi_class_t*)secure_dbgi_space(hcl, req_bytes);
if (!di) return -1;
di->_type = HCL_DBGI_MAKE_TYPE(HCL_DBGI_TYPE_CODE_CLASS, 0);
di->_len = req_bytes;
di->_next = hcl->dbgi->_last_class;
di->_file = file_offset;
di->_line = file_line;
hcl_copy_oocstr ((hcl_ooch_t*)(di + 1), name_len + 1, class_name);
hcl->dbgi->_last_class = hcl->dbgi->_len;
hcl->dbgi->_len += req_bytes;
if (start_offset) *start_offset = hcl->dbgi->_last_class;
return 0;
}
int hcl_addmethodtodbgi (hcl_t* hcl, hcl_oow_t file_offset, hcl_oow_t class_offset, const hcl_ooch_t* method_name, hcl_oow_t start_line, const hcl_oow_t* code_loc_ptr, hcl_oow_t code_loc_len, const hcl_ooch_t* text_ptr, hcl_oow_t text_len, hcl_oow_t* start_offset)
{
hcl_oow_t name_len, name_bytes, name_bytes_aligned, code_loc_bytes, code_loc_bytes_aligned, text_bytes, text_bytes_aligned, req_bytes;
hcl_dbgi_method_t* di;
hcl_uint8_t* curptr;
if (!hcl->dbgi) return 0; /* debug information is disabled*/
name_len = hcl_count_oocstr(method_name);
name_bytes = (name_len + 1) * HCL_SIZEOF(*method_name);
name_bytes_aligned = HCL_ALIGN_POW2(name_bytes, HCL_SIZEOF_OOW_T);
code_loc_bytes = code_loc_len * HCL_SIZEOF(*code_loc_ptr);
code_loc_bytes_aligned = HCL_ALIGN_POW2(code_loc_bytes, HCL_SIZEOF_OOW_T);
text_bytes = text_len * HCL_SIZEOF(*text_ptr);
text_bytes_aligned = HCL_ALIGN_POW2(text_bytes, HCL_SIZEOF_OOW_T);
req_bytes = HCL_SIZEOF(hcl_dbgi_method_t) + name_bytes_aligned + code_loc_bytes_aligned + text_bytes_aligned;
di = (hcl_dbgi_method_t*)secure_dbgi_space(hcl, req_bytes);
if (HCL_UNLIKELY(!di)) return -1;
di->_type = HCL_DBGI_MAKE_TYPE(HCL_DBGI_TYPE_CODE_METHOD, 0);
di->_len = req_bytes;
di->_next = hcl->dbgi->_last_method;
di->_file = file_offset;
di->_class = class_offset;
di->start_line = start_line;
di->code_loc_start = name_bytes_aligned; /* distance from the beginning of the variable payload */
di->code_loc_len = code_loc_len;
di->text_start = name_bytes_aligned + code_loc_bytes_aligned; /* distance from the beginning of the variable payload */
di->text_len = text_len;
curptr = (hcl_uint8_t*)(di + 1);
hcl_copy_oocstr ((hcl_ooch_t*)curptr, name_len + 1, method_name);
curptr += name_bytes_aligned;
HCL_MEMCPY (curptr, code_loc_ptr, code_loc_bytes);
if (text_len > 0)
{
curptr += code_loc_bytes_aligned;
hcl_copy_oochars ((hcl_ooch_t*)curptr, text_ptr, text_len);
}
hcl->dbgi->_last_method = hcl->dbgi->_len;
hcl->dbgi->_len += req_bytes;
if (start_offset) *start_offset = hcl->dbgi->_last_method;
return 0;
}

View File

@ -261,7 +261,7 @@ static HCL_INLINE hcl_oop_context_t make_context (hcl_t* hcl, hcl_ooi_t ntmprs)
return (hcl_oop_context_t)hcl_allocoopobj(hcl, HCL_BRAND_CONTEXT, HCL_CONTEXT_NAMED_INSTVARS + (hcl_oow_t)ntmprs); return (hcl_oop_context_t)hcl_allocoopobj(hcl, HCL_BRAND_CONTEXT, HCL_CONTEXT_NAMED_INSTVARS + (hcl_oow_t)ntmprs);
} }
static HCL_INLINE hcl_oop_function_t make_function (hcl_t* hcl, hcl_oow_t lfsize, const hcl_oob_t* bptr, hcl_oow_t blen, hcl_dbgl_t* locptr) static HCL_INLINE hcl_oop_function_t make_function (hcl_t* hcl, hcl_oow_t lfsize, const hcl_oob_t* bptr, hcl_oow_t blen, hcl_dbgi_t* dbgi)
{ {
hcl_oop_function_t func; hcl_oop_function_t func;
@ -270,11 +270,11 @@ static HCL_INLINE hcl_oop_function_t make_function (hcl_t* hcl, hcl_oow_t lfsize
func = (hcl_oop_function_t)hcl_allocoopobjwithtrailer(hcl, HCL_BRAND_FUNCTION, HCL_FUNCTION_NAMED_INSTVARS + lfsize, bptr, blen); func = (hcl_oop_function_t)hcl_allocoopobjwithtrailer(hcl, HCL_BRAND_FUNCTION, HCL_FUNCTION_NAMED_INSTVARS + lfsize, bptr, blen);
if (HCL_UNLIKELY(!func)) return HCL_NULL; if (HCL_UNLIKELY(!func)) return HCL_NULL;
if (locptr) if (dbgi)
{ {
hcl_oop_t tmp; hcl_oop_t tmp;
hcl_pushvolat (hcl, (hcl_oop_t*)&func); hcl_pushvolat (hcl, (hcl_oop_t*)&func);
tmp = hcl_makebytearray(hcl, (hcl_oob_t*)locptr, HCL_SIZEOF(*locptr) * blen); tmp = hcl_makebytearray(hcl, (hcl_oob_t*)dbgi, HCL_SIZEOF(*dbgi) * blen);
hcl_popvolat (hcl); hcl_popvolat (hcl);
if (tmp) func->dbgi = tmp; if (tmp) func->dbgi = tmp;
} }
@ -2575,16 +2575,16 @@ static void supplement_errmsg (hcl_t* hcl, hcl_ooi_t ip)
{ {
if (hcl->active_function->dbgi != hcl->_nil) if (hcl->active_function->dbgi != hcl->_nil)
{ {
hcl_dbgl_t* dbgl; hcl_dbgi_t* dbgi;
static hcl_ooch_t dash[] = { '-', '\0' }; static hcl_ooch_t dash[] = { '-', '\0' };
const hcl_ooch_t* orgmsg = hcl_backuperrmsg(hcl); const hcl_ooch_t* orgmsg = hcl_backuperrmsg(hcl);
hcl_errnum_t orgnum = hcl_geterrnum(hcl); hcl_errnum_t orgnum = hcl_geterrnum(hcl);
HCL_ASSERT (hcl, HCL_IS_BYTEARRAY(hcl, hcl->active_function->dbgi)); HCL_ASSERT (hcl, HCL_IS_BYTEARRAY(hcl, hcl->active_function->dbgi));
dbgl = (hcl_dbgl_t*)HCL_OBJ_GET_BYTE_SLOT(hcl->active_function->dbgi); dbgi = (hcl_dbgi_t*)HCL_OBJ_GET_BYTE_SLOT(hcl->active_function->dbgi);
hcl_seterrbfmt (hcl, orgnum, "%js (%js:%zu)", orgmsg, hcl_seterrbfmt (hcl, orgnum, "%js (%js:%zu)", orgmsg,
(dbgl[ip].fname? dbgl[ip].fname: dash), dbgl[ip].sline); (dbgi[ip].fname? dbgi[ip].fname: dash), dbgi[ip].sline);
} }
} }
@ -2599,8 +2599,6 @@ static int execute (hcl_t* hcl)
hcl_uintmax_t inst_counter = 0; hcl_uintmax_t inst_counter = 0;
#endif #endif
HCL_ASSERT (hcl, hcl->active_context != HCL_NULL); HCL_ASSERT (hcl, hcl->active_context != HCL_NULL);
hcl->abort_req = 0; hcl->abort_req = 0;
@ -3659,7 +3657,7 @@ hcl_oop_t hcl_execute (hcl_t* hcl)
} }
/* create a virtual function object that hold the bytes codes generated */ /* create a virtual function object that hold the bytes codes generated */
func = make_function(hcl, hcl->code.lit.len, hcl->code.bc.ptr, hcl->code.bc.len, hcl->code.locptr); func = make_function(hcl, hcl->code.lit.len, hcl->code.bc.ptr, hcl->code.bc.len, hcl->code.dbgi);
if (HCL_UNLIKELY(!func)) return HCL_NULL; if (HCL_UNLIKELY(!func)) return HCL_NULL;
/* pass nil for the home context of the initial function */ /* pass nil for the home context of the initial function */

View File

@ -813,19 +813,19 @@ int hcl_ignite (hcl_t* hcl)
hcl->code.bc.capa = HCL_BC_BUFFER_INIT; hcl->code.bc.capa = HCL_BC_BUFFER_INIT;
} }
if (!hcl->code.locptr) if (!hcl->code.dbgi)
{ {
hcl->code.locptr = (hcl_oow_t*)hcl_allocmem(hcl, HCL_SIZEOF(*hcl->code.locptr) * HCL_BC_BUFFER_INIT); hcl->code.dbgi = (hcl_oow_t*)hcl_allocmem(hcl, HCL_SIZEOF(*hcl->code.dbgi) * HCL_BC_BUFFER_INIT);
if (HCL_UNLIKELY(!hcl->code.locptr)) if (HCL_UNLIKELY(!hcl->code.dbgi))
{ {
/* bc.ptr and locptr go together. so free bc.ptr if locptr allocation fails */ /* bc.ptr and dbgi go together. so free bc.ptr if dbgi allocation fails */
hcl_freemem (hcl, hcl->code.bc.ptr); hcl_freemem (hcl, hcl->code.bc.ptr);
hcl->code.bc.ptr = HCL_NULL; hcl->code.bc.ptr = HCL_NULL;
hcl->code.bc.capa = 0; hcl->code.bc.capa = 0;
return -1; return -1;
} }
HCL_MEMSET (hcl->code.locptr, 0, HCL_SIZEOF(*hcl->code.locptr) * HCL_BC_BUFFER_INIT); HCL_MEMSET (hcl->code.dbgi, 0, HCL_SIZEOF(*hcl->code.dbgi) * HCL_BC_BUFFER_INIT);
} }
/* TODO: move code.lit.arr creation to hcl_init() after swithching to hcl_allocmem? */ /* TODO: move code.lit.arr creation to hcl_init() after swithching to hcl_allocmem? */

View File

@ -749,7 +749,7 @@ hcl_server_proto_t* hcl_server_proto_open (hcl_oow_t xtnsize, hcl_server_worker_
hcl_getoption (proto->hcl, HCL_TRAIT, &trait); hcl_getoption (proto->hcl, HCL_TRAIT, &trait);
#if defined(HCL_BUILD_DEBUG) #if defined(HCL_BUILD_DEBUG)
if (proto->worker->server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_GC) trait |= HCL_TRAIT_DEBUG_GC; if (proto->worker->server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_GC) trait |= HCL_TRAIT_DEBUG_GC;
if (proto->worker->server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_BIGINT) trait |= HCL_DEBUG_BIGINT; if (proto->worker->server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_BIGINT) trait |= HCL_TRAIT_DEBUG_BIGINT;
#endif #endif
hcl_setoption (proto->hcl, HCL_TRAIT, &trait); hcl_setoption (proto->hcl, HCL_TRAIT, &trait);
@ -1686,7 +1686,7 @@ hcl_server_t* hcl_server_open (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_server_p
hcl_getoption (server->dummy_hcl, HCL_TRAIT, &trait); hcl_getoption (server->dummy_hcl, HCL_TRAIT, &trait);
#if defined(HCL_BUILD_DEBUG) #if defined(HCL_BUILD_DEBUG)
if (server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_GC) trait |= HCL_TRAIT_DEBUG_GC; if (server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_GC) trait |= HCL_TRAIT_DEBUG_GC;
if (server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_BIGINT) trait |= HCL_DEBUG_BIGINT; if (server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_BIGINT) trait |= HCL_TRAIT_DEBUG_BIGINT;
#endif #endif
hcl_setoption (server->dummy_hcl, HCL_TRAIT, &trait); hcl_setoption (server->dummy_hcl, HCL_TRAIT, &trait);
@ -2366,7 +2366,7 @@ int hcl_server_setoption (hcl_server_t* server, hcl_server_option_t id, const vo
hcl_getoption (server->dummy_hcl, HCL_TRAIT, &trait); hcl_getoption (server->dummy_hcl, HCL_TRAIT, &trait);
#if defined(HCL_BUILD_DEBUG) #if defined(HCL_BUILD_DEBUG)
if (server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_GC) trait |= HCL_TRAIT_DEBUG_GC; if (server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_GC) trait |= HCL_TRAIT_DEBUG_GC;
if (server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_BIGINT) trait |= HCL_DEBUG_BIGINT; if (server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_BIGINT) trait |= HCL_TRAIT_DEBUG_BIGINT;
#endif #endif
hcl_setoption (server->dummy_hcl, HCL_TRAIT, &trait); hcl_setoption (server->dummy_hcl, HCL_TRAIT, &trait);
} }

View File

@ -258,10 +258,10 @@ void hcl_fini (hcl_t* hcl)
hcl->proc_map_free_last = -1; hcl->proc_map_free_last = -1;
} }
if (hcl->code.locptr) if (hcl->code.dbgi)
{ {
hcl_freemem (hcl, hcl->code.locptr); hcl_freemem (hcl, hcl->code.dbgi);
hcl->code.locptr = HCL_NULL; hcl->code.dbgi = HCL_NULL;
} }
if (hcl->code.bc.ptr) if (hcl->code.bc.ptr)
@ -310,7 +310,6 @@ void hcl_fini (hcl_t* hcl)
} }
hcl_killheap (hcl, hcl->heap); hcl_killheap (hcl, hcl->heap);
hcl_finidbgi (hcl);
if (hcl->log.ptr) if (hcl->log.ptr)
{ {
@ -384,7 +383,7 @@ int hcl_setoption (hcl_t* hcl, hcl_option_t id, const void* value)
case HCL_TRAIT: case HCL_TRAIT:
hcl->option.trait = *(const hcl_bitmask_t*)value; hcl->option.trait = *(const hcl_bitmask_t*)value;
#if defined(HCL_BUILD_DEBUG) #if defined(HCL_BUILD_DEBUG)
hcl->option.karatsuba_cutoff = ((hcl->option.trait & HCL_DEBUG_BIGINT)? HCL_KARATSUBA_CUTOFF_DEBUG: HCL_KARATSUBA_CUTOFF); hcl->option.karatsuba_cutoff = ((hcl->option.trait & HCL_TRAIT_DEBUG_BIGINT)? HCL_KARATSUBA_CUTOFF_DEBUG: HCL_KARATSUBA_CUTOFF);
#endif #endif
return 0; return 0;

View File

@ -186,7 +186,7 @@ enum hcl_trait_t
{ {
#if defined(HCL_BUILD_DEBUG) #if defined(HCL_BUILD_DEBUG)
HCL_TRAIT_DEBUG_GC = (1u << 0), HCL_TRAIT_DEBUG_GC = (1u << 0),
HCL_DEBUG_BIGINT = (1u << 1), HCL_TRAIT_DEBUG_BIGINT = (1u << 1),
#endif #endif
HCL_TRAIT_INTERACTIVE = (1u << 7), HCL_TRAIT_INTERACTIVE = (1u << 7),
@ -822,74 +822,6 @@ struct hcl_heap_t
hcl_mmgr_t xmmgr; hcl_mmgr_t xmmgr;
}; };
typedef struct hcl_dbgi_t hcl_dbgi_t;
struct hcl_dbgi_t
{
hcl_oow_t _capa;
hcl_oow_t _len;
hcl_oow_t _last_file; /* offset to the last file element added */
hcl_oow_t _last_class; /* offset to the last class element added */
hcl_oow_t _last_text; /* offset to the last text element added */
hcl_oow_t _last_method;
/* actual information is recorded here */
};
enum hcl_dbgi_type_t
{
/* bit 8 to bit 15 */
HCL_DBGI_TYPE_CODE_FILE = 0,
HCL_DBGI_TYPE_CODE_CLASS = 1,
HCL_DBGI_TYPE_CODE_TEXT = 2,
HCL_DBGI_TYPE_CODE_METHOD = 3, /* method instruction location information */
/* low 8 bits */
HCL_DBGI_TYPE_FLAG_INVALID = (1 << 0)
};
typedef enum hcl_dbgi_type_t hcl_dbgi_type_t;
#define HCL_DBGI_MAKE_TYPE(code,flags) (((code) << 8) | (flags))
#define HCL_DBGI_GET_TYPE_CODE(type) ((type) >> 8)
#define HCL_DBGI_GET_TYPE_FLAGS(type) ((type) & 0xFF)
#define HCL_DBGI_GET_DATA(hcl, offset) ((hcl_uint8_t*)(hcl)->dbgi + (offset))
typedef struct hcl_dbgi_file_t hcl_dbgi_file_t;
struct hcl_dbgi_file_t
{
hcl_oow_t _type;
hcl_oow_t _len; /* length of this record including the header and the file path payload */
hcl_oow_t _next;
/* ... file path here ... */
};
typedef struct hcl_dbgi_class_t hcl_dbgi_class_t;
struct hcl_dbgi_class_t
{
hcl_oow_t _type;
hcl_oow_t _len; /* length of this record including the header and the class name payload */
hcl_oow_t _next; /* offset to a previous class */
hcl_oow_t _file;
hcl_oow_t _line;
/* ... class name here ... */
};
typedef struct hcl_dbgi_method_t hcl_dbgi_method_t;
struct hcl_dbgi_method_t
{
hcl_oow_t _type;
hcl_oow_t _len; /* length of this record including the header and the payload including method name and code line numbers */
hcl_oow_t _next;
hcl_oow_t _file;
hcl_oow_t _class;
hcl_oow_t start_line;
hcl_oow_t code_loc_start; /* start offset from the payload beginning within this record */
hcl_oow_t code_loc_len;
hcl_oow_t text_start;
hcl_oow_t text_len;
/* ... method name here ... */
/* ... code line numbers here ... */
};
/* ========================================================================= /* =========================================================================
* VM LOGGING * VM LOGGING
* ========================================================================= */ * ========================================================================= */
@ -1374,8 +1306,8 @@ struct hcl_synerr_t
}; };
typedef struct hcl_dbgl_t hcl_dbgl_t; typedef struct hcl_dbgi_t hcl_dbgi_t;
struct hcl_dbgl_t struct hcl_dbgi_t
{ {
const hcl_ooch_t* fname; /* file name */ const hcl_ooch_t* fname; /* file name */
hcl_oow_t sline; /* source line in the file */ hcl_oow_t sline; /* source line in the file */
@ -1441,7 +1373,6 @@ struct hcl_t
/* ========================= */ /* ========================= */
hcl_heap_t* heap; hcl_heap_t* heap;
hcl_dbgi_t* dbgi;
/* ========================= */ /* ========================= */
hcl_oop_t _nil; /* pointer to the nil object */ hcl_oop_t _nil; /* pointer to the nil object */
@ -1577,7 +1508,7 @@ struct hcl_t
/* array that hold the location of the byte code emitted */ /* array that hold the location of the byte code emitted */
hcl_dbgl_t* locptr; hcl_dbgi_t* dbgi;
} code; } code;
/* == PRINTER == */ /* == PRINTER == */
@ -2096,24 +2027,6 @@ HCL_EXPORT void hcl_setsynerrufmt (
# define hcl_setsynerr(hcl,num,loc,tgt) hcl_setsynerrbfmt(hcl,num,loc,tgt,HCL_NULL) # define hcl_setsynerr(hcl,num,loc,tgt) hcl_setsynerrbfmt(hcl,num,loc,tgt,HCL_NULL)
#endif #endif
/* =========================================================================
* DEBUG SUPPORT
* ========================================================================= */
HCL_EXPORT int hcl_initdbgi (
hcl_t* hcl,
hcl_oow_t init_capa
);
/**
* The hcl_finidbgi() function deletes the debug information.
* It is called by hcl_close(). Unless you want the debug information to
* be deleted earlier, you need not call this function explicitly.
*/
HCL_EXPORT void hcl_finidbgi (
hcl_t* hcl
);
/* ========================================================================= /* =========================================================================
* TEMPORARY OOP MANAGEMENT FUNCTIONS * TEMPORARY OOP MANAGEMENT FUNCTIONS
* ========================================================================= */ * ========================================================================= */