mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2025-03-14 20:15:05 +00:00
Reformat CHash.CC
This commit is contained in:
parent
b179792268
commit
b7cb14ccb2
3 changed files with 89 additions and 75 deletions
Binary file not shown.
|
@ -2,7 +2,8 @@ I64 HashEntrySize(CHashSrcSym *tmph)
|
||||||
{//Logical size of a std system hash entry.
|
{//Logical size of a std system hash entry.
|
||||||
CDebugInfo *debug_info;
|
CDebugInfo *debug_info;
|
||||||
CBinFile *bfh;
|
CBinFile *bfh;
|
||||||
switch (HashTypeNum(tmph)) {
|
switch (HashTypeNum(tmph))
|
||||||
|
{
|
||||||
case HTt_DEFINE_STR:
|
case HTt_DEFINE_STR:
|
||||||
return MSize(tmph(CHashDefineStr *)->data);
|
return MSize(tmph(CHashDefineStr *)->data);
|
||||||
case HTt_GLOBAL_VAR:
|
case HTt_GLOBAL_VAR:
|
||||||
|
@ -10,18 +11,18 @@ I64 HashEntrySize(CHashSrcSym *tmph)
|
||||||
case HTt_INTERNAL_TYPE:
|
case HTt_INTERNAL_TYPE:
|
||||||
return tmph(CHashClass *)->size;
|
return tmph(CHashClass *)->size;
|
||||||
case HTt_FUN:
|
case HTt_FUN:
|
||||||
if (debug_info=tmph->debug_info)
|
if (debug_info = tmph->debug_info)
|
||||||
return debug_info->body[debug_info->max_line+1-debug_info->min_line]
|
return debug_info->body[debug_info->max_line + 1 - debug_info->min_line] - debug_info->body[0];
|
||||||
-debug_info->body[0];
|
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
case HTt_FILE:
|
case HTt_FILE:
|
||||||
return MSize(tmph(CHashGeneric *)->user_data0);
|
return MSize(tmph(CHashGeneric *)->user_data0);
|
||||||
case HTt_MODULE:
|
case HTt_MODULE:
|
||||||
if (StrCompare(tmph->str,KERNEL_MODULE_NAME))
|
if (StrCompare(tmph->str, KERNEL_MODULE_NAME))
|
||||||
return MSize(tmph(CHashGeneric *)->user_data0);
|
return MSize(tmph(CHashGeneric *)->user_data0);
|
||||||
else {
|
else
|
||||||
bfh=mem_boot_base-sizeof(CBinFile);
|
{
|
||||||
|
bfh = mem_boot_base - sizeof(CBinFile);
|
||||||
return bfh->file_size;
|
return bfh->file_size;
|
||||||
}
|
}
|
||||||
case HTt_WORD:
|
case HTt_WORD:
|
||||||
|
@ -33,109 +34,121 @@ I64 HashEntrySize(CHashSrcSym *tmph)
|
||||||
I64 HashEntrySize2(CHashSrcSym *tmph)
|
I64 HashEntrySize2(CHashSrcSym *tmph)
|
||||||
{//Memory size of a std system hash entry.
|
{//Memory size of a std system hash entry.
|
||||||
CDebugInfo *debug_info;
|
CDebugInfo *debug_info;
|
||||||
I64 res=MSize2(tmph);
|
I64 res = MSize2(tmph);
|
||||||
if (!(tmph->type&HTT_DICT_WORD))
|
if (!(tmph->type & HTT_DICT_WORD))
|
||||||
res+=MSize2(tmph->str);
|
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->src_link);
|
||||||
res+=MSize2(tmph->import_name);
|
res += MSize2(tmph->idx);
|
||||||
res+=LinkedListSize(tmph->ie_list);
|
res += MSize2(tmph->import_name);
|
||||||
|
res += LinkedListSize(tmph->ie_list);
|
||||||
if (tmph->type & (HTT_FUN | HTT_EXPORT_SYS_SYM))
|
if (tmph->type & (HTT_FUN | HTT_EXPORT_SYS_SYM))
|
||||||
res+=MSize2(tmph->debug_info);
|
res += MSize2(tmph->debug_info);
|
||||||
if (tmph->type & HTT_CLASS)
|
if (tmph->type & HTT_CLASS)
|
||||||
res+=MemberListSize(tmph);
|
res += MemberListSize(tmph);
|
||||||
else if (tmph->type & HTT_FUN) {
|
else if (tmph->type & HTT_FUN)
|
||||||
res+=MemberListSize(tmph);
|
{
|
||||||
if (debug_info=tmph->debug_info)
|
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.
|
//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]
|
res += debug_info->body[debug_info->max_line + 1 - debug_info->min_line] - debug_info->body[0];
|
||||||
-debug_info->body[0];
|
|
||||||
} else if (tmph->type&HTT_DEFINE_STR)
|
|
||||||
res+=MSize2(tmph(CHashDefineStr *)->data);
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
} else if (tmph->type & HTT_FILE)
|
else if (tmph->type & HTT_DEFINE_STR)
|
||||||
res+=MSize2(tmph(CHashGeneric *)->user_data0);
|
res += MSize2(tmph(CHashDefineStr *)->data);
|
||||||
else if (tmph->type & HTT_MODULE &&
|
else if (tmph->type & HTT_GLOBAL_VAR)
|
||||||
StrCompare(tmph->str,KERNEL_MODULE_NAME))
|
{
|
||||||
res+=MSize2(tmph(CHashGeneric *)->user_data0);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (tmph->type & HTT_FILE)
|
||||||
|
res += MSize2(tmph(CHashGeneric *)->user_data0);
|
||||||
|
else if (tmph->type & HTT_MODULE && StrCompare(tmph->str, KERNEL_MODULE_NAME))
|
||||||
|
res += MSize2(tmph(CHashGeneric *)->user_data0);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
I64 HashTableSize2(CHashTable *table)
|
I64 HashTableSize2(CHashTable *table)
|
||||||
{//Memory size of std system hash table and all entries.
|
{//Memory size of std system hash table and all entries.
|
||||||
I64 i,res=0;
|
I64 i, res = 0;
|
||||||
CHashSrcSym *tmph;
|
CHashSrcSym *tmph;
|
||||||
if (!table)
|
if (!table)
|
||||||
return 0;
|
return 0;
|
||||||
for (i=0;i<=table->mask;i++) {
|
for (i = 0; i <= table->mask; i++)
|
||||||
tmph=table->body[i];
|
{
|
||||||
while (tmph) {
|
tmph = table->body[i];
|
||||||
res+=HashEntrySize2(tmph);
|
while (tmph)
|
||||||
tmph=tmph->next;
|
{
|
||||||
|
res += HashEntrySize2(tmph);
|
||||||
|
tmph = tmph->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res+=MSize2(table->body);
|
res += MSize2(table->body);
|
||||||
res+=MSize2(table);
|
res += MSize2(table);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 MapFileWrite(CHashTable *h,U8 *map_name,U8 drv_let)
|
U0 MapFileWrite(CHashTable *h, U8 *map_name, U8 drv_let)
|
||||||
{
|
{
|
||||||
CHashSrcSym *tmph;
|
CHashSrcSym *tmph;
|
||||||
I64 i,size;
|
I64 i, size;
|
||||||
U8 *src_link;
|
U8 *src_link;
|
||||||
CDoc *doc;
|
CDoc *doc;
|
||||||
CDocBin *tmpb;
|
CDocBin *tmpb;
|
||||||
CDebugInfo *debug_info;
|
CDebugInfo *debug_info;
|
||||||
|
|
||||||
doc=DocNew(map_name);
|
doc = DocNew(map_name);
|
||||||
doc->flags|=DOCF_NO_CURSOR;
|
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) {
|
tmph = h->body[i];
|
||||||
if (tmph->src_link && !(tmph->type & (HTF_IMPORT | HTF_PRIVATE))) {
|
while (tmph)
|
||||||
src_link=StrNew(tmph->src_link);
|
{
|
||||||
if (drv_let && StrLen(src_link)>=4)
|
if (tmph->src_link && !(tmph->type & (HTF_IMPORT | HTF_PRIVATE)))
|
||||||
src_link[3]=drv_let;
|
{
|
||||||
if (debug_info=tmph->debug_info) {
|
src_link = StrNew(tmph->src_link);
|
||||||
size=offset(CDebugInfo.body)+
|
if (drv_let && StrLen(src_link) >= 4)
|
||||||
sizeof(U32)*(debug_info->max_line+2-debug_info->min_line);
|
src_link[3] = drv_let;
|
||||||
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";
|
"Corrupt Map Entry\n";
|
||||||
debug_info=NULL;
|
debug_info = NULL;
|
||||||
} else {
|
}
|
||||||
if (debug_info->min_line<=debug_info->max_line) {
|
else
|
||||||
tmpb=CAlloc(sizeof(CDocBin));
|
{
|
||||||
tmpb->size=size;
|
if (debug_info->min_line <= debug_info->max_line)
|
||||||
tmpb->data=MAlloc(size);
|
{
|
||||||
MemCopy(tmpb->data,debug_info,size);
|
tmpb = CAlloc(sizeof(CDocBin));
|
||||||
tmpb->num=doc->cur_bin_num++;
|
tmpb->size = size;
|
||||||
tmpb->use_count=1;
|
tmpb->data = MAlloc(size);
|
||||||
QueueInsert(tmpb,doc->bin_head.last);
|
MemCopy(tmpb->data, debug_info, size);
|
||||||
} else
|
tmpb->num = doc->cur_bin_num++;
|
||||||
debug_info=NULL;
|
tmpb->use_count = 1;
|
||||||
|
QueueInsert(tmpb, doc->bin_head.last);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
debug_info = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (debug_info)
|
if (debug_info)
|
||||||
DocPrint(doc,"$$LK,\"%s\",A=\"%s\",BI=%d$$\n",
|
DocPrint(doc,"$$LK,\"%s\",A=\"%s\",BI=%d$$\n", tmph->str, src_link, tmpb->num);
|
||||||
tmph->str,src_link,tmpb->num);
|
|
||||||
else
|
else
|
||||||
DocPrint(doc,"$$LK,\"%s\",A=\"%s\"$$\n",tmph->str,src_link);
|
DocPrint(doc,"$$LK,\"%s\",A=\"%s\"$$\n", tmph->str, src_link);
|
||||||
|
|
||||||
Free(src_link);
|
Free(src_link);
|
||||||
}
|
}
|
||||||
tmph=tmph->next;
|
tmph = tmph->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DocBinsValidate(doc);
|
DocBinsValidate(doc);
|
||||||
DocWrite(doc);
|
DocWrite(doc);
|
||||||
DocDel(doc);
|
DocDel(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ StartOS.CC
|
||||||
BackFB.CC
|
BackFB.CC
|
||||||
CExcept.CC
|
CExcept.CC
|
||||||
CExterns.CC
|
CExterns.CC
|
||||||
|
CHash.CC
|
||||||
CInit.CC
|
CInit.CC
|
||||||
CompilerA.HH
|
CompilerA.HH
|
||||||
CompilerB.HH
|
CompilerB.HH
|
||||||
|
|
Loading…
Reference in a new issue