355 lines
33 KiB
Plaintext
355 lines
33 KiB
Plaintext
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta name="generator" content="TempleOS V5.03">
|
||
|
<meta name="viewport" content="width=device-width">
|
||
|
<link rel="stylesheet" href="/style/templeos.css">
|
||
|
<script src="/script/templeos.js"></script>
|
||
|
<style type="text/css">
|
||
|
.cF0{color:#000000;background-color:#ffffff;}
|
||
|
.cF1{color:#0000aa;background-color:#ffffff;}
|
||
|
.cF2{color:#00aa00;background-color:#ffffff;}
|
||
|
.cF3{color:#00aaaa;background-color:#ffffff;}
|
||
|
.cF4{color:#aa0000;background-color:#ffffff;}
|
||
|
.cF5{color:#aa00aa;background-color:#ffffff;}
|
||
|
.cF6{color:#aa5500;background-color:#ffffff;}
|
||
|
.cF7{color:#aaaaaa;background-color:#ffffff;}
|
||
|
.cF8{color:#555555;background-color:#ffffff;}
|
||
|
.cF9{color:#5555ff;background-color:#ffffff;}
|
||
|
.cFA{color:#55ff55;background-color:#ffffff;}
|
||
|
.cFB{color:#55ffff;background-color:#ffffff;}
|
||
|
.cFC{color:#ff5555;background-color:#ffffff;}
|
||
|
.cFD{color:#ff55ff;background-color:#ffffff;}
|
||
|
.cFE{color:#ffff55;background-color:#ffffff;}
|
||
|
.cFF{color:#ffffff;background-color:#ffffff;}
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<pre id="content">
|
||
|
<a name="l1"></a><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>PrsPush</span><span class=cF0>(</span><span class=cF9>CPrsStk</span><span class=cF0> *ps,</span><span class=cF9>I64</span><span class=cF0> val)
|
||
|
<a name="l2"></a>{
|
||
|
<a name="l3"></a> ps->stk[++ps->ptr]=val;
|
||
|
<a name="l4"></a>}
|
||
|
<a name="l5"></a>
|
||
|
<a name="l6"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cFD>PrsPop</span><span class=cF0>(</span><span class=cF9>CPrsStk</span><span class=cF0> *ps)
|
||
|
<a name="l7"></a>{
|
||
|
<a name="l8"></a> </span><span class=cF1>return</span><span class=cF0> ps->stk[ps->ptr--];
|
||
|
<a name="l9"></a>}
|
||
|
<a name="l10"></a>
|
||
|
<a name="l11"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>PrsPush2</span><span class=cF0>(</span><span class=cF9>CPrsStk</span><span class=cF0> *ps,</span><span class=cF9>I64</span><span class=cF0> val)
|
||
|
<a name="l12"></a>{
|
||
|
<a name="l13"></a> ps->stk2[++ps->ptr2]=val;
|
||
|
<a name="l14"></a>}
|
||
|
<a name="l15"></a>
|
||
|
<a name="l16"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cFD>PrsPop2</span><span class=cF0>(</span><span class=cF9>CPrsStk</span><span class=cF0> *ps)
|
||
|
<a name="l17"></a>{
|
||
|
<a name="l18"></a> </span><span class=cF1>return</span><span class=cF0> ps->stk2[ps->ptr2--];
|
||
|
<a name="l19"></a>}
|
||
|
<a name="l20"></a>
|
||
|
<a name="l21"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>PrsPopDeref</span><span class=cF0>(</span><span class=cF9>CPrsStk</span><span class=cF0> *ps)
|
||
|
<a name="l22"></a>{
|
||
|
<a name="l23"></a> </span><span class=cF9>I64</span><span class=cF0> i=</span><span class=cFD>PrsPop</span><span class=cF0>(ps);
|
||
|
<a name="l24"></a> </span><span class=cF9>CHashClass</span><span class=cF0> *tmpc=</span><span class=cFD>PrsPop</span><span class=cF0>(ps);
|
||
|
<a name="l25"></a> </span><span class=cF1>if</span><span class=cF0> (i.u16[0]!=</span><span class=cF3>IC_DEREF</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l26"></a> </span><span class=cFD>PrsPush</span><span class=cF0>(ps,tmpc);
|
||
|
<a name="l27"></a> </span><span class=cFD>PrsPush</span><span class=cF0>(ps,i);
|
||
|
<a name="l28"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l29"></a>}
|
||
|
<a name="l30"></a>
|
||
|
<a name="l31"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>PrsKeyWord</span><span class=cF0>(</span><span class=cF9>CCmpCtrl</span><span class=cF0> *cc)
|
||
|
<a name="l32"></a>{</span><span class=cF2>//Cvt cur token to </span><a href="/Wb/Compiler/OpCodes.DD.HTML#l140"><span class=cF4>KEYWORD</span></a><span class=cF2> or -1.</span><span class=cF0>
|
||
|
<a name="l33"></a> </span><span class=cF9>CHashGeneric</span><span class=cF0> *tmph;
|
||
|
<a name="l34"></a> </span><span class=cF1>if</span><span class=cF0> (cc->token==</span><span class=cF3>TK_IDENT</span><span class=cF0> &&</span><span class=cF7>(</span><span class=cF0>tmph=cc->hash_entry</span><span class=cF7>)</span><span class=cF0> && tmph->type&</span><span class=cF3>HTT_KEYWORD</span><span class=cF0>)
|
||
|
<a name="l35"></a> </span><span class=cF1>return</span><span class=cF0> tmph->user_data0;
|
||
|
<a name="l36"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l37"></a> </span><span class=cF1>return</span><span class=cF0> -1;
|
||
|
<a name="l38"></a>}
|
||
|
<a name="l39"></a>
|
||
|
<a name="l40"></a></span><span class=cF9>CHashClass</span><span class=cF0> *</span><span class=cFD>PrsClassNew</span><span class=cF0>()
|
||
|
<a name="l41"></a>{</span><span class=cF2>/*Ptrs to classes are handled by</span><span class=cF0>
|
||
|
<a name="l42"></a></span><span class=cF2>allocating 5 structures for each</span><span class=cF0>
|
||
|
<a name="l43"></a></span><span class=cF2>new class and representing a pointer</span><span class=cF0>
|
||
|
<a name="l44"></a></span><span class=cF2>to a class by advancing 1 struct fwd</span><span class=cF0>
|
||
|
<a name="l45"></a></span><span class=cF2>for one * and two fwd for two **.</span><span class=cF0>
|
||
|
<a name="l46"></a></span><span class=cF2>*/</span><span class=cF0>
|
||
|
<a name="l47"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
||
|
<a name="l48"></a> </span><span class=cF9>CHashClass</span><span class=cF0> *res=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CHashClass</span><span class=cF7>)</span><span class=cF0>*</span><span class=cF7>(</span><span class=cF3>PTR_STARS_NUM</span><span class=cF0>+1</span><span class=cF7>)</span><span class=cF0>,</span><span class=cF5>Fs</span><span class=cF0>->code_heap),
|
||
|
<a name="l49"></a> *tmpc=res;
|
||
|
<a name="l50"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<=</span><span class=cF3>PTR_STARS_NUM</span><span class=cF0>;i++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l51"></a> tmpc->type=</span><span class=cF3>HTT_CLASS</span><span class=cF0>;
|
||
|
<a name="l52"></a> tmpc->raw_type=</span><span class=cF3>RT_PTR</span><span class=cF0>;
|
||
|
<a name="l53"></a> tmpc->size=</span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *);
|
||
|
<a name="l54"></a> tmpc->ptr_stars_cnt=i;
|
||
|
<a name="l55"></a> tmpc++;
|
||
|
<a name="l56"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l57"></a> res->last_in_member_lst=&res->member_lst_and_root;
|
||
|
<a name="l58"></a> res->size=0;
|
||
|
<a name="l59"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l60"></a>}
|
||
|
<a name="l61"></a>
|
||
|
<a name="l62"></a></span><span class=cF9>CHashFun</span><span class=cF0> *</span><span class=cFD>PrsFunNew</span><span class=cF0>()
|
||
|
<a name="l63"></a>{
|
||
|
<a name="l64"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
||
|
<a name="l65"></a> </span><span class=cF9>CHashFun</span><span class=cF0> *res=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CHashFun</span><span class=cF7>)</span><span class=cF0>*</span><span class=cF7>(</span><span class=cF3>PTR_STARS_NUM</span><span class=cF0>+1</span><span class=cF7>)</span><span class=cF0>,</span><span class=cF5>Fs</span><span class=cF0>->code_heap),
|
||
|
<a name="l66"></a> *tmpf=res;
|
||
|
<a name="l67"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<=</span><span class=cF3>PTR_STARS_NUM</span><span class=cF0>;i++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l68"></a> tmpf->type=</span><span class=cF3>HTT_FUN</span><span class=cF0>;
|
||
|
<a name="l69"></a> tmpf->raw_type=</span><span class=cF3>RT_PTR</span><span class=cF0>;
|
||
|
<a name="l70"></a> tmpf->size=</span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *);
|
||
|
<a name="l71"></a> tmpf->ptr_stars_cnt=i;
|
||
|
<a name="l72"></a> tmpf++;
|
||
|
<a name="l73"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l74"></a> res->last_in_member_lst=&res->member_lst_and_root;
|
||
|
<a name="l75"></a> res->size=0;
|
||
|
<a name="l76"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l77"></a>}
|
||
|
<a name="l78"></a>
|
||
|
<a name="l79"></a></span><span class=cF9>CIntermediateCode</span><span class=cF0> *</span><span class=cFD>ICAdd</span><span class=cF0>(</span><span class=cF9>CCmpCtrl</span><span class=cF0> *cc,
|
||
|
<a name="l80"></a> </span><span class=cF9>I64</span><span class=cF0> opcode_and_precedence,</span><span class=cF9>I64</span><span class=cF0> arg, </span><span class=cF9>CHashClass</span><span class=cF0> *c,</span><span class=cF9>I64</span><span class=cF0> flags=0)
|
||
|
<a name="l81"></a>{
|
||
|
<a name="l82"></a> </span><span class=cF9>CIntermediateCode</span><span class=cF0> *tmpi=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CIntermediateCode</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l83"></a> tmpi->ic_code=opcode_and_precedence.u16[0];
|
||
|
<a name="l84"></a> tmpi->ic_precedence=opcode_and_precedence.u16[1];
|
||
|
<a name="l85"></a> tmpi->ic_data=arg;
|
||
|
<a name="l86"></a> tmpi->ic_class=c;
|
||
|
<a name="l87"></a> </span><span class=cF1>if</span><span class=cF0> (cc->pass_trace) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l88"></a> </span><span class=cF5>Bts</span><span class=cF0>(&cc->flags,</span><span class=cF3>CCf_PASS_TRACE_PRESENT</span><span class=cF0>);
|
||
|
<a name="l89"></a> flags|=</span><span class=cF3>ICF_PASS_TRACE</span><span class=cF0>;
|
||
|
<a name="l90"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l91"></a> </span><span class=cF1>if</span><span class=cF0> (cc->lock_cnt)
|
||
|
<a name="l92"></a> flags|=</span><span class=cF3>ICF_LOCK</span><span class=cF0>;
|
||
|
<a name="l93"></a> tmpi->ic_flags=flags;
|
||
|
<a name="l94"></a> tmpi->ic_line=cc->last_line_num;
|
||
|
<a name="l95"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmpi,cc->coc.coc_head.last);
|
||
|
<a name="l96"></a> </span><span class=cF1>return</span><span class=cF0> tmpi;
|
||
|
<a name="l97"></a>}
|
||
|
<a name="l98"></a>
|
||
|
<a name="l99"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>COCInit</span><span class=cF0>(</span><span class=cF9>CCmpCtrl</span><span class=cF0> *cc)
|
||
|
<a name="l100"></a>{
|
||
|
<a name="l101"></a> </span><span class=cF9>CCodeCtrl</span><span class=cF0> *tmpcbh=&cc->coc;
|
||
|
<a name="l102"></a> </span><span class=cF5>QueInit</span><span class=cF0>(&tmpcbh->coc_head.next);
|
||
|
<a name="l103"></a> </span><span class=cF5>QueInit</span><span class=cF0>(&tmpcbh->coc_next_misc);
|
||
|
<a name="l104"></a> tmpcbh->coc_head.ic_code=</span><span class=cF3>IC_END</span><span class=cF0>;
|
||
|
<a name="l105"></a>}
|
||
|
<a name="l106"></a>
|
||
|
<a name="l107"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>COCPush</span><span class=cF0>(</span><span class=cF9>CCmpCtrl</span><span class=cF0> *cc)
|
||
|
<a name="l108"></a>{
|
||
|
<a name="l109"></a> </span><span class=cF9>CCodeCtrl</span><span class=cF0> *tmpcbh=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CCodeCtrl</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l110"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(tmpcbh,&cc->coc,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CCodeCtrl</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l111"></a> cc->coc.coc_next=tmpcbh;
|
||
|
<a name="l112"></a>}
|
||
|
<a name="l113"></a>
|
||
|
<a name="l114"></a></span><span class=cF9>CCmpCtrl</span><span class=cF0> *</span><span class=cFD>COCPopNoFree</span><span class=cF0>(</span><span class=cF9>CCmpCtrl</span><span class=cF0> *cc)
|
||
|
<a name="l115"></a>{
|
||
|
<a name="l116"></a> </span><span class=cF9>CCodeCtrl</span><span class=cF0> *tmpcbh=cc->coc.coc_next;
|
||
|
<a name="l117"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(&cc->coc,tmpcbh,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CCodeCtrl</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l118"></a> </span><span class=cF1>return</span><span class=cF0> tmpcbh;
|
||
|
<a name="l119"></a>}
|
||
|
<a name="l120"></a>
|
||
|
<a name="l121"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>COCPop</span><span class=cF0>(</span><span class=cF9>CCmpCtrl</span><span class=cF0> *cc)
|
||
|
<a name="l122"></a>{
|
||
|
<a name="l123"></a> </span><span class=cF5>Free</span><span class=cF0>(</span><span class=cFD>COCPopNoFree</span><span class=cF7>(</span><span class=cF0>cc</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l124"></a>}
|
||
|
<a name="l125"></a>
|
||
|
<a name="l126"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>COCAppend</span><span class=cF0>(</span><span class=cF9>CCmpCtrl</span><span class=cF0> *cc, </span><span class=cF9>CCodeCtrl</span><span class=cF0> *tmpcbh)
|
||
|
<a name="l127"></a>{
|
||
|
<a name="l128"></a> </span><span class=cF1>if</span><span class=cF0> (tmpcbh->coc_head.next!=&cc->coc.coc_head.next) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l129"></a> cc->coc.coc_head.last->next=tmpcbh->coc_head.next;
|
||
|
<a name="l130"></a> tmpcbh->coc_head.next->last=cc->coc.coc_head.last;
|
||
|
<a name="l131"></a> cc->coc.coc_head.last=tmpcbh->coc_head.last;
|
||
|
<a name="l132"></a> tmpcbh->coc_head.last->next=&cc->coc.coc_head.next;
|
||
|
<a name="l133"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l134"></a> </span><span class=cF1>if</span><span class=cF0> (tmpcbh->coc_next_misc!=&cc->coc.coc_next_misc) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l135"></a> cc->coc.coc_last_misc->next=tmpcbh->coc_next_misc;
|
||
|
<a name="l136"></a> tmpcbh->coc_next_misc->last=cc->coc.coc_last_misc;
|
||
|
<a name="l137"></a> cc->coc.coc_last_misc=tmpcbh->coc_last_misc;
|
||
|
<a name="l138"></a> tmpcbh->coc_last_misc->next=&cc->coc.coc_next_misc;
|
||
|
<a name="l139"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l140"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpcbh);
|
||
|
<a name="l141"></a>}
|
||
|
<a name="l142"></a>
|
||
|
<a name="l143"></a></span><span class=cF9>CCodeMisc</span><span class=cF0> *</span><span class=cFD>COCMiscNew</span><span class=cF0>(</span><span class=cF9>CCmpCtrl</span><span class=cF0> *cc,</span><span class=cF9>I64</span><span class=cF0> ty)
|
||
|
<a name="l144"></a>{
|
||
|
<a name="l145"></a> </span><span class=cF9>CCodeMisc</span><span class=cF0> *res=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CCodeMisc</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l146"></a> res->addr=</span><span class=cF3>INVALID_PTR</span><span class=cF0>;
|
||
|
<a name="l147"></a> res->type=ty;
|
||
|
<a name="l148"></a> </span><span class=cF5>QueIns</span><span class=cF0>(res,cc->coc.coc_last_misc);
|
||
|
<a name="l149"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l150"></a>}
|
||
|
<a name="l151"></a>
|
||
|
<a name="l152"></a></span><span class=cF9>CCodeMisc</span><span class=cF0> *</span><span class=cFD>COCGoToLabelFind</span><span class=cF0>(</span><span class=cF9>CCmpCtrl</span><span class=cF0> *cc,</span><span class=cF1>U8</span><span class=cF0> *name)
|
||
|
<a name="l153"></a>{
|
||
|
<a name="l154"></a> </span><span class=cF9>CCodeMisc</span><span class=cF0> *cm=cc->coc.coc_next_misc;
|
||
|
<a name="l155"></a> </span><span class=cF1>while</span><span class=cF0> (cm!=&cc->coc.coc_next_misc) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l156"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>cm->type==</span><span class=cF3>CMT_GOTO_LABEL</span><span class=cF0>||cm->type==</span><span class=cF3>CMT_ASM_LABEL</span><span class=cF7>)</span><span class=cF0> &&
|
||
|
<a name="l157"></a> !</span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF0>cm->str,name</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l158"></a> </span><span class=cF1>return</span><span class=cF0> cm;
|
||
|
<a name="l159"></a> cm=cm->next;
|
||
|
<a name="l160"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l161"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l162"></a>}
|
||
|
<a name="l163"></a>
|
||
|
<a name="l164"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cFD>COCFloatConstFind</span><span class=cF0>(</span><span class=cF9>CCmpCtrl</span><span class=cF0> *cc,</span><span class=cF1>F64</span><span class=cF0> d)
|
||
|
<a name="l165"></a>{
|
||
|
<a name="l166"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
||
|
<a name="l167"></a> </span><span class=cF9>CCodeMisc</span><span class=cF0> *cm=cc->coc.coc_next_misc;
|
||
|
<a name="l168"></a> </span><span class=cF1>while</span><span class=cF0> (cm!=&cc->coc.coc_next_misc) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l169"></a> </span><span class=cF1>if</span><span class=cF0> (cm->type==</span><span class=cF3>CMT_FLOAT_CONSTS</span><span class=cF0>) {
|
||
|
<a name="l170"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<cm->num_consts;i++)
|
||
|
<a name="l171"></a> </span><span class=cF1>if</span><span class=cF0> (cm->float_consts[i]==d)
|
||
|
<a name="l172"></a> </span><span class=cF1>return</span><span class=cF0> cm->addr+i*</span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF1>F64</span><span class=cF0>);
|
||
|
<a name="l173"></a> </span><span class=cF1>if</span><span class=cF0> (cm->num_consts<</span><span class=cF3>CM_CONSTS_NUM</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l174"></a> cm->float_consts[cm->num_consts++]=d;
|
||
|
<a name="l175"></a> </span><span class=cF1>return</span><span class=cF0> cm->addr+i*</span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF1>F64</span><span class=cF0>);
|
||
|
<a name="l176"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l177"></a> }
|
||
|
<a name="l178"></a> cm=cm->next;
|
||
|
<a name="l179"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l180"></a> cm=</span><span class=cFD>COCMiscNew</span><span class=cF0>(cc,</span><span class=cF3>CMT_FLOAT_CONSTS</span><span class=cF0>);
|
||
|
<a name="l181"></a> cm->float_consts=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF3>CM_CONSTS_NUM</span><span class=cF0>*</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF1>F64</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l182"></a> cm->float_consts[cm->num_consts++]=d;
|
||
|
<a name="l183"></a> </span><span class=cF1>return</span><span class=cF0> cm->addr;
|
||
|
<a name="l184"></a>}
|
||
|
<a name="l185"></a>
|
||
|
<a name="l186"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>COCDel</span><span class=cF0>(</span><span class=cF9>CCmpCtrl</span><span class=cF0> *cc,</span><span class=cF9>CCodeCtrl</span><span class=cF0> *coc)
|
||
|
<a name="l187"></a>{
|
||
|
<a name="l188"></a> </span><span class=cF9>CCodeMisc</span><span class=cF0> *cm,*cm1;
|
||
|
<a name="l189"></a> </span><span class=cF1>U8</span><span class=cF0> *undef=</span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l190"></a> </span><span class=cF5>QueDel</span><span class=cF0>(&coc->coc_head.next);
|
||
|
<a name="l191"></a> cm=coc->coc_next_misc;
|
||
|
<a name="l192"></a> </span><span class=cF1>while</span><span class=cF0> (cm!=&coc->coc_next_misc) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l193"></a> cm1=cm->next;
|
||
|
<a name="l194"></a> </span><span class=cF1>switch</span><span class=cF0> (cm->type) {
|
||
|
<a name="l195"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CMT_GOTO_LABEL</span><span class=cF0>:
|
||
|
<a name="l196"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CMT_ASM_LABEL</span><span class=cF0>:
|
||
|
<a name="l197"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>cm->flags&</span><span class=cF3>CMF_DEFINED</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l198"></a> undef=cm->str;
|
||
|
<a name="l199"></a> cm->str=</span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l200"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (!cm->use_cnt) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l201"></a> </span><span class=cF5>PrintWarn</span><span class=cF0>(</span><span class=cF6>"Unused label %s\n"</span><span class=cF0>,cm->str);
|
||
|
<a name="l202"></a> </span><span class=cF5>LexWarn</span><span class=cF0>(cc,</span><span class=cF6>"Unused label at "</span><span class=cF0>);
|
||
|
<a name="l203"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l204"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l205"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CMT_JMP_TABLE</span><span class=cF0>:
|
||
|
<a name="l206"></a> </span><span class=cF5>Free</span><span class=cF0>(cm->jmp_table);
|
||
|
<a name="l207"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l208"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CMT_FLOAT_CONSTS</span><span class=cF0>:
|
||
|
<a name="l209"></a> </span><span class=cF5>Free</span><span class=cF0>(cm->float_consts);
|
||
|
<a name="l210"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l211"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CMT_ARRAY_DIM</span><span class=cF0>:
|
||
|
<a name="l212"></a> </span><span class=cF5>LinkedLstDel</span><span class=cF0>(cm->dim);
|
||
|
<a name="l213"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l214"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CMT_HASH_ENTRY</span><span class=cF0>:
|
||
|
<a name="l215"></a> </span><span class=cF5>HashDel</span><span class=cF0>(cm->h);
|
||
|
<a name="l216"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l217"></a> }
|
||
|
<a name="l218"></a> </span><span class=cF5>Free</span><span class=cF0>(cm->str);
|
||
|
<a name="l219"></a> </span><span class=cF5>Free</span><span class=cF0>(cm);
|
||
|
<a name="l220"></a> cm=cm1;
|
||
|
<a name="l221"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l222"></a> </span><span class=cF1>if</span><span class=cF0> (undef) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l223"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>"Undefined goto label %s\n"</span><span class=cF0>,undef);
|
||
|
<a name="l224"></a> </span><span class=cF5>Free</span><span class=cF0>(undef);
|
||
|
<a name="l225"></a> </span><span class=cF5>LexExcept</span><span class=cF0>(cc,</span><span class=cF6>"Undefined goto label at "</span><span class=cF0>);
|
||
|
<a name="l226"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l227"></a>}
|
||
|
<a name="l228"></a>
|
||
|
<a name="l229"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>COCHeaderPut</span><span class=cF0>(</span><span class=cF9>CCmpCtrl</span><span class=cF0> *cc,</span><span class=cF9>I64</span><span class=cF0> pass,</span><span class=cF1>Bool</span><span class=cF0> put)
|
||
|
<a name="l230"></a>{
|
||
|
<a name="l231"></a> </span><span class=cF9>CIntermediateCode</span><span class=cF0> *tmpi;
|
||
|
<a name="l232"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&cc->flags,</span><span class=cF3>CCf_PASS_TRACE_PRESENT</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l233"></a> </span><span class=cF1>if</span><span class=cF0> (put) {
|
||
|
<a name="l234"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&cc->saved_pass_trace,pass-1</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l235"></a> </span><span class=cF6>"$IV,1$Pass %d:$IV,0$\n"</span><span class=cF0>,pass-1;
|
||
|
<a name="l236"></a> tmpi=cc->coc.coc_head.next;
|
||
|
<a name="l237"></a> </span><span class=cF1>while</span><span class=cF0> (tmpi->ic_code) {
|
||
|
<a name="l238"></a> </span><span class=cF1>if</span><span class=cF0> (tmpi->ic_flags&</span><span class=cF3>ICF_PASS_TRACE</span><span class=cF0>)
|
||
|
<a name="l239"></a> </span><span class=cFD>ICPut</span><span class=cF0>(cc,tmpi);
|
||
|
<a name="l240"></a> tmpi=tmpi->next;
|
||
|
<a name="l241"></a> }
|
||
|
<a name="l242"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l243"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&cc->saved_pass_trace,pass</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l244"></a> </span><span class=cF6>"$IV,1$Pass %d:$IV,0$\n"</span><span class=cF0>,pass;
|
||
|
<a name="l245"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l246"></a> cc->pass=pass;
|
||
|
<a name="l247"></a>}
|
||
|
<a name="l248"></a>
|
||
|
<a name="l249"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cFD>COCCompile</span><span class=cF0>(</span><span class=cF9>CCmpCtrl</span><span class=cF0> *cc,</span><span class=cF9>I64</span><span class=cF0> *_code_size,</span><span class=cF9>CDbgInfo</span><span class=cF0> **_dbg,</span><span class=cF9>I64</span><span class=cF0> *_type)
|
||
|
<a name="l250"></a>{
|
||
|
<a name="l251"></a> </span><span class=cF1>U8</span><span class=cF0> *res;
|
||
|
<a name="l252"></a> </span><span class=cF9>CCodeMisc</span><span class=cF0> *lb;
|
||
|
<a name="l253"></a> </span><span class=cF9>I64</span><span class=cF0> i,code_size,last_code_size;
|
||
|
<a name="l254"></a>
|
||
|
<a name="l255"></a> </span><span class=cF9>COptReg</span><span class=cF0> reg_offsets[</span><span class=cF3>REG_REGS_NUM</span><span class=cF0>];
|
||
|
<a name="l256"></a> </span><span class=cF1>if</span><span class=cF0> (_dbg) *_dbg=</span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l257"></a> cc->pass=0;
|
||
|
<a name="l258"></a> </span><span class=cFD>COCHeaderPut</span><span class=cF0>(cc,1,</span><span class=cF3>TRUE</span><span class=cF0>);
|
||
|
<a name="l259"></a> </span><span class=cFD>OptPass012</span><span class=cF0>(cc);
|
||
|
<a name="l260"></a> </span><span class=cFD>COCHeaderPut</span><span class=cF0>(cc,2,</span><span class=cF3>TRUE</span><span class=cF0>);
|
||
|
<a name="l261"></a> </span><span class=cFD>OptPass012</span><span class=cF0>(cc);
|
||
|
<a name="l262"></a> </span><span class=cFD>COCHeaderPut</span><span class=cF0>(cc,3,</span><span class=cF3>TRUE</span><span class=cF0>);
|
||
|
<a name="l263"></a> </span><span class=cFD>OptPass3</span><span class=cF0>(cc,reg_offsets);
|
||
|
<a name="l264"></a> </span><span class=cFD>COCHeaderPut</span><span class=cF0>(cc,4,</span><span class=cF3>TRUE</span><span class=cF0>);
|
||
|
<a name="l265"></a> </span><span class=cFD>OptPass4</span><span class=cF0>(cc,reg_offsets,_type);
|
||
|
<a name="l266"></a> </span><span class=cFD>COCHeaderPut</span><span class=cF0>(cc,5,</span><span class=cF3>TRUE</span><span class=cF0>);
|
||
|
<a name="l267"></a> </span><span class=cFD>OptPass5</span><span class=cF0>(cc);
|
||
|
<a name="l268"></a> </span><span class=cFD>COCHeaderPut</span><span class=cF0>(cc,6,</span><span class=cF3>TRUE</span><span class=cF0>);
|
||
|
<a name="l269"></a> </span><span class=cFD>OptPass6</span><span class=cF0>(cc);
|
||
|
<a name="l270"></a> </span><span class=cFD>COCHeaderPut</span><span class=cF0>(cc,7,</span><span class=cF3>TRUE</span><span class=cF0>);
|
||
|
<a name="l271"></a>
|
||
|
<a name="l272"></a> lb=cc->coc.coc_next_misc;
|
||
|
<a name="l273"></a> </span><span class=cF1>while</span><span class=cF0> (lb!=&cc->coc.coc_next_misc) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l274"></a> </span><span class=cF1>if</span><span class=cF0> (lb->type==</span><span class=cF3>CMT_JMP_TABLE</span><span class=cF0>) {
|
||
|
<a name="l275"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<lb->range;i++)
|
||
|
<a name="l276"></a> lb->jmp_table[i]=</span><span class=cFD>OptLabelFwd</span><span class=cF0>(lb->jmp_table[i]);
|
||
|
<a name="l277"></a> lb->dft=</span><span class=cFD>OptLabelFwd</span><span class=cF0>(lb->dft);
|
||
|
<a name="l278"></a> }
|
||
|
<a name="l279"></a> lb=lb->next;
|
||
|
<a name="l280"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l281"></a>
|
||
|
<a name="l282"></a> </span><span class=cFD>COCHeaderPut</span><span class=cF0>(cc,7,</span><span class=cF3>FALSE</span><span class=cF0>);
|
||
|
<a name="l283"></a> </span><span class=cFD>OptPass789A</span><span class=cF0>(cc,reg_offsets,</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF3>NULL</span><span class=cF0>);
|
||
|
<a name="l284"></a> </span><span class=cFD>COCHeaderPut</span><span class=cF0>(cc,8,</span><span class=cF3>FALSE</span><span class=cF0>);
|
||
|
<a name="l285"></a> </span><span class=cFD>OptPass789A</span><span class=cF0>(cc,reg_offsets,</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF3>NULL</span><span class=cF0>);
|
||
|
<a name="l286"></a> </span><span class=cFD>COCHeaderPut</span><span class=cF0>(cc,9,</span><span class=cF3>FALSE</span><span class=cF0>);
|
||
|
<a name="l287"></a> code_size=</span><span class=cFD>OptPass789A</span><span class=cF0>(cc,reg_offsets,</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF3>NULL</span><span class=cF0>);
|
||
|
<a name="l288"></a> </span><span class=cF1>do</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l289"></a> last_code_size=code_size;
|
||
|
<a name="l290"></a> </span><span class=cFD>COCHeaderPut</span><span class=cF0>(cc,9,</span><span class=cF3>FALSE</span><span class=cF0>);
|
||
|
<a name="l291"></a> code_size=</span><span class=cFD>OptPass789A</span><span class=cF0>(cc,reg_offsets,</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF3>NULL</span><span class=cF0>);
|
||
|
<a name="l292"></a> </span><span class=cF1>if</span><span class=cF0> (code_size>last_code_size) {
|
||
|
<a name="l293"></a> </span><span class=cF6>"Pass:9 Code Size\n"</span><span class=cF0>;
|
||
|
<a name="l294"></a> </span><span class=cF5>LexExcept</span><span class=cF0>(cc,</span><span class=cF6>"Compiler Optimization Error at "</span><span class=cF0>);
|
||
|
<a name="l295"></a> }
|
||
|
<a name="l296"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>while</span><span class=cF0> (code_size<last_code_size);
|
||
|
<a name="l297"></a>
|
||
|
<a name="l298"></a> </span><span class=cF1>if</span><span class=cF0> (cc->flags&</span><span class=cF3>CCF_AOT_COMPILE</span><span class=cF0>)
|
||
|
<a name="l299"></a> res=</span><span class=cF5>MAlloc</span><span class=cF0>(code_size);
|
||
|
<a name="l300"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l301"></a> res=</span><span class=cF5>MAlloc</span><span class=cF0>(code_size,</span><span class=cF5>Fs</span><span class=cF0>->code_heap);
|
||
|
<a name="l302"></a> </span><span class=cF1>if</span><span class=cF0> (cc->htc.fun)
|
||
|
<a name="l303"></a> </span><span class=cF5>Fs</span><span class=cF0>->last_fun=cc->htc.fun;
|
||
|
<a name="l304"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l305"></a> </span><span class=cFD>COCHeaderPut</span><span class=cF0>(cc,10,</span><span class=cF3>FALSE</span><span class=cF0>);
|
||
|
<a name="l306"></a> code_size=</span><span class=cFD>OptPass789A</span><span class=cF0>(cc,reg_offsets,res,_dbg);
|
||
|
<a name="l307"></a>
|
||
|
<a name="l308"></a> </span><span class=cFD>COCDel</span><span class=cF0>(cc,&cc->coc);
|
||
|
<a name="l309"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&cc->opts,</span><span class=cF3>OPTf_TRACE</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l310"></a> </span><span class=cF1>if</span><span class=cF0> (cc->flags&</span><span class=cF3>CCF_AOT_COMPILE</span><span class=cF0>) {
|
||
|
<a name="l311"></a> </span><span class=cF1>if</span><span class=cF0> (cc->aotc->seg_size==16)
|
||
|
<a name="l312"></a> </span><span class=cF5>Un</span><span class=cF0>(res,code_size,16);
|
||
|
<a name="l313"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (cc->aotc->seg_size==64)
|
||
|
<a name="l314"></a> </span><span class=cF5>Un</span><span class=cF0>(res,code_size,64);
|
||
|
<a name="l315"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l316"></a> </span><span class=cF5>Un</span><span class=cF0>(res,code_size,32);
|
||
|
<a name="l317"></a> } </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l318"></a> </span><span class=cF5>Un</span><span class=cF0>(res,code_size,64);
|
||
|
<a name="l319"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l320"></a> </span><span class=cF1>if</span><span class=cF0> (_code_size) *_code_size=code_size;
|
||
|
<a name="l321"></a> cc->saved_pass_trace=cc->pass_trace;
|
||
|
<a name="l322"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l323"></a>}
|
||
|
</span></pre></body>
|
||
|
</html>
|