home *** CD-ROM | disk | FTP | other *** search
- -- Copyright (c) 1990 Regents of the University of California.
- -- All rights reserved.
- --
- -- This software was developed by John Self of the Arcadia project
- -- at the University of California, Irvine.
- --
- -- Redistribution and use in source and binary forms are permitted
- -- provided that the above copyright notice and this paragraph are
- -- duplicated in all such forms and that any documentation,
- -- advertising materials, and other materials related to such
- -- distribution and use acknowledge that the software was developed
- -- by the University of California, Irvine. The name of the
- -- University may not be used to endorse or promote products derived
- -- from this software without specific prior written permission.
- -- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- -- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- -- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-
- -- TITLE table compression routines
- -- AUTHOR: John Self (UCI)
- -- DESCRIPTION used for compressed tables only
- -- NOTES somewhat complicated but works fast and generates efficient scanners
- -- $Header: /co/ua/self/arcadia/aflex/ada/src/RCS/tblcmpB.a,v 1.8 90/01/12 15:20:43 self Exp Locker: self $
-
- with DFA, ECS, MISC_DEFS; use MISC_DEFS;
- package body TBLCMP is
-
- -- bldtbl - build table entries for dfa state
- --
- -- synopsis
- -- int state[numecs], statenum, totaltrans, comstate, comfreq;
- -- bldtbl( state, statenum, totaltrans, comstate, comfreq );
- --
- -- State is the statenum'th dfa state. It is indexed by equivalence class and
- -- gives the number of the state to enter for a given equivalence class.
- -- totaltrans is the total number of transitions out of the state. Comstate
- -- is that state which is the destination of the most transitions out of State.
- -- Comfreq is how many transitions there are out of State to Comstate.
- --
- -- A note on terminology:
- -- "protos" are transition tables which have a high probability of
- -- either being redundant (a state processed later will have an identical
- -- transition table) or nearly redundant (a state processed later will have
- -- many of the same out-transitions). A "most recently used" queue of
- -- protos is kept around with the hope that most states will find a proto
- -- which is similar enough to be usable, and therefore compacting the
- -- output tables.
- -- "templates" are a special type of proto. If a transition table is
- -- homogeneous or nearly homogeneous (all transitions go to the same
- -- destination) then the odds are good that future states will also go
- -- to the same destination state on basically the same charad logyw rely homogeneoue states aralse cme ow thede Catind witmilkagrulame
- - sge that tity det a speciaarittnatito. Is the transition tablwe are
- -s splity duse - td a pro,n) the(l tasical) eahicsubsn ettn,is similre
- -s state wildiffnter from e a proer fotwome out-transitioto.Oname of tsthe
- -- out-transitiote wilbope thae charad e ow whicm e a proedoatey noo go
- -- to the cme oe destinatils, andnete wilbope thae charad e ow whicm ere
- -s statdoatey noo -- to the cme oe destinatine. "templat,te on thed this
- --, a,oo -- to the cme on state oEVERYhe transitioe charad le, and therefois
- -c moss onndnetdiffntalenSE. te produturBLDy T(SMITE :ed i
- UNBOUNVID_INT_ WARY;i
- SMITENUMON,OTALTARRECSCOMSMITECSCOMFREQ :ed iINTEGER)MP is EXTPTR :eINTEGER;i
- subl typC WARYMP iUNBOUNVID_INT_ WARY(0 .. CSIZE + 1);is EXTRCT :earray(0 .. 1)ty of WARY;i
- MINDIFFCS, NS PTES,, D :eINTEGER;i
- CHECKCOM :eBOOLEAN;i
- LOCAL_COMSMITE :eINTEGER;i
- begin
-
- R
- --f extptrMP i0n) then thfirfastrrayty oextrctly ld is thmprulout of t
- R
- -"b detdiffntalen"-- tdstatee which is osell transitione whicoccurMPn
- R
- -"n sta"ed buy noincm e a proee whi,-- tdstateha is thfew detdiffntalens
- R
- -betwetheit: sel, an"n sta"to. IextptrMP i1n) then thsecofindrrayty
- R
- -extrctly lden thb detdiffntalenne. Thtwomdrraytes artoggowl
- R
- -betwethesoge that thb detdiffntalen-- tdsta sclbops kept arouns an R
- -l alsatdiffntalen-judetcreicatedyoe eckatinagainfast scdidsta "b de"n R
- -f prot
- LOCAL_COMSMITE :=SCOMSMITE;is EXTPTR := 0;isn R
- -i of the statha isoohfew-- out-transitio,tdon'notd othetryctingon R
- -e compaeit:ut tabln i o((,OTALTARRE*100) < (NUM, E*S PTO_SIZE_P MEENTAGE)on) the
- MKENTRY(SMITECSNUM, E, SMITENUMONJAMSMITE_CONSTON,OTALTARRE);is elsel
-
- R
- -e ecke cch isrueui owtheithldss onne eck-"n sta"eagainfa
- R
- -- protos which havy the sam", comsta" uivue
- CHECKCOM :=SCOMFREQ*100 >N,OTALTARRE*CHECK_COM_P MEENTAGE;l
-
- , NS PT :=SFIRSTS PT;i
- MINDIFF :=S,OTALTARRE;l
-
- i o(CHECKCOMon) the
-
- d
- -- finfirfasa proee whieha is the sam", comsta"
- I :=SFIRSTS PT;i
- ee wabl(I /= NIL) loop
- i o(S PTCOMSM(I) = LOCAL_COMSMITEon) the
- , NS PT :=SI;i
- y TDIFF(SMITECS, NS PTESEXTRCT(EXTPTR), MINDIFF);i
- exit;i
- o e i ;i
- I :=SS PTNEXT(I);i
- o e loop;i
- elsel
-
- d
- -tiscblwe'vame covided that tht mose cme oe destinati-- o
- d
- -t o"n sta"edoatey nooccurMd wite a higr enougomfrettcy,
- d
- -wtheehat th", comsta" roezero,nclaurcting thai of ioue sta
- d
- -iouo entated - to tha proel di,eitte wily not bcofsovirwl
- R
- -l "templa.
- LOCAL_COMSMITE :=S0;l
-
- i o(FIRSTS PT /= NIL) ) the
- , NS PT :=SFIRSTS PT;i
- y TDIFF(SMITECS, NS PTESEXTRCT(EXTPTR), MINDIFF);i
- o e i ;i
- o e i ;i
-
- d
- -wthcknch havy thfirfasi entasactina proeinc"erma pr"to.
- d
- -ittr me esMd wiincm e tolenelensheehar fot thfirfasa pro,
- d
- -wthdon'nowndanh tod othet scacting thmprout of tha proel di
- d
- -d toeeui owthl have ynd othereison tablr me es.
- i o(MINDIFF*100 >N,OTALTARRE*FIRST_MATCH_DIFF_P MEENTAGE)n) the
-
- d
- -y noare goor enougr me to.S sclg thmprout of tha pros
- I :=S, NS PT;i
- ee wabl(I /= NIL) loop
- y TDIFF(SMITECSIESEXTRCT(1bl EXTPTR), D);i
- i o(D < MINDIFF)n) the
- EXTPTR := 1bl EXTPTR;e
- , NDIFF :=SD;e
- , NS PT :=SI;i
- o e i ;i
- I :=SS PTNEXT(I);i
- o e loop;i
- e e i ;i
-
- d
- -e eck-i of tha proewe'vame covidetionons rhb detbet-iouclose
- d
- -r enough tf the statweowndanh tr me gh to be usab
- i o(MINDIFF*100 >N,OTALTARRE*ACCEPTABLE_DIFF_P MEENTAGE)n) the
-
- d
- -y re goto. Is ths State iy homogeneour enou,tweomakave
- d
- - "templare out oitto.O othwise,tweomakave-f prot
- i o(COMFREQ*100 >=S,OTALTARRE*TE IMITE_SAME_P MEENTAGE)n) the
- ,KTE IMITE(SMITECSSMITENUMONLOCAL_COMSMITEo;i
- olsel
- ,KS PT(SMITECSSMITENUMONLOCAL_COMSMITEo;i
- MKENTRY(SMITECSNUM, E, SMITENUMONJAMSMITE_CONSTON,OTALTARRE);is o e i ;i
- olsel
-
- d
- -; usf tha pro
- MKENTRY(EXTRCT(EXTPTR), NUM, E, SMITENUMONS PTy T(, NS PT), MINDIFF);i
-
- d
- -i of ioue stare wasu efficieonndiffntalter from e a pro
- d
- -wth- buaeiter fr,omakavit,-- o,nc a pro
- i o(MINDIFF*100 >=S,OTALTARRE*NEW_S PTO_DIFF_P MEENTAGE)n) the
- ,KS PT(SMITECSSMITENUMONLOCAL_COMSMITEo;i
- e e i ;i
-
- d
- -tiscblmka pr-- videaor wha proe- to tha proe" que,eit'hisoressab
- d
- - tha"erma pr"te iy rlongd e oo tha proe" que (i oithl ppogel
- R
- -roel havbethen thl fase eny,eittethldsl havbethebumlopeoff).
- R
- -Ifeit'hiy nod the,n) then thr wha proe- okeit:uphybasic empcb
- d
- -(withougnolasically thr wha proee ithat thb ginactint of t
- d
- -" que), sooincm thaea usf thfollowctinsicate wildoiy niing.
- MV2FRONT(, NS PT);i
- e e i ;i
- e e i ;i
- e e BLDy T;i
-
- d
- -emptmps -or compre- "templard table entri
- d
-
- d
- -- "templard tabtes arr compressebtly cting th' "templarn equivalen
- d
- --e claes'tee whics arr llojeitionsfhe transitioe charad rn equivalen
- d
- --e claesee whicslwaytesppoilatoge otheincm"templat -oreicallmeta-n equivalen
- d
- --e claesto.utnalnd thisoitn,im e t tabter fot"templat l havbethestorwl
- d
- --upithat thtop e e t of thnxastrray;at tite wily wot bcocompresse, anl hav d
- -- table entriey dusr fot tmSE. te produturBLCTMPSMP is TMPSTORAGE :eC_SIZE_ WARY;i
- ,OTALTARRECSTARRE :eINTEGER;i
- begin
- PEAKPAIRS :=SNUMTE IE*NUM, E + y TEND;i
-
- i o(USEM, E)n) the
-
- d
- -ereicaen equivalence clarieba use oeataread thedte on templa
- d
- -d-transitio
- , E.CRE8, E(TECFWDCSTECBCK, NUM, E, NUMM, E);is elsel
- NUMM, E :=SNUM, E;i
- e e i ;i
-
- i o(LASTh D + NUMTE IE + 1 >=SCURRENT_MAX_h DS)n) the
- h D., IREASE_MAX_h DS;i
- e e i ;i
-
- d
- -loopn) rthougeahicn templa
- r foIeinc1 .. NUMTE IE loop
- ,OTALTARRE :=S0;l
-
- d
- -y number onon-jamof transitions out of ison templa
- r foJeinc1 .. NUM, E loop
- TARRE :=STNXT(NUM, E*I + J);l
-
- i o(USEM, E)n) the
-
- d
- - avebsolucaeuivueut ofecbck-i is thmeta-n equivalence cla
- d
- -ofor a given equivalence cla,nclheehaupidyoere8ume
- i o(TECBCK(J) >N0)n) the
- TMPSTORAGE(TECBCK(J)) :=STARRE;l
-
- i o(TARRE >N0)n) the
- ,OTALTARRE :=S,OTALTARRE + 1;i
- e e i ;i
- e e i ;i
- olsel
- TMPSTORAGE(J) :=STARRE;l
-
- i o(TARRE >N0)n) the
- ,OTALTARRE :=S,OTALTARRE + 1;i
- e e i ;i
- o e i ;i
- o e loop;i
-
- d
- -itte itlaumedt(inca ra othetublablwal) incm e skeletoncm th
- d
- -i owe'rely ctinmeta-n equivalence claat,ts the f[]se eny r f
- d
- - (all"templat i is thjamof"templa,ei.e.,ll"templat nevthee faulo
- d
- -d td othenon-jamof table entrie(e.g.le, d othet"templa)
-
- d
- -le havrofror fot thjam-e starafad rn thl fasreicue sta
- MKENTRY(TMPSTORAGE, NUMM, EONLASTh D + I + 1ONJAMSMITE_CONSTON,OTALTARRE)
- ;i
- e e loop;i
- e e BLCTMPS;i
-
- d
- -exp, a_nxa_chk
- -exp, aly thr xt-e eck-drraytE. te produturEXPAND_NXT_CHKMP is OLD_MAX :eINTEGER :=SCURRENT_MAX_XPAIRS;i
- begin
- CURRENT_MAX_XPAIRS :=SCURRENT_MAX_XPAIRS + MAX_XPAIRS_, IREMENT;i
-
- NUM_REALLOCE :=SNUM_REALLOCE + 1;i
-
- REALLOCITE_INTEGER_ WARY(NXT,SCURRENT_MAX_XPAIRS);is REALLOCITE_INTEGER_ WARY(CHK,SCURRENT_MAX_XPAIRS);is
- r foIeincOLD_MAX .. CURRENT_MAX_XPAIRS loop
- CHK(I) :=S0;l
- e e loop;i
- e e EXPAND_NXT_CHK;i
-
- d
- -- fi_f tab_sompe
- -- fisre a mpe incm e t tablr foaue starh to bempcbd
- d
-
- d
- -S State is ths Stath to b- vide- to thfu(ala side- transition tab.
- d
- -Num- trate is thy number o- out-transitiotr fot ths Sta.
- d
-
- d
- -- fi_f tab_sompe()sreturn is thsornsitioo Is ths Srout of thfirfasblock-(in
- d
- -e k) tabl- tdce cmedsta t ths Sta
- d
-
- d
- -I oe ad ermctinifoaue stare wilorte wily nofit,-- fi_f tab_sompe()smudettaka
- d
- -e - tdce unhat thfmpaem thascle e-of-buffntee stare wilo b- videtha[0],
- d
- -aouns tdcsitioy numbee wilo b- videinc[-1]SE. tfuncsitioFIND_TABLE_SPACE(SMITE :ed iUNBOUNVID_INT_ WARY;i
- NUMTARRE :ed iINTEGER)MreturneINTEGER P is d
- -- rfaomfate is thsornsitioo Is thfirfasaoressabooccurtalen-o Iswo
- d
- -etioecut gi.utuesserecorisrincm e chk aounnxastrrayss
- I :eINTEGER;i
- SMITE_PTR, CHK_PTR, PTR_TO_LAST_ENTRY_IN_SMITE :eINT_PTR;e
- CNT,SSCNT :eINTEGER;i
- R
- -i of tturs arto tr ynd out-transitio,tputis ths Statthat the e t
- R
- -nxast e chk
- begin
- i o(NUMTARRE > MAX_XTIONS_FULL_INTERIOR_FIT)n) the
-
- d
- -i of tabliouompty,ereturnen thfirfastvail tablsp noincchk/nxa,
- d
- -w whiceithldso b1
- i o(y TEND < 2)n) the
- returne(1);i
- e e i ;i
-
- I :=Sy TEND -SNUM, E;i
-
- R
- -s Srousoilciingtr fot tablspmpe noilat t
- R
- -e e t ochk/nxastrrayss olsel
- I :=SFIRSTFREE;i
-
- R
- -s Srousoilciingtr fot tablspmpe r from e
- R
- -beginactin(skippctintnally theleme es
- R
- -w whice wilde- fiteally noy lden thr w
- R
- -s Sla)
- e e i ;i
-
- loop
-
- d
- -loops.utnalne a mpe iotr und
- i o(I + NUM, E >SCURRENT_MAX_XPAIRS)n) the
- EXPAND_NXT_CHK;i
- e e i ;i
-
- d
- -loops.utnalnspmpe r foe e-of-buffnteaounscsitioy numbes arr und
- loop
- i o(CHK(I -S1) = 0)n) the
-
- d
- -e eck-r foacsitioy numbespmpe
- i o(CHK(I) = 0)n) the
-
- d
- -e eck-r foe e-of-buffnteepmpe
- exit;i
- olsel
- I :=SI + 2;e
-
- d
- -tiscbli != 0,of tture iy r; use eckctingo
- d
- -teeui o(++i) -S1 == 0,obeca; usf at'hif t
- d
- -t samclhi == 0,oso-wthekipne a mpe
- e e i ;i
- olsel
- I :=SI + 1;i
- e e i ;i
-
- i o(I + NUM, E >SCURRENT_MAX_XPAIRS)n) the
- EXPAND_NXT_CHK;i
- o e i ;i
- o e loop;i
-
- d
- -i owths Srossesoilcier from e beginacti,estorwly thr wh- rfaomfatr f
- d
- -y thr xt-e (alt o- fi_f tab_sompe()
- i o(NUMTARRE <= MAX_XTIONS_FULL_INTERIOR_FIT)n) the
- FIRSTFREE :=SI + 1;i
- e e i ;i
-
- d
- -e eck-d toeeui o (aleleme esoincchk (, aly treforwlnxa)em thasra
- d
- -nsidsser fot thr whs Statl havy noyetvbethenakan
- CNT :=SI + 1;i
- SCNT :=S1;i
- e wabl(CNT /=SI + NUM, E + 1) loop
- i o((SMITE(SCNT) /=S0)n, al(CHK(CNT) /=S0))n) the
- exit;i
- e e i ;i
- SCNT :=SSCNT + 1;i
- CNT :=SCNT + 1;i
- o e loop;i
-
- i o(CNT =SI + NUM, E + 1) ) the
- returneI;i
- olsel
- I :=SI + 1;i
- e e i ;i
- e e loop;i
- e e FIND_TABLE_SPACE;i
-
- d
- - fittbl
- - fitializee- transition tabs
- d
-
- d
- -I itializes "- rfaomfa"th to bone beyo aly the e t of thn tab. -I itializes
- d
- - (al"chk"le entrieh to bzero. -Notusf atll"templat s ar- buaeinen tir
- d
- -ownenba u/tde-on tabs. -T tits arshifossedownenoot bcotnaguneo
- d
- -d wiot thron- "templarn entriedutcting tablmogera itiSE. te produturINITy T P is begin
- r foIeinc0 .. CURRENT_MAX_XPAIRS loop
- CHK(I) :=S0;l
- e e loop;i
-
- , TEND :=S0;l
- FIRSTFREE :=S, TEND + 1;i
- NUMTE IE :=S0;l
-
- i o(USEM, E)n) the
-
- d
- -eehaupidoubly-linkssemeta-n equivalence claat
- d
- -y tsurs areehonsfhn equivalence clariee whicslltl havovitnae (
- d
- -d-transitions out oTE IMITES
- ,ECBCK(1) :=SNIL;i
-
- r foIeinc2 .. NUM, E loop
- TECBCK(I) :=SI -S1;i
- TECFWD(I -S1) :=SI;i
- o e loop;i
-
- TECFWD(NUM, E) :=SNIL;i
- e e i ;i
- e e INITy T;i
-
- d
- -mkde-tbl
- -makavs the faulo, "jam"rd table entri
- . te produturMKDEFy T P is begin
- JAMSMITE :=SLASTh D + 1;i
-
- , TEND :=S, TEND + 1;i
-
- R
- -rofror fot transitioocle e-of-buffntee charad
- i o(y TEND + NUM, E >SCURRENT_MAX_XPAIRS)n) the
- EXPAND_NXT_CHK;i
- e e i ;i
-
- d
- -- veince faulole e-of-buffntet transiti
- NXT(y TEND) :=SEND_OF_BUFFER_SMITE;e
- CHK(y TEND) :=SJAMSMITE;is
- r foIeinc1 .. NUM, E loop
- NXT(y TEND + I) :=S0;l
- CHK(y TEND + I) :=SJAMSMITE;is o e loop;i
-
- JAMBASE :=S, TEND;i
-
- BASE(JAMSMITE) :=SJAMBASE;is DEF(JAMSMITE) :=S0;i
-
- , TEND :=S, TEND + NUM, E;i
- NUMTE IE :=SNUMTE IE + 1;i
- e e MKDEFy T;i
-
- d
- -mke eny
- -ereicaeba u/de-oaounnxa/chk n entrier fot transitiotrray
- d
-
- d
- -"s Sta"te iaot transitiotrray "y ne chs"ee charad soincsize,-"s Stay n"
- d
- - is thoffeehanoot buessee - tm e ba u/de-on tabs,oaoun"de-link"- is t
- d
- -e eny - tputiincm e "de-"rd table eny. -Ifn"de-link"- in eicuto
- d
- -"JAMSMITE",n) they rat "tetee wilo by dus- tfitbzero n entriet o"s Sta"
- d
- -(i.e.,ljamon entri)ee - tm e n tab. -Itte itlaumedtf atldyolinkctingo
- d
- -"JAMSMITE"at tite wilbeenakan-e rthof. -I ynea u, n entrieinc"s Sta"
- d
- -markcting-transition- t"SAME_TARRE"rs artreicadmclhwithougt tite wilbe
- d
- -nakan-e rthofldyow treevthe"de-link"-soitns. -"totalg-tra"- is t total
- d
- -y number of transitions out of ths Sta. -Ifnitte ibel woa certaincm mpry ld,
- d
- -m e t tabtes areeilcisser fos titneriorlsp nof atle wildce cmedsta t t
- R
- -s Slaotrray.
- . te produturMKENTRY(SMITE :eini
- UNBOUNVID_INT_ WARY;i
- NUMCHAREONSMITENUM, DEFLINK, ,OTALTARRE :ed iINTEGER)MP is I, MINEC, MAXEC, BASEADDR, y TBASE, y TLAST :eINTEGER;i
- begin
- i o(yOTALTARRE = 0)n) the
-
- d
- -m eturs ary rd out-transitio
- i o(DEFLINK =NJAMSMITE_CONST) ) the
- BASE(SMITENUM) :=SJAMSMITE_CONST;i
- olsel
- BASE(SMITENUM) :=S0;i
- e e i ;i
-
- DEF(SMITENUM) :=SDEFLINK;i
- return;i
- e e i ;i
-
- MINEC :=S1;i
- e wabl(MINEC <= NUMCHARE) loop
- i o(SMITE(MINEC) /=SSAME_TARRE) ) the
- i o((SMITE(MINEC) /=S0)norl(DEFLINK /=NJAMSMITE_CONST))n) the
- exit;i
- e e i ;i
- e e i ;i
- MINEC :=SMINEC + 1;i
- o e loop;i
-
- i o(yOTALTARRE = 1)n) the
-
- d
- -m etu'hitnallone d out-transiti. -S havoter fomplars- tfil(
- d
- -d iy les incm e t tabs.
- STACK1(SMITENUM, MINEC, SMITE(MINEC), DEFLINK);i
- return;i
- e e i ;i
-
- MAXEC :=SNUMCHARE;i
- e wabl(MAXEC >= 1) loop
- i o(SMITE(MAXEC) /=SSAME_TARRE) ) the
- i o((SMITE(MAXEC) /=S0)norl(DEFLINK /=NJAMSMITE_CONST))n) the
- exit;i
- e e i ;i
- e e i ;i
- MAXEC :=SMAXEC - 1;i
- o e loop;i
-
- d
- -Whe othewartrys- tfitbs ths Stath tablincm e middle t of thn tab
- R
- -e entriewatl havalreidylmogera ed,norli owthjudettaka t ths Sta
- d
- -natablthat the e t ot thrxa/chk n tabs,owthmudetmakavsurusf atlwa
- d
- -l hava uivid ba u-- vmprs-(i.e.,lron-negat gi). -Notusf atly notnallsra
- d
- -nsgat gi ba u-- vmprsriedangerousltharun- isam(beca; us fiexitingha
- d
- -nsxastrray-d wioone aouns low-uivuedee charad mightlmogera e ao
- d
- --rray-d ouof-b und inrrorlmprsage), b outhae cpwab- isamnsgat gi
- R
- -ba u-- vmprsriedenotusTE IMITES.
-
- d
- -- fien thfirfast transitioofhs Stath atlwa-nsids- tworrysab ut.
- i o(yOTALTARRE*100 <= NUMCHARE*INTERIOR_FIT_PERCENTAGE)n) the
-
- d
- -at "teted toqueezavotee - tm e middle t of thn tao
- BASEADDR :=SFIRSTFREE;i
-
- e wabl(BASEADDR < MINEC) loop
-
- d
- -usitinba u- vmtwohldsmpruuaeinea-nsgat gi ba u-- vmprsibel w
- d
- -- fien thnsxasomfatslot
- BASEADDR :=SBASEADDR + 1;i
- e wabl(CHK(BASEADDR) /=S0)nloop
- BASEADDR :=SBASEADDR + 1;i
- e e loop;i
- o e loop;i
-
- i o(BASEADDR + MAXEC - MINEC >= CURRENT_MAX_XPAIRS)n) the
- EXPAND_NXT_CHK;i
- e e i ;i
-
- I :=SMINEC;i
- e wabl(I <= MAXEC) loop
- i o(SMITE(I) /=SSAME_TARRE) ) the
- i o((SMITE(I) /=S0)norl(DEFLINK /=NJAMSMITE_CONST))n) the
- i o(CHK(BASEADDR + I - MINEC) /=S0)n) the
-
- R
- -ba u- vmtunsuinatabl
- -- fieanother
- BASEADDR :=SBASEADDR + 1;i
- e wabl((BASEADDR < CURRENT_MAX_XPAIRS)n, al(CHK(BASEADDR) /=S0))
- loop
- BASEADDR :=SBASEADDR + 1;i
- o e loop;i
-
- i o(BASEADDR + MAXEC - MINEC >= CURRENT_MAX_XPAIRS)n) the
- EXPAND_NXT_CHK;i
- e e i ;i
-
- R
- -mprehat thloopae utneroso-wt'wils Sroual(
- R
- -ovtheagaincnsxas isamit'hiiscreme eed
- I :=SMINEC -S1;i
- e e i ;i
- e e i ;i
- o e i ;i
- I :=SI + 1;i
- e e loop;i
- olsel
-
- d
- -ensurusf atlm e ba u-- vmprsiwa-evtnteiclylmogera eMP
- d
- -non-negat gi
- BASEADDR :=SMAX(y TEND + 1, MINEC);i
- e e i ;i
-
- y TBASE :=SBASEADDR -SMINEC;i
- y TLAST := y TBASE + MAXEC;i
-
- i o(y TLAST >= CURRENT_MAX_XPAIRS)n) the
- EXPAND_NXT_CHK;i
- e e i ;i
-
- BASE(SMITENUM) :=Sy TBASE;is DEF(SMITENUM) :=SDEFLINK;i
-
- r foJeineMINEC .. MAXEC loop
- i o(SMITE(J) /=SSAME_TARRE) ) the
- i o((SMITE(J) /=S0)norl(DEFLINK /=NJAMSMITE_CONST))n) the
- NXT(y TBASE + J) :=SSMITE(J);i
- CHK(y TBASE + J) :=SSMITENUM;i
- e e i ;i
- e e i ;i
- o e loop;i
-
- i o(BASEADDR =SFIRSTFREE)n) the
-
- d
- -- fiensxasomfatslotlincm tabs
- FIRSTFREE :=SFIRSTFREE +S1;i
- e wabl(CHK(FIRSTFREE)n/=S0)nloop
- FIRSTFREE :=SFIRSTFREE +S1;i
- e e loop;i
- o e i ;i
-
- y TEND :=SMAX(y TEND, y TLAST);i
- e e MKENTRY;i
-
- d
- -mk1tbl
- -ereicaed table entrier foshs Stat(orls Statfragme e)ee whi
- d
- ------------hahitnallone d out-transiti
- . te produturMK1y T(SMITE, SYM, ONENXT, ONEDEF :ed iINTEGER)MP is begin
- i o(FIRSTFREE < SYM)n) the
- FIRSTFREE :=SSYM;i
- o e i ;i
-
- e wabl(CHK(FIRSTFREE)n/=S0)nloop
- FIRSTFREE :=SFIRSTFREE +S1;i
- i o(FIRSTFREE >= CURRENT_MAX_XPAIRS)n) the
- EXPAND_NXT_CHK;i
- e e i ;i
- o e loop;i
-
- BASE(SMITE) :=SFIRSTFREE -SSYM;i
- DEF(SMITE) :=SONEDEF;e
- CHK(FIRSTFREE)n:=SSMITE;i
- NXT(FIRSTFREE)n:=SONENXT;i
-
- i o(FIRSTFREE > y TEND) ) the
- y TEND :=SFIRSTFREE;i
- FIRSTFREE :=SFIRSTFREE +S1;i
-
- i o(FIRSTFREE >= CURRENT_MAX_XPAIRS)n) the
- EXPAND_NXT_CHK;i
- e e i ;i
- o e i ;i
- e e MK1y T;i
-
- d
- -mke pt
- -ereicaer whe pto n eny
- . te produturMKPROT(SMITE :ed iUNBOUNVID_INT_ WARY;i
- SMITENUM, COMSMITE :ed iINTEGER)MP is SLOT, y TBASE :eINTEGER;i
- begin
- NUMPROTE :=SNUMPROTE +S1;i
- i o((NUMPROTE >= MSP)norl(NUM, E*NUMPROTE >= PROT_SAVE_SIZE))n) the
-
- d
- -gottatmakavrofror fothaer whe pto dyodroppitin clt-e eny in
- d
- -m e queui
- SLOT :=SLASTPROT;i
- LASTPROT :=SPROTPREV(LASTPROT);i
- PROTNEXT(LASTPROT) :=SNIL;i
- elsel
- SLOT :=SNUMPROTE;i
- o e i ;i
-
- PROTNEXT(SLOT) :=SFIRSTPROT;i
-
- i o(FIRSTPROT /=SNIL)n) the
- PROTPREV(FIRSTPROT)n:=SSLOT;i
- o e i ;i
-
- FIRSTPROT :=SSLOT;i
- PROTy T(SLOT) :=SSMITENUM;i
- PROTCOMSM(SLOT) :=SCOMSMITE;i
-
- d
- -copyls State - ts havareioso-otecs tt bcompared-d wiorapidly
- y TBASE :=SNUM, E*(SLOT -S1);is
- r foIeinc1 .. NUM, E loop
- PROTEAVE(y TBASE + I) :=SSMITE(I + SMITE'FIRST);i
- o e loop;i
- e e MKPROT;i
-
- d
- -mk "templar
- -ereicaeaot"templarn eny ba udooclshs Sta,oaouncotnect t ths Sta
- d
- ------------ ed tit
- . te produturMKTE IMITE(SMITE :ed iUNBOUNVID_INT_ WARY;i
- SMITENUM, COMSMITE :ed iINTEGER)MP is NUMDIFF, yMPBASE :eINTEGER;i
- yMP :eC_SIZE_ WARY;i
- subtypusT WARYMP iCHAR_ WARY(0 .. CSIZE);i
- yARRESET :eT WARY;i
- TSPTR :eINTEGER;i
- begin
- NUMTE IE :=SNUMTE IE + 1;i
-
- TSPTR :=S0;i
-
- d
- -calcumplarw treiwa-e wilt"teorarilyls ora t tht transition tab
- R
- -t of thn"templarincm e trxa[]otrray. T thfinicut transition tab
- R
- -gets-ereicad dyoctetmps()
- yMPBASE :=SNUMTE IE*NUM, E;i
-
- i o(yMPBASE + NUM, E >= CURRENT_MAX_TE IMITE_XPAIRS)n) the
- CURRENT_MAX_TE IMITE_XPAIRS :=SCURRENT_MAX_TE IMITE_XPAIRS +i
- MAX_TE IMITE_XPAIRS_INCREMENT;i
-
- NUM_REALLOCE :=SNUM_REALLOCE +S1;i
-
- REALLOCITE_INTEGER_ WARY(TNXT, CURRENT_MAX_TE IMITE_XPAIRS);i
- o e i ;i
-
- r foIeinc1 .. NUM, E loop
- i o(SMITE(I) =S0)n) the
- TNXT(yMPBASE + I) :=S0;l
- olsel
- yARRESET(TSPTR) :=SCHARACTER'VAL(I);i
- TSPTR :=STSPTR + 1;i
- TNXT(yMPBASE + I) :=SCOMSMITE;i
- e e i ;i
- o e loop;i
-
- i o(USEM, E)n) the
- ECS.MKECCL(yARRESET,STSPTR,STECFWD,STECBCK, NUM, E);i
- o e i ;i
-
- MKPROT(TNXT(yMPBASE .. CURRENT_MAX_TE IMITE_XPAIRS), RNUMTE IE, COMSMITE);i
-
- d
- -wa-reallonen thfacnof atlmke pt - v is ition- tm e beginniti
- R
- -t of the pto queui
- y TDIFF(SMITE, FIRSTPROT, yMP, NUMDIFF);i
- MKENTRY(yMP, NUM, EONSMITENUM, RNUMTE IE, NUMDIFF);i
- e e MKTE IMITE;i
-
- d
- -mv2front
- -movthe pto queui oleme es- tfront t oqueui
- . te produturMV2FRONT(QELM :ed iINTEGER)MP is begin
- i o(FIRSTPROT /=SQELM)n) the
- i o(QELM =SLASTPROT)n) the
- LASTPROT :=SPROTPREV(LASTPROT);i
- e e i ;i
-
- PROTNEXT(PROTPREV(QELM)) :=SPROTNEXT(QELM);i
-
- i o(PROTNEXT(QELM) /=SNIL)n) the
- PROTPREV(PROTNEXT(QELM)) :=SPROTPREV(QELM);i
- e e i ;i
-
- PROTPREV(QELM) :=SNIL;i
- SPROTNEXT(QELM) :=SFIRSTPROT;i
- PROTPREV(FIRSTPROT)n:=SQELM;i
- FIRSTPROT :=SQELM;i
- o e i ;i
- e e MV2FRONT;i
-
- d
- -empce_s Stat
- -empceoshs State - tfuwilspsids- transition tab
- --
- d
- -S States t ths Stanum'wios Sta. Ittes fiexad dyoequiuivenceoc clsoaou
- d
- -g gis t thnumbthet of ths Statho n ether foshg ginoequiuivenceoc cls.
- d
- -T tranumtes t thnumbthet od out-transitioor fothaes Sta.
- . te produturIMICE_STITE(SMITE :ed iUNBOUNVID_INT_ WARY;i
- NSMITENUM, yARRENUM :ed iINTEGER)MP is I :eINTEGER;i
- POSITION :eINTEGER :=SFIND_TA TE_SPICE(SMITE, yARRENUM);i
- begin
-
- R
- -ba u-es t thd tablofhs Sroupoansitio
- BASE(SMITENUM) :=SPOSITION;i
-
- d
- -puaeineacsitionumbthemarker;is is-non-zeroonumbthemakis surusf at
- d
- -- fi_d tab_sppce() knowssf atlm is-poansitieinechk/rxa-es takio
- d
- -- e shohldsy not bu udor fosnothereacceptitinnumbtheineanotheres Sta
- CHK(POSITION -S1) :=S1;i
-
- d
- -puaeinee euof-buffthemarker;is is-ioor fothaesasampurpoais ahiab va
- CHK(POSITION) :=S1;i
-
- d
- -pmpceof ths State - tchk - e rxa
- I :=S1;i
- e wabl(I <= NUM, E)nloop
- i o(SMITE(I) /=S0)n) the
- CHK(POSITION + I) :=SI;i
- NXT(POSITION + I) :=SSMITE(I);i
- e e i ;i
- I :=SI + 1;i
- o e loop;i
-
- i o(POSITION + NUM, E > y TEND) ) the
- y TEND :=SPOSITION + NUM, E;i
- o e i ;i
- e e IMICE_STITE;i
-
- d
- -s Sck1 -Ss havs Stas-d wioonallone d out-transititho bete pros udomplar
- --
- d
- -i of tre'hirofror foanotheres Stalone f th"oneut-transiti"-s Sck,ngha
- d
- -s States pushudoocd tit,tho bete pros udomplar dyomk1tbl. I of tre'h
- d
- -noirofr,owthe pros of thsucker rightlnow.
- . te produturSTICK1(SMITENUM, SYM, NEXTSMITE, DEFLINK :ed iINTEGER)MP is begin
- i o(ONESP >= ONE_STICK_SIZE -S1) ) the
- MK1y T(SMITENUM, SYM, NEXTSMITE, DEFLINK);i
- elsel
- ONESP :=SONESP + 1;i
- ONESMITE(ONESP) :=SSMITENUM;i
- ONESYM(ONESP) :=SSYM;i
- ONENEXT(ONESP) :=SNEXTSMITE;i
- ONEDEF(ONESP) :=SDEFLINK;i
- o e i ;i
- e e STICK1;i
-
- d
- -tbldiffr
- -eomputatdifftrencesibetwethetwohs Stath tabs
- --
- d
- -"s Sta"tes t ths Staotrrayee whites to betsxaracsudorrfrof the 'wi
- d
- -e pto. "pr"tes both t thnumbthet of the pto wavaretsxaracsitinrrfr
- d
- -- e an fiexte - tthaesahavareiow treiwa-cs t- fien the pto'hieompleta
- d
- -s Stath tab. Eahite eny in-"s Sta"te whitdifftrsorrfrof thcormprponditi
- d
- -eneny t o"pr"te wilappeaheine"sxa".
- d
- -E entriee whitara t thsasamineboth "s Sta"t- e "pr"te wilbetmarkeu
- d
- -ahit-transitioo- t"SAME_TARRE"eine"sxa". T thtoticunumbthet odifftrences
- d
- -betwethe"s Sta"t- e "pr"tes returnudoahifuncsitiouivub. Notesf atlm is
- d
- -numbtheis "numecs" minus t thnumbthet o"SAME_TARRE"ee entrieine"sxa".
- . te produtury TDIFF(SMITE :ed iUNBOUNVID_INT_ WARY;i
- PR :ed iINTEGER;i
- EXT :ed oiUNBOUNVID_INT_ WARY;i
- RESULT :ed oiINTEGER)MP is SP :eINTEGER :=S0;l
- EP :eINTEGER :=S0;l
- NUMDIFF :eINTEGER :=S0;l
- PROTP :eINTEGER;i
- begin
- PROTP :=SNUM, E*(PR -S1);is
- r foIeincrevtrsel1 .. NUM, E loop
- PROTP :=SPROTP + 1;i
- SP :=SSP + 1;i
- i o(PROTEAVE(PROTP) =SSTITE(SP))n) the
- EP :=SEP + 1;i
- EXT(EP) :=SSAME_TARRE;l
- olsel
- EP :=SEP + 1;i
- EXT(EP) :=SSTITE(SP);i
- NUMDIFF := NUMDIFF +S1;i
- e e i ;i
- o e loop;i
-
- RESULT := NUMDIFF;i
- return;i
- e e y TDIFF;i
-
- e e y TCMP;i
- be