Reformat CHash.CC

This commit is contained in:
TomAwezome 2020-07-24 13:37:33 -05:00 committed by VoidNV
parent b179792268
commit b7cb14ccb2
3 changed files with 89 additions and 75 deletions

View file

@ -2,7 +2,8 @@ I64 HashEntrySize(CHashSrcSym *tmph)
{//Logical size of a std system hash entry.
CDebugInfo *debug_info;
CBinFile *bfh;
switch (HashTypeNum(tmph)) {
switch (HashTypeNum(tmph))
{
case HTt_DEFINE_STR:
return MSize(tmph(CHashDefineStr *)->data);
case HTt_GLOBAL_VAR:
@ -11,8 +12,7 @@ I64 HashEntrySize(CHashSrcSym *tmph)
return tmph(CHashClass *)->size;
case HTt_FUN:
if (debug_info = tmph->debug_info)
return debug_info->body[debug_info->max_line+1-debug_info->min_line]
-debug_info->body[0];
return debug_info->body[debug_info->max_line + 1 - debug_info->min_line] - debug_info->body[0];
else
return -1;
case HTt_FILE:
@ -20,7 +20,8 @@ I64 HashEntrySize(CHashSrcSym *tmph)
case HTt_MODULE:
if (StrCompare(tmph->str, KERNEL_MODULE_NAME))
return MSize(tmph(CHashGeneric *)->user_data0);
else {
else
{
bfh = mem_boot_base - sizeof(CBinFile);
return bfh->file_size;
}
@ -36,7 +37,8 @@ I64 HashEntrySize2(CHashSrcSym *tmph)
I64 res = MSize2(tmph);
if (!(tmph->type & HTT_DICT_WORD))
res += MSize2(tmph->str);
if (tmph->type & HTG_SRC_SYM) {
if (tmph->type & HTG_SRC_SYM)
{
res += MSize2(tmph->src_link);
res += MSize2(tmph->idx);
res += MSize2(tmph->import_name);
@ -45,26 +47,27 @@ I64 HashEntrySize2(CHashSrcSym *tmph)
res += MSize2(tmph->debug_info);
if (tmph->type & HTT_CLASS)
res += MemberListSize(tmph);
else if (tmph->type & HTT_FUN) {
else if (tmph->type & HTT_FUN)
{
res += MemberListSize(tmph);
if (debug_info = tmph->debug_info)
//This should be $LK,"MSize",A="MN:MSize"$() but it would crash on AOT .BIN file funs.
res+=debug_info->body[debug_info->max_line+1-debug_info->min_line]
-debug_info->body[0];
} else if (tmph->type&HTT_DEFINE_STR)
res += debug_info->body[debug_info->max_line + 1 - debug_info->min_line] - debug_info->body[0];
}
else if (tmph->type & HTT_DEFINE_STR)
res += MSize2(tmph(CHashDefineStr *)->data);
else if (tmph->type & HTT_GLOBAL_VAR) {
else if (tmph->type & HTT_GLOBAL_VAR)
{
res += LinkedListSize(tmph(CHashGlobalVar *)->dim.next);
if (!(tmph(CHashGlobalVar *)->flags & GVF_ALIAS))
res += MSize2(tmph(CHashGlobalVar *)->data_addr);
if (tmph(CHashGlobalVar *)->fun_ptr)
res+=HashEntrySize2(tmph(CHashGlobalVar *)->fun_ptr
-tmph(CHashGlobalVar *)->fun_ptr->ptr_stars_count);
res += HashEntrySize2(tmph(CHashGlobalVar *)->fun_ptr - tmph(CHashGlobalVar *)->fun_ptr->ptr_stars_count);
}
} else if (tmph->type & HTT_FILE)
}
else if (tmph->type & HTT_FILE)
res += MSize2(tmph(CHashGeneric *)->user_data0);
else if (tmph->type & HTT_MODULE &&
StrCompare(tmph->str,KERNEL_MODULE_NAME))
else if (tmph->type & HTT_MODULE && StrCompare(tmph->str, KERNEL_MODULE_NAME))
res += MSize2(tmph(CHashGeneric *)->user_data0);
return res;
}
@ -75,9 +78,11 @@ I64 HashTableSize2(CHashTable *table)
CHashSrcSym *tmph;
if (!table)
return 0;
for (i=0;i<=table->mask;i++) {
for (i = 0; i <= table->mask; i++)
{
tmph = table->body[i];
while (tmph) {
while (tmph)
{
res += HashEntrySize2(tmph);
tmph = tmph->next;
}
@ -98,21 +103,28 @@ U0 MapFileWrite(CHashTable *h,U8 *map_name,U8 drv_let)
doc = DocNew(map_name);
doc->flags |= DOCF_NO_CURSOR;
for (i=0;i<=h->mask;i++) {
for (i = 0; i <= h->mask; i++)
{
tmph = h->body[i];
while (tmph) {
if (tmph->src_link && !(tmph->type & (HTF_IMPORT | HTF_PRIVATE))) {
while (tmph)
{
if (tmph->src_link && !(tmph->type & (HTF_IMPORT | HTF_PRIVATE)))
{
src_link = StrNew(tmph->src_link);
if (drv_let && StrLen(src_link) >= 4)
src_link[3] = drv_let;
if (debug_info=tmph->debug_info) {
size=offset(CDebugInfo.body)+
sizeof(U32)*(debug_info->max_line+2-debug_info->min_line);
if (size>MSize(debug_info)) {
if (debug_info = tmph->debug_info)
{
size = offset(CDebugInfo.body) + sizeof(U32) * (debug_info->max_line + 2 - debug_info->min_line);
if (size > MSize(debug_info))
{
"Corrupt Map Entry\n";
debug_info = NULL;
} else {
if (debug_info->min_line<=debug_info->max_line) {
}
else
{
if (debug_info->min_line <= debug_info->max_line)
{
tmpb = CAlloc(sizeof(CDocBin));
tmpb->size = size;
tmpb->data = MAlloc(size);
@ -120,13 +132,13 @@ U0 MapFileWrite(CHashTable *h,U8 *map_name,U8 drv_let)
tmpb->num = doc->cur_bin_num++;
tmpb->use_count = 1;
QueueInsert(tmpb, doc->bin_head.last);
} else
}
else
debug_info = NULL;
}
}
if (debug_info)
DocPrint(doc,"$$LK,\"%s\",A=\"%s\",BI=%d$$\n",
tmph->str,src_link,tmpb->num);
DocPrint(doc,"$$LK,\"%s\",A=\"%s\",BI=%d$$\n", tmph->str, src_link, tmpb->num);
else
DocPrint(doc,"$$LK,\"%s\",A=\"%s\"$$\n", tmph->str, src_link);
@ -139,3 +151,4 @@ U0 MapFileWrite(CHashTable *h,U8 *map_name,U8 drv_let)
DocWrite(doc);
DocDel(doc);
}

View file

@ -48,6 +48,7 @@ StartOS.CC
BackFB.CC
CExcept.CC
CExterns.CC
CHash.CC
CInit.CC
CompilerA.HH
CompilerB.HH