ZealOS/docs/Compiler/CHash.CC.html

194 lines
20 KiB
HTML
Raw Normal View History

2021-07-03 05:07:57 +01:00
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V0.06">
2021-07-03 05:07:57 +01:00
<style type="text/css">
body {background-color:#000000;}
.cF0{color:#ffffff;background-color:#000000;}
.cF1{color:#3465a4;background-color:#000000;}
.cF2{color:#4e9a06;background-color:#000000;}
.cF3{color:#06989a;background-color:#000000;}
.cF4{color:#a24444;background-color:#000000;}
.cF5{color:#75507b;background-color:#000000;}
.cF6{color:#ce982f;background-color:#000000;}
.cF7{color:#bcc0b9;background-color:#000000;}
.cF8{color:#555753;background-color:#000000;}
.cF9{color:#729fcf;background-color:#000000;}
.cFA{color:#82bc49;background-color:#000000;}
.cFB{color:#34e2e2;background-color:#000000;}
.cFC{color:#ac3535;background-color:#000000;}
.cFD{color:#ad7fa8;background-color:#000000;}
.cFE{color:#fce94f;background-color:#000000;}
.cFF{color:#000000;background-color:#000000;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
2021-07-03 05:07:57 +01:00
<a name="l1"></a><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>HashEntrySize</span><span class=cF0>(</span><span class=cF9>CHashSrcSym</span><span class=cF0> *tmph)
<a name="l2"></a>{</span><span class=cF2>//Logical size of a std system hash entry.</span><span class=cF0>
<a name="l3"></a> </span><span class=cF9>CDebugInfo</span><span class=cF0> *debug_info;
<a name="l4"></a> </span><span class=cF9>CBinFile</span><span class=cF0> *bfh;
2021-07-03 05:07:57 +01:00
<a name="l5"></a>
<a name="l6"></a> </span><span class=cF1>switch</span><span class=cF0> (</span><span class=cF5>HashTypeNum</span><span class=cF7>(</span><span class=cF0>tmph</span><span class=cF7>)</span><span class=cF0>)
<a name="l7"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l8"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>HTt_DEFINE_STR</span><span class=cF0>:
<a name="l9"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>MSize</span><span class=cF0>(tmph</span><span class=cF7>(</span><span class=cF9>CHashDefineStr</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>-&gt;data);
2021-07-03 05:07:57 +01:00
<a name="l10"></a>
<a name="l11"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>HTt_GLOBAL_VAR</span><span class=cF0>:
<a name="l12"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>HTt_CLASS</span><span class=cF0>:
<a name="l13"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>HTt_INTERNAL_TYPE</span><span class=cF0>:
<a name="l14"></a> </span><span class=cF1>return</span><span class=cF0> tmph(</span><span class=cF9>CHashClass</span><span class=cF0> *)-&gt;size;
2021-07-03 05:07:57 +01:00
<a name="l15"></a>
<a name="l16"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>HTt_FUN</span><span class=cF0>:
<a name="l17"></a> </span><span class=cF1>if</span><span class=cF0> (debug_info = tmph-&gt;debug_info)
<a name="l18"></a> </span><span class=cF1>return</span><span class=cF0> debug_info-&gt;body[debug_info-&gt;max_line + </span><span class=cFE>1</span><span class=cF0> - debug_info-&gt;min_line] - debug_info-&gt;body[</span><span class=cFE>0</span><span class=cF0>];
<a name="l19"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l20"></a> </span><span class=cF1>return</span><span class=cF0> -</span><span class=cFE>1</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l21"></a>
<a name="l22"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>HTt_FILE</span><span class=cF0>:
<a name="l23"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>MSize</span><span class=cF0>(tmph</span><span class=cF7>(</span><span class=cF9>CHashGeneric</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>-&gt;user_data0);
2021-07-03 05:07:57 +01:00
<a name="l24"></a>
<a name="l25"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>HTt_MODULE</span><span class=cF0>:
<a name="l26"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>StrCompare</span><span class=cF7>(</span><span class=cF0>tmph-&gt;str, </span><span class=cF3>KERNEL_MODULE_NAME</span><span class=cF7>)</span><span class=cF0>)
<a name="l27"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>MSize</span><span class=cF0>(tmph</span><span class=cF7>(</span><span class=cF9>CHashGeneric</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>-&gt;user_data0);
<a name="l28"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l29"></a> {
<a name="l30"></a> bfh = </span><span class=cFB>mem_boot_base</span><span class=cF0> - </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CBinFile</span><span class=cF0>);
<a name="l31"></a> </span><span class=cF1>return</span><span class=cF0> bfh-&gt;file_size;
<a name="l32"></a> }
2021-07-03 05:07:57 +01:00
<a name="l33"></a>
<a name="l34"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>HTt_WORD</span><span class=cF0>:
<a name="l35"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>StrLen</span><span class=cF0>(tmph-&gt;str);
<a name="l36"></a> </span><span class=cF7>}</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l37"></a>
<a name="l38"></a> </span><span class=cF1>return</span><span class=cF0> -</span><span class=cFE>1</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l39"></a>}
<a name="l40"></a>
<a name="l41"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>HashEntrySize2</span><span class=cF0>(</span><span class=cF9>CHashSrcSym</span><span class=cF0> *tmph)
<a name="l42"></a>{</span><span class=cF2>//Memory size of a std system hash entry.</span><span class=cF0>
<a name="l43"></a> </span><span class=cF9>CDebugInfo</span><span class=cF0> *debug_info;
<a name="l44"></a> </span><span class=cF9>I64</span><span class=cF0> res = </span><span class=cF5>MSize2</span><span class=cF0>(tmph);
2021-07-03 05:07:57 +01:00
<a name="l45"></a>
<a name="l46"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>tmph-&gt;type &amp; </span><span class=cF3>HTT_DICT_WORD</span><span class=cF7>)</span><span class=cF0>)
<a name="l47"></a> res += </span><span class=cF5>MSize2</span><span class=cF0>(tmph-&gt;str);
<a name="l48"></a> </span><span class=cF1>if</span><span class=cF0> (tmph-&gt;type &amp; </span><span class=cF3>HTG_SRC_SYM</span><span class=cF0>)
<a name="l49"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l50"></a> res += </span><span class=cF5>MSize2</span><span class=cF0>(tmph-&gt;src_link);
<a name="l51"></a> res += </span><span class=cF5>MSize2</span><span class=cF0>(tmph-&gt;idx);
<a name="l52"></a> res += </span><span class=cF5>MSize2</span><span class=cF0>(tmph-&gt;import_name);
<a name="l53"></a> res += </span><span class=cF5>LinkedListSize</span><span class=cF0>(tmph-&gt;ie_list);
<a name="l54"></a> </span><span class=cF1>if</span><span class=cF0> (tmph-&gt;type &amp; </span><span class=cF7>(</span><span class=cF3>HTT_FUN</span><span class=cF0> | </span><span class=cF3>HTT_EXPORT_SYS_SYM</span><span class=cF7>)</span><span class=cF0>)
<a name="l55"></a> res += </span><span class=cF5>MSize2</span><span class=cF0>(tmph-&gt;debug_info);
<a name="l56"></a> </span><span class=cF1>if</span><span class=cF0> (tmph-&gt;type &amp; </span><span class=cF3>HTT_CLASS</span><span class=cF0>)
<a name="l57"></a> res += </span><span class=cFD>MemberListSize</span><span class=cF0>(tmph);
<a name="l58"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmph-&gt;type &amp; </span><span class=cF3>HTT_FUN</span><span class=cF0>)
<a name="l59"></a> {
<a name="l60"></a> res += </span><span class=cFD>MemberListSize</span><span class=cF0>(tmph);
<a name="l61"></a> </span><span class=cF1>if</span><span class=cF0> (debug_info = tmph-&gt;debug_info)
<a name="l62"></a></span><span class=cF2>//This should be </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MAllocFree.CC.html#l388"><span class=cF4>MSize</span></a><span class=cF2>() but it would crash on AOT .BIN file funs.</span><span class=cF0>
<a name="l63"></a> res += debug_info-&gt;body[debug_info-&gt;max_line + </span><span class=cFE>1</span><span class=cF0> - debug_info-&gt;min_line] - debug_info-&gt;body[</span><span class=cFE>0</span><span class=cF0>];
<a name="l64"></a> }
<a name="l65"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmph-&gt;type &amp; </span><span class=cF3>HTT_DEFINE_STR</span><span class=cF0>)
<a name="l66"></a> res += </span><span class=cF5>MSize2</span><span class=cF0>(tmph</span><span class=cF7>(</span><span class=cF9>CHashDefineStr</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>-&gt;data);
<a name="l67"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmph-&gt;type &amp; </span><span class=cF3>HTT_GLOBAL_VAR</span><span class=cF0>)
<a name="l68"></a> {
<a name="l69"></a> res += </span><span class=cF5>LinkedListSize</span><span class=cF0>(tmph</span><span class=cF7>(</span><span class=cF9>CHashGlobalVar</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>-&gt;dim.next);
<a name="l70"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>tmph(</span><span class=cF9>CHashGlobalVar</span><span class=cF0> *)-&gt;flags &amp; </span><span class=cF3>GVF_ALIAS</span><span class=cF7>)</span><span class=cF0>)
<a name="l71"></a> res += </span><span class=cF5>MSize2</span><span class=cF0>(tmph</span><span class=cF7>(</span><span class=cF9>CHashGlobalVar</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>-&gt;data_addr);
<a name="l72"></a> </span><span class=cF1>if</span><span class=cF0> (tmph</span><span class=cF7>(</span><span class=cF9>CHashGlobalVar</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>-&gt;fun_ptr)
<a name="l73"></a> res += </span><span class=cF5>HashEntrySize2</span><span class=cF0>(tmph</span><span class=cF7>(</span><span class=cF9>CHashGlobalVar</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>-&gt;fun_ptr - tmph</span><span class=cF7>(</span><span class=cF9>CHashGlobalVar</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>-&gt;fun_ptr-&gt;ptr_stars_count);
<a name="l74"></a> }
<a name="l75"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l76"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmph-&gt;type &amp; </span><span class=cF3>HTT_FILE</span><span class=cF0>)
<a name="l77"></a> res += </span><span class=cF5>MSize2</span><span class=cF0>(tmph</span><span class=cF7>(</span><span class=cF9>CHashGeneric</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>-&gt;user_data0);
<a name="l78"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmph-&gt;type &amp; </span><span class=cF3>HTT_MODULE</span><span class=cF0> &amp;&amp; </span><span class=cF5>StrCompare</span><span class=cF7>(</span><span class=cF0>tmph-&gt;str, </span><span class=cF3>KERNEL_MODULE_NAME</span><span class=cF7>)</span><span class=cF0>)
<a name="l79"></a> res += </span><span class=cF5>MSize2</span><span class=cF0>(tmph</span><span class=cF7>(</span><span class=cF9>CHashGeneric</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>-&gt;user_data0);
2021-07-03 05:07:57 +01:00
<a name="l80"></a>
<a name="l81"></a> </span><span class=cF1>return</span><span class=cF0> res;
2021-07-03 05:07:57 +01:00
<a name="l82"></a>}
<a name="l83"></a>
<a name="l84"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>HashTableSize2</span><span class=cF0>(</span><span class=cF9>CHashTable</span><span class=cF0> *table)
<a name="l85"></a>{</span><span class=cF2>//Memory size of std system hash table and all entries.</span><span class=cF0>
<a name="l86"></a> </span><span class=cF9>I64</span><span class=cF0> i, res = </span><span class=cFE>0</span><span class=cF0>;
<a name="l87"></a> </span><span class=cF9>CHashSrcSym</span><span class=cF0> *tmph;
2021-07-03 05:07:57 +01:00
<a name="l88"></a>
<a name="l89"></a> </span><span class=cF1>if</span><span class=cF0> (!table)
<a name="l90"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
<a name="l91"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt;= table-&gt;mask; i++)
<a name="l92"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l93"></a> tmph = table-&gt;body[i];
<a name="l94"></a> </span><span class=cF1>while</span><span class=cF0> (tmph)
<a name="l95"></a> {
<a name="l96"></a> res += </span><span class=cF5>HashEntrySize2</span><span class=cF0>(tmph);
<a name="l97"></a> tmph = tmph-&gt;next;
<a name="l98"></a> }
<a name="l99"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l100"></a> res += </span><span class=cF5>MSize2</span><span class=cF0>(table-&gt;body);
<a name="l101"></a> res += </span><span class=cF5>MSize2</span><span class=cF0>(table);
<a name="l102"></a> </span><span class=cF1>return</span><span class=cF0> res;
2021-07-03 05:07:57 +01:00
<a name="l103"></a>}
<a name="l104"></a>
<a name="l105"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>MapFileWrite</span><span class=cF0>(</span><span class=cF9>CHashTable</span><span class=cF0> *h, </span><span class=cF1>U8</span><span class=cF0> *map_name, </span><span class=cF1>U8</span><span class=cF0> drv_let)
<a name="l106"></a>{
<a name="l107"></a> </span><span class=cF9>CHashSrcSym</span><span class=cF0> *tmph;
<a name="l108"></a> </span><span class=cF9>I64</span><span class=cF0> i, size;
<a name="l109"></a> </span><span class=cF1>U8</span><span class=cF0> *src_link;
<a name="l110"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc;
<a name="l111"></a> </span><span class=cF9>CDocBin</span><span class=cF0> *tmpb;
<a name="l112"></a> </span><span class=cF9>CDebugInfo</span><span class=cF0> *debug_info;
2021-07-03 05:07:57 +01:00
<a name="l113"></a>
<a name="l114"></a> doc = </span><span class=cF5>DocNew</span><span class=cF0>(map_name);
<a name="l115"></a> doc-&gt;flags |= </span><span class=cF3>DOCF_NO_CURSOR</span><span class=cF0>;
<a name="l116"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt;= h-&gt;mask; i++)
<a name="l117"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l118"></a> tmph = h-&gt;body[i];
<a name="l119"></a> </span><span class=cF1>while</span><span class=cF0> (tmph)
<a name="l120"></a> {
<a name="l121"></a> </span><span class=cF1>if</span><span class=cF0> (tmph-&gt;src_link &amp;&amp; !</span><span class=cF7>(</span><span class=cF0>tmph-&gt;type &amp; (</span><span class=cF3>HTF_IMPORT</span><span class=cF0> | </span><span class=cF3>HTF_PRIVATE</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>)
<a name="l122"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l123"></a> src_link = </span><span class=cF5>StrNew</span><span class=cF0>(tmph-&gt;src_link);
<a name="l124"></a> </span><span class=cF1>if</span><span class=cF0> (drv_let &amp;&amp; </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>src_link</span><span class=cF7>)</span><span class=cF0> &gt;= </span><span class=cFE>4</span><span class=cF0>)
<a name="l125"></a> src_link[</span><span class=cFE>3</span><span class=cF0>] = drv_let;
<a name="l126"></a> </span><span class=cF1>if</span><span class=cF0> (debug_info = tmph-&gt;debug_info)
<a name="l127"></a> {
<a name="l128"></a> size = </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CDebugInfo</span><span class=cF0>.body) + </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>U32</span><span class=cF0>) * (debug_info-&gt;max_line + </span><span class=cFE>2</span><span class=cF0> - debug_info-&gt;min_line);
<a name="l129"></a> </span><span class=cF1>if</span><span class=cF0> (size &gt; </span><span class=cF5>MSize</span><span class=cF7>(</span><span class=cF0>debug_info</span><span class=cF7>)</span><span class=cF0>)
<a name="l130"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l131"></a> </span><span class=cF6>&quot;Corrupt Map Entry\n&quot;</span><span class=cF0>;
<a name="l132"></a> debug_info = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l133"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l134"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l135"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l136"></a> </span><span class=cF1>if</span><span class=cF0> (debug_info-&gt;min_line &lt;= debug_info-&gt;max_line)
<a name="l137"></a> {
<a name="l138"></a> tmpb = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDocBin</span><span class=cF7>)</span><span class=cF0>);
<a name="l139"></a> tmpb-&gt;size = size;
<a name="l140"></a> tmpb-&gt;data = </span><span class=cF5>MAlloc</span><span class=cF0>(size);
<a name="l141"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(tmpb-&gt;data, debug_info, size);
<a name="l142"></a> tmpb-&gt;num = doc-&gt;cur_bin_num++;
<a name="l143"></a> tmpb-&gt;use_count = </span><span class=cFE>1</span><span class=cF0>;
<a name="l144"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpb, doc-&gt;bin_head.last);
<a name="l145"></a> }
<a name="l146"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l147"></a> debug_info = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l148"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l149"></a> }
<a name="l150"></a> </span><span class=cF1>if</span><span class=cF0> (debug_info)
<a name="l151"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc,</span><span class=cF6>&quot;$LK,\&quot;%s\&quot;,A=\&quot;%s\&quot;,BI=%d$\n&quot;</span><span class=cF0>, tmph-&gt;str, src_link, tmpb-&gt;num);
<a name="l152"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l153"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc,</span><span class=cF6>&quot;$LK,\&quot;%s\&quot;,A=\&quot;%s\&quot;$\n&quot;</span><span class=cF0>, tmph-&gt;str, src_link);
2021-07-03 05:07:57 +01:00
<a name="l154"></a>
<a name="l155"></a> </span><span class=cF5>Free</span><span class=cF0>(src_link);
<a name="l156"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l157"></a> tmph = tmph-&gt;next;
<a name="l158"></a> }
<a name="l159"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l160"></a> </span><span class=cF5>DocBinsValidate</span><span class=cF0>(doc);
<a name="l161"></a> </span><span class=cF5>DocWrite</span><span class=cF0>(doc);
<a name="l162"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
2021-07-03 05:07:57 +01:00
<a name="l163"></a>}
<a name="l164"></a>
</span></pre></body>
</html>