symdef.pas 181 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
  4. Symbol table implementation for the definitions
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit symdef;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. { common }
  23. cutils,cclasses,
  24. { global }
  25. globtype,globals,tokens,
  26. { symtable }
  27. symconst,symbase,symtype,
  28. { ppu }
  29. symppu,ppu,
  30. { node }
  31. node,
  32. { aasm }
  33. aasmbase,aasmtai,cpubase,cpuinfo
  34. {$ifdef Delphi}
  35. ,dmisc
  36. {$endif}
  37. ;
  38. type
  39. {************************************************
  40. TDef
  41. ************************************************}
  42. tstoreddef = class(tdef)
  43. { persistent (available across units) rtti and init tables }
  44. rttitablesym,
  45. inittablesym : tsym; {trttisym}
  46. { local (per module) rtti and init tables }
  47. localrttilab : array[trttitype] of tasmlabel;
  48. { linked list of global definitions }
  49. nextglobal,
  50. previousglobal : tstoreddef;
  51. {$ifdef EXTDEBUG}
  52. fileinfo : tfileposinfo;
  53. {$endif}
  54. {$ifdef GDB}
  55. globalnb : word;
  56. is_def_stab_written : tdefstabstatus;
  57. {$endif GDB}
  58. constructor create;
  59. constructor ppuloaddef(ppufile:tcompilerppufile);
  60. destructor destroy;override;
  61. function getcopy : tstoreddef;virtual;
  62. procedure ppuwritedef(ppufile:tcompilerppufile);
  63. procedure ppuwrite(ppufile:tcompilerppufile);virtual;abstract;
  64. procedure deref;override;
  65. procedure derefimpl;override;
  66. function size:longint;override;
  67. function alignment:longint;override;
  68. function is_publishable : boolean;override;
  69. function needs_inittable : boolean;override;
  70. { debug }
  71. {$ifdef GDB}
  72. function stabstring : pchar;virtual;
  73. procedure concatstabto(asmlist : taasmoutput);virtual;
  74. function NumberString:string;
  75. procedure set_globalnb;virtual;
  76. function allstabstring : pchar;virtual;
  77. {$endif GDB}
  78. { rtti generation }
  79. procedure write_rtti_name;
  80. procedure write_rtti_data(rt:trttitype);virtual;
  81. procedure write_child_rtti_data(rt:trttitype);virtual;
  82. function get_rtti_label(rt:trttitype):tasmsymbol;
  83. { regvars }
  84. function is_intregable : boolean;
  85. function is_fpuregable : boolean;
  86. private
  87. savesize : longint;
  88. end;
  89. tparaitem = class(TLinkedListItem)
  90. paratype : ttype;
  91. parasym : tsym;
  92. defaultvalue : tsym; { tconstsym }
  93. paratyp : tvarspez;
  94. paraloc : tparalocation;
  95. {$ifdef EXTDEBUG}
  96. eqval : tequaltype;
  97. {$endif EXTDEBUG}
  98. end;
  99. { this is only here to override the count method,
  100. which can't be used }
  101. tparalinkedlist = class(tlinkedlist)
  102. function count:longint;
  103. end;
  104. tfiletyp = (ft_text,ft_typed,ft_untyped);
  105. tfiledef = class(tstoreddef)
  106. filetyp : tfiletyp;
  107. typedfiletype : ttype;
  108. constructor createtext;
  109. constructor createuntyped;
  110. constructor createtyped(const tt : ttype);
  111. constructor ppuload(ppufile:tcompilerppufile);
  112. procedure ppuwrite(ppufile:tcompilerppufile);override;
  113. procedure deref;override;
  114. function gettypename:string;override;
  115. function getmangledparaname:string;override;
  116. procedure setsize;
  117. { debug }
  118. {$ifdef GDB}
  119. function stabstring : pchar;override;
  120. procedure concatstabto(asmlist : taasmoutput);override;
  121. {$endif GDB}
  122. end;
  123. tvariantdef = class(tstoreddef)
  124. constructor create;
  125. constructor ppuload(ppufile:tcompilerppufile);
  126. function gettypename:string;override;
  127. procedure ppuwrite(ppufile:tcompilerppufile);override;
  128. procedure setsize;
  129. function needs_inittable : boolean;override;
  130. procedure write_rtti_data(rt:trttitype);override;
  131. {$ifdef GDB}
  132. procedure concatstabto(asmlist : taasmoutput);override;
  133. {$endif GDB}
  134. end;
  135. tformaldef = class(tstoreddef)
  136. constructor create;
  137. constructor ppuload(ppufile:tcompilerppufile);
  138. procedure ppuwrite(ppufile:tcompilerppufile);override;
  139. function gettypename:string;override;
  140. {$ifdef GDB}
  141. function stabstring : pchar;override;
  142. procedure concatstabto(asmlist : taasmoutput);override;
  143. {$endif GDB}
  144. end;
  145. tforwarddef = class(tstoreddef)
  146. tosymname : pstring;
  147. forwardpos : tfileposinfo;
  148. constructor create(const s:string;const pos : tfileposinfo);
  149. destructor destroy;override;
  150. function gettypename:string;override;
  151. end;
  152. terrordef = class(tstoreddef)
  153. constructor create;
  154. function gettypename:string;override;
  155. function getmangledparaname : string;override;
  156. { debug }
  157. {$ifdef GDB}
  158. function stabstring : pchar;override;
  159. procedure concatstabto(asmlist : taasmoutput);override;
  160. {$endif GDB}
  161. end;
  162. { tpointerdef and tclassrefdef should get a common
  163. base class, but I derived tclassrefdef from tpointerdef
  164. to avoid problems with bugs (FK)
  165. }
  166. tpointerdef = class(tstoreddef)
  167. pointertype : ttype;
  168. is_far : boolean;
  169. constructor create(const tt : ttype);
  170. constructor createfar(const tt : ttype);
  171. constructor ppuload(ppufile:tcompilerppufile);
  172. procedure ppuwrite(ppufile:tcompilerppufile);override;
  173. procedure deref;override;
  174. function gettypename:string;override;
  175. { debug }
  176. {$ifdef GDB}
  177. function stabstring : pchar;override;
  178. procedure concatstabto(asmlist : taasmoutput);override;
  179. {$endif GDB}
  180. end;
  181. tabstractrecorddef = class(tstoreddef)
  182. private
  183. Count : integer;
  184. FRTTIType : trttitype;
  185. {$ifdef GDB}
  186. StabRecString : pchar;
  187. StabRecSize : Integer;
  188. RecOffset : Integer;
  189. procedure addname(p : tnamedindexitem;arg:pointer);
  190. {$endif}
  191. procedure count_field_rtti(sym : tnamedindexitem;arg:pointer);
  192. procedure write_field_rtti(sym : tnamedindexitem;arg:pointer);
  193. procedure generate_field_rtti(sym : tnamedindexitem;arg:pointer);
  194. public
  195. symtable : tsymtable;
  196. function getsymtable(t:tgetsymtable):tsymtable;override;
  197. end;
  198. trecorddef = class(tabstractrecorddef)
  199. public
  200. isunion : boolean;
  201. constructor create(p : tsymtable);
  202. constructor ppuload(ppufile:tcompilerppufile);
  203. destructor destroy;override;
  204. procedure ppuwrite(ppufile:tcompilerppufile);override;
  205. procedure deref;override;
  206. function size:longint;override;
  207. function alignment : longint;override;
  208. function gettypename:string;override;
  209. { debug }
  210. {$ifdef GDB}
  211. function stabstring : pchar;override;
  212. procedure concatstabto(asmlist : taasmoutput);override;
  213. {$endif GDB}
  214. function needs_inittable : boolean;override;
  215. { rtti }
  216. procedure write_child_rtti_data(rt:trttitype);override;
  217. procedure write_rtti_data(rt:trttitype);override;
  218. end;
  219. tprocdef = class;
  220. timplementedinterfaces = class;
  221. tobjectdef = class(tabstractrecorddef)
  222. private
  223. sd : tprocdef;
  224. procedure _searchdestructor(sym : tnamedindexitem;arg:pointer);
  225. {$ifdef GDB}
  226. procedure addprocname(p :tnamedindexitem;arg:pointer);
  227. {$endif GDB}
  228. procedure count_published_properties(sym:tnamedindexitem;arg:pointer);
  229. procedure write_property_info(sym : tnamedindexitem;arg:pointer);
  230. procedure generate_published_child_rtti(sym : tnamedindexitem;arg:pointer);
  231. procedure count_published_fields(sym:tnamedindexitem;arg:pointer);
  232. procedure writefields(sym:tnamedindexitem;arg:pointer);
  233. public
  234. childof : tobjectdef;
  235. objname,
  236. objrealname : pstring;
  237. objectoptions : tobjectoptions;
  238. { to be able to have a variable vmt position }
  239. { and no vmt field for objects without virtuals }
  240. vmt_offset : longint;
  241. {$ifdef GDB}
  242. writing_class_record_stab : boolean;
  243. {$endif GDB}
  244. objecttype : tobjectdeftype;
  245. iidguid: pguid;
  246. iidstr: pstring;
  247. lastvtableindex: longint;
  248. { store implemented interfaces defs and name mappings }
  249. implementedinterfaces: timplementedinterfaces;
  250. constructor create(ot : tobjectdeftype;const n : string;c : tobjectdef);
  251. constructor ppuload(ppufile:tcompilerppufile);
  252. destructor destroy;override;
  253. procedure ppuwrite(ppufile:tcompilerppufile);override;
  254. procedure deref;override;
  255. function size : longint;override;
  256. function alignment:longint;override;
  257. function vmtmethodoffset(index:longint):longint;
  258. function members_need_inittable : boolean;
  259. { this should be called when this class implements an interface }
  260. procedure prepareguid;
  261. function is_publishable : boolean;override;
  262. function needs_inittable : boolean;override;
  263. function vmt_mangledname : string;
  264. function rtti_name : string;
  265. procedure check_forwards;
  266. function is_related(d : tobjectdef) : boolean;
  267. function next_free_name_index : longint;
  268. procedure insertvmt;
  269. procedure set_parent(c : tobjectdef);
  270. function searchdestructor : tprocdef;
  271. { debug }
  272. {$ifdef GDB}
  273. function stabstring : pchar;override;
  274. procedure set_globalnb;override;
  275. function classnumberstring : string;
  276. procedure concatstabto(asmlist : taasmoutput);override;
  277. function allstabstring : pchar;override;
  278. {$endif GDB}
  279. { rtti }
  280. procedure write_child_rtti_data(rt:trttitype);override;
  281. procedure write_rtti_data(rt:trttitype);override;
  282. function generate_field_table : tasmlabel;
  283. end;
  284. timplementedinterfaces = class
  285. constructor create;
  286. destructor destroy; override;
  287. function count: longint;
  288. function interfaces(intfindex: longint): tobjectdef;
  289. function ioffsets(intfindex: longint): plongint;
  290. function searchintf(def: tdef): longint;
  291. procedure addintf(def: tdef);
  292. procedure deref;
  293. { add interface reference loaded from ppu }
  294. procedure addintfref(def: pointer);
  295. procedure clearmappings;
  296. procedure addmappings(intfindex: longint; const name, newname: string);
  297. function getmappings(intfindex: longint; const name: string; var nextexist: pointer): string;
  298. procedure clearimplprocs;
  299. procedure addimplproc(intfindex: longint; procdef: tprocdef);
  300. function implproccount(intfindex: longint): longint;
  301. function implprocs(intfindex: longint; procindex: longint): tprocdef;
  302. function isimplmergepossible(intfindex, remainindex: longint; var weight: longint): boolean;
  303. private
  304. finterfaces: tindexarray;
  305. procedure checkindex(intfindex: longint);
  306. end;
  307. tclassrefdef = class(tpointerdef)
  308. constructor create(const t:ttype);
  309. constructor ppuload(ppufile:tcompilerppufile);
  310. procedure ppuwrite(ppufile:tcompilerppufile);override;
  311. function gettypename:string;override;
  312. { debug }
  313. {$ifdef GDB}
  314. function stabstring : pchar;override;
  315. procedure concatstabto(asmlist : taasmoutput);override;
  316. {$endif GDB}
  317. end;
  318. tarraydef = class(tstoreddef)
  319. lowrange,
  320. highrange : longint;
  321. rangetype : ttype;
  322. IsDynamicArray,
  323. IsVariant,
  324. IsConstructor,
  325. IsArrayOfConst : boolean;
  326. protected
  327. _elementtype : ttype;
  328. public
  329. function elesize : longint;
  330. constructor create(l,h : longint;const t : ttype);
  331. constructor ppuload(ppufile:tcompilerppufile);
  332. procedure ppuwrite(ppufile:tcompilerppufile);override;
  333. function gettypename:string;override;
  334. function getmangledparaname : string;override;
  335. procedure setelementtype(t: ttype);
  336. {$ifdef GDB}
  337. function stabstring : pchar;override;
  338. procedure concatstabto(asmlist : taasmoutput);override;
  339. {$endif GDB}
  340. procedure deref;override;
  341. function size : longint;override;
  342. function alignment : longint;override;
  343. { returns the label of the range check string }
  344. function needs_inittable : boolean;override;
  345. procedure write_child_rtti_data(rt:trttitype);override;
  346. procedure write_rtti_data(rt:trttitype);override;
  347. property elementtype : ttype Read _ElementType;
  348. end;
  349. torddef = class(tstoreddef)
  350. low,high : TConstExprInt;
  351. typ : tbasetype;
  352. constructor create(t : tbasetype;v,b : TConstExprInt);
  353. constructor ppuload(ppufile:tcompilerppufile);
  354. function getcopy : tstoreddef;override;
  355. procedure ppuwrite(ppufile:tcompilerppufile);override;
  356. function is_publishable : boolean;override;
  357. function gettypename:string;override;
  358. procedure setsize;
  359. { debug }
  360. {$ifdef GDB}
  361. function stabstring : pchar;override;
  362. {$endif GDB}
  363. { rtti }
  364. procedure write_rtti_data(rt:trttitype);override;
  365. end;
  366. tfloatdef = class(tstoreddef)
  367. typ : tfloattype;
  368. constructor create(t : tfloattype);
  369. constructor ppuload(ppufile:tcompilerppufile);
  370. function getcopy : tstoreddef;override;
  371. procedure ppuwrite(ppufile:tcompilerppufile);override;
  372. function gettypename:string;override;
  373. function is_publishable : boolean;override;
  374. procedure setsize;
  375. { debug }
  376. {$ifdef GDB}
  377. function stabstring : pchar;override;
  378. {$endif GDB}
  379. { rtti }
  380. procedure write_rtti_data(rt:trttitype);override;
  381. end;
  382. tabstractprocdef = class(tstoreddef)
  383. { saves a definition to the return type }
  384. rettype : ttype;
  385. para : tparalinkedlist;
  386. selfpara : tparaitem;
  387. proctypeoption : tproctypeoption;
  388. proccalloption : tproccalloption;
  389. procoptions : tprocoptions;
  390. maxparacount,
  391. minparacount : byte;
  392. symtablelevel : byte;
  393. fpu_used : byte; { how many stack fpu must be empty }
  394. constructor create;
  395. constructor ppuload(ppufile:tcompilerppufile);
  396. destructor destroy;override;
  397. procedure ppuwrite(ppufile:tcompilerppufile);override;
  398. procedure deref;override;
  399. function concatpara(const tt:ttype;sym : tsym;vsp : tvarspez;defval:tsym):tparaitem;
  400. function para_size(alignsize:longint) : longint;
  401. function typename_paras : string;
  402. procedure test_if_fpu_result;
  403. function is_methodpointer:boolean;virtual;
  404. function is_addressonly:boolean;virtual;
  405. { debug }
  406. {$ifdef GDB}
  407. function stabstring : pchar;override;
  408. procedure concatstabto(asmlist : taasmoutput);override;
  409. {$endif GDB}
  410. end;
  411. tprocvardef = class(tabstractprocdef)
  412. constructor create;
  413. constructor ppuload(ppufile:tcompilerppufile);
  414. procedure ppuwrite(ppufile:tcompilerppufile);override;
  415. function size : longint;override;
  416. function gettypename:string;override;
  417. function is_publishable : boolean;override;
  418. function is_methodpointer:boolean;override;
  419. function is_addressonly:boolean;override;
  420. { debug }
  421. {$ifdef GDB}
  422. function stabstring : pchar;override;
  423. procedure concatstabto(asmlist : taasmoutput); override;
  424. {$endif GDB}
  425. { rtti }
  426. procedure write_rtti_data(rt:trttitype);override;
  427. end;
  428. tmessageinf = record
  429. case integer of
  430. 0 : (str : pchar);
  431. 1 : (i : longint);
  432. end;
  433. tprocdef = class(tabstractprocdef)
  434. private
  435. _mangledname : pstring;
  436. {$ifdef GDB}
  437. isstabwritten : boolean;
  438. {$endif GDB}
  439. public
  440. extnumber : word;
  441. overloadnumber : word;
  442. messageinf : tmessageinf;
  443. {$ifndef EXTDEBUG}
  444. { where is this function defined, needed here because there
  445. is only one symbol for all overloaded functions
  446. EXTDEBUG has fileinfo in tdef (PFV) }
  447. fileinfo : tfileposinfo;
  448. {$endif}
  449. { symbol owning this definition }
  450. procsym : tsym;
  451. { alias names }
  452. aliasnames : tstringlist;
  453. { symtables }
  454. parast,
  455. localst : tsymtable;
  456. funcretsym : tsym;
  457. { next is only used to check if RESULT is accessed,
  458. not stored in a tnode }
  459. resultfuncretsym : tsym;
  460. { browser info }
  461. lastref,
  462. defref,
  463. lastwritten : tref;
  464. refcount : longint;
  465. _class : tobjectdef;
  466. { it's a tree, but this not easy to handle }
  467. { used for inlined procs }
  468. code : tnode;
  469. { info about register variables (JM) }
  470. regvarinfo: pointer;
  471. { true, if the procedure is only declared }
  472. { (forward procedure) }
  473. forwarddef,
  474. { true if the procedure is declared in the interface }
  475. interfacedef : boolean;
  476. { true if the procedure has a forward declaration }
  477. hasforward : boolean;
  478. { check the problems of manglednames }
  479. has_mangledname : boolean;
  480. { small set which contains the modified registers }
  481. usedregisters : tregisterset;
  482. constructor create;
  483. constructor ppuload(ppufile:tcompilerppufile);
  484. destructor destroy;override;
  485. procedure ppuwrite(ppufile:tcompilerppufile);override;
  486. procedure deref;override;
  487. procedure derefimpl;override;
  488. function getsymtable(t:tgetsymtable):tsymtable;override;
  489. function haspara:boolean;
  490. function gettypename : string;override;
  491. function mangledname : string;
  492. procedure setmangledname(const s : string);
  493. procedure load_references(ppufile:tcompilerppufile;locals:boolean);
  494. function write_references(ppufile:tcompilerppufile;locals:boolean):boolean;
  495. { inserts the local symbol table, if this is not
  496. no local symbol table is built. Should be called only
  497. when we are sure that a local symbol table will be required.
  498. }
  499. procedure insert_localst;
  500. function fullprocname:string;
  501. function fullprocnamewithret:string;
  502. function cplusplusmangledname : string;
  503. function is_methodpointer:boolean;override;
  504. function is_addressonly:boolean;override;
  505. { debug }
  506. {$ifdef GDB}
  507. function stabstring : pchar;override;
  508. procedure concatstabto(asmlist : taasmoutput);override;
  509. {$endif GDB}
  510. end;
  511. { single linked list of overloaded procs }
  512. pprocdeflist = ^tprocdeflist;
  513. tprocdeflist = record
  514. def : tprocdef;
  515. next : pprocdeflist;
  516. end;
  517. tstringdef = class(tstoreddef)
  518. string_typ : tstringtype;
  519. len : longint;
  520. constructor createshort(l : byte);
  521. constructor loadshort(ppufile:tcompilerppufile);
  522. constructor createlong(l : longint);
  523. constructor loadlong(ppufile:tcompilerppufile);
  524. constructor createansi(l : longint);
  525. constructor loadansi(ppufile:tcompilerppufile);
  526. constructor createwide(l : longint);
  527. constructor loadwide(ppufile:tcompilerppufile);
  528. function getcopy : tstoreddef;override;
  529. function stringtypname:string;
  530. function size : longint;override;
  531. procedure ppuwrite(ppufile:tcompilerppufile);override;
  532. function gettypename:string;override;
  533. function getmangledparaname:string;override;
  534. function is_publishable : boolean;override;
  535. { debug }
  536. {$ifdef GDB}
  537. function stabstring : pchar;override;
  538. procedure concatstabto(asmlist : taasmoutput);override;
  539. {$endif GDB}
  540. { init/final }
  541. function needs_inittable : boolean;override;
  542. { rtti }
  543. procedure write_rtti_data(rt:trttitype);override;
  544. end;
  545. tenumdef = class(tstoreddef)
  546. minval,
  547. maxval : longint;
  548. has_jumps : boolean;
  549. firstenum : tsym; {tenumsym}
  550. basedef : tenumdef;
  551. constructor create;
  552. constructor create_subrange(_basedef:tenumdef;_min,_max:longint);
  553. constructor ppuload(ppufile:tcompilerppufile);
  554. destructor destroy;override;
  555. procedure ppuwrite(ppufile:tcompilerppufile);override;
  556. procedure deref;override;
  557. function gettypename:string;override;
  558. function is_publishable : boolean;override;
  559. procedure calcsavesize;
  560. procedure setmax(_max:longint);
  561. procedure setmin(_min:longint);
  562. function min:longint;
  563. function max:longint;
  564. { debug }
  565. {$ifdef GDB}
  566. function stabstring : pchar;override;
  567. {$endif GDB}
  568. { rtti }
  569. procedure write_rtti_data(rt:trttitype);override;
  570. procedure write_child_rtti_data(rt:trttitype);override;
  571. private
  572. procedure correct_owner_symtable;
  573. end;
  574. tsetdef = class(tstoreddef)
  575. elementtype : ttype;
  576. settype : tsettype;
  577. constructor create(const t:ttype;high : longint);
  578. constructor ppuload(ppufile:tcompilerppufile);
  579. destructor destroy;override;
  580. procedure ppuwrite(ppufile:tcompilerppufile);override;
  581. procedure deref;override;
  582. function gettypename:string;override;
  583. function is_publishable : boolean;override;
  584. procedure changesettype(s:tsettype);
  585. { debug }
  586. {$ifdef GDB}
  587. function stabstring : pchar;override;
  588. procedure concatstabto(asmlist : taasmoutput);override;
  589. {$endif GDB}
  590. { rtti }
  591. procedure write_rtti_data(rt:trttitype);override;
  592. procedure write_child_rtti_data(rt:trttitype);override;
  593. end;
  594. Tdefmatch=(dm_exact,dm_equal,dm_convertl1);
  595. var
  596. aktobjectdef : tobjectdef; { used for private functions check !! }
  597. firstglobaldef, { linked list of all globals defs }
  598. lastglobaldef : tstoreddef; { used to reset stabs/ranges }
  599. {$ifdef GDB}
  600. { for STAB debugging }
  601. globaltypecount : word;
  602. pglobaltypecount : pword;
  603. {$endif GDB}
  604. { default types }
  605. generrortype, { error in definition }
  606. voidpointertype, { pointer for Void-Pointerdef }
  607. charpointertype, { pointer for Char-Pointerdef }
  608. voidfarpointertype,
  609. cformaltype, { unique formal definition }
  610. voidtype, { Pointer to Void (procedure) }
  611. cchartype, { Pointer to Char }
  612. cwidechartype, { Pointer to WideChar }
  613. booltype, { pointer to boolean type }
  614. u8bittype, { Pointer to 8-Bit unsigned }
  615. u16bittype, { Pointer to 16-Bit unsigned }
  616. u32bittype, { Pointer to 32-Bit unsigned }
  617. s32bittype, { Pointer to 32-Bit signed }
  618. cu64bittype, { pointer to 64 bit unsigned def }
  619. cs64bittype, { pointer to 64 bit signed def, }
  620. s32floattype, { pointer for realconstn }
  621. s64floattype, { pointer for realconstn }
  622. s80floattype, { pointer to type of temp. floats }
  623. s64currencytype, { pointer to a currency type }
  624. s32fixedtype, { pointer to type of temp. fixed }
  625. cshortstringtype, { pointer to type of short string const }
  626. clongstringtype, { pointer to type of long string const }
  627. cansistringtype, { pointer to type of ansi string const }
  628. cwidestringtype, { pointer to type of wide string const }
  629. openshortstringtype, { pointer to type of an open shortstring,
  630. needed for readln() }
  631. openchararraytype, { pointer to type of an open array of char,
  632. needed for readln() }
  633. cfiletype, { get the same definition for all file }
  634. { used for stabs }
  635. { we use only one variant def }
  636. cvarianttype,
  637. { unsigned ord type with the same size as a pointer }
  638. ordpointertype,
  639. pvmttype : ttype; { type of classrefs, used for stabs }
  640. class_tobject : tobjectdef; { pointer to the anchestor of all classes }
  641. interface_iunknown : tobjectdef; { KAZ: pointer to the ancestor }
  642. rec_tguid : trecorddef; { KAZ: pointer to the TGUID type }
  643. { of all interfaces }
  644. const
  645. {$ifdef i386}
  646. pbestrealtype : ^ttype = @s80floattype;
  647. {$endif}
  648. {$ifdef x86_64}
  649. pbestrealtype : ^ttype = @s80floattype;
  650. {$endif}
  651. {$ifdef m68k}
  652. pbestrealtype : ^ttype = @s64floattype;
  653. {$endif}
  654. {$ifdef alpha}
  655. pbestrealtype : ^ttype = @s64floattype;
  656. {$endif}
  657. {$ifdef powerpc}
  658. pbestrealtype : ^ttype = @s64floattype;
  659. {$endif}
  660. {$ifdef ia64}
  661. pbestrealtype : ^ttype = @s64floattype;
  662. {$endif}
  663. {$ifdef SPARC}
  664. pbestrealtype : ^ttype = @s64floattype;
  665. {$endif SPARC}
  666. {$ifdef vis}
  667. pbestrealtype : ^ttype = @s64floattype;
  668. {$endif vis}
  669. function mangledname_prefix(typeprefix:string;st:tsymtable):string;
  670. {$ifdef GDB}
  671. { GDB Helpers }
  672. function typeglobalnumber(const s : string) : string;
  673. {$endif GDB}
  674. { should be in the types unit, but the types unit uses the node stuff :( }
  675. function is_interfacecom(def: tdef): boolean;
  676. function is_interfacecorba(def: tdef): boolean;
  677. function is_interface(def: tdef): boolean;
  678. function is_object(def: tdef): boolean;
  679. function is_class(def: tdef): boolean;
  680. function is_cppclass(def: tdef): boolean;
  681. function is_class_or_interface(def: tdef): boolean;
  682. procedure reset_global_defs;
  683. implementation
  684. uses
  685. {$ifdef Delphi}
  686. sysutils,
  687. {$else Delphi}
  688. strings,
  689. {$endif Delphi}
  690. { global }
  691. verbose,
  692. { target }
  693. aasmcpu,
  694. systems,
  695. { symtable }
  696. symsym,symtable,paramgr,
  697. symutil,defutil,
  698. { module }
  699. {$ifdef GDB}
  700. gdb,
  701. {$endif GDB}
  702. fmodule,
  703. { other }
  704. gendef
  705. ;
  706. {****************************************************************************
  707. Helpers
  708. ****************************************************************************}
  709. function mangledname_prefix(typeprefix:string;st:tsymtable):string;
  710. var
  711. s,
  712. prefix : string;
  713. begin
  714. prefix:='';
  715. if not assigned(st) then
  716. internalerror(200204212);
  717. { sub procedures }
  718. while (st.symtabletype=localsymtable) do
  719. begin
  720. if st.defowner.deftype<>procdef then
  721. internalerror(200204173);
  722. s:=tprocdef(st.defowner).procsym.name;
  723. if tprocdef(st.defowner).overloadnumber>0 then
  724. s:=s+'$'+tostr(tprocdef(st.defowner).overloadnumber);
  725. prefix:=s+'$'+prefix;
  726. st:=st.defowner.owner;
  727. end;
  728. { object/classes symtable }
  729. if (st.symtabletype=objectsymtable) then
  730. begin
  731. if st.defowner.deftype<>objectdef then
  732. internalerror(200204174);
  733. prefix:=tobjectdef(st.defowner).objname^+'_$_'+prefix;
  734. st:=st.defowner.owner;
  735. end;
  736. { symtable must now be static or global }
  737. if not(st.symtabletype in [staticsymtable,globalsymtable]) then
  738. internalerror(200204175);
  739. mangledname_prefix:=typeprefix+'_'+st.name^+'_'+prefix;
  740. end;
  741. {$ifdef GDB}
  742. procedure forcestabto(asmlist : taasmoutput; pd : tdef);
  743. begin
  744. if tstoreddef(pd).is_def_stab_written = not_written then
  745. begin
  746. if assigned(pd.typesym) then
  747. ttypesym(pd.typesym).isusedinstab := true;
  748. tstoreddef(pd).concatstabto(asmlist);
  749. end;
  750. end;
  751. {$endif GDB}
  752. {****************************************************************************
  753. TDEF (base class for definitions)
  754. ****************************************************************************}
  755. constructor tstoreddef.create;
  756. begin
  757. inherited create;
  758. savesize := 0;
  759. {$ifdef EXTDEBUG}
  760. fileinfo := aktfilepos;
  761. {$endif}
  762. if registerdef then
  763. symtablestack.registerdef(self);
  764. {$ifdef GDB}
  765. is_def_stab_written := not_written;
  766. globalnb := 0;
  767. {$endif GDB}
  768. if assigned(lastglobaldef) then
  769. begin
  770. lastglobaldef.nextglobal := self;
  771. previousglobal:=lastglobaldef;
  772. end
  773. else
  774. begin
  775. firstglobaldef := self;
  776. previousglobal := nil;
  777. end;
  778. lastglobaldef := self;
  779. nextglobal := nil;
  780. fillchar(localrttilab,sizeof(localrttilab),0);
  781. end;
  782. constructor tstoreddef.ppuloaddef(ppufile:tcompilerppufile);
  783. begin
  784. inherited create;
  785. {$ifdef EXTDEBUG}
  786. fillchar(fileinfo,sizeof(fileinfo),0);
  787. {$endif}
  788. {$ifdef GDB}
  789. is_def_stab_written := not_written;
  790. globalnb := 0;
  791. {$endif GDB}
  792. if assigned(lastglobaldef) then
  793. begin
  794. lastglobaldef.nextglobal := self;
  795. previousglobal:=lastglobaldef;
  796. end
  797. else
  798. begin
  799. firstglobaldef := self;
  800. previousglobal:=nil;
  801. end;
  802. lastglobaldef := self;
  803. nextglobal := nil;
  804. fillchar(localrttilab,sizeof(localrttilab),0);
  805. { load }
  806. indexnr:=ppufile.getword;
  807. typesym:=ttypesym(pointer(ppufile.getderef));
  808. ppufile.getsmallset(defoptions);
  809. if df_has_rttitable in defoptions then
  810. rttitablesym:=tsym(ppufile.getderef);
  811. if df_has_inittable in defoptions then
  812. inittablesym:=tsym(ppufile.getderef);
  813. end;
  814. destructor tstoreddef.destroy;
  815. begin
  816. { first element ? }
  817. if not(assigned(previousglobal)) then
  818. begin
  819. firstglobaldef := nextglobal;
  820. if assigned(firstglobaldef) then
  821. firstglobaldef.previousglobal:=nil;
  822. end
  823. else
  824. begin
  825. { remove reference in the element before }
  826. previousglobal.nextglobal:=nextglobal;
  827. end;
  828. { last element ? }
  829. if not(assigned(nextglobal)) then
  830. begin
  831. lastglobaldef := previousglobal;
  832. if assigned(lastglobaldef) then
  833. lastglobaldef.nextglobal:=nil;
  834. end
  835. else
  836. nextglobal.previousglobal:=previousglobal;
  837. previousglobal:=nil;
  838. nextglobal:=nil;
  839. end;
  840. function tstoreddef.getcopy : tstoreddef;
  841. begin
  842. Message(sym_e_cant_create_unique_type);
  843. getcopy:=nil;
  844. end;
  845. procedure tstoreddef.ppuwritedef(ppufile:tcompilerppufile);
  846. begin
  847. ppufile.putword(indexnr);
  848. ppufile.putderef(typesym);
  849. ppufile.putsmallset(defoptions);
  850. if df_has_rttitable in defoptions then
  851. ppufile.putderef(rttitablesym);
  852. if df_has_inittable in defoptions then
  853. ppufile.putderef(inittablesym);
  854. {$ifdef GDB}
  855. if globalnb = 0 then
  856. begin
  857. if assigned(owner) then
  858. globalnb := owner.getnewtypecount
  859. else
  860. begin
  861. globalnb := PGlobalTypeCount^;
  862. Inc(PGlobalTypeCount^);
  863. end;
  864. end;
  865. {$endif GDB}
  866. end;
  867. procedure tstoreddef.deref;
  868. begin
  869. resolvesym(pointer(typesym));
  870. resolvesym(pointer(rttitablesym));
  871. resolvesym(pointer(inittablesym));
  872. end;
  873. procedure tstoreddef.derefimpl;
  874. begin
  875. end;
  876. function tstoreddef.size : longint;
  877. begin
  878. size:=savesize;
  879. end;
  880. function tstoreddef.alignment : longint;
  881. begin
  882. { normal alignment by default }
  883. alignment:=0;
  884. end;
  885. {$ifdef GDB}
  886. procedure tstoreddef.set_globalnb;
  887. begin
  888. globalnb :=PGlobalTypeCount^;
  889. inc(PglobalTypeCount^);
  890. end;
  891. function tstoreddef.stabstring : pchar;
  892. begin
  893. stabstring := strpnew('t'+numberstring+';');
  894. end;
  895. function tstoreddef.numberstring : string;
  896. var table : tsymtable;
  897. begin
  898. {formal def have no type !}
  899. if deftype = formaldef then
  900. begin
  901. numberstring := tstoreddef(voidtype.def).numberstring;
  902. exit;
  903. end;
  904. if (not assigned(typesym)) or (not ttypesym(typesym).isusedinstab) then
  905. begin
  906. {set even if debuglist is not defined}
  907. if assigned(typesym) then
  908. ttypesym(typesym).isusedinstab := true;
  909. if assigned(debuglist) and (is_def_stab_written = not_written) then
  910. concatstabto(debuglist);
  911. end;
  912. if not (cs_gdb_dbx in aktglobalswitches) then
  913. begin
  914. if globalnb = 0 then
  915. set_globalnb;
  916. numberstring := tostr(globalnb);
  917. end
  918. else
  919. begin
  920. if globalnb = 0 then
  921. begin
  922. if assigned(owner) then
  923. globalnb := owner.getnewtypecount
  924. else
  925. begin
  926. globalnb := PGlobalTypeCount^;
  927. Inc(PGlobalTypeCount^);
  928. end;
  929. end;
  930. if assigned(typesym) then
  931. begin
  932. table := ttypesym(typesym).owner;
  933. if table.unitid > 0 then
  934. numberstring := '('+tostr(table.unitid)+','+tostr(tstoreddef(ttypesym(typesym).restype.def).globalnb)+')'
  935. else
  936. numberstring := tostr(globalnb);
  937. exit;
  938. end;
  939. numberstring := tostr(globalnb);
  940. end;
  941. end;
  942. function tstoreddef.allstabstring : pchar;
  943. var stabchar : string[2];
  944. ss,st : pchar;
  945. sname : string;
  946. sym_line_no : longint;
  947. begin
  948. ss := stabstring;
  949. getmem(st,strlen(ss)+512);
  950. stabchar := 't';
  951. if deftype in tagtypes then
  952. stabchar := 'Tt';
  953. if assigned(typesym) then
  954. begin
  955. sname := ttypesym(typesym).name;
  956. sym_line_no:=ttypesym(typesym).fileinfo.line;
  957. end
  958. else
  959. begin
  960. sname := ' ';
  961. sym_line_no:=0;
  962. end;
  963. strpcopy(st,'"'+sname+':'+stabchar+numberstring+'=');
  964. strpcopy(strecopy(strend(st),ss),'",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0');
  965. allstabstring := strnew(st);
  966. freemem(st,strlen(ss)+512);
  967. strdispose(ss);
  968. end;
  969. procedure tstoreddef.concatstabto(asmlist : taasmoutput);
  970. var stab_str : pchar;
  971. begin
  972. if ((typesym = nil) or ttypesym(typesym).isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  973. and (is_def_stab_written = not_written) then
  974. begin
  975. If cs_gdb_dbx in aktglobalswitches then
  976. begin
  977. { otherwise you get two of each def }
  978. If assigned(typesym) then
  979. begin
  980. if ttypesym(typesym).typ=symconst.typesym then
  981. ttypesym(typesym).isusedinstab:=true;
  982. if (ttypesym(typesym).owner = nil) or
  983. ((ttypesym(typesym).owner.symtabletype = globalsymtable) and
  984. tglobalsymtable(ttypesym(typesym).owner).dbx_count_ok) then
  985. begin
  986. {with DBX we get the definition from the other objects }
  987. is_def_stab_written := written;
  988. exit;
  989. end;
  990. end;
  991. end;
  992. { to avoid infinite loops }
  993. is_def_stab_written := being_written;
  994. stab_str := allstabstring;
  995. asmList.concat(Tai_stabs.Create(stab_str));
  996. is_def_stab_written := written;
  997. end;
  998. end;
  999. {$endif GDB}
  1000. procedure tstoreddef.write_rtti_name;
  1001. var
  1002. str : string;
  1003. begin
  1004. { name }
  1005. if assigned(typesym) then
  1006. begin
  1007. str:=ttypesym(typesym).realname;
  1008. rttiList.concat(Tai_string.Create(chr(length(str))+str));
  1009. end
  1010. else
  1011. rttiList.concat(Tai_string.Create(#0))
  1012. end;
  1013. procedure tstoreddef.write_rtti_data(rt:trttitype);
  1014. begin
  1015. rttilist.concat(tai_const.create_8bit(tkUnknown));
  1016. write_rtti_name;
  1017. end;
  1018. procedure tstoreddef.write_child_rtti_data(rt:trttitype);
  1019. begin
  1020. end;
  1021. function tstoreddef.get_rtti_label(rt:trttitype) : tasmsymbol;
  1022. begin
  1023. { try to reuse persistent rtti data }
  1024. if (rt=fullrtti) and (df_has_rttitable in defoptions) then
  1025. get_rtti_label:=trttisym(rttitablesym).get_label
  1026. else
  1027. if (rt=initrtti) and (df_has_inittable in defoptions) then
  1028. get_rtti_label:=trttisym(inittablesym).get_label
  1029. else
  1030. begin
  1031. if not assigned(localrttilab[rt]) then
  1032. begin
  1033. objectlibrary.getdatalabel(localrttilab[rt]);
  1034. write_child_rtti_data(rt);
  1035. if (cs_create_smart in aktmoduleswitches) then
  1036. rttiList.concat(Tai_cut.Create);
  1037. rttiList.concat(Tai_align.create(const_align(pointer_size)));
  1038. rttiList.concat(Tai_symbol.Create(localrttilab[rt],0));
  1039. write_rtti_data(rt);
  1040. rttiList.concat(Tai_symbol_end.Create(localrttilab[rt]));
  1041. end;
  1042. get_rtti_label:=localrttilab[rt];
  1043. end;
  1044. end;
  1045. { returns true, if the definition can be published }
  1046. function tstoreddef.is_publishable : boolean;
  1047. begin
  1048. is_publishable:=false;
  1049. end;
  1050. { needs an init table }
  1051. function tstoreddef.needs_inittable : boolean;
  1052. begin
  1053. needs_inittable:=false;
  1054. end;
  1055. function tstoreddef.is_intregable : boolean;
  1056. begin
  1057. is_intregable:=false;
  1058. case deftype of
  1059. pointerdef,
  1060. enumdef:
  1061. is_intregable:=true;
  1062. procvardef :
  1063. is_intregable:=not(po_methodpointer in tprocvardef(self).procoptions);
  1064. orddef :
  1065. case torddef(self).typ of
  1066. bool8bit,bool16bit,bool32bit,
  1067. u8bit,u16bit,u32bit,
  1068. s8bit,s16bit,s32bit:
  1069. is_intregable:=true;
  1070. end;
  1071. setdef:
  1072. is_intregable:=(tsetdef(self).settype=smallset);
  1073. end;
  1074. end;
  1075. function tstoreddef.is_fpuregable : boolean;
  1076. begin
  1077. is_fpuregable:=(deftype=floatdef);
  1078. end;
  1079. {****************************************************************************
  1080. TPARALINKEDLIST
  1081. ****************************************************************************}
  1082. function tparalinkedlist.count:longint;
  1083. begin
  1084. { You must use tabstractprocdef.minparacount and .maxparacount instead }
  1085. internalerror(432432978);
  1086. count:=0;
  1087. end;
  1088. {****************************************************************************
  1089. Tstringdef
  1090. ****************************************************************************}
  1091. constructor tstringdef.createshort(l : byte);
  1092. begin
  1093. inherited create;
  1094. string_typ:=st_shortstring;
  1095. deftype:=stringdef;
  1096. len:=l;
  1097. savesize:=len+1;
  1098. end;
  1099. constructor tstringdef.loadshort(ppufile:tcompilerppufile);
  1100. begin
  1101. inherited ppuloaddef(ppufile);
  1102. string_typ:=st_shortstring;
  1103. deftype:=stringdef;
  1104. len:=ppufile.getbyte;
  1105. savesize:=len+1;
  1106. end;
  1107. constructor tstringdef.createlong(l : longint);
  1108. begin
  1109. inherited create;
  1110. string_typ:=st_longstring;
  1111. deftype:=stringdef;
  1112. len:=l;
  1113. savesize:=POINTER_SIZE;
  1114. end;
  1115. constructor tstringdef.loadlong(ppufile:tcompilerppufile);
  1116. begin
  1117. inherited ppuloaddef(ppufile);
  1118. deftype:=stringdef;
  1119. string_typ:=st_longstring;
  1120. len:=ppufile.getlongint;
  1121. savesize:=POINTER_SIZE;
  1122. end;
  1123. constructor tstringdef.createansi(l : longint);
  1124. begin
  1125. inherited create;
  1126. string_typ:=st_ansistring;
  1127. deftype:=stringdef;
  1128. len:=l;
  1129. savesize:=POINTER_SIZE;
  1130. end;
  1131. constructor tstringdef.loadansi(ppufile:tcompilerppufile);
  1132. begin
  1133. inherited ppuloaddef(ppufile);
  1134. deftype:=stringdef;
  1135. string_typ:=st_ansistring;
  1136. len:=ppufile.getlongint;
  1137. savesize:=POINTER_SIZE;
  1138. end;
  1139. constructor tstringdef.createwide(l : longint);
  1140. begin
  1141. inherited create;
  1142. string_typ:=st_widestring;
  1143. deftype:=stringdef;
  1144. len:=l;
  1145. savesize:=POINTER_SIZE;
  1146. end;
  1147. constructor tstringdef.loadwide(ppufile:tcompilerppufile);
  1148. begin
  1149. inherited ppuloaddef(ppufile);
  1150. deftype:=stringdef;
  1151. string_typ:=st_widestring;
  1152. len:=ppufile.getlongint;
  1153. savesize:=POINTER_SIZE;
  1154. end;
  1155. function tstringdef.getcopy : tstoreddef;
  1156. begin
  1157. result:=tstringdef.create;
  1158. result.deftype:=stringdef;
  1159. tstringdef(result).string_typ:=string_typ;
  1160. tstringdef(result).len:=len;
  1161. tstringdef(result).savesize:=savesize;
  1162. end;
  1163. function tstringdef.stringtypname:string;
  1164. const
  1165. typname:array[tstringtype] of string[8]=('',
  1166. 'shortstr','longstr','ansistr','widestr'
  1167. );
  1168. begin
  1169. stringtypname:=typname[string_typ];
  1170. end;
  1171. function tstringdef.size : longint;
  1172. begin
  1173. size:=savesize;
  1174. end;
  1175. procedure tstringdef.ppuwrite(ppufile:tcompilerppufile);
  1176. begin
  1177. inherited ppuwritedef(ppufile);
  1178. if string_typ=st_shortstring then
  1179. begin
  1180. {$ifdef extdebug}
  1181. if len > 255 then internalerror(12122002);
  1182. {$endif}
  1183. ppufile.putbyte(byte(len))
  1184. end
  1185. else
  1186. ppufile.putlongint(len);
  1187. case string_typ of
  1188. st_shortstring : ppufile.writeentry(ibshortstringdef);
  1189. st_longstring : ppufile.writeentry(iblongstringdef);
  1190. st_ansistring : ppufile.writeentry(ibansistringdef);
  1191. st_widestring : ppufile.writeentry(ibwidestringdef);
  1192. end;
  1193. end;
  1194. {$ifdef GDB}
  1195. function tstringdef.stabstring : pchar;
  1196. var
  1197. bytest,charst,longst : string;
  1198. begin
  1199. case string_typ of
  1200. st_shortstring:
  1201. begin
  1202. charst := typeglobalnumber('char');
  1203. { this is what I found in stabs.texinfo but
  1204. gdb 4.12 for go32 doesn't understand that !! }
  1205. {$IfDef GDBknowsstrings}
  1206. stabstring := strpnew('n'+charst+';'+tostr(len));
  1207. {$else}
  1208. bytest := typeglobalnumber('byte');
  1209. stabstring := strpnew('s'+tostr(len+1)+'length:'+bytest
  1210. +',0,8;st:ar'+bytest
  1211. +';1;'+tostr(len)+';'+charst+',8,'+tostr(len*8)+';;');
  1212. {$EndIf}
  1213. end;
  1214. st_longstring:
  1215. begin
  1216. charst := typeglobalnumber('char');
  1217. { this is what I found in stabs.texinfo but
  1218. gdb 4.12 for go32 doesn't understand that !! }
  1219. {$IfDef GDBknowsstrings}
  1220. stabstring := strpnew('n'+charst+';'+tostr(len));
  1221. {$else}
  1222. bytest := typeglobalnumber('byte');
  1223. longst := typeglobalnumber('longint');
  1224. stabstring := strpnew('s'+tostr(len+5)+'length:'+longst
  1225. +',0,32;dummy:'+bytest+',32,8;st:ar'+bytest
  1226. +';1;'+tostr(len)+';'+charst+',40,'+tostr(len*8)+';;');
  1227. {$EndIf}
  1228. end;
  1229. st_ansistring:
  1230. begin
  1231. { an ansi string looks like a pchar easy !! }
  1232. stabstring:=strpnew('*'+typeglobalnumber('char'));
  1233. end;
  1234. st_widestring:
  1235. begin
  1236. { an ansi string looks like a pwidechar easy !! }
  1237. stabstring:=strpnew('*'+typeglobalnumber('widechar'));
  1238. end;
  1239. end;
  1240. end;
  1241. procedure tstringdef.concatstabto(asmlist : taasmoutput);
  1242. begin
  1243. inherited concatstabto(asmlist);
  1244. end;
  1245. {$endif GDB}
  1246. function tstringdef.needs_inittable : boolean;
  1247. begin
  1248. needs_inittable:=string_typ in [st_ansistring,st_widestring];
  1249. end;
  1250. function tstringdef.gettypename : string;
  1251. const
  1252. names : array[tstringtype] of string[20] = ('',
  1253. 'ShortString','LongString','AnsiString','WideString');
  1254. begin
  1255. gettypename:=names[string_typ];
  1256. end;
  1257. procedure tstringdef.write_rtti_data(rt:trttitype);
  1258. begin
  1259. case string_typ of
  1260. st_ansistring:
  1261. begin
  1262. rttiList.concat(Tai_const.Create_8bit(tkAString));
  1263. write_rtti_name;
  1264. end;
  1265. st_widestring:
  1266. begin
  1267. rttiList.concat(Tai_const.Create_8bit(tkWString));
  1268. write_rtti_name;
  1269. end;
  1270. st_longstring:
  1271. begin
  1272. rttiList.concat(Tai_const.Create_8bit(tkLString));
  1273. write_rtti_name;
  1274. end;
  1275. st_shortstring:
  1276. begin
  1277. rttiList.concat(Tai_const.Create_8bit(tkSString));
  1278. write_rtti_name;
  1279. rttiList.concat(Tai_const.Create_8bit(len));
  1280. end;
  1281. end;
  1282. end;
  1283. function tstringdef.getmangledparaname : string;
  1284. begin
  1285. getmangledparaname:='STRING';
  1286. end;
  1287. function tstringdef.is_publishable : boolean;
  1288. begin
  1289. is_publishable:=true;
  1290. end;
  1291. {****************************************************************************
  1292. TENUMDEF
  1293. ****************************************************************************}
  1294. constructor tenumdef.create;
  1295. begin
  1296. inherited create;
  1297. deftype:=enumdef;
  1298. minval:=0;
  1299. maxval:=0;
  1300. calcsavesize;
  1301. has_jumps:=false;
  1302. basedef:=nil;
  1303. firstenum:=nil;
  1304. correct_owner_symtable;
  1305. end;
  1306. constructor tenumdef.create_subrange(_basedef:tenumdef;_min,_max:longint);
  1307. begin
  1308. inherited create;
  1309. deftype:=enumdef;
  1310. minval:=_min;
  1311. maxval:=_max;
  1312. basedef:=_basedef;
  1313. calcsavesize;
  1314. has_jumps:=false;
  1315. firstenum:=basedef.firstenum;
  1316. while assigned(firstenum) and (tenumsym(firstenum).value<>minval) do
  1317. firstenum:=tenumsym(firstenum).nextenum;
  1318. correct_owner_symtable;
  1319. end;
  1320. constructor tenumdef.ppuload(ppufile:tcompilerppufile);
  1321. begin
  1322. inherited ppuloaddef(ppufile);
  1323. deftype:=enumdef;
  1324. basedef:=tenumdef(ppufile.getderef);
  1325. minval:=ppufile.getlongint;
  1326. maxval:=ppufile.getlongint;
  1327. savesize:=ppufile.getlongint;
  1328. has_jumps:=false;
  1329. firstenum:=Nil;
  1330. end;
  1331. procedure tenumdef.calcsavesize;
  1332. begin
  1333. if (aktpackenum=4) or (min<0) or (max>65535) then
  1334. savesize:=4
  1335. else
  1336. if (aktpackenum=2) or (min<0) or (max>255) then
  1337. savesize:=2
  1338. else
  1339. savesize:=1;
  1340. end;
  1341. procedure tenumdef.setmax(_max:longint);
  1342. begin
  1343. maxval:=_max;
  1344. calcsavesize;
  1345. end;
  1346. procedure tenumdef.setmin(_min:longint);
  1347. begin
  1348. minval:=_min;
  1349. calcsavesize;
  1350. end;
  1351. function tenumdef.min:longint;
  1352. begin
  1353. min:=minval;
  1354. end;
  1355. function tenumdef.max:longint;
  1356. begin
  1357. max:=maxval;
  1358. end;
  1359. procedure tenumdef.deref;
  1360. begin
  1361. inherited deref;
  1362. resolvedef(pointer(basedef));
  1363. end;
  1364. destructor tenumdef.destroy;
  1365. begin
  1366. inherited destroy;
  1367. end;
  1368. procedure tenumdef.ppuwrite(ppufile:tcompilerppufile);
  1369. begin
  1370. inherited ppuwritedef(ppufile);
  1371. ppufile.putderef(basedef);
  1372. ppufile.putlongint(min);
  1373. ppufile.putlongint(max);
  1374. ppufile.putlongint(savesize);
  1375. ppufile.writeentry(ibenumdef);
  1376. end;
  1377. { used for enumdef because the symbols are
  1378. inserted in the owner symtable }
  1379. procedure tenumdef.correct_owner_symtable;
  1380. var
  1381. st : tsymtable;
  1382. begin
  1383. if assigned(owner) and
  1384. (owner.symtabletype in [recordsymtable,objectsymtable]) then
  1385. begin
  1386. owner.defindex.deleteindex(self);
  1387. st:=owner;
  1388. while (st.symtabletype in [recordsymtable,objectsymtable]) do
  1389. st:=st.next;
  1390. st.registerdef(self);
  1391. end;
  1392. end;
  1393. {$ifdef GDB}
  1394. function tenumdef.stabstring : pchar;
  1395. var st,st2 : pchar;
  1396. p : tenumsym;
  1397. s : string;
  1398. memsize : word;
  1399. begin
  1400. memsize := memsizeinc;
  1401. getmem(st,memsize);
  1402. { we can specify the size with @s<size>; prefix PM }
  1403. if savesize <> std_param_align then
  1404. strpcopy(st,'@s'+tostr(savesize*8)+';e')
  1405. else
  1406. strpcopy(st,'e');
  1407. p := tenumsym(firstenum);
  1408. while assigned(p) do
  1409. begin
  1410. s :=p.name+':'+tostr(p.value)+',';
  1411. { place for the ending ';' also }
  1412. if (strlen(st)+length(s)+1<memsize) then
  1413. strpcopy(strend(st),s)
  1414. else
  1415. begin
  1416. getmem(st2,memsize+memsizeinc);
  1417. strcopy(st2,st);
  1418. freemem(st,memsize);
  1419. st := st2;
  1420. memsize := memsize+memsizeinc;
  1421. strpcopy(strend(st),s);
  1422. end;
  1423. p := p.nextenum;
  1424. end;
  1425. strpcopy(strend(st),';');
  1426. stabstring := strnew(st);
  1427. freemem(st,memsize);
  1428. end;
  1429. {$endif GDB}
  1430. procedure tenumdef.write_child_rtti_data(rt:trttitype);
  1431. begin
  1432. if assigned(basedef) then
  1433. basedef.get_rtti_label(rt);
  1434. end;
  1435. procedure tenumdef.write_rtti_data(rt:trttitype);
  1436. var
  1437. hp : tenumsym;
  1438. begin
  1439. rttiList.concat(Tai_const.Create_8bit(tkEnumeration));
  1440. write_rtti_name;
  1441. case savesize of
  1442. 1:
  1443. rttiList.concat(Tai_const.Create_8bit(otUByte));
  1444. 2:
  1445. rttiList.concat(Tai_const.Create_8bit(otUWord));
  1446. 4:
  1447. rttiList.concat(Tai_const.Create_8bit(otULong));
  1448. end;
  1449. rttiList.concat(Tai_const.Create_32bit(min));
  1450. rttiList.concat(Tai_const.Create_32bit(max));
  1451. if assigned(basedef) then
  1452. rttiList.concat(Tai_const_symbol.Create(basedef.get_rtti_label(rt)))
  1453. else
  1454. rttiList.concat(Tai_const.Create_32bit(0));
  1455. hp:=tenumsym(firstenum);
  1456. while assigned(hp) do
  1457. begin
  1458. rttiList.concat(Tai_const.Create_8bit(length(hp.name)));
  1459. rttiList.concat(Tai_string.Create(lower(hp.name)));
  1460. hp:=hp.nextenum;
  1461. end;
  1462. rttiList.concat(Tai_const.Create_8bit(0));
  1463. end;
  1464. function tenumdef.is_publishable : boolean;
  1465. begin
  1466. is_publishable:=true;
  1467. end;
  1468. function tenumdef.gettypename : string;
  1469. begin
  1470. gettypename:='<enumeration type>';
  1471. end;
  1472. {****************************************************************************
  1473. TORDDEF
  1474. ****************************************************************************}
  1475. constructor torddef.create(t : tbasetype;v,b : TConstExprInt);
  1476. begin
  1477. inherited create;
  1478. deftype:=orddef;
  1479. low:=v;
  1480. high:=b;
  1481. typ:=t;
  1482. setsize;
  1483. end;
  1484. constructor torddef.ppuload(ppufile:tcompilerppufile);
  1485. var
  1486. l1,l2 : longint;
  1487. begin
  1488. inherited ppuloaddef(ppufile);
  1489. deftype:=orddef;
  1490. typ:=tbasetype(ppufile.getbyte);
  1491. if sizeof(TConstExprInt)=8 then
  1492. begin
  1493. l1:=ppufile.getlongint;
  1494. l2:=ppufile.getlongint;
  1495. {$ifopt R+}
  1496. {$define Range_check_on}
  1497. {$endif opt R+}
  1498. {$R- needed here }
  1499. low:=qword(l1)+(int64(l2) shl 32);
  1500. {$ifdef Range_check_on}
  1501. {$R+}
  1502. {$undef Range_check_on}
  1503. {$endif Range_check_on}
  1504. end
  1505. else
  1506. low:=ppufile.getlongint;
  1507. if sizeof(TConstExprInt)=8 then
  1508. begin
  1509. l1:=ppufile.getlongint;
  1510. l2:=ppufile.getlongint;
  1511. {$ifopt R+}
  1512. {$define Range_check_on}
  1513. {$endif opt R+}
  1514. {$R- needed here }
  1515. high:=qword(l1)+(int64(l2) shl 32);
  1516. {$ifdef Range_check_on}
  1517. {$R+}
  1518. {$undef Range_check_on}
  1519. {$endif Range_check_on}
  1520. end
  1521. else
  1522. high:=ppufile.getlongint;
  1523. setsize;
  1524. end;
  1525. function torddef.getcopy : tstoreddef;
  1526. begin
  1527. result:=torddef.create(typ,low,high);
  1528. result.deftype:=orddef;
  1529. torddef(result).low:=low;
  1530. torddef(result).high:=high;
  1531. torddef(result).typ:=typ;
  1532. torddef(result).savesize:=savesize;
  1533. end;
  1534. procedure torddef.setsize;
  1535. begin
  1536. case typ of
  1537. u8bit,s8bit,
  1538. uchar,bool8bit:
  1539. savesize:=1;
  1540. u16bit,s16bit,
  1541. bool16bit,uwidechar:
  1542. savesize:=2;
  1543. s32bit,u32bit,
  1544. bool32bit:
  1545. savesize:=4;
  1546. u64bit,s64bit:
  1547. savesize:=8;
  1548. else
  1549. savesize:=0;
  1550. end;
  1551. end;
  1552. procedure torddef.ppuwrite(ppufile:tcompilerppufile);
  1553. begin
  1554. inherited ppuwritedef(ppufile);
  1555. ppufile.putbyte(byte(typ));
  1556. if sizeof(TConstExprInt)=8 then
  1557. begin
  1558. ppufile.putlongint(longint(lo(low)));
  1559. ppufile.putlongint(longint(hi(low)));
  1560. end
  1561. else
  1562. ppufile.putlongint(low);
  1563. if sizeof(TConstExprInt)=8 then
  1564. begin
  1565. ppufile.putlongint(longint(lo(high)));
  1566. ppufile.putlongint(longint(hi(high)));
  1567. end
  1568. else
  1569. ppufile.putlongint(high);
  1570. ppufile.writeentry(iborddef);
  1571. end;
  1572. {$ifdef GDB}
  1573. function torddef.stabstring : pchar;
  1574. begin
  1575. case typ of
  1576. uvoid : stabstring := strpnew(numberstring+';');
  1577. {GDB 4.12 for go32 doesn't like boolean as range for 0 to 1 !!!}
  1578. {$ifdef Use_integer_types_for_boolean}
  1579. bool8bit,
  1580. bool16bit,
  1581. bool32bit : stabstring := strpnew('r'+numberstring+';0;255;');
  1582. {$else : not Use_integer_types_for_boolean}
  1583. uchar : stabstring := strpnew('-20;');
  1584. uwidechar : stabstring := strpnew('-30;');
  1585. bool8bit : stabstring := strpnew('-21;');
  1586. bool16bit : stabstring := strpnew('-22;');
  1587. bool32bit : stabstring := strpnew('-23;');
  1588. u64bit : stabstring := strpnew('-32;');
  1589. s64bit : stabstring := strpnew('-31;');
  1590. {$endif not Use_integer_types_for_boolean}
  1591. {u32bit : stabstring := tstoreddef(s32bittype.def).numberstring+';0;-1;'); }
  1592. else
  1593. stabstring := strpnew('r'+tstoreddef(s32bittype.def).numberstring+';'+tostr(longint(low))+';'+tostr(longint(high))+';');
  1594. end;
  1595. end;
  1596. {$endif GDB}
  1597. procedure torddef.write_rtti_data(rt:trttitype);
  1598. procedure dointeger;
  1599. const
  1600. trans : array[tbasetype] of byte =
  1601. (otUByte{otNone},
  1602. otUByte,otUWord,otULong,otUByte{otNone},
  1603. otSByte,otSWord,otSLong,otUByte{otNone},
  1604. otUByte,otUWord,otULong,
  1605. otUByte,otUWord);
  1606. begin
  1607. write_rtti_name;
  1608. rttiList.concat(Tai_const.Create_8bit(byte(trans[typ])));
  1609. rttiList.concat(Tai_const.Create_32bit(longint(low)));
  1610. rttiList.concat(Tai_const.Create_32bit(longint(high)));
  1611. end;
  1612. begin
  1613. case typ of
  1614. s64bit :
  1615. begin
  1616. rttiList.concat(Tai_const.Create_8bit(tkInt64));
  1617. write_rtti_name;
  1618. if target_info.endian=endian_little then
  1619. begin
  1620. { low }
  1621. rttiList.concat(Tai_const.Create_32bit($0));
  1622. rttiList.concat(Tai_const.Create_32bit(longint($80000000)));
  1623. { high }
  1624. rttiList.concat(Tai_const.Create_32bit(longint($ffffffff)));
  1625. rttiList.concat(Tai_const.Create_32bit($7fffffff));
  1626. end
  1627. else
  1628. begin
  1629. { low }
  1630. rttiList.concat(Tai_const.Create_32bit(longint($80000000)));
  1631. rttiList.concat(Tai_const.Create_32bit($0));
  1632. { high }
  1633. rttiList.concat(Tai_const.Create_32bit($7fffffff));
  1634. rttiList.concat(Tai_const.Create_32bit(longint($ffffffff)));
  1635. end;
  1636. end;
  1637. u64bit :
  1638. begin
  1639. rttiList.concat(Tai_const.Create_8bit(tkQWord));
  1640. write_rtti_name;
  1641. { low }
  1642. rttiList.concat(Tai_const.Create_32bit($0));
  1643. rttiList.concat(Tai_const.Create_32bit($0));
  1644. { high }
  1645. rttiList.concat(Tai_const.Create_32bit(longint($ffffffff)));
  1646. rttiList.concat(Tai_const.Create_32bit(longint($ffffffff)));
  1647. end;
  1648. bool8bit:
  1649. begin
  1650. rttiList.concat(Tai_const.Create_8bit(tkBool));
  1651. dointeger;
  1652. end;
  1653. uchar:
  1654. begin
  1655. rttiList.concat(Tai_const.Create_8bit(tkChar));
  1656. dointeger;
  1657. end;
  1658. uwidechar:
  1659. begin
  1660. rttiList.concat(Tai_const.Create_8bit(tkWChar));
  1661. dointeger;
  1662. end;
  1663. else
  1664. begin
  1665. rttiList.concat(Tai_const.Create_8bit(tkInteger));
  1666. dointeger;
  1667. end;
  1668. end;
  1669. end;
  1670. function torddef.is_publishable : boolean;
  1671. begin
  1672. is_publishable:=(typ<>uvoid);
  1673. end;
  1674. function torddef.gettypename : string;
  1675. const
  1676. names : array[tbasetype] of string[20] = (
  1677. 'untyped',
  1678. 'Byte','Word','DWord','QWord',
  1679. 'ShortInt','SmallInt','LongInt','Int64',
  1680. 'Boolean','WordBool','LongBool',
  1681. 'Char','WideChar');
  1682. begin
  1683. gettypename:=names[typ];
  1684. end;
  1685. {****************************************************************************
  1686. TFLOATDEF
  1687. ****************************************************************************}
  1688. constructor tfloatdef.create(t : tfloattype);
  1689. begin
  1690. inherited create;
  1691. deftype:=floatdef;
  1692. typ:=t;
  1693. setsize;
  1694. end;
  1695. constructor tfloatdef.ppuload(ppufile:tcompilerppufile);
  1696. begin
  1697. inherited ppuloaddef(ppufile);
  1698. deftype:=floatdef;
  1699. typ:=tfloattype(ppufile.getbyte);
  1700. setsize;
  1701. end;
  1702. function tfloatdef.getcopy : tstoreddef;
  1703. begin
  1704. result:=tfloatdef.create(typ);
  1705. result.deftype:=floatdef;
  1706. tfloatdef(result).savesize:=savesize;
  1707. end;
  1708. procedure tfloatdef.setsize;
  1709. begin
  1710. case typ of
  1711. s32real : savesize:=4;
  1712. s80real : savesize:=extended_size;
  1713. s64real,
  1714. s64currency,
  1715. s64comp : savesize:=8;
  1716. else
  1717. savesize:=0;
  1718. end;
  1719. end;
  1720. procedure tfloatdef.ppuwrite(ppufile:tcompilerppufile);
  1721. begin
  1722. inherited ppuwritedef(ppufile);
  1723. ppufile.putbyte(byte(typ));
  1724. ppufile.writeentry(ibfloatdef);
  1725. end;
  1726. {$ifdef GDB}
  1727. function tfloatdef.stabstring : pchar;
  1728. begin
  1729. case typ of
  1730. s32real,
  1731. s64real : stabstring := strpnew('r'+
  1732. tstoreddef(s32bittype.def).numberstring+';'+tostr(savesize)+';0;');
  1733. { found this solution in stabsread.c from GDB v4.16 }
  1734. s64currency,
  1735. s64comp : stabstring := strpnew('r'+
  1736. tstoreddef(s32bittype.def).numberstring+';-'+tostr(savesize)+';0;');
  1737. { under dos at least you must give a size of twelve instead of 10 !! }
  1738. { this is probably do to the fact that in gcc all is pushed in 4 bytes size }
  1739. s80real : stabstring := strpnew('r'+tstoreddef(s32bittype.def).numberstring+';12;0;');
  1740. else
  1741. internalerror(10005);
  1742. end;
  1743. end;
  1744. {$endif GDB}
  1745. procedure tfloatdef.write_rtti_data(rt:trttitype);
  1746. const
  1747. {tfloattype = (s32real,s64real,s80real,s64bit,s128bit);}
  1748. translate : array[tfloattype] of byte =
  1749. (ftSingle,ftDouble,ftExtended,ftComp,ftCurr,ftFloat128);
  1750. begin
  1751. rttiList.concat(Tai_const.Create_8bit(tkFloat));
  1752. write_rtti_name;
  1753. rttiList.concat(Tai_const.Create_8bit(translate[typ]));
  1754. end;
  1755. function tfloatdef.is_publishable : boolean;
  1756. begin
  1757. is_publishable:=true;
  1758. end;
  1759. function tfloatdef.gettypename : string;
  1760. const
  1761. names : array[tfloattype] of string[20] = (
  1762. 'Single','Double','Extended','Comp','Currency','Float128');
  1763. begin
  1764. gettypename:=names[typ];
  1765. end;
  1766. {****************************************************************************
  1767. TFILEDEF
  1768. ****************************************************************************}
  1769. constructor tfiledef.createtext;
  1770. begin
  1771. inherited create;
  1772. deftype:=filedef;
  1773. filetyp:=ft_text;
  1774. typedfiletype.reset;
  1775. setsize;
  1776. end;
  1777. constructor tfiledef.createuntyped;
  1778. begin
  1779. inherited create;
  1780. deftype:=filedef;
  1781. filetyp:=ft_untyped;
  1782. typedfiletype.reset;
  1783. setsize;
  1784. end;
  1785. constructor tfiledef.createtyped(const tt : ttype);
  1786. begin
  1787. inherited create;
  1788. deftype:=filedef;
  1789. filetyp:=ft_typed;
  1790. typedfiletype:=tt;
  1791. setsize;
  1792. end;
  1793. constructor tfiledef.ppuload(ppufile:tcompilerppufile);
  1794. begin
  1795. inherited ppuloaddef(ppufile);
  1796. deftype:=filedef;
  1797. filetyp:=tfiletyp(ppufile.getbyte);
  1798. if filetyp=ft_typed then
  1799. ppufile.gettype(typedfiletype)
  1800. else
  1801. typedfiletype.reset;
  1802. setsize;
  1803. end;
  1804. procedure tfiledef.deref;
  1805. begin
  1806. inherited deref;
  1807. if filetyp=ft_typed then
  1808. typedfiletype.resolve;
  1809. end;
  1810. procedure tfiledef.setsize;
  1811. begin
  1812. case filetyp of
  1813. ft_text :
  1814. savesize:=572;
  1815. ft_typed,
  1816. ft_untyped :
  1817. savesize:=316;
  1818. end;
  1819. end;
  1820. procedure tfiledef.ppuwrite(ppufile:tcompilerppufile);
  1821. begin
  1822. inherited ppuwritedef(ppufile);
  1823. ppufile.putbyte(byte(filetyp));
  1824. if filetyp=ft_typed then
  1825. ppufile.puttype(typedfiletype);
  1826. ppufile.writeentry(ibfiledef);
  1827. end;
  1828. {$ifdef GDB}
  1829. function tfiledef.stabstring : pchar;
  1830. begin
  1831. {$IfDef GDBknowsfiles}
  1832. case filetyp of
  1833. ft_typed :
  1834. stabstring := strpnew('d'+typedfiletype.def.numberstring{+';'});
  1835. ft_untyped :
  1836. stabstring := strpnew('d'+voiddef.numberstring{+';'});
  1837. ft_text :
  1838. stabstring := strpnew('d'+cchartype^.numberstring{+';'});
  1839. end;
  1840. {$Else}
  1841. {based on
  1842. FileRec = Packed Record
  1843. Handle,
  1844. Mode,
  1845. RecSize : longint;
  1846. _private : array[1..32] of byte;
  1847. UserData : array[1..16] of byte;
  1848. name : array[0..255] of char;
  1849. End; }
  1850. { the buffer part is still missing !! (PM) }
  1851. { but the string could become too long !! }
  1852. stabstring := strpnew('s'+tostr(savesize)+
  1853. 'HANDLE:'+typeglobalnumber('longint')+',0,32;'+
  1854. 'MODE:'+typeglobalnumber('longint')+',32,32;'+
  1855. 'RECSIZE:'+typeglobalnumber('longint')+',64,32;'+
  1856. '_PRIVATE:ar'+typeglobalnumber('word')+';1;32;'+typeglobalnumber('byte')
  1857. +',96,256;'+
  1858. 'USERDATA:ar'+typeglobalnumber('word')+';1;16;'+typeglobalnumber('byte')
  1859. +',352,128;'+
  1860. 'NAME:ar'+typeglobalnumber('word')+';0;255;'+typeglobalnumber('char')
  1861. +',480,2048;;');
  1862. {$EndIf}
  1863. end;
  1864. procedure tfiledef.concatstabto(asmlist : taasmoutput);
  1865. begin
  1866. { most file defs are unnamed !!! }
  1867. if ((typesym = nil) or ttypesym(typesym).isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1868. (is_def_stab_written = not_written) then
  1869. begin
  1870. if assigned(typedfiletype.def) then
  1871. forcestabto(asmlist,typedfiletype.def);
  1872. inherited concatstabto(asmlist);
  1873. end;
  1874. end;
  1875. {$endif GDB}
  1876. function tfiledef.gettypename : string;
  1877. begin
  1878. case filetyp of
  1879. ft_untyped:
  1880. gettypename:='File';
  1881. ft_typed:
  1882. gettypename:='File Of '+typedfiletype.def.typename;
  1883. ft_text:
  1884. gettypename:='Text'
  1885. end;
  1886. end;
  1887. function tfiledef.getmangledparaname : string;
  1888. begin
  1889. case filetyp of
  1890. ft_untyped:
  1891. getmangledparaname:='FILE';
  1892. ft_typed:
  1893. getmangledparaname:='FILE$OF$'+typedfiletype.def.mangledparaname;
  1894. ft_text:
  1895. getmangledparaname:='TEXT'
  1896. end;
  1897. end;
  1898. {****************************************************************************
  1899. TVARIANTDEF
  1900. ****************************************************************************}
  1901. constructor tvariantdef.create;
  1902. begin
  1903. inherited create;
  1904. deftype:=variantdef;
  1905. setsize;
  1906. end;
  1907. constructor tvariantdef.ppuload(ppufile:tcompilerppufile);
  1908. begin
  1909. inherited ppuloaddef(ppufile);
  1910. deftype:=variantdef;
  1911. setsize;
  1912. end;
  1913. procedure tvariantdef.ppuwrite(ppufile:tcompilerppufile);
  1914. begin
  1915. inherited ppuwritedef(ppufile);
  1916. ppufile.writeentry(ibvariantdef);
  1917. end;
  1918. procedure tvariantdef.setsize;
  1919. begin
  1920. savesize:=16;
  1921. end;
  1922. function tvariantdef.gettypename : string;
  1923. begin
  1924. gettypename:='Variant';
  1925. end;
  1926. procedure tvariantdef.write_rtti_data(rt:trttitype);
  1927. begin
  1928. rttiList.concat(Tai_const.Create_8bit(tkVariant));
  1929. end;
  1930. function tvariantdef.needs_inittable : boolean;
  1931. begin
  1932. needs_inittable:=true;
  1933. end;
  1934. {$ifdef GDB}
  1935. procedure tvariantdef.concatstabto(asmlist : taasmoutput);
  1936. begin
  1937. { don't know how to handle this }
  1938. end;
  1939. {$endif GDB}
  1940. {****************************************************************************
  1941. TPOINTERDEF
  1942. ****************************************************************************}
  1943. constructor tpointerdef.create(const tt : ttype);
  1944. begin
  1945. inherited create;
  1946. deftype:=pointerdef;
  1947. pointertype:=tt;
  1948. is_far:=false;
  1949. savesize:=POINTER_SIZE;
  1950. end;
  1951. constructor tpointerdef.createfar(const tt : ttype);
  1952. begin
  1953. inherited create;
  1954. deftype:=pointerdef;
  1955. pointertype:=tt;
  1956. is_far:=true;
  1957. savesize:=POINTER_SIZE;
  1958. end;
  1959. constructor tpointerdef.ppuload(ppufile:tcompilerppufile);
  1960. begin
  1961. inherited ppuloaddef(ppufile);
  1962. deftype:=pointerdef;
  1963. ppufile.gettype(pointertype);
  1964. is_far:=(ppufile.getbyte<>0);
  1965. savesize:=POINTER_SIZE;
  1966. end;
  1967. procedure tpointerdef.deref;
  1968. begin
  1969. inherited deref;
  1970. pointertype.resolve;
  1971. end;
  1972. procedure tpointerdef.ppuwrite(ppufile:tcompilerppufile);
  1973. begin
  1974. inherited ppuwritedef(ppufile);
  1975. ppufile.puttype(pointertype);
  1976. ppufile.putbyte(byte(is_far));
  1977. ppufile.writeentry(ibpointerdef);
  1978. end;
  1979. {$ifdef GDB}
  1980. function tpointerdef.stabstring : pchar;
  1981. begin
  1982. stabstring := strpnew('*'+tstoreddef(pointertype.def).numberstring);
  1983. end;
  1984. procedure tpointerdef.concatstabto(asmlist : taasmoutput);
  1985. var st,nb : string;
  1986. sym_line_no : longint;
  1987. begin
  1988. if assigned(pointertype.def) and
  1989. (pointertype.def.deftype=forwarddef) then
  1990. exit;
  1991. if ( (typesym=nil) or ttypesym(typesym).isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1992. (is_def_stab_written = not_written) then
  1993. begin
  1994. is_def_stab_written := being_written;
  1995. if assigned(pointertype.def) and
  1996. (pointertype.def.deftype in [recorddef,objectdef]) then
  1997. begin
  1998. if pointertype.def.deftype=objectdef then
  1999. nb:=tobjectdef(pointertype.def).classnumberstring
  2000. else
  2001. nb:=tstoreddef(pointertype.def).numberstring;
  2002. {to avoid infinite recursion in record with next-like fields }
  2003. if tstoreddef(pointertype.def).is_def_stab_written = being_written then
  2004. begin
  2005. if assigned(pointertype.def.typesym) then
  2006. begin
  2007. if assigned(typesym) then
  2008. begin
  2009. st := ttypesym(typesym).name;
  2010. sym_line_no:=ttypesym(typesym).fileinfo.line;
  2011. end
  2012. else
  2013. begin
  2014. st := ' ';
  2015. sym_line_no:=0;
  2016. end;
  2017. st := '"'+st+':t'+numberstring+'=*'+nb
  2018. +'=xs'+pointertype.def.typesym.name+':",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0';
  2019. asmList.concat(Tai_stabs.Create(strpnew(st)));
  2020. end;
  2021. end
  2022. else
  2023. begin
  2024. is_def_stab_written := not_written;
  2025. inherited concatstabto(asmlist);
  2026. end;
  2027. is_def_stab_written := written;
  2028. end
  2029. else
  2030. begin
  2031. if assigned(pointertype.def) then
  2032. forcestabto(asmlist,pointertype.def);
  2033. is_def_stab_written := not_written;
  2034. inherited concatstabto(asmlist);
  2035. end;
  2036. end;
  2037. end;
  2038. {$endif GDB}
  2039. function tpointerdef.gettypename : string;
  2040. begin
  2041. if is_far then
  2042. gettypename:='^'+pointertype.def.typename+';far'
  2043. else
  2044. gettypename:='^'+pointertype.def.typename;
  2045. end;
  2046. {****************************************************************************
  2047. TCLASSREFDEF
  2048. ****************************************************************************}
  2049. constructor tclassrefdef.create(const t:ttype);
  2050. begin
  2051. inherited create(t);
  2052. deftype:=classrefdef;
  2053. end;
  2054. constructor tclassrefdef.ppuload(ppufile:tcompilerppufile);
  2055. begin
  2056. { be careful, tclassdefref inherits from tpointerdef }
  2057. inherited ppuloaddef(ppufile);
  2058. deftype:=classrefdef;
  2059. ppufile.gettype(pointertype);
  2060. is_far:=false;
  2061. savesize:=POINTER_SIZE;
  2062. end;
  2063. procedure tclassrefdef.ppuwrite(ppufile:tcompilerppufile);
  2064. begin
  2065. { be careful, tclassdefref inherits from tpointerdef }
  2066. inherited ppuwritedef(ppufile);
  2067. ppufile.puttype(pointertype);
  2068. ppufile.writeentry(ibclassrefdef);
  2069. end;
  2070. {$ifdef GDB}
  2071. function tclassrefdef.stabstring : pchar;
  2072. begin
  2073. stabstring:=strpnew(tstoreddef(pvmttype.def).numberstring+';');
  2074. end;
  2075. procedure tclassrefdef.concatstabto(asmlist : taasmoutput);
  2076. begin
  2077. inherited concatstabto(asmlist);
  2078. end;
  2079. {$endif GDB}
  2080. function tclassrefdef.gettypename : string;
  2081. begin
  2082. gettypename:='Class Of '+pointertype.def.typename;
  2083. end;
  2084. {***************************************************************************
  2085. TSETDEF
  2086. ***************************************************************************}
  2087. constructor tsetdef.create(const t:ttype;high : longint);
  2088. begin
  2089. inherited create;
  2090. deftype:=setdef;
  2091. elementtype:=t;
  2092. if high<32 then
  2093. begin
  2094. settype:=smallset;
  2095. {$ifdef testvarsets}
  2096. if aktsetalloc=0 THEN { $PACKSET Fixed?}
  2097. {$endif}
  2098. savesize:=Sizeof(longint)
  2099. {$ifdef testvarsets}
  2100. else {No, use $PACKSET VALUE for rounding}
  2101. savesize:=aktsetalloc*((high+aktsetalloc*8-1) DIV (aktsetalloc*8))
  2102. {$endif}
  2103. ;
  2104. end
  2105. else
  2106. if high<256 then
  2107. begin
  2108. settype:=normset;
  2109. savesize:=32;
  2110. end
  2111. else
  2112. {$ifdef testvarsets}
  2113. if high<$10000 then
  2114. begin
  2115. settype:=varset;
  2116. savesize:=4*((high+31) div 32);
  2117. end
  2118. else
  2119. {$endif testvarsets}
  2120. Message(sym_e_ill_type_decl_set);
  2121. end;
  2122. constructor tsetdef.ppuload(ppufile:tcompilerppufile);
  2123. begin
  2124. inherited ppuloaddef(ppufile);
  2125. deftype:=setdef;
  2126. ppufile.gettype(elementtype);
  2127. settype:=tsettype(ppufile.getbyte);
  2128. case settype of
  2129. normset : savesize:=32;
  2130. varset : savesize:=ppufile.getlongint;
  2131. smallset : savesize:=Sizeof(longint);
  2132. end;
  2133. end;
  2134. destructor tsetdef.destroy;
  2135. begin
  2136. inherited destroy;
  2137. end;
  2138. procedure tsetdef.ppuwrite(ppufile:tcompilerppufile);
  2139. begin
  2140. inherited ppuwritedef(ppufile);
  2141. ppufile.puttype(elementtype);
  2142. ppufile.putbyte(byte(settype));
  2143. if settype=varset then
  2144. ppufile.putlongint(savesize);
  2145. ppufile.writeentry(ibsetdef);
  2146. end;
  2147. procedure tsetdef.changesettype(s:tsettype);
  2148. begin
  2149. case s of
  2150. smallset :
  2151. savesize:=sizeof(longint);
  2152. normset :
  2153. savesize:=32;
  2154. varset :
  2155. internalerror(200110201);
  2156. end;
  2157. settype:=s;
  2158. end;
  2159. {$ifdef GDB}
  2160. function tsetdef.stabstring : pchar;
  2161. begin
  2162. { For small sets write a longint, which can at least be seen
  2163. in the current GDB's (PFV)
  2164. this is obsolete with GDBPAS !!
  2165. and anyhow creates problems with version 4.18!! PM
  2166. if settype=smallset then
  2167. stabstring := strpnew('r'+s32bittype^.numberstring+';0;0xffffffff;')
  2168. else }
  2169. stabstring := strpnew('@s'+tostr(savesize*8)+';S'+tstoreddef(elementtype.def).numberstring);
  2170. end;
  2171. procedure tsetdef.concatstabto(asmlist : taasmoutput);
  2172. begin
  2173. if ( not assigned(typesym) or ttypesym(typesym).isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  2174. (is_def_stab_written = not_written) then
  2175. begin
  2176. if assigned(elementtype.def) then
  2177. forcestabto(asmlist,elementtype.def);
  2178. inherited concatstabto(asmlist);
  2179. end;
  2180. end;
  2181. {$endif GDB}
  2182. procedure tsetdef.deref;
  2183. begin
  2184. inherited deref;
  2185. elementtype.resolve;
  2186. end;
  2187. procedure tsetdef.write_child_rtti_data(rt:trttitype);
  2188. begin
  2189. tstoreddef(elementtype.def).get_rtti_label(rt);
  2190. end;
  2191. procedure tsetdef.write_rtti_data(rt:trttitype);
  2192. begin
  2193. rttiList.concat(Tai_const.Create_8bit(tkSet));
  2194. write_rtti_name;
  2195. rttiList.concat(Tai_const.Create_8bit(otULong));
  2196. rttiList.concat(Tai_const_symbol.Create(tstoreddef(elementtype.def).get_rtti_label(rt)));
  2197. end;
  2198. function tsetdef.is_publishable : boolean;
  2199. begin
  2200. is_publishable:=(settype=smallset);
  2201. end;
  2202. function tsetdef.gettypename : string;
  2203. begin
  2204. if assigned(elementtype.def) then
  2205. gettypename:='Set Of '+elementtype.def.typename
  2206. else
  2207. gettypename:='Empty Set';
  2208. end;
  2209. {***************************************************************************
  2210. TFORMALDEF
  2211. ***************************************************************************}
  2212. constructor tformaldef.create;
  2213. var
  2214. stregdef : boolean;
  2215. begin
  2216. stregdef:=registerdef;
  2217. registerdef:=false;
  2218. inherited create;
  2219. deftype:=formaldef;
  2220. registerdef:=stregdef;
  2221. { formaldef must be registered at unit level !! }
  2222. if registerdef and assigned(current_module) then
  2223. if assigned(current_module.localsymtable) then
  2224. tsymtable(current_module.localsymtable).registerdef(self)
  2225. else if assigned(current_module.globalsymtable) then
  2226. tsymtable(current_module.globalsymtable).registerdef(self);
  2227. savesize:=POINTER_SIZE;
  2228. end;
  2229. constructor tformaldef.ppuload(ppufile:tcompilerppufile);
  2230. begin
  2231. inherited ppuloaddef(ppufile);
  2232. deftype:=formaldef;
  2233. savesize:=POINTER_SIZE;
  2234. end;
  2235. procedure tformaldef.ppuwrite(ppufile:tcompilerppufile);
  2236. begin
  2237. inherited ppuwritedef(ppufile);
  2238. ppufile.writeentry(ibformaldef);
  2239. end;
  2240. {$ifdef GDB}
  2241. function tformaldef.stabstring : pchar;
  2242. begin
  2243. stabstring := strpnew('formal'+numberstring+';');
  2244. end;
  2245. procedure tformaldef.concatstabto(asmlist : taasmoutput);
  2246. begin
  2247. { formaldef can't be stab'ed !}
  2248. end;
  2249. {$endif GDB}
  2250. function tformaldef.gettypename : string;
  2251. begin
  2252. gettypename:='<Formal type>';
  2253. end;
  2254. {***************************************************************************
  2255. TARRAYDEF
  2256. ***************************************************************************}
  2257. constructor tarraydef.create(l,h : longint;const t : ttype);
  2258. begin
  2259. inherited create;
  2260. deftype:=arraydef;
  2261. lowrange:=l;
  2262. highrange:=h;
  2263. rangetype:=t;
  2264. elementtype.reset;
  2265. IsVariant:=false;
  2266. IsConstructor:=false;
  2267. IsArrayOfConst:=false;
  2268. IsDynamicArray:=false;
  2269. end;
  2270. constructor tarraydef.ppuload(ppufile:tcompilerppufile);
  2271. begin
  2272. inherited ppuloaddef(ppufile);
  2273. deftype:=arraydef;
  2274. { the addresses are calculated later }
  2275. ppufile.gettype(_elementtype);
  2276. ppufile.gettype(rangetype);
  2277. lowrange:=ppufile.getlongint;
  2278. highrange:=ppufile.getlongint;
  2279. IsArrayOfConst:=boolean(ppufile.getbyte);
  2280. IsDynamicArray:=boolean(ppufile.getbyte);
  2281. IsVariant:=false;
  2282. IsConstructor:=false;
  2283. end;
  2284. procedure tarraydef.deref;
  2285. begin
  2286. inherited deref;
  2287. _elementtype.resolve;
  2288. rangetype.resolve;
  2289. end;
  2290. procedure tarraydef.ppuwrite(ppufile:tcompilerppufile);
  2291. begin
  2292. inherited ppuwritedef(ppufile);
  2293. ppufile.puttype(_elementtype);
  2294. ppufile.puttype(rangetype);
  2295. ppufile.putlongint(lowrange);
  2296. ppufile.putlongint(highrange);
  2297. ppufile.putbyte(byte(IsArrayOfConst));
  2298. ppufile.putbyte(byte(IsDynamicArray));
  2299. ppufile.writeentry(ibarraydef);
  2300. end;
  2301. {$ifdef GDB}
  2302. function tarraydef.stabstring : pchar;
  2303. begin
  2304. stabstring := strpnew('ar'+tstoreddef(rangetype.def).numberstring+';'
  2305. +tostr(lowrange)+';'+tostr(highrange)+';'+tstoreddef(_elementtype.def).numberstring);
  2306. end;
  2307. procedure tarraydef.concatstabto(asmlist : taasmoutput);
  2308. begin
  2309. if (not assigned(typesym) or ttypesym(typesym).isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  2310. and (is_def_stab_written = not_written) then
  2311. begin
  2312. {when array are inserted they have no definition yet !!}
  2313. if assigned(_elementtype.def) then
  2314. inherited concatstabto(asmlist);
  2315. end;
  2316. end;
  2317. {$endif GDB}
  2318. function tarraydef.elesize : longint;
  2319. begin
  2320. elesize:=_elementtype.def.size;
  2321. end;
  2322. function tarraydef.size : longint;
  2323. var
  2324. _resultsize,
  2325. newsize,
  2326. cachedsize: TConstExprInt;
  2327. begin
  2328. if IsDynamicArray then
  2329. begin
  2330. size:=POINTER_SIZE;
  2331. exit;
  2332. end;
  2333. cachedsize := elesize;
  2334. {Tarraydef.size may never be called for an open array!}
  2335. if highrange<lowrange then
  2336. internalerror(99080501);
  2337. newsize:=(int64(highrange)-int64(lowrange)+1)*cachedsize;
  2338. if (cachedsize>0) and
  2339. (
  2340. (TConstExprInt(highrange)-TConstExprInt(lowrange) > $7fffffff) or
  2341. { () are needed around elesize-1 to avoid a possible
  2342. integer overflow for elesize=1 !! PM }
  2343. (($7fffffff div cachedsize + (cachedsize -1)) < (int64(highrange) - int64(lowrange)))
  2344. ) Then
  2345. begin
  2346. Message(sym_e_segment_too_large);
  2347. _resultsize := 4
  2348. end
  2349. else
  2350. begin
  2351. { prevent an overflow }
  2352. if newsize>high(longint) then
  2353. _resultsize:=high(longint)
  2354. else
  2355. _resultsize:=newsize;
  2356. end;
  2357. size := _resultsize;
  2358. end;
  2359. procedure tarraydef.setelementtype(t: ttype);
  2360. begin
  2361. _elementtype:=t;
  2362. If IsDynamicArray then
  2363. exit;
  2364. if (TConstExprInt(highrange)-TConstExprInt(lowrange) > $7fffffff) then
  2365. Message(sym_e_segment_too_large);
  2366. end;
  2367. function tarraydef.alignment : longint;
  2368. begin
  2369. { alignment is the size of the elements }
  2370. if elementtype.def.deftype=recorddef then
  2371. alignment:=elementtype.def.alignment
  2372. else
  2373. alignment:=elesize;
  2374. end;
  2375. function tarraydef.needs_inittable : boolean;
  2376. begin
  2377. needs_inittable:=IsDynamicArray or elementtype.def.needs_inittable;
  2378. end;
  2379. procedure tarraydef.write_child_rtti_data(rt:trttitype);
  2380. begin
  2381. tstoreddef(elementtype.def).get_rtti_label(rt);
  2382. end;
  2383. procedure tarraydef.write_rtti_data(rt:trttitype);
  2384. begin
  2385. if IsDynamicArray then
  2386. rttiList.concat(Tai_const.Create_8bit(tkdynarray))
  2387. else
  2388. rttiList.concat(Tai_const.Create_8bit(tkarray));
  2389. write_rtti_name;
  2390. { size of elements }
  2391. rttiList.concat(Tai_const.Create_32bit(elesize));
  2392. { count of elements }
  2393. if not(IsDynamicArray) then
  2394. rttiList.concat(Tai_const.Create_32bit(highrange-lowrange+1));
  2395. { element type }
  2396. rttiList.concat(Tai_const_symbol.Create(tstoreddef(elementtype.def).get_rtti_label(rt)));
  2397. { variant type }
  2398. // !!!!!!!!!!!!!!!!
  2399. end;
  2400. function tarraydef.gettypename : string;
  2401. begin
  2402. if isarrayofconst or isConstructor then
  2403. begin
  2404. if isvariant or ((highrange=-1) and (lowrange=0)) then
  2405. gettypename:='Array Of Const'
  2406. else
  2407. gettypename:='Array Of '+elementtype.def.typename;
  2408. end
  2409. else if ((highrange=-1) and (lowrange=0)) or IsDynamicArray then
  2410. gettypename:='Array Of '+elementtype.def.typename
  2411. else
  2412. begin
  2413. if rangetype.def.deftype=enumdef then
  2414. gettypename:='Array['+rangetype.def.typename+'] Of '+elementtype.def.typename
  2415. else
  2416. gettypename:='Array['+tostr(lowrange)+'..'+
  2417. tostr(highrange)+'] Of '+elementtype.def.typename
  2418. end;
  2419. end;
  2420. function tarraydef.getmangledparaname : string;
  2421. begin
  2422. if isarrayofconst then
  2423. getmangledparaname:='array_of_const'
  2424. else
  2425. if ((highrange=-1) and (lowrange=0)) then
  2426. getmangledparaname:='array_of_'+elementtype.def.mangledparaname
  2427. else
  2428. internalerror(200204176);
  2429. end;
  2430. {***************************************************************************
  2431. tabstractrecorddef
  2432. ***************************************************************************}
  2433. function tabstractrecorddef.getsymtable(t:tgetsymtable):tsymtable;
  2434. begin
  2435. if t=gs_record then
  2436. getsymtable:=symtable
  2437. else
  2438. getsymtable:=nil;
  2439. end;
  2440. {$ifdef GDB}
  2441. procedure tabstractrecorddef.addname(p : tnamedindexitem;arg:pointer);
  2442. var
  2443. news, newrec : pchar;
  2444. spec : string[3];
  2445. varsize : longint;
  2446. begin
  2447. { static variables from objects are like global objects }
  2448. if (sp_static in tsym(p).symoptions) then
  2449. exit;
  2450. If tsym(p).typ = varsym then
  2451. begin
  2452. if (sp_protected in tsym(p).symoptions) then
  2453. spec:='/1'
  2454. else if (sp_private in tsym(p).symoptions) then
  2455. spec:='/0'
  2456. else
  2457. spec:='';
  2458. if not assigned(tvarsym(p).vartype.def) then
  2459. writeln(tvarsym(p).name);
  2460. { class fields are pointers PM, obsolete now PM }
  2461. {if (tvarsym(p).vartype.def.deftype=objectdef) and
  2462. tobjectdef(tvarsym(p).vartype.def).is_class then
  2463. spec:=spec+'*'; }
  2464. varsize:=tvarsym(p).vartype.def.size;
  2465. { open arrays made overflows !! }
  2466. if varsize>$fffffff then
  2467. varsize:=$fffffff;
  2468. newrec := strpnew(p.name+':'+spec+tstoreddef(tvarsym(p).vartype.def).numberstring
  2469. +','+tostr(tvarsym(p).address*8)+','
  2470. +tostr(varsize*8)+';');
  2471. if strlen(StabRecString) + strlen(newrec) >= StabRecSize-256 then
  2472. begin
  2473. getmem(news,stabrecsize+memsizeinc);
  2474. strcopy(news,stabrecstring);
  2475. freemem(stabrecstring,stabrecsize);
  2476. stabrecsize:=stabrecsize+memsizeinc;
  2477. stabrecstring:=news;
  2478. end;
  2479. strcat(StabRecstring,newrec);
  2480. strdispose(newrec);
  2481. {This should be used for case !!}
  2482. inc(RecOffset,tvarsym(p).vartype.def.size);
  2483. end;
  2484. end;
  2485. {$endif GDB}
  2486. procedure tabstractrecorddef.count_field_rtti(sym : tnamedindexitem;arg:pointer);
  2487. begin
  2488. if (FRTTIType=fullrtti) or
  2489. ((tsym(sym).typ=varsym) and
  2490. tvarsym(sym).vartype.def.needs_inittable) then
  2491. inc(Count);
  2492. end;
  2493. procedure tabstractrecorddef.generate_field_rtti(sym:tnamedindexitem;arg:pointer);
  2494. begin
  2495. if (FRTTIType=fullrtti) or
  2496. ((tsym(sym).typ=varsym) and
  2497. tvarsym(sym).vartype.def.needs_inittable) then
  2498. tstoreddef(tvarsym(sym).vartype.def).get_rtti_label(FRTTIType);
  2499. end;
  2500. procedure tabstractrecorddef.write_field_rtti(sym : tnamedindexitem;arg:pointer);
  2501. begin
  2502. if (FRTTIType=fullrtti) or
  2503. ((tsym(sym).typ=varsym) and
  2504. tvarsym(sym).vartype.def.needs_inittable) then
  2505. begin
  2506. rttiList.concat(Tai_const_symbol.Create(tstoreddef(tvarsym(sym).vartype.def).get_rtti_label(FRTTIType)));
  2507. rttiList.concat(Tai_const.Create_32bit(tvarsym(sym).address));
  2508. end;
  2509. end;
  2510. {***************************************************************************
  2511. trecorddef
  2512. ***************************************************************************}
  2513. constructor trecorddef.create(p : tsymtable);
  2514. begin
  2515. inherited create;
  2516. deftype:=recorddef;
  2517. symtable:=p;
  2518. symtable.defowner:=self;
  2519. { recordalign -1 means C record packing, that starts
  2520. with an alignment of 1 }
  2521. if aktalignment.recordalignmax=-1 then
  2522. symtable.dataalignment:=1
  2523. else
  2524. symtable.dataalignment:=aktalignment.recordalignmax;
  2525. isunion:=false;
  2526. end;
  2527. constructor trecorddef.ppuload(ppufile:tcompilerppufile);
  2528. var
  2529. oldread_member : boolean;
  2530. begin
  2531. inherited ppuloaddef(ppufile);
  2532. deftype:=recorddef;
  2533. savesize:=ppufile.getlongint;
  2534. oldread_member:=read_member;
  2535. read_member:=true;
  2536. symtable:=trecordsymtable.create;
  2537. trecordsymtable(symtable).ppuload(ppufile);
  2538. read_member:=oldread_member;
  2539. symtable.defowner:=self;
  2540. isunion:=false;
  2541. end;
  2542. destructor trecorddef.destroy;
  2543. begin
  2544. if assigned(symtable) then
  2545. symtable.free;
  2546. inherited destroy;
  2547. end;
  2548. function trecorddef.needs_inittable : boolean;
  2549. begin
  2550. needs_inittable:=trecordsymtable(symtable).needs_init_final
  2551. end;
  2552. procedure trecorddef.deref;
  2553. var
  2554. oldrecsyms : tsymtable;
  2555. begin
  2556. inherited deref;
  2557. oldrecsyms:=aktrecordsymtable;
  2558. aktrecordsymtable:=symtable;
  2559. { now dereference the definitions }
  2560. tstoredsymtable(symtable).deref;
  2561. aktrecordsymtable:=oldrecsyms;
  2562. { assign TGUID? load only from system unit (unitid=1) }
  2563. if not(assigned(rec_tguid)) and
  2564. (upper(typename)='TGUID') and
  2565. assigned(owner) and
  2566. assigned(owner.name) and
  2567. (owner.name^='SYSTEM') then
  2568. rec_tguid:=self;
  2569. end;
  2570. procedure trecorddef.ppuwrite(ppufile:tcompilerppufile);
  2571. var
  2572. oldread_member : boolean;
  2573. begin
  2574. oldread_member:=read_member;
  2575. read_member:=true;
  2576. inherited ppuwritedef(ppufile);
  2577. ppufile.putlongint(savesize);
  2578. ppufile.writeentry(ibrecorddef);
  2579. trecordsymtable(symtable).ppuwrite(ppufile);
  2580. read_member:=oldread_member;
  2581. end;
  2582. function trecorddef.size:longint;
  2583. var
  2584. _resultsize : longint;
  2585. begin
  2586. _resultsize:=symtable.datasize;
  2587. size:=_resultsize;
  2588. end;
  2589. function trecorddef.alignment:longint;
  2590. var
  2591. l : longint;
  2592. hp : tvarsym;
  2593. begin
  2594. { also check the first symbol for it's size, because a
  2595. packed record has dataalignment of 1, but the first
  2596. sym could be a longint which should be aligned on 4 bytes,
  2597. this is compatible with C record packing (PFV) }
  2598. hp:=tvarsym(symtable.symindex.first);
  2599. if assigned(hp) then
  2600. begin
  2601. if hp.vartype.def.deftype in [recorddef,arraydef] then
  2602. l:=hp.vartype.def.alignment
  2603. else
  2604. l:=hp.vartype.def.size;
  2605. if l>symtable.dataalignment then
  2606. begin
  2607. if l>=4 then
  2608. alignment:=4
  2609. else
  2610. if l>=2 then
  2611. alignment:=2
  2612. else
  2613. alignment:=1;
  2614. end
  2615. else
  2616. alignment:=symtable.dataalignment;
  2617. end
  2618. else
  2619. alignment:=symtable.dataalignment;
  2620. end;
  2621. {$ifdef GDB}
  2622. function trecorddef.stabstring : pchar;
  2623. begin
  2624. GetMem(stabrecstring,memsizeinc);
  2625. stabrecsize:=memsizeinc;
  2626. strpcopy(stabRecString,'s'+tostr(size));
  2627. RecOffset := 0;
  2628. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}addname,nil);
  2629. strpcopy(strend(StabRecString),';');
  2630. stabstring := strnew(StabRecString);
  2631. Freemem(stabrecstring,stabrecsize);
  2632. end;
  2633. procedure trecorddef.concatstabto(asmlist : taasmoutput);
  2634. begin
  2635. if (not assigned(typesym) or ttypesym(typesym).isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  2636. (is_def_stab_written = not_written) then
  2637. inherited concatstabto(asmlist);
  2638. end;
  2639. {$endif GDB}
  2640. procedure trecorddef.write_child_rtti_data(rt:trttitype);
  2641. begin
  2642. FRTTIType:=rt;
  2643. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}generate_field_rtti,nil);
  2644. end;
  2645. procedure trecorddef.write_rtti_data(rt:trttitype);
  2646. begin
  2647. rttiList.concat(Tai_const.Create_8bit(tkrecord));
  2648. write_rtti_name;
  2649. rttiList.concat(Tai_const.Create_32bit(size));
  2650. Count:=0;
  2651. FRTTIType:=rt;
  2652. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}count_field_rtti,nil);
  2653. rttiList.concat(Tai_const.Create_32bit(Count));
  2654. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}write_field_rtti,nil);
  2655. end;
  2656. function trecorddef.gettypename : string;
  2657. begin
  2658. gettypename:='<record type>'
  2659. end;
  2660. {***************************************************************************
  2661. TABSTRACTPROCDEF
  2662. ***************************************************************************}
  2663. constructor tabstractprocdef.create;
  2664. begin
  2665. inherited create;
  2666. para:=TParaLinkedList.Create;
  2667. selfpara:=nil;
  2668. minparacount:=0;
  2669. maxparacount:=0;
  2670. proctypeoption:=potype_none;
  2671. proccalloption:=pocall_none;
  2672. procoptions:=[];
  2673. rettype:=voidtype;
  2674. symtablelevel:=0;
  2675. fpu_used:=0;
  2676. savesize:=POINTER_SIZE;
  2677. end;
  2678. destructor tabstractprocdef.destroy;
  2679. begin
  2680. Para.Free;
  2681. inherited destroy;
  2682. end;
  2683. function tabstractprocdef.concatpara(const tt:ttype;sym : tsym;vsp : tvarspez;defval:tsym):tparaitem;
  2684. var
  2685. hp : TParaItem;
  2686. begin
  2687. hp:=TParaItem.Create;
  2688. hp.paratyp:=vsp;
  2689. hp.parasym:=sym;
  2690. hp.paratype:=tt;
  2691. hp.defaultvalue:=defval;
  2692. Para.insert(hp);
  2693. { Don't count hidden parameters }
  2694. if (vsp<>vs_hidden) then
  2695. begin
  2696. if not assigned(defval) then
  2697. inc(minparacount);
  2698. inc(maxparacount);
  2699. end;
  2700. concatpara:=hp;
  2701. end;
  2702. { all functions returning in FPU are
  2703. assume to use 2 FPU registers
  2704. until the function implementation
  2705. is processed PM }
  2706. procedure tabstractprocdef.test_if_fpu_result;
  2707. begin
  2708. if assigned(rettype.def) and
  2709. (rettype.def.deftype=floatdef) then
  2710. fpu_used:=maxfpuregs;
  2711. end;
  2712. procedure tabstractprocdef.deref;
  2713. var
  2714. hp : TParaItem;
  2715. begin
  2716. inherited deref;
  2717. rettype.resolve;
  2718. hp:=TParaItem(Para.first);
  2719. while assigned(hp) do
  2720. begin
  2721. hp.paratype.resolve;
  2722. resolvesym(pointer(hp.defaultvalue));
  2723. resolvesym(pointer(hp.parasym));
  2724. hp:=TParaItem(hp.next);
  2725. end;
  2726. end;
  2727. constructor tabstractprocdef.ppuload(ppufile:tcompilerppufile);
  2728. var
  2729. hp : TParaItem;
  2730. count,i : word;
  2731. begin
  2732. inherited ppuloaddef(ppufile);
  2733. Para:=TParaLinkedList.Create;
  2734. selfpara:=nil;
  2735. minparacount:=0;
  2736. maxparacount:=0;
  2737. ppufile.gettype(rettype);
  2738. fpu_used:=ppufile.getbyte;
  2739. proctypeoption:=tproctypeoption(ppufile.getbyte);
  2740. proccalloption:=tproccalloption(ppufile.getbyte);
  2741. ppufile.getsmallset(procoptions);
  2742. { get the number of parameters }
  2743. count:=ppufile.getbyte;
  2744. savesize:=POINTER_SIZE;
  2745. for i:=1 to count do
  2746. begin
  2747. hp:=TParaItem.Create;
  2748. hp.paratyp:=tvarspez(ppufile.getbyte);
  2749. { hp.register:=tregister(ppufile.getbyte); }
  2750. ppufile.gettype(hp.paratype);
  2751. hp.defaultvalue:=tsym(ppufile.getderef);
  2752. hp.parasym:=tsym(ppufile.getderef);
  2753. { later, we'll gerate this on the fly (FK) }
  2754. ppufile.getdata(hp.paraloc,sizeof(tparalocation));
  2755. { Don't count hidden parameters }
  2756. if (hp.paratyp<>vs_hidden) then
  2757. begin
  2758. if not assigned(hp.defaultvalue) then
  2759. inc(minparacount);
  2760. inc(maxparacount);
  2761. end;
  2762. Para.concat(hp);
  2763. end;
  2764. end;
  2765. procedure tabstractprocdef.ppuwrite(ppufile:tcompilerppufile);
  2766. var
  2767. hp : TParaItem;
  2768. oldintfcrc : boolean;
  2769. begin
  2770. inherited ppuwritedef(ppufile);
  2771. ppufile.puttype(rettype);
  2772. oldintfcrc:=ppufile.do_interface_crc;
  2773. ppufile.do_interface_crc:=false;
  2774. if simplify_ppu then
  2775. fpu_used:=0;
  2776. ppufile.putbyte(fpu_used);
  2777. ppufile.putbyte(ord(proctypeoption));
  2778. ppufile.putbyte(ord(proccalloption));
  2779. ppufile.putsmallset(procoptions);
  2780. ppufile.do_interface_crc:=oldintfcrc;
  2781. ppufile.putbyte(maxparacount);
  2782. hp:=TParaItem(Para.first);
  2783. while assigned(hp) do
  2784. begin
  2785. ppufile.putbyte(byte(hp.paratyp));
  2786. { ppufile.putbyte(byte(hp.register)); }
  2787. ppufile.puttype(hp.paratype);
  2788. ppufile.putderef(hp.defaultvalue);
  2789. ppufile.putderef(hp.parasym);
  2790. ppufile.putdata(hp.paraloc,sizeof(tparalocation));
  2791. hp:=TParaItem(hp.next);
  2792. end;
  2793. end;
  2794. function tabstractprocdef.para_size(alignsize:longint) : longint;
  2795. var
  2796. pdc : TParaItem;
  2797. l : longint;
  2798. begin
  2799. l:=0;
  2800. pdc:=TParaItem(Para.first);
  2801. while assigned(pdc) do
  2802. begin
  2803. inc(l,paramanager.push_size(pdc.paratyp,pdc.paratype.def,proccalloption));
  2804. l:=align(l,alignsize);
  2805. if assigned(pdc.paratype.def) and
  2806. is_special_array(pdc.paratype.def) then
  2807. begin
  2808. inc(l,POINTER_SIZE);
  2809. l:=align(l,alignsize);
  2810. end;
  2811. pdc:=TParaItem(pdc.next);
  2812. end;
  2813. para_size:=l;
  2814. end;
  2815. function tabstractprocdef.typename_paras : string;
  2816. var
  2817. hs,s : string;
  2818. hp : TParaItem;
  2819. hpc : tconstsym;
  2820. begin
  2821. { look for a visible parameter }
  2822. hp:=TParaItem(Para.last);
  2823. while assigned(hp) do
  2824. begin
  2825. if hp.paratyp<>vs_hidden then
  2826. break;
  2827. hp:=TParaItem(hp.previous);
  2828. end;
  2829. { no visible parameter? }
  2830. if not(assigned(hp)) then
  2831. begin
  2832. typename_paras:='';
  2833. exit;
  2834. end;
  2835. hp:=TParaItem(Para.last);
  2836. s:='(';
  2837. while assigned(hp) do
  2838. begin
  2839. if hp.paratyp=vs_var then
  2840. s:=s+'var'
  2841. else if hp.paratyp=vs_const then
  2842. s:=s+'const'
  2843. else if hp.paratyp=vs_out then
  2844. s:=s+'out';
  2845. if hp.paratyp<>vs_hidden then
  2846. begin
  2847. if assigned(hp.paratype.def.typesym) then
  2848. begin
  2849. if hp.paratyp in [vs_var,vs_const,vs_out] then
  2850. s := s + ' ';
  2851. hs:=hp.paratype.def.typesym.realname;
  2852. if hs[1]<>'$' then
  2853. s:=s+hp.paratype.def.typesym.realname
  2854. else
  2855. s:=s+hp.paratype.def.gettypename;
  2856. end;
  2857. { default value }
  2858. if assigned(hp.defaultvalue) then
  2859. begin
  2860. hpc:=tconstsym(hp.defaultvalue);
  2861. hs:='';
  2862. case hpc.consttyp of
  2863. conststring,
  2864. constresourcestring :
  2865. hs:=strpas(pchar(hpc.value.valueptr));
  2866. constreal :
  2867. str(pbestreal(hpc.value.valueptr)^,hs);
  2868. constord :
  2869. hs:=tostr(hpc.value.valueord);
  2870. constpointer :
  2871. hs:=tostr(hpc.value.valueordptr);
  2872. constbool :
  2873. begin
  2874. if hpc.value.valueord<>0 then
  2875. hs:='TRUE'
  2876. else
  2877. hs:='FALSE';
  2878. end;
  2879. constnil :
  2880. hs:='nil';
  2881. constchar :
  2882. hs:=chr(hpc.value.valueord);
  2883. constset :
  2884. hs:='<set>';
  2885. end;
  2886. if hs<>'' then
  2887. s:=s+'="'+hs+'"';
  2888. end;
  2889. end;
  2890. hp:=TParaItem(hp.previous);
  2891. if assigned(hp) and (hp.paratyp<>vs_hidden) then
  2892. s:=s+',';
  2893. end;
  2894. s:=s+')';
  2895. if (po_varargs in procoptions) then
  2896. s:=s+';VarArgs';
  2897. typename_paras:=s;
  2898. end;
  2899. function tabstractprocdef.is_methodpointer:boolean;
  2900. begin
  2901. result:=false;
  2902. end;
  2903. function tabstractprocdef.is_addressonly:boolean;
  2904. begin
  2905. result:=true;
  2906. end;
  2907. {$ifdef GDB}
  2908. function tabstractprocdef.stabstring : pchar;
  2909. begin
  2910. stabstring := strpnew('abstractproc'+numberstring+';');
  2911. end;
  2912. procedure tabstractprocdef.concatstabto(asmlist : taasmoutput);
  2913. begin
  2914. if (not assigned(typesym) or ttypesym(typesym).isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  2915. and (is_def_stab_written = not_written) then
  2916. begin
  2917. if assigned(rettype.def) then forcestabto(asmlist,rettype.def);
  2918. inherited concatstabto(asmlist);
  2919. end;
  2920. end;
  2921. {$endif GDB}
  2922. {***************************************************************************
  2923. TPROCDEF
  2924. ***************************************************************************}
  2925. constructor tprocdef.create;
  2926. begin
  2927. inherited create;
  2928. deftype:=procdef;
  2929. has_mangledname:=false;
  2930. _mangledname:=nil;
  2931. fileinfo:=aktfilepos;
  2932. extnumber:=$ffff;
  2933. aliasnames:=tstringlist.create;
  2934. parast:=tparasymtable.create;
  2935. funcretsym:=nil;
  2936. localst := nil;
  2937. parast.defowner:=self;
  2938. defref:=nil;
  2939. lastwritten:=nil;
  2940. refcount:=0;
  2941. if (cs_browser in aktmoduleswitches) and make_ref then
  2942. begin
  2943. defref:=tref.create(defref,@akttokenpos);
  2944. inc(refcount);
  2945. end;
  2946. lastref:=defref;
  2947. { first, we assume that all registers are used }
  2948. usedregisters:=ALL_REGISTERS;
  2949. forwarddef:=true;
  2950. interfacedef:=false;
  2951. hasforward:=false;
  2952. _class := nil;
  2953. code:=nil;
  2954. regvarinfo := nil;
  2955. overloadnumber:=0;
  2956. {$ifdef GDB}
  2957. isstabwritten := false;
  2958. {$endif GDB}
  2959. end;
  2960. constructor tprocdef.ppuload(ppufile:tcompilerppufile);
  2961. begin
  2962. inherited ppuload(ppufile);
  2963. deftype:=procdef;
  2964. ppufile.getnormalset(usedregisters);
  2965. has_mangledname:=boolean(ppufile.getbyte);
  2966. if has_mangledname then
  2967. _mangledname:=stringdup(ppufile.getstring)
  2968. else
  2969. _mangledname:=nil;
  2970. overloadnumber:=ppufile.getword;
  2971. extnumber:=ppufile.getword;
  2972. _class := tobjectdef(ppufile.getderef);
  2973. procsym := tsym(ppufile.getderef);
  2974. ppufile.getposinfo(fileinfo);
  2975. { inline stuff }
  2976. if proccalloption=pocall_inline then
  2977. begin
  2978. funcretsym:=tsym(ppufile.getderef);
  2979. code:=ppuloadnode(ppufile);
  2980. end
  2981. else
  2982. begin
  2983. code := nil;
  2984. funcretsym:=nil;
  2985. end;
  2986. { load para and local symtables }
  2987. parast:=tparasymtable.create;
  2988. tparasymtable(parast).ppuload(ppufile);
  2989. parast.defowner:=self;
  2990. if (proccalloption=pocall_inline) or
  2991. ((current_module.flags and uf_local_browser)<>0) then
  2992. begin
  2993. localst:=tlocalsymtable.create;
  2994. tlocalsymtable(localst).ppuload(ppufile);
  2995. localst.defowner:=self;
  2996. end
  2997. else
  2998. localst:=nil;
  2999. { default values for no persistent data }
  3000. if (cs_link_deffile in aktglobalswitches) and
  3001. (tf_need_export in target_info.flags) and
  3002. (po_exports in procoptions) then
  3003. deffile.AddExport(mangledname);
  3004. aliasnames:=tstringlist.create;
  3005. forwarddef:=false;
  3006. interfacedef:=false;
  3007. hasforward:=false;
  3008. regvarinfo := nil;
  3009. lastref:=nil;
  3010. lastwritten:=nil;
  3011. defref:=nil;
  3012. refcount:=0;
  3013. {$ifdef GDB}
  3014. isstabwritten := false;
  3015. {$endif GDB}
  3016. end;
  3017. destructor tprocdef.destroy;
  3018. begin
  3019. if assigned(defref) then
  3020. begin
  3021. defref.freechain;
  3022. defref.free;
  3023. end;
  3024. aliasnames.free;
  3025. if assigned(parast) then
  3026. begin
  3027. {$ifdef MEMDEBUG}
  3028. memprocparast.start;
  3029. {$endif MEMDEBUG}
  3030. parast.free;
  3031. {$ifdef MEMDEBUG}
  3032. memprocparast.stop;
  3033. {$endif MEMDEBUG}
  3034. end;
  3035. if assigned(localst) and (localst.symtabletype<>staticsymtable) then
  3036. begin
  3037. {$ifdef MEMDEBUG}
  3038. memproclocalst.start;
  3039. {$endif MEMDEBUG}
  3040. localst.free;
  3041. {$ifdef MEMDEBUG}
  3042. memproclocalst.start;
  3043. {$endif MEMDEBUG}
  3044. end;
  3045. if (proccalloption=pocall_inline) and assigned(code) then
  3046. begin
  3047. {$ifdef MEMDEBUG}
  3048. memprocnodetree.start;
  3049. {$endif MEMDEBUG}
  3050. tnode(code).free;
  3051. {$ifdef MEMDEBUG}
  3052. memprocnodetree.start;
  3053. {$endif MEMDEBUG}
  3054. end;
  3055. if assigned(regvarinfo) then
  3056. dispose(pregvarinfo(regvarinfo));
  3057. if (po_msgstr in procoptions) then
  3058. strdispose(messageinf.str);
  3059. if assigned(_mangledname) then
  3060. begin
  3061. {$ifdef MEMDEBUG}
  3062. memmanglednames.start;
  3063. {$endif MEMDEBUG}
  3064. stringdispose(_mangledname);
  3065. {$ifdef MEMDEBUG}
  3066. memmanglednames.stop;
  3067. {$endif MEMDEBUG}
  3068. end;
  3069. inherited destroy;
  3070. end;
  3071. procedure tprocdef.ppuwrite(ppufile:tcompilerppufile);
  3072. var
  3073. oldintfcrc : boolean;
  3074. begin
  3075. inherited ppuwrite(ppufile);
  3076. oldintfcrc:=ppufile.do_interface_crc;
  3077. ppufile.do_interface_crc:=false;
  3078. { set all registers to used for simplified compilation PM }
  3079. if simplify_ppu then
  3080. begin
  3081. usedregisters:=ALL_REGISTERS;
  3082. end;
  3083. ppufile.putnormalset(usedregisters);
  3084. ppufile.do_interface_crc:=oldintfcrc;
  3085. ppufile.putbyte(byte(has_mangledname));
  3086. if has_mangledname then
  3087. ppufile.putstring(mangledname);
  3088. ppufile.putword(overloadnumber);
  3089. ppufile.putword(extnumber);
  3090. ppufile.putderef(_class);
  3091. ppufile.putderef(procsym);
  3092. ppufile.putposinfo(fileinfo);
  3093. { inline stuff references to localsymtable, no influence
  3094. on the crc }
  3095. oldintfcrc:=ppufile.do_crc;
  3096. ppufile.do_crc:=false;
  3097. { inline stuff }
  3098. if proccalloption=pocall_inline then
  3099. begin
  3100. ppufile.putderef(funcretsym);
  3101. ppuwritenode(ppufile,code);
  3102. end;
  3103. ppufile.do_crc:=oldintfcrc;
  3104. { write this entry }
  3105. ppufile.writeentry(ibprocdef);
  3106. { Save the para symtable, this is taken from the interface }
  3107. if not assigned(parast) then
  3108. begin
  3109. parast:=tparasymtable.create;
  3110. parast.defowner:=self;
  3111. end;
  3112. tparasymtable(parast).ppuwrite(ppufile);
  3113. { save localsymtable for inline procedures or when local
  3114. browser info is requested, this has no influence on the crc }
  3115. if (proccalloption=pocall_inline) or
  3116. ((current_module.flags and uf_local_browser)<>0) then
  3117. begin
  3118. oldintfcrc:=ppufile.do_crc;
  3119. ppufile.do_crc:=false;
  3120. if not assigned(localst) then
  3121. begin
  3122. localst:=tlocalsymtable.create;
  3123. localst.defowner:=self;
  3124. end;
  3125. tlocalsymtable(localst).ppuwrite(ppufile);
  3126. ppufile.do_crc:=oldintfcrc;
  3127. end;
  3128. end;
  3129. procedure tprocdef.insert_localst;
  3130. begin
  3131. localst:=tlocalsymtable.create;
  3132. localst.defowner:=self;
  3133. { this is used by insert
  3134. to check same names in parast and localst }
  3135. localst.next:=parast;
  3136. end;
  3137. function tprocdef.fullprocname:string;
  3138. var
  3139. s : string;
  3140. begin
  3141. s:='';
  3142. if assigned(_class) then
  3143. begin
  3144. if po_classmethod in procoptions then
  3145. s:=s+'class ';
  3146. s:=s+_class.objrealname^+'.';
  3147. end;
  3148. s:=s+procsym.realname+typename_paras;
  3149. fullprocname:=s;
  3150. end;
  3151. function tprocdef.fullprocnamewithret:string;
  3152. var
  3153. s : string;
  3154. begin
  3155. s:=fullprocname;
  3156. if assigned(rettype.def) and
  3157. not(is_void(rettype.def)) then
  3158. s:=s+' : '+rettype.def.gettypename;
  3159. fullprocnamewithret:=s;
  3160. end;
  3161. function tprocdef.is_methodpointer:boolean;
  3162. begin
  3163. result:=assigned(owner) and
  3164. (owner.symtabletype=objectsymtable);
  3165. end;
  3166. function tprocdef.is_addressonly:boolean;
  3167. begin
  3168. result:=assigned(owner) and
  3169. (owner.symtabletype<>objectsymtable);
  3170. end;
  3171. function tprocdef.getsymtable(t:tgetsymtable):tsymtable;
  3172. begin
  3173. case t of
  3174. gs_local :
  3175. getsymtable:=localst;
  3176. gs_para :
  3177. getsymtable:=parast;
  3178. else
  3179. getsymtable:=nil;
  3180. end;
  3181. end;
  3182. procedure tprocdef.load_references(ppufile:tcompilerppufile;locals:boolean);
  3183. var
  3184. pos : tfileposinfo;
  3185. move_last : boolean;
  3186. begin
  3187. move_last:=lastwritten=lastref;
  3188. while (not ppufile.endofentry) do
  3189. begin
  3190. ppufile.getposinfo(pos);
  3191. inc(refcount);
  3192. lastref:=tref.create(lastref,@pos);
  3193. lastref.is_written:=true;
  3194. if refcount=1 then
  3195. defref:=lastref;
  3196. end;
  3197. if move_last then
  3198. lastwritten:=lastref;
  3199. if ((current_module.flags and uf_local_browser)<>0) and
  3200. locals then
  3201. begin
  3202. tparasymtable(parast).load_references(ppufile,locals);
  3203. tlocalsymtable(localst).load_references(ppufile,locals);
  3204. end;
  3205. end;
  3206. Const
  3207. local_symtable_index : word = $8001;
  3208. function tprocdef.write_references(ppufile:tcompilerppufile;locals:boolean):boolean;
  3209. var
  3210. ref : tref;
  3211. pdo : tobjectdef;
  3212. move_last : boolean;
  3213. begin
  3214. move_last:=lastwritten=lastref;
  3215. if move_last and
  3216. (((current_module.flags and uf_local_browser)=0) or
  3217. not locals) then
  3218. exit;
  3219. { write address of this symbol }
  3220. ppufile.putderef(self);
  3221. { write refs }
  3222. if assigned(lastwritten) then
  3223. ref:=lastwritten
  3224. else
  3225. ref:=defref;
  3226. while assigned(ref) do
  3227. begin
  3228. if ref.moduleindex=current_module.unit_index then
  3229. begin
  3230. ppufile.putposinfo(ref.posinfo);
  3231. ref.is_written:=true;
  3232. if move_last then
  3233. lastwritten:=ref;
  3234. end
  3235. else if not ref.is_written then
  3236. move_last:=false
  3237. else if move_last then
  3238. lastwritten:=ref;
  3239. ref:=ref.nextref;
  3240. end;
  3241. ppufile.writeentry(ibdefref);
  3242. write_references:=true;
  3243. if ((current_module.flags and uf_local_browser)<>0) and
  3244. locals then
  3245. begin
  3246. pdo:=_class;
  3247. if (owner.symtabletype<>localsymtable) then
  3248. while assigned(pdo) do
  3249. begin
  3250. if pdo.symtable<>aktrecordsymtable then
  3251. begin
  3252. pdo.symtable.unitid:=local_symtable_index;
  3253. inc(local_symtable_index);
  3254. end;
  3255. pdo:=pdo.childof;
  3256. end;
  3257. parast.unitid:=local_symtable_index;
  3258. inc(local_symtable_index);
  3259. localst.unitid:=local_symtable_index;
  3260. inc(local_symtable_index);
  3261. tstoredsymtable(parast).write_references(ppufile,locals);
  3262. tstoredsymtable(localst).write_references(ppufile,locals);
  3263. { decrement for }
  3264. local_symtable_index:=local_symtable_index-2;
  3265. pdo:=_class;
  3266. if (owner.symtabletype<>localsymtable) then
  3267. while assigned(pdo) do
  3268. begin
  3269. if pdo.symtable<>aktrecordsymtable then
  3270. dec(local_symtable_index);
  3271. pdo:=pdo.childof;
  3272. end;
  3273. end;
  3274. end;
  3275. function tprocdef.haspara:boolean;
  3276. begin
  3277. haspara:=assigned(parast.symindex.first);
  3278. end;
  3279. {$ifdef GDB}
  3280. {$ifdef unused}
  3281. { procedure addparaname(p : tsym);
  3282. var vs : char;
  3283. begin
  3284. if tvarsym(p).varspez = vs_value then vs := '1'
  3285. else vs := '0';
  3286. strpcopy(strend(StabRecString),p^.name+':'+tstoreddef(tvarsym(p).vartype.def).numberstring+','+vs+';');
  3287. end; }
  3288. function tprocdef.stabstring : pchar;
  3289. var
  3290. i : longint;
  3291. stabrecstring : pchar;
  3292. begin
  3293. getmem(StabRecString,1024);
  3294. strpcopy(StabRecString,'f'+tstoreddef(rettype.def).numberstring);
  3295. i:=maxparacount;
  3296. if i>0 then
  3297. begin
  3298. strpcopy(strend(StabRecString),','+tostr(i)+';');
  3299. (* confuse gdb !! PM
  3300. if assigned(parast) then
  3301. parast.foreach({$ifdef FPCPROCVAR}@{$endif}addparaname)
  3302. else
  3303. begin
  3304. param := para1;
  3305. i := 0;
  3306. while assigned(param) do
  3307. begin
  3308. inc(i);
  3309. if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
  3310. {Here we have lost the parameter names !!}
  3311. {using lower case parameters }
  3312. strpcopy(strend(stabrecstring),'p'+tostr(i)
  3313. +':'+param^.paratype.def.numberstring+','+vartyp+';');
  3314. param := param^.next;
  3315. end;
  3316. end; *)
  3317. {strpcopy(strend(StabRecString),';');}
  3318. end;
  3319. stabstring := strnew(stabrecstring);
  3320. freemem(stabrecstring,1024);
  3321. end;
  3322. {$endif unused}
  3323. function tprocdef.stabstring: pchar;
  3324. Var RType : Char;
  3325. Obj,Info : String;
  3326. stabsstr : string;
  3327. p : pchar;
  3328. begin
  3329. obj := procsym.name;
  3330. info := '';
  3331. if tprocsym(procsym).is_global then
  3332. RType := 'F'
  3333. else
  3334. RType := 'f';
  3335. if assigned(owner) then
  3336. begin
  3337. if (owner.symtabletype = objectsymtable) then
  3338. obj := owner.name^+'__'+procsym.name;
  3339. { this code was correct only as long as the local symboltable
  3340. of the parent had the same name as the function
  3341. but this is no true anymore !! PM
  3342. if (owner.symtabletype=localsymtable) and assigned(owner.name) then
  3343. info := ','+name+','+owner.name^; }
  3344. if (owner.symtabletype=localsymtable) and
  3345. assigned(owner.defowner) and
  3346. assigned(tprocdef(owner.defowner).procsym) then
  3347. info := ','+procsym.name+','+tprocdef(owner.defowner).procsym.name;
  3348. end;
  3349. stabsstr:=mangledname;
  3350. getmem(p,length(stabsstr)+255);
  3351. strpcopy(p,'"'+obj+':'+RType
  3352. +tstoreddef(rettype.def).numberstring+info+'",'+tostr(n_function)
  3353. +',0,'+
  3354. tostr(fileinfo.line)
  3355. +',');
  3356. strpcopy(strend(p),stabsstr);
  3357. stabstring:=strnew(p);
  3358. freemem(p,length(stabsstr)+255);
  3359. end;
  3360. procedure tprocdef.concatstabto(asmlist : taasmoutput);
  3361. begin
  3362. if (proccalloption=pocall_internproc) then
  3363. exit;
  3364. if not isstabwritten then
  3365. asmList.concat(Tai_stabs.Create(stabstring));
  3366. isstabwritten := true;
  3367. if assigned(parast) then
  3368. tstoredsymtable(parast).concatstabto(asmlist);
  3369. { local type defs and vars should not be written
  3370. inside the main proc stab }
  3371. if assigned(localst) and
  3372. (lexlevel>main_program_level) then
  3373. tstoredsymtable(localst).concatstabto(asmlist);
  3374. is_def_stab_written := written;
  3375. end;
  3376. {$endif GDB}
  3377. procedure tprocdef.deref;
  3378. var
  3379. oldlocalsymtable : tsymtable;
  3380. begin
  3381. inherited deref;
  3382. resolvedef(pointer(_class));
  3383. { parast }
  3384. oldlocalsymtable:=aktlocalsymtable;
  3385. aktlocalsymtable:=parast;
  3386. tparasymtable(parast).deref;
  3387. aktlocalsymtable:=oldlocalsymtable;
  3388. { procsym that originaly defined this definition, should be in the
  3389. same symtable }
  3390. resolvesym(pointer(procsym));
  3391. end;
  3392. procedure tprocdef.derefimpl;
  3393. var
  3394. oldlocalsymtable : tsymtable;
  3395. begin
  3396. { locals }
  3397. if assigned(localst) then
  3398. begin
  3399. { localst }
  3400. oldlocalsymtable:=aktlocalsymtable;
  3401. aktlocalsymtable:=localst;
  3402. { we can deref both interface and implementation parts }
  3403. tlocalsymtable(localst).deref;
  3404. tlocalsymtable(localst).derefimpl;
  3405. aktlocalsymtable:=oldlocalsymtable;
  3406. { funcretsym, this is always located in the localst }
  3407. resolvesym(pointer(funcretsym));
  3408. end
  3409. else
  3410. begin
  3411. { safety }
  3412. funcretsym:=nil;
  3413. end;
  3414. { inline tree }
  3415. if (proccalloption=pocall_inline) then
  3416. code.derefimpl;
  3417. end;
  3418. function tprocdef.gettypename : string;
  3419. begin
  3420. gettypename := FullProcName+';'+ProcCallOptionStr[proccalloption];
  3421. end;
  3422. function tprocdef.mangledname : string;
  3423. var
  3424. s : string;
  3425. hp : TParaItem;
  3426. begin
  3427. if assigned(_mangledname) then
  3428. begin
  3429. mangledname:=_mangledname^;
  3430. exit;
  3431. end;
  3432. { we need to use the symtable where the procsym is inserted,
  3433. because that is visible to the world }
  3434. s:=mangledname_prefix('',procsym.owner)+procsym.name;
  3435. if overloadnumber>0 then
  3436. s:=s+'$'+tostr(overloadnumber);
  3437. { add parameter types }
  3438. hp:=TParaItem(Para.last);
  3439. if assigned(hp) and (hp.paratyp<>vs_hidden) then
  3440. s:=s+'$';
  3441. while assigned(hp) do
  3442. begin
  3443. if hp.paratyp<>vs_hidden then
  3444. s:=s+hp.paratype.def.mangledparaname;
  3445. hp:=TParaItem(hp.previous);
  3446. if assigned(hp) and (hp.paratyp<>vs_hidden) then
  3447. s:=s+'$';
  3448. end;
  3449. _mangledname:=stringdup(s);
  3450. mangledname:=_mangledname^;
  3451. end;
  3452. function tprocdef.cplusplusmangledname : string;
  3453. function getcppparaname(p : tdef) : string;
  3454. const
  3455. ordtype2str : array[tbasetype] of string[2] = (
  3456. '',
  3457. 'Uc','Us','Ui','Us',
  3458. 'Sc','s','i','x',
  3459. 'b','b','b',
  3460. 'c','w');
  3461. var
  3462. s : string;
  3463. begin
  3464. case p.deftype of
  3465. orddef:
  3466. s:=ordtype2str[torddef(p).typ];
  3467. pointerdef:
  3468. s:='P'+getcppparaname(tpointerdef(p).pointertype.def);
  3469. else
  3470. internalerror(2103001);
  3471. end;
  3472. getcppparaname:=s;
  3473. end;
  3474. var
  3475. s,s2 : string;
  3476. param : TParaItem;
  3477. begin
  3478. s := procsym.realname;
  3479. if procsym.owner.symtabletype=objectsymtable then
  3480. begin
  3481. s2:=upper(tobjectdef(procsym.owner.defowner).typesym.realname);
  3482. case proctypeoption of
  3483. potype_destructor:
  3484. s:='_$_'+tostr(length(s2))+s2;
  3485. potype_constructor:
  3486. s:='___'+tostr(length(s2))+s2;
  3487. else
  3488. s:='_'+s+'__'+tostr(length(s2))+s2;
  3489. end;
  3490. end
  3491. else s:=s+'__';
  3492. s:=s+'F';
  3493. { concat modifiers }
  3494. { !!!!! }
  3495. { now we handle the parameters }
  3496. param := TParaItem(Para.first);
  3497. if assigned(param) then
  3498. while assigned(param) do
  3499. begin
  3500. s2:=getcppparaname(param.paratype.def);
  3501. if param.paratyp in [vs_var,vs_out] then
  3502. s2:='R'+s2;
  3503. s:=s+s2;
  3504. param:=TParaItem(param.next);
  3505. end
  3506. else
  3507. s:=s+'v';
  3508. cplusplusmangledname:=s;
  3509. end;
  3510. procedure tprocdef.setmangledname(const s : string);
  3511. begin
  3512. stringdispose(_mangledname);
  3513. _mangledname:=stringdup(s);
  3514. has_mangledname:=true;
  3515. end;
  3516. {***************************************************************************
  3517. TPROCVARDEF
  3518. ***************************************************************************}
  3519. constructor tprocvardef.create;
  3520. begin
  3521. inherited create;
  3522. deftype:=procvardef;
  3523. end;
  3524. constructor tprocvardef.ppuload(ppufile:tcompilerppufile);
  3525. begin
  3526. inherited ppuload(ppufile);
  3527. deftype:=procvardef;
  3528. end;
  3529. procedure tprocvardef.ppuwrite(ppufile:tcompilerppufile);
  3530. begin
  3531. { here we cannot get a real good value so just give something }
  3532. { plausible (PM) }
  3533. { a more secure way would be
  3534. to allways store in a temp }
  3535. if is_fpu(rettype.def) then
  3536. fpu_used:={2}maxfpuregs
  3537. else
  3538. fpu_used:=0;
  3539. inherited ppuwrite(ppufile);
  3540. ppufile.writeentry(ibprocvardef);
  3541. end;
  3542. function tprocvardef.size : longint;
  3543. begin
  3544. if (po_methodpointer in procoptions) and
  3545. not(po_addressonly in procoptions) then
  3546. size:=2*POINTER_SIZE
  3547. else
  3548. size:=POINTER_SIZE;
  3549. end;
  3550. function tprocvardef.is_methodpointer:boolean;
  3551. begin
  3552. result:=(po_methodpointer in procoptions);
  3553. end;
  3554. function tprocvardef.is_addressonly:boolean;
  3555. begin
  3556. result:=not(po_methodpointer in procoptions) or
  3557. (po_addressonly in procoptions);
  3558. end;
  3559. {$ifdef GDB}
  3560. function tprocvardef.stabstring : pchar;
  3561. var
  3562. nss : pchar;
  3563. { i : longint; }
  3564. begin
  3565. { i := maxparacount; }
  3566. getmem(nss,1024);
  3567. { it is not a function but a function pointer !! (PM) }
  3568. strpcopy(nss,'*f'+tstoreddef(rettype.def).numberstring{+','+tostr(i)}+';');
  3569. { this confuses gdb !!
  3570. we should use 'F' instead of 'f' but
  3571. as we use c++ language mode
  3572. it does not like that either
  3573. Please do not remove this part
  3574. might be used once
  3575. gdb for pascal is ready PM }
  3576. (*
  3577. param := para1;
  3578. i := 0;
  3579. while assigned(param) do
  3580. begin
  3581. inc(i);
  3582. if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
  3583. {Here we have lost the parameter names !!}
  3584. pst := strpnew('p'+tostr(i)+':'+param^.paratype.def.numberstring+','+vartyp+';');
  3585. strcat(nss,pst);
  3586. strdispose(pst);
  3587. param := param^.next;
  3588. end; *)
  3589. {strpcopy(strend(nss),';');}
  3590. stabstring := strnew(nss);
  3591. freemem(nss,1024);
  3592. end;
  3593. procedure tprocvardef.concatstabto(asmlist : taasmoutput);
  3594. begin
  3595. if ( not assigned(typesym) or ttypesym(typesym).isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  3596. and (is_def_stab_written = not_written) then
  3597. inherited concatstabto(asmlist);
  3598. is_def_stab_written:=written;
  3599. end;
  3600. {$endif GDB}
  3601. procedure tprocvardef.write_rtti_data(rt:trttitype);
  3602. var
  3603. pdc : TParaItem;
  3604. methodkind, paraspec : byte;
  3605. begin
  3606. if po_methodpointer in procoptions then
  3607. begin
  3608. { write method id and name }
  3609. rttiList.concat(Tai_const.Create_8bit(tkmethod));
  3610. write_rtti_name;
  3611. { write kind of method (can only be function or procedure)}
  3612. if rettype.def = voidtype.def then
  3613. methodkind := mkProcedure
  3614. else
  3615. methodkind := mkFunction;
  3616. rttiList.concat(Tai_const.Create_8bit(methodkind));
  3617. { get # of parameters }
  3618. rttiList.concat(Tai_const.Create_8bit(maxparacount));
  3619. { write parameter info. The parameters must be written in reverse order
  3620. if this method uses right to left parameter pushing! }
  3621. if (po_leftright in procoptions) then
  3622. pdc:=TParaItem(Para.last)
  3623. else
  3624. pdc:=TParaItem(Para.first);
  3625. while assigned(pdc) do
  3626. begin
  3627. case pdc.paratyp of
  3628. vs_value: paraspec := 0;
  3629. vs_const: paraspec := pfConst;
  3630. vs_var : paraspec := pfVar;
  3631. vs_out : paraspec := pfOut;
  3632. end;
  3633. { write flags for current parameter }
  3634. rttiList.concat(Tai_const.Create_8bit(paraspec));
  3635. { write name of current parameter ### how can I get this??? (sg)}
  3636. rttiList.concat(Tai_const.Create_8bit(0));
  3637. { write name of type of current parameter }
  3638. tstoreddef(pdc.paratype.def).write_rtti_name;
  3639. if (po_leftright in procoptions) then
  3640. pdc:=TParaItem(pdc.previous)
  3641. else
  3642. pdc:=TParaItem(pdc.next);
  3643. end;
  3644. { write name of result type }
  3645. tstoreddef(rettype.def).write_rtti_name;
  3646. end;
  3647. end;
  3648. function tprocvardef.is_publishable : boolean;
  3649. begin
  3650. is_publishable:=(po_methodpointer in procoptions);
  3651. end;
  3652. function tprocvardef.gettypename : string;
  3653. var
  3654. s: string;
  3655. begin
  3656. s:='<';
  3657. if po_classmethod in procoptions then
  3658. s := s+'class method type of'
  3659. else
  3660. if po_addressonly in procoptions then
  3661. s := s+'address of'
  3662. else
  3663. s := s+'procedure variable type of';
  3664. if assigned(rettype.def) and
  3665. (rettype.def<>voidtype.def) then
  3666. s:=s+' function'+typename_paras+':'+rettype.def.gettypename
  3667. else
  3668. s:=s+' procedure'+typename_paras;
  3669. if po_methodpointer in procoptions then
  3670. s := s+' of object';
  3671. gettypename := s+';'+ProcCallOptionStr[proccalloption]+'>';
  3672. end;
  3673. {***************************************************************************
  3674. TOBJECTDEF
  3675. ***************************************************************************}
  3676. constructor tobjectdef.create(ot : tobjectdeftype;const n : string;c : tobjectdef);
  3677. begin
  3678. inherited create;
  3679. objecttype:=ot;
  3680. deftype:=objectdef;
  3681. objectoptions:=[];
  3682. childof:=nil;
  3683. symtable:=tobjectsymtable.create(n);
  3684. { create space for vmt !! }
  3685. vmt_offset:=0;
  3686. symtable.datasize:=0;
  3687. symtable.defowner:=self;
  3688. { recordalign -1 means C record packing, that starts
  3689. with an alignment of 1 }
  3690. if aktalignment.recordalignmax=-1 then
  3691. symtable.dataalignment:=1
  3692. else
  3693. symtable.dataalignment:=aktalignment.recordalignmax;
  3694. lastvtableindex:=0;
  3695. set_parent(c);
  3696. objname:=stringdup(upper(n));
  3697. objrealname:=stringdup(n);
  3698. if objecttype in [odt_interfacecorba,odt_interfacecom] then
  3699. prepareguid;
  3700. { setup implemented interfaces }
  3701. if objecttype in [odt_class,odt_interfacecorba] then
  3702. implementedinterfaces:=timplementedinterfaces.create
  3703. else
  3704. implementedinterfaces:=nil;
  3705. {$ifdef GDB}
  3706. writing_class_record_stab:=false;
  3707. {$endif GDB}
  3708. end;
  3709. constructor tobjectdef.ppuload(ppufile:tcompilerppufile);
  3710. var
  3711. oldread_member : boolean;
  3712. i,implintfcount: longint;
  3713. begin
  3714. inherited ppuloaddef(ppufile);
  3715. deftype:=objectdef;
  3716. objecttype:=tobjectdeftype(ppufile.getbyte);
  3717. savesize:=ppufile.getlongint;
  3718. vmt_offset:=ppufile.getlongint;
  3719. objrealname:=stringdup(ppufile.getstring);
  3720. objname:=stringdup(upper(objrealname^));
  3721. childof:=tobjectdef(ppufile.getderef);
  3722. ppufile.getsmallset(objectoptions);
  3723. { load guid }
  3724. iidstr:=nil;
  3725. if objecttype in [odt_interfacecom,odt_interfacecorba] then
  3726. begin
  3727. new(iidguid);
  3728. ppufile.getguid(iidguid^);
  3729. iidstr:=stringdup(ppufile.getstring);
  3730. lastvtableindex:=ppufile.getlongint;
  3731. end;
  3732. { load implemented interfaces }
  3733. if objecttype in [odt_class,odt_interfacecorba] then
  3734. begin
  3735. implementedinterfaces:=timplementedinterfaces.create;
  3736. implintfcount:=ppufile.getlongint;
  3737. for i:=1 to implintfcount do
  3738. begin
  3739. implementedinterfaces.addintfref(ppufile.getderef);
  3740. implementedinterfaces.ioffsets(i)^:=ppufile.getlongint;
  3741. end;
  3742. end
  3743. else
  3744. implementedinterfaces:=nil;
  3745. oldread_member:=read_member;
  3746. read_member:=true;
  3747. symtable:=tobjectsymtable.create(objrealname^);
  3748. tobjectsymtable(symtable).ppuload(ppufile);
  3749. read_member:=oldread_member;
  3750. symtable.defowner:=self;
  3751. { handles the predefined class tobject }
  3752. { the last TOBJECT which is loaded gets }
  3753. { it ! }
  3754. if (childof=nil) and
  3755. (objecttype=odt_class) and
  3756. (objname^='TOBJECT') then
  3757. class_tobject:=self;
  3758. if (childof=nil) and
  3759. (objecttype=odt_interfacecom) and
  3760. (objname^='IUNKNOWN') then
  3761. interface_iunknown:=self;
  3762. {$ifdef GDB}
  3763. writing_class_record_stab:=false;
  3764. {$endif GDB}
  3765. end;
  3766. destructor tobjectdef.destroy;
  3767. begin
  3768. if assigned(symtable) then
  3769. symtable.free;
  3770. stringdispose(objname);
  3771. stringdispose(objrealname);
  3772. if assigned(iidstr) then
  3773. stringdispose(iidstr);
  3774. if assigned(implementedinterfaces) then
  3775. implementedinterfaces.free;
  3776. if assigned(iidguid) then
  3777. dispose(iidguid);
  3778. inherited destroy;
  3779. end;
  3780. procedure tobjectdef.ppuwrite(ppufile:tcompilerppufile);
  3781. var
  3782. oldread_member : boolean;
  3783. implintfcount : longint;
  3784. i : longint;
  3785. begin
  3786. inherited ppuwritedef(ppufile);
  3787. ppufile.putbyte(byte(objecttype));
  3788. ppufile.putlongint(size);
  3789. ppufile.putlongint(vmt_offset);
  3790. ppufile.putstring(objrealname^);
  3791. ppufile.putderef(childof);
  3792. ppufile.putsmallset(objectoptions);
  3793. if objecttype in [odt_interfacecom,odt_interfacecorba] then
  3794. begin
  3795. ppufile.putguid(iidguid^);
  3796. ppufile.putstring(iidstr^);
  3797. ppufile.putlongint(lastvtableindex);
  3798. end;
  3799. if objecttype in [odt_class,odt_interfacecorba] then
  3800. begin
  3801. implintfcount:=implementedinterfaces.count;
  3802. ppufile.putlongint(implintfcount);
  3803. for i:=1 to implintfcount do
  3804. begin
  3805. ppufile.putderef(implementedinterfaces.interfaces(i));
  3806. ppufile.putlongint(implementedinterfaces.ioffsets(i)^);
  3807. end;
  3808. end;
  3809. ppufile.writeentry(ibobjectdef);
  3810. oldread_member:=read_member;
  3811. read_member:=true;
  3812. tobjectsymtable(symtable).ppuwrite(ppufile);
  3813. read_member:=oldread_member;
  3814. end;
  3815. procedure tobjectdef.deref;
  3816. var
  3817. oldrecsyms : tsymtable;
  3818. begin
  3819. inherited deref;
  3820. resolvedef(pointer(childof));
  3821. oldrecsyms:=aktrecordsymtable;
  3822. aktrecordsymtable:=symtable;
  3823. tstoredsymtable(symtable).deref;
  3824. aktrecordsymtable:=oldrecsyms;
  3825. if objecttype in [odt_class,odt_interfacecorba] then
  3826. implementedinterfaces.deref;
  3827. end;
  3828. procedure tobjectdef.prepareguid;
  3829. begin
  3830. { set up guid }
  3831. if not assigned(iidguid) then
  3832. begin
  3833. new(iidguid);
  3834. fillchar(iidguid^,sizeof(iidguid^),0); { default null guid }
  3835. end;
  3836. { setup iidstring }
  3837. if not assigned(iidstr) then
  3838. iidstr:=stringdup(''); { default is empty string }
  3839. end;
  3840. procedure tobjectdef.set_parent( c : tobjectdef);
  3841. begin
  3842. { nothing to do if the parent was not forward !}
  3843. if assigned(childof) then
  3844. exit;
  3845. childof:=c;
  3846. { some options are inherited !! }
  3847. if assigned(c) then
  3848. begin
  3849. { only important for classes }
  3850. lastvtableindex:=c.lastvtableindex;
  3851. objectoptions:=objectoptions+(c.objectoptions*
  3852. [oo_has_virtual,oo_has_private,oo_has_protected,
  3853. oo_has_constructor,oo_has_destructor]);
  3854. if not (objecttype in [odt_interfacecom,odt_interfacecorba]) then
  3855. begin
  3856. { add the data of the anchestor class }
  3857. inc(symtable.datasize,c.symtable.datasize);
  3858. if (oo_has_vmt in objectoptions) and
  3859. (oo_has_vmt in c.objectoptions) then
  3860. dec(symtable.datasize,POINTER_SIZE);
  3861. { if parent has a vmt field then
  3862. the offset is the same for the child PM }
  3863. if (oo_has_vmt in c.objectoptions) or is_class(self) then
  3864. begin
  3865. vmt_offset:=c.vmt_offset;
  3866. include(objectoptions,oo_has_vmt);
  3867. end;
  3868. end;
  3869. end;
  3870. savesize := symtable.datasize;
  3871. end;
  3872. procedure tobjectdef.insertvmt;
  3873. begin
  3874. if objecttype in [odt_interfacecom,odt_interfacecorba] then
  3875. exit;
  3876. if (oo_has_vmt in objectoptions) then
  3877. internalerror(12345)
  3878. else
  3879. begin
  3880. symtable.datasize:=align(symtable.datasize,symtable.dataalignment);
  3881. vmt_offset:=symtable.datasize;
  3882. inc(symtable.datasize,POINTER_SIZE);
  3883. include(objectoptions,oo_has_vmt);
  3884. end;
  3885. end;
  3886. procedure tobjectdef.check_forwards;
  3887. begin
  3888. if not(objecttype in [odt_interfacecom,odt_interfacecorba]) then
  3889. tstoredsymtable(symtable).check_forwards;
  3890. if (oo_is_forward in objectoptions) then
  3891. begin
  3892. { ok, in future, the forward can be resolved }
  3893. Message1(sym_e_class_forward_not_resolved,objrealname^);
  3894. exclude(objectoptions,oo_is_forward);
  3895. end;
  3896. end;
  3897. { true, if self inherits from d (or if they are equal) }
  3898. function tobjectdef.is_related(d : tobjectdef) : boolean;
  3899. var
  3900. hp : tobjectdef;
  3901. begin
  3902. hp:=self;
  3903. while assigned(hp) do
  3904. begin
  3905. if hp=d then
  3906. begin
  3907. is_related:=true;
  3908. exit;
  3909. end;
  3910. hp:=hp.childof;
  3911. end;
  3912. is_related:=false;
  3913. end;
  3914. (* procedure tobjectdef._searchdestructor(sym : tnamedindexitem;arg:pointer);
  3915. var
  3916. p : pprocdeflist;
  3917. begin
  3918. { if we found already a destructor, then we exit }
  3919. if assigned(sd) then
  3920. exit;
  3921. if tsym(sym).typ=procsym then
  3922. begin
  3923. p:=tprocsym(sym).defs;
  3924. while assigned(p) do
  3925. begin
  3926. if p^.def.proctypeoption=potype_destructor then
  3927. begin
  3928. sd:=p^.def;
  3929. exit;
  3930. end;
  3931. p:=p^.next;
  3932. end;
  3933. end;
  3934. end;*)
  3935. procedure Tobjectdef._searchdestructor(sym:Tnamedindexitem;arg:pointer);
  3936. begin
  3937. { if we found already a destructor, then we exit }
  3938. if (sd=nil) and (Tsym(sym).typ=procsym) then
  3939. sd:=Tprocsym(sym).search_procdef_bytype(potype_destructor);
  3940. end;
  3941. function tobjectdef.searchdestructor : tprocdef;
  3942. var
  3943. o : tobjectdef;
  3944. begin
  3945. searchdestructor:=nil;
  3946. o:=self;
  3947. sd:=nil;
  3948. while assigned(o) do
  3949. begin
  3950. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}_searchdestructor,nil);
  3951. if assigned(sd) then
  3952. begin
  3953. searchdestructor:=sd;
  3954. exit;
  3955. end;
  3956. o:=o.childof;
  3957. end;
  3958. end;
  3959. function tobjectdef.size : longint;
  3960. var
  3961. _resultsize : longint;
  3962. begin
  3963. if objecttype in [odt_class,odt_interfacecom,odt_interfacecorba] then
  3964. _resultsize:=POINTER_SIZE
  3965. else
  3966. _resultsize:=symtable.datasize;
  3967. size := _resultsize;
  3968. end;
  3969. function tobjectdef.alignment:longint;
  3970. begin
  3971. alignment:=symtable.dataalignment;
  3972. end;
  3973. function tobjectdef.vmtmethodoffset(index:longint):longint;
  3974. begin
  3975. { for offset of methods for classes, see rtl/inc/objpash.inc }
  3976. case objecttype of
  3977. odt_class:
  3978. vmtmethodoffset:=(index+12)*POINTER_SIZE;
  3979. odt_interfacecom,odt_interfacecorba:
  3980. vmtmethodoffset:=index*POINTER_SIZE;
  3981. else
  3982. {$ifdef WITHDMT}
  3983. vmtmethodoffset:=(index+4)*POINTER_SIZE;
  3984. {$else WITHDMT}
  3985. vmtmethodoffset:=(index+3)*POINTER_SIZE;
  3986. {$endif WITHDMT}
  3987. end;
  3988. end;
  3989. function tobjectdef.vmt_mangledname : string;
  3990. begin
  3991. if not(oo_has_vmt in objectoptions) then
  3992. Message1(parser_n_object_has_no_vmt,objrealname^);
  3993. vmt_mangledname:=mangledname_prefix('VMT',owner)+objname^;
  3994. end;
  3995. function tobjectdef.rtti_name : string;
  3996. begin
  3997. rtti_name:=mangledname_prefix('RTTI',owner)+objname^;
  3998. end;
  3999. {$ifdef GDB}
  4000. procedure tobjectdef.addprocname(p :tnamedindexitem;arg:pointer);
  4001. var virtualind,argnames : string;
  4002. news, newrec : pchar;
  4003. pd,ipd : tprocdef;
  4004. lindex : longint;
  4005. para : TParaItem;
  4006. arglength : byte;
  4007. sp : char;
  4008. begin
  4009. If tsym(p).typ = procsym then
  4010. begin
  4011. pd := tprocsym(p).first_procdef;
  4012. { this will be used for full implementation of object stabs
  4013. not yet done }
  4014. ipd := Tprocsym(p).last_procdef;
  4015. if (po_virtualmethod in pd.procoptions) then
  4016. begin
  4017. lindex := pd.extnumber;
  4018. {doesnt seem to be necessary
  4019. lindex := lindex or $80000000;}
  4020. virtualind := '*'+tostr(lindex)+';'+ipd._class.classnumberstring+';'
  4021. end
  4022. else
  4023. virtualind := '.';
  4024. { used by gdbpas to recognize constructor and destructors }
  4025. if (pd.proctypeoption=potype_constructor) then
  4026. argnames:='__ct__'
  4027. else if (pd.proctypeoption=potype_destructor) then
  4028. argnames:='__dt__'
  4029. else
  4030. argnames := '';
  4031. { arguments are not listed here }
  4032. {we don't need another definition}
  4033. para := TParaItem(pd.Para.first);
  4034. while assigned(para) do
  4035. begin
  4036. if Para.paratype.def.deftype = formaldef then
  4037. begin
  4038. if Para.paratyp=vs_var then
  4039. argnames := argnames+'3var'
  4040. else if Para.paratyp=vs_const then
  4041. argnames:=argnames+'5const'
  4042. else if Para.paratyp=vs_out then
  4043. argnames:=argnames+'3out';
  4044. end
  4045. else
  4046. begin
  4047. { if the arg definition is like (v: ^byte;..
  4048. there is no sym attached to data !!! }
  4049. if assigned(Para.paratype.def.typesym) then
  4050. begin
  4051. arglength := length(Para.paratype.def.typesym.name);
  4052. argnames := argnames + tostr(arglength)+Para.paratype.def.typesym.name;
  4053. end
  4054. else
  4055. begin
  4056. argnames:=argnames+'11unnamedtype';
  4057. end;
  4058. end;
  4059. para := TParaItem(Para.next);
  4060. end;
  4061. ipd.is_def_stab_written := written;
  4062. { here 2A must be changed for private and protected }
  4063. { 0 is private 1 protected and 2 public }
  4064. if (sp_private in tsym(p).symoptions) then sp:='0'
  4065. else if (sp_protected in tsym(p).symoptions) then sp:='1'
  4066. else sp:='2';
  4067. newrec := strpnew(p.name+'::'+ipd.numberstring
  4068. +'=##'+tstoreddef(pd.rettype.def).numberstring+';:'+argnames+';'+sp+'A'
  4069. +virtualind+';');
  4070. { get spare place for a string at the end }
  4071. if strlen(StabRecString) + strlen(newrec) >= StabRecSize-256 then
  4072. begin
  4073. getmem(news,stabrecsize+memsizeinc);
  4074. strcopy(news,stabrecstring);
  4075. freemem(stabrecstring,stabrecsize);
  4076. stabrecsize:=stabrecsize+memsizeinc;
  4077. stabrecstring:=news;
  4078. end;
  4079. strcat(StabRecstring,newrec);
  4080. {freemem(newrec,memsizeinc); }
  4081. strdispose(newrec);
  4082. {This should be used for case !!
  4083. RecOffset := RecOffset + pd.size;}
  4084. end;
  4085. end;
  4086. function tobjectdef.stabstring : pchar;
  4087. var anc : tobjectdef;
  4088. oldrec : pchar;
  4089. oldrecsize,oldrecoffset : longint;
  4090. str_end : string;
  4091. begin
  4092. if not (objecttype=odt_class) or writing_class_record_stab then
  4093. begin
  4094. oldrec := stabrecstring;
  4095. oldrecsize:=stabrecsize;
  4096. stabrecsize:=memsizeinc;
  4097. GetMem(stabrecstring,stabrecsize);
  4098. strpcopy(stabRecString,'s'+tostr(symtable.datasize));
  4099. if assigned(childof) then
  4100. begin
  4101. {only one ancestor not virtual, public, at base offset 0 }
  4102. { !1 , 0 2 0 , }
  4103. strpcopy(strend(stabrecstring),'!1,020,'+childof.classnumberstring+';');
  4104. end;
  4105. {virtual table to implement yet}
  4106. OldRecOffset:=RecOffset;
  4107. RecOffset := 0;
  4108. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}addname,nil);
  4109. RecOffset:=OldRecOffset;
  4110. if (oo_has_vmt in objectoptions) then
  4111. if not assigned(childof) or not(oo_has_vmt in childof.objectoptions) then
  4112. begin
  4113. strpcopy(strend(stabrecstring),'$vf'+classnumberstring+':'+typeglobalnumber('vtblarray')
  4114. +','+tostr(vmt_offset*8)+';');
  4115. end;
  4116. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}addprocname,nil);
  4117. if (oo_has_vmt in objectoptions) then
  4118. begin
  4119. anc := self;
  4120. while assigned(anc.childof) and (oo_has_vmt in anc.childof.objectoptions) do
  4121. anc := anc.childof;
  4122. { just in case anc = self }
  4123. str_end:=';~%'+anc.classnumberstring+';';
  4124. end
  4125. else
  4126. str_end:=';';
  4127. strpcopy(strend(stabrecstring),str_end);
  4128. stabstring := strnew(StabRecString);
  4129. freemem(stabrecstring,stabrecsize);
  4130. stabrecstring := oldrec;
  4131. stabrecsize:=oldrecsize;
  4132. end
  4133. else
  4134. begin
  4135. stabstring:=strpnew('*'+classnumberstring);
  4136. end;
  4137. end;
  4138. procedure tobjectdef.set_globalnb;
  4139. begin
  4140. globalnb:=PglobalTypeCount^;
  4141. inc(PglobalTypeCount^);
  4142. { classes need two type numbers, the globalnb is set to the ptr }
  4143. if objecttype=odt_class then
  4144. begin
  4145. globalnb:=PGlobalTypeCount^;
  4146. inc(PglobalTypeCount^);
  4147. end;
  4148. end;
  4149. function tobjectdef.classnumberstring : string;
  4150. begin
  4151. { write stabs again if needed }
  4152. numberstring;
  4153. if objecttype=odt_class then
  4154. begin
  4155. dec(globalnb);
  4156. classnumberstring:=numberstring;
  4157. inc(globalnb);
  4158. end
  4159. else
  4160. classnumberstring:=numberstring;
  4161. end;
  4162. function tobjectdef.allstabstring : pchar;
  4163. var stabchar : string[2];
  4164. ss,st : pchar;
  4165. sname : string;
  4166. sym_line_no : longint;
  4167. begin
  4168. ss := stabstring;
  4169. getmem(st,strlen(ss)+512);
  4170. stabchar := 't';
  4171. if deftype in tagtypes then
  4172. stabchar := 'Tt';
  4173. if assigned(typesym) then
  4174. begin
  4175. sname := typesym.name;
  4176. sym_line_no:=typesym.fileinfo.line;
  4177. end
  4178. else
  4179. begin
  4180. sname := ' ';
  4181. sym_line_no:=0;
  4182. end;
  4183. if writing_class_record_stab then
  4184. strpcopy(st,'"'+sname+':'+stabchar+classnumberstring+'=')
  4185. else
  4186. strpcopy(st,'"'+sname+':'+stabchar+numberstring+'=');
  4187. strpcopy(strecopy(strend(st),ss),'",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0');
  4188. allstabstring := strnew(st);
  4189. freemem(st,strlen(ss)+512);
  4190. strdispose(ss);
  4191. end;
  4192. procedure tobjectdef.concatstabto(asmlist : taasmoutput);
  4193. var st : pstring;
  4194. begin
  4195. if objecttype<>odt_class then
  4196. begin
  4197. inherited concatstabto(asmlist);
  4198. exit;
  4199. end;
  4200. if ((typesym=nil) or ttypesym(typesym).isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  4201. (is_def_stab_written = not_written) then
  4202. begin
  4203. if globalnb=0 then
  4204. set_globalnb;
  4205. { Write the record class itself }
  4206. writing_class_record_stab:=true;
  4207. inherited concatstabto(asmlist);
  4208. writing_class_record_stab:=false;
  4209. { Write the invisible pointer class }
  4210. is_def_stab_written:=not_written;
  4211. if assigned(typesym) then
  4212. begin
  4213. st:=typesym.FName;
  4214. typesym.FName:=stringdup(' ');
  4215. end;
  4216. inherited concatstabto(asmlist);
  4217. if assigned(typesym) then
  4218. begin
  4219. stringdispose(typesym.FName);
  4220. typesym.FName:=st;
  4221. end;
  4222. end;
  4223. end;
  4224. {$endif GDB}
  4225. function tobjectdef.needs_inittable : boolean;
  4226. begin
  4227. case objecttype of
  4228. odt_class :
  4229. needs_inittable:=false;
  4230. odt_interfacecom:
  4231. needs_inittable:=true;
  4232. odt_interfacecorba:
  4233. needs_inittable:=is_related(interface_iunknown);
  4234. odt_object:
  4235. needs_inittable:=tobjectsymtable(symtable).needs_init_final;
  4236. else
  4237. internalerror(200108267);
  4238. end;
  4239. end;
  4240. function tobjectdef.members_need_inittable : boolean;
  4241. begin
  4242. members_need_inittable:=tobjectsymtable(symtable).needs_init_final;
  4243. end;
  4244. procedure tobjectdef.count_published_properties(sym:tnamedindexitem;arg:pointer);
  4245. begin
  4246. if needs_prop_entry(tsym(sym)) and
  4247. (tsym(sym).typ<>varsym) then
  4248. inc(count);
  4249. end;
  4250. procedure tobjectdef.write_property_info(sym : tnamedindexitem;arg:pointer);
  4251. var
  4252. proctypesinfo : byte;
  4253. procedure writeproc(proc : tsymlist; shiftvalue : byte);
  4254. var
  4255. typvalue : byte;
  4256. hp : psymlistitem;
  4257. address : longint;
  4258. begin
  4259. if not(assigned(proc) and assigned(proc.firstsym)) then
  4260. begin
  4261. rttiList.concat(Tai_const.Create_32bit(1));
  4262. typvalue:=3;
  4263. end
  4264. else if proc.firstsym^.sym.typ=varsym then
  4265. begin
  4266. address:=0;
  4267. hp:=proc.firstsym;
  4268. while assigned(hp) do
  4269. begin
  4270. inc(address,tvarsym(hp^.sym).address);
  4271. hp:=hp^.next;
  4272. end;
  4273. rttiList.concat(Tai_const.Create_32bit(address));
  4274. typvalue:=0;
  4275. end
  4276. else
  4277. begin
  4278. if not(po_virtualmethod in tprocdef(proc.def).procoptions) then
  4279. begin
  4280. rttiList.concat(Tai_const_symbol.Createname(tprocdef(proc.def).mangledname));
  4281. typvalue:=1;
  4282. end
  4283. else
  4284. begin
  4285. { virtual method, write vmt offset }
  4286. rttiList.concat(Tai_const.Create_32bit(
  4287. tprocdef(proc.def)._class.vmtmethodoffset(tprocdef(proc.def).extnumber)));
  4288. typvalue:=2;
  4289. end;
  4290. end;
  4291. proctypesinfo:=proctypesinfo or (typvalue shl shiftvalue);
  4292. end;
  4293. begin
  4294. if needs_prop_entry(tsym(sym)) then
  4295. case tsym(sym).typ of
  4296. varsym:
  4297. begin
  4298. {$ifdef dummy}
  4299. if not(tvarsym(sym).vartype.def.deftype=objectdef) or
  4300. not(tobjectdef(tvarsym(sym).vartype.def).is_class) then
  4301. internalerror(1509992);
  4302. { access to implicit class property as field }
  4303. proctypesinfo:=(0 shl 0) or (0 shl 2) or (0 shl 4);
  4304. rttiList.concat(Tai_const_symbol.Createname(tvarsym(sym.vartype.def.get_rtti_label)));
  4305. rttiList.concat(Tai_const.Create_32bit(tvarsym(sym.address)));
  4306. rttiList.concat(Tai_const.Create_32bit(tvarsym(sym.address)));
  4307. { per default stored }
  4308. rttiList.concat(Tai_const.Create_32bit(1));
  4309. { index as well as ... }
  4310. rttiList.concat(Tai_const.Create_32bit(0));
  4311. { default value are zero }
  4312. rttiList.concat(Tai_const.Create_32bit(0));
  4313. rttiList.concat(Tai_const.Create_16bit(count));
  4314. inc(count);
  4315. rttiList.concat(Tai_const.Create_8bit(proctypesinfo));
  4316. rttiList.concat(Tai_const.Create_8bit(length(tvarsym(sym.realname))));
  4317. rttiList.concat(Tai_string.Create(tvarsym(sym.realname)));
  4318. {$endif dummy}
  4319. end;
  4320. propertysym:
  4321. begin
  4322. if ppo_indexed in tpropertysym(sym).propoptions then
  4323. proctypesinfo:=$40
  4324. else
  4325. proctypesinfo:=0;
  4326. rttiList.concat(Tai_const_symbol.Create(tstoreddef(tpropertysym(sym).proptype.def).get_rtti_label(fullrtti)));
  4327. writeproc(tpropertysym(sym).readaccess,0);
  4328. writeproc(tpropertysym(sym).writeaccess,2);
  4329. { isn't it stored ? }
  4330. if not(ppo_stored in tpropertysym(sym).propoptions) then
  4331. begin
  4332. rttiList.concat(Tai_const.Create_32bit(0));
  4333. proctypesinfo:=proctypesinfo or (3 shl 4);
  4334. end
  4335. else
  4336. writeproc(tpropertysym(sym).storedaccess,4);
  4337. rttiList.concat(Tai_const.Create_32bit(tpropertysym(sym).index));
  4338. rttiList.concat(Tai_const.Create_32bit(tpropertysym(sym).default));
  4339. rttiList.concat(Tai_const.Create_16bit(count));
  4340. inc(count);
  4341. rttiList.concat(Tai_const.Create_8bit(proctypesinfo));
  4342. rttiList.concat(Tai_const.Create_8bit(length(tpropertysym(sym).realname)));
  4343. rttiList.concat(Tai_string.Create(tpropertysym(sym).realname));
  4344. end;
  4345. else internalerror(1509992);
  4346. end;
  4347. end;
  4348. procedure tobjectdef.generate_published_child_rtti(sym : tnamedindexitem;arg:pointer);
  4349. begin
  4350. if needs_prop_entry(tsym(sym)) then
  4351. begin
  4352. case tsym(sym).typ of
  4353. propertysym:
  4354. tstoreddef(tpropertysym(sym).proptype.def).get_rtti_label(fullrtti);
  4355. varsym:
  4356. tstoreddef(tvarsym(sym).vartype.def).get_rtti_label(fullrtti);
  4357. else
  4358. internalerror(1509991);
  4359. end;
  4360. end;
  4361. end;
  4362. procedure tobjectdef.write_child_rtti_data(rt:trttitype);
  4363. begin
  4364. FRTTIType:=rt;
  4365. case rt of
  4366. initrtti :
  4367. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}generate_field_rtti,nil);
  4368. fullrtti :
  4369. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}generate_published_child_rtti,nil);
  4370. else
  4371. internalerror(200108301);
  4372. end;
  4373. end;
  4374. type
  4375. tclasslistitem = class(TLinkedListItem)
  4376. index : longint;
  4377. p : tobjectdef;
  4378. end;
  4379. var
  4380. classtablelist : tlinkedlist;
  4381. tablecount : longint;
  4382. function searchclasstablelist(p : tobjectdef) : tclasslistitem;
  4383. var
  4384. hp : tclasslistitem;
  4385. begin
  4386. hp:=tclasslistitem(classtablelist.first);
  4387. while assigned(hp) do
  4388. if hp.p=p then
  4389. begin
  4390. searchclasstablelist:=hp;
  4391. exit;
  4392. end
  4393. else
  4394. hp:=tclasslistitem(hp.next);
  4395. searchclasstablelist:=nil;
  4396. end;
  4397. procedure tobjectdef.count_published_fields(sym:tnamedindexitem;arg:pointer);
  4398. var
  4399. hp : tclasslistitem;
  4400. begin
  4401. if needs_prop_entry(tsym(sym)) and
  4402. (tsym(sym).typ=varsym) then
  4403. begin
  4404. if tvarsym(sym).vartype.def.deftype<>objectdef then
  4405. internalerror(0206001);
  4406. hp:=searchclasstablelist(tobjectdef(tvarsym(sym).vartype.def));
  4407. if not(assigned(hp)) then
  4408. begin
  4409. hp:=tclasslistitem.create;
  4410. hp.p:=tobjectdef(tvarsym(sym).vartype.def);
  4411. hp.index:=tablecount;
  4412. classtablelist.concat(hp);
  4413. inc(tablecount);
  4414. end;
  4415. inc(count);
  4416. end;
  4417. end;
  4418. procedure tobjectdef.writefields(sym:tnamedindexitem;arg:pointer);
  4419. var
  4420. hp : tclasslistitem;
  4421. begin
  4422. if needs_prop_entry(tsym(sym)) and
  4423. (tsym(sym).typ=varsym) then
  4424. begin
  4425. rttiList.concat(Tai_const.Create_32bit(tvarsym(sym).address));
  4426. hp:=searchclasstablelist(tobjectdef(tvarsym(sym).vartype.def));
  4427. if not(assigned(hp)) then
  4428. internalerror(0206002);
  4429. rttiList.concat(Tai_const.Create_16bit(hp.index));
  4430. rttiList.concat(Tai_const.Create_8bit(length(tvarsym(sym).realname)));
  4431. rttiList.concat(Tai_string.Create(tvarsym(sym).realname));
  4432. end;
  4433. end;
  4434. function tobjectdef.generate_field_table : tasmlabel;
  4435. var
  4436. fieldtable,
  4437. classtable : tasmlabel;
  4438. hp : tclasslistitem;
  4439. begin
  4440. classtablelist:=TLinkedList.Create;
  4441. objectlibrary.getdatalabel(fieldtable);
  4442. objectlibrary.getdatalabel(classtable);
  4443. count:=0;
  4444. tablecount:=0;
  4445. symtable.foreach({$ifdef FPC}@{$endif}count_published_fields,nil);
  4446. if (cs_create_smart in aktmoduleswitches) then
  4447. rttiList.concat(Tai_cut.Create);
  4448. rttilist.concat(tai_align.create(const_align(pointer_size)));
  4449. rttiList.concat(Tai_label.Create(fieldtable));
  4450. rttiList.concat(Tai_const.Create_16bit(count));
  4451. rttiList.concat(Tai_const_symbol.Create(classtable));
  4452. symtable.foreach({$ifdef FPC}@{$endif}writefields,nil);
  4453. { generate the class table }
  4454. rttilist.concat(tai_align.create(const_align(pointer_size)));
  4455. rttiList.concat(Tai_label.Create(classtable));
  4456. rttiList.concat(Tai_const.Create_16bit(tablecount));
  4457. hp:=tclasslistitem(classtablelist.first);
  4458. while assigned(hp) do
  4459. begin
  4460. rttiList.concat(Tai_const_symbol.Createname(tobjectdef(hp.p).vmt_mangledname));
  4461. hp:=tclasslistitem(hp.next);
  4462. end;
  4463. generate_field_table:=fieldtable;
  4464. classtablelist.free;
  4465. end;
  4466. function tobjectdef.next_free_name_index : longint;
  4467. var
  4468. i : longint;
  4469. begin
  4470. if assigned(childof) and (oo_can_have_published in childof.objectoptions) then
  4471. i:=childof.next_free_name_index
  4472. else
  4473. i:=0;
  4474. count:=0;
  4475. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}count_published_properties,nil);
  4476. next_free_name_index:=i+count;
  4477. end;
  4478. procedure tobjectdef.write_rtti_data(rt:trttitype);
  4479. begin
  4480. case objecttype of
  4481. odt_class:
  4482. rttiList.concat(Tai_const.Create_8bit(tkclass));
  4483. odt_object:
  4484. rttiList.concat(Tai_const.Create_8bit(tkobject));
  4485. odt_interfacecom:
  4486. rttiList.concat(Tai_const.Create_8bit(tkinterface));
  4487. odt_interfacecorba:
  4488. rttiList.concat(Tai_const.Create_8bit(tkinterfaceCorba));
  4489. else
  4490. exit;
  4491. end;
  4492. { generate the name }
  4493. rttiList.concat(Tai_const.Create_8bit(length(objrealname^)));
  4494. rttiList.concat(Tai_string.Create(objrealname^));
  4495. case rt of
  4496. initrtti :
  4497. begin
  4498. rttiList.concat(Tai_const.Create_32bit(size));
  4499. if objecttype in [odt_class,odt_object] then
  4500. begin
  4501. count:=0;
  4502. FRTTIType:=rt;
  4503. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}count_field_rtti,nil);
  4504. rttiList.concat(Tai_const.Create_32bit(count));
  4505. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}write_field_rtti,nil);
  4506. end;
  4507. end;
  4508. fullrtti :
  4509. begin
  4510. if objecttype in [odt_interfacecom,odt_interfacecorba] then
  4511. rttiList.concat(Tai_const.Create_32bit(0))
  4512. else
  4513. rttiList.concat(Tai_const_symbol.Createname(vmt_mangledname));
  4514. { write owner typeinfo }
  4515. if assigned(childof) and (oo_can_have_published in childof.objectoptions) then
  4516. rttiList.concat(Tai_const_symbol.Create(childof.get_rtti_label(fullrtti)))
  4517. else
  4518. rttiList.concat(Tai_const.Create_32bit(0));
  4519. { count total number of properties }
  4520. if assigned(childof) and (oo_can_have_published in childof.objectoptions) then
  4521. count:=childof.next_free_name_index
  4522. else
  4523. count:=0;
  4524. { write it }
  4525. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}count_published_properties,nil);
  4526. rttiList.concat(Tai_const.Create_16bit(count));
  4527. { write unit name }
  4528. rttiList.concat(Tai_const.Create_8bit(length(current_module.realmodulename^)));
  4529. rttiList.concat(Tai_string.Create(current_module.realmodulename^));
  4530. { write published properties count }
  4531. count:=0;
  4532. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}count_published_properties,nil);
  4533. rttiList.concat(Tai_const.Create_16bit(count));
  4534. { count is used to write nameindex }
  4535. { but we need an offset of the owner }
  4536. { to give each property an own slot }
  4537. if assigned(childof) and (oo_can_have_published in childof.objectoptions) then
  4538. count:=childof.next_free_name_index
  4539. else
  4540. count:=0;
  4541. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}write_property_info,nil);
  4542. end;
  4543. end;
  4544. end;
  4545. function tobjectdef.is_publishable : boolean;
  4546. begin
  4547. is_publishable:=objecttype in [odt_class,odt_interfacecom,odt_interfacecorba];
  4548. end;
  4549. {****************************************************************************
  4550. TIMPLEMENTEDINTERFACES
  4551. ****************************************************************************}
  4552. type
  4553. tnamemap = class(TNamedIndexItem)
  4554. newname: pstring;
  4555. constructor create(const aname, anewname: string);
  4556. destructor destroy; override;
  4557. end;
  4558. constructor tnamemap.create(const aname, anewname: string);
  4559. begin
  4560. inherited createname(name);
  4561. newname:=stringdup(anewname);
  4562. end;
  4563. destructor tnamemap.destroy;
  4564. begin
  4565. stringdispose(newname);
  4566. inherited destroy;
  4567. end;
  4568. type
  4569. tprocdefstore = class(TNamedIndexItem)
  4570. procdef: tprocdef;
  4571. constructor create(aprocdef: tprocdef);
  4572. end;
  4573. constructor tprocdefstore.create(aprocdef: tprocdef);
  4574. begin
  4575. inherited create;
  4576. procdef:=aprocdef;
  4577. end;
  4578. type
  4579. timplintfentry = class(TNamedIndexItem)
  4580. intf: tobjectdef;
  4581. ioffs: longint;
  4582. namemappings: tdictionary;
  4583. procdefs: TIndexArray;
  4584. constructor create(aintf: tobjectdef);
  4585. destructor destroy; override;
  4586. end;
  4587. constructor timplintfentry.create(aintf: tobjectdef);
  4588. begin
  4589. inherited create;
  4590. intf:=aintf;
  4591. ioffs:=-1;
  4592. namemappings:=nil;
  4593. procdefs:=nil;
  4594. end;
  4595. destructor timplintfentry.destroy;
  4596. begin
  4597. if assigned(namemappings) then
  4598. namemappings.free;
  4599. if assigned(procdefs) then
  4600. procdefs.free;
  4601. inherited destroy;
  4602. end;
  4603. constructor timplementedinterfaces.create;
  4604. begin
  4605. finterfaces:=tindexarray.create(1);
  4606. end;
  4607. destructor timplementedinterfaces.destroy;
  4608. begin
  4609. finterfaces.destroy;
  4610. end;
  4611. function timplementedinterfaces.count: longint;
  4612. begin
  4613. count:=finterfaces.count;
  4614. end;
  4615. procedure timplementedinterfaces.checkindex(intfindex: longint);
  4616. begin
  4617. if (intfindex<1) or (intfindex>count) then
  4618. InternalError(200006123);
  4619. end;
  4620. function timplementedinterfaces.interfaces(intfindex: longint): tobjectdef;
  4621. begin
  4622. checkindex(intfindex);
  4623. interfaces:=timplintfentry(finterfaces.search(intfindex)).intf;
  4624. end;
  4625. function timplementedinterfaces.ioffsets(intfindex: longint): plongint;
  4626. begin
  4627. checkindex(intfindex);
  4628. ioffsets:=@timplintfentry(finterfaces.search(intfindex)).ioffs;
  4629. end;
  4630. function timplementedinterfaces.searchintf(def: tdef): longint;
  4631. var
  4632. i: longint;
  4633. begin
  4634. i:=1;
  4635. while (i<=count) and (tdef(interfaces(i))<>def) do inc(i);
  4636. if i<=count then
  4637. searchintf:=i
  4638. else
  4639. searchintf:=-1;
  4640. end;
  4641. procedure timplementedinterfaces.deref;
  4642. var
  4643. i: longint;
  4644. begin
  4645. for i:=1 to count do
  4646. with timplintfentry(finterfaces.search(i)) do
  4647. resolvedef(pointer(intf));
  4648. end;
  4649. procedure timplementedinterfaces.addintfref(def: pointer);
  4650. begin
  4651. finterfaces.insert(timplintfentry.create(tobjectdef(def)));
  4652. end;
  4653. procedure timplementedinterfaces.addintf(def: tdef);
  4654. begin
  4655. if not assigned(def) or (searchintf(def)<>-1) or (def.deftype<>objectdef) or
  4656. not (tobjectdef(def).objecttype in [odt_interfacecom,odt_interfacecorba]) then
  4657. internalerror(200006124);
  4658. finterfaces.insert(timplintfentry.create(tobjectdef(def)));
  4659. end;
  4660. procedure timplementedinterfaces.clearmappings;
  4661. var
  4662. i: longint;
  4663. begin
  4664. for i:=1 to count do
  4665. with timplintfentry(finterfaces.search(i)) do
  4666. begin
  4667. if assigned(namemappings) then
  4668. namemappings.free;
  4669. namemappings:=nil;
  4670. end;
  4671. end;
  4672. procedure timplementedinterfaces.addmappings(intfindex: longint; const name, newname: string);
  4673. begin
  4674. checkindex(intfindex);
  4675. with timplintfentry(finterfaces.search(intfindex)) do
  4676. begin
  4677. if not assigned(namemappings) then
  4678. namemappings:=tdictionary.create;
  4679. namemappings.insert(tnamemap.create(name,newname));
  4680. end;
  4681. end;
  4682. function timplementedinterfaces.getmappings(intfindex: longint; const name: string; var nextexist: pointer): string;
  4683. begin
  4684. checkindex(intfindex);
  4685. if not assigned(nextexist) then
  4686. with timplintfentry(finterfaces.search(intfindex)) do
  4687. begin
  4688. if assigned(namemappings) then
  4689. nextexist:=namemappings.search(name)
  4690. else
  4691. nextexist:=nil;
  4692. end;
  4693. if assigned(nextexist) then
  4694. begin
  4695. getmappings:=tnamemap(nextexist).newname^;
  4696. nextexist:=tnamemap(nextexist).listnext;
  4697. end
  4698. else
  4699. getmappings:='';
  4700. end;
  4701. procedure timplementedinterfaces.clearimplprocs;
  4702. var
  4703. i: longint;
  4704. begin
  4705. for i:=1 to count do
  4706. with timplintfentry(finterfaces.search(i)) do
  4707. begin
  4708. if assigned(procdefs) then
  4709. procdefs.free;
  4710. procdefs:=nil;
  4711. end;
  4712. end;
  4713. procedure timplementedinterfaces.addimplproc(intfindex: longint; procdef: tprocdef);
  4714. begin
  4715. checkindex(intfindex);
  4716. with timplintfentry(finterfaces.search(intfindex)) do
  4717. begin
  4718. if not assigned(procdefs) then
  4719. procdefs:=tindexarray.create(4);
  4720. procdefs.insert(tprocdefstore.create(procdef));
  4721. end;
  4722. end;
  4723. function timplementedinterfaces.implproccount(intfindex: longint): longint;
  4724. begin
  4725. checkindex(intfindex);
  4726. with timplintfentry(finterfaces.search(intfindex)) do
  4727. if assigned(procdefs) then
  4728. implproccount:=procdefs.count
  4729. else
  4730. implproccount:=0;
  4731. end;
  4732. function timplementedinterfaces.implprocs(intfindex: longint; procindex: longint): tprocdef;
  4733. begin
  4734. checkindex(intfindex);
  4735. with timplintfentry(finterfaces.search(intfindex)) do
  4736. if assigned(procdefs) then
  4737. implprocs:=tprocdefstore(procdefs.search(procindex)).procdef
  4738. else
  4739. internalerror(200006131);
  4740. end;
  4741. function timplementedinterfaces.isimplmergepossible(intfindex, remainindex: longint; var weight: longint): boolean;
  4742. var
  4743. possible: boolean;
  4744. i: longint;
  4745. iiep1: TIndexArray;
  4746. iiep2: TIndexArray;
  4747. begin
  4748. checkindex(intfindex);
  4749. checkindex(remainindex);
  4750. iiep1:=timplintfentry(finterfaces.search(intfindex)).procdefs;
  4751. iiep2:=timplintfentry(finterfaces.search(remainindex)).procdefs;
  4752. if not assigned(iiep1) then { empty interface is mergeable :-) }
  4753. begin
  4754. possible:=true;
  4755. weight:=0;
  4756. end
  4757. else
  4758. begin
  4759. possible:=assigned(iiep2) and (iiep1.count<=iiep2.count);
  4760. i:=1;
  4761. while (possible) and (i<=iiep1.count) do
  4762. begin
  4763. possible:=
  4764. (tprocdefstore(iiep1.search(i)).procdef=tprocdefstore(iiep2.search(i)).procdef);
  4765. inc(i);
  4766. end;
  4767. if possible then
  4768. weight:=iiep1.count;
  4769. end;
  4770. isimplmergepossible:=possible;
  4771. end;
  4772. {****************************************************************************
  4773. TFORWARDDEF
  4774. ****************************************************************************}
  4775. constructor tforwarddef.create(const s:string;const pos : tfileposinfo);
  4776. var
  4777. oldregisterdef : boolean;
  4778. begin
  4779. { never register the forwarddefs, they are disposed at the
  4780. end of the type declaration block }
  4781. oldregisterdef:=registerdef;
  4782. registerdef:=false;
  4783. inherited create;
  4784. registerdef:=oldregisterdef;
  4785. deftype:=forwarddef;
  4786. tosymname:=stringdup(s);
  4787. forwardpos:=pos;
  4788. end;
  4789. function tforwarddef.gettypename:string;
  4790. begin
  4791. gettypename:='unresolved forward to '+tosymname^;
  4792. end;
  4793. destructor tforwarddef.destroy;
  4794. begin
  4795. if assigned(tosymname) then
  4796. stringdispose(tosymname);
  4797. inherited destroy;
  4798. end;
  4799. {****************************************************************************
  4800. TERRORDEF
  4801. ****************************************************************************}
  4802. constructor terrordef.create;
  4803. begin
  4804. inherited create;
  4805. deftype:=errordef;
  4806. end;
  4807. {$ifdef GDB}
  4808. function terrordef.stabstring : pchar;
  4809. begin
  4810. stabstring:=strpnew('error'+numberstring);
  4811. end;
  4812. procedure terrordef.concatstabto(asmlist : taasmoutput);
  4813. begin
  4814. internalerror(20021119);
  4815. end;
  4816. {$endif GDB}
  4817. function terrordef.gettypename:string;
  4818. begin
  4819. gettypename:='<erroneous type>';
  4820. end;
  4821. function terrordef.getmangledparaname:string;
  4822. begin
  4823. getmangledparaname:='error';
  4824. end;
  4825. {****************************************************************************
  4826. GDB Helpers
  4827. ****************************************************************************}
  4828. {$ifdef GDB}
  4829. function typeglobalnumber(const s : string) : string;
  4830. var st : string;
  4831. symt : tsymtable;
  4832. srsym : tsym;
  4833. srsymtable : tsymtable;
  4834. old_make_ref : boolean;
  4835. begin
  4836. old_make_ref:=make_ref;
  4837. make_ref:=false;
  4838. typeglobalnumber := '0';
  4839. srsym := nil;
  4840. if pos('.',s) > 0 then
  4841. begin
  4842. st := copy(s,1,pos('.',s)-1);
  4843. searchsym(st,srsym,srsymtable);
  4844. st := copy(s,pos('.',s)+1,255);
  4845. if assigned(srsym) then
  4846. begin
  4847. if srsym.typ = unitsym then
  4848. begin
  4849. symt := tunitsym(srsym).unitsymtable;
  4850. srsym := tsym(symt.search(st));
  4851. end else srsym := nil;
  4852. end;
  4853. end else st := s;
  4854. if srsym = nil then
  4855. searchsym(st,srsym,srsymtable);
  4856. if (srsym=nil) or
  4857. (srsym.typ<>typesym) then
  4858. begin
  4859. Message(type_e_type_id_expected);
  4860. exit;
  4861. end;
  4862. typeglobalnumber := tstoreddef(ttypesym(srsym).restype.def).numberstring;
  4863. make_ref:=old_make_ref;
  4864. end;
  4865. {$endif GDB}
  4866. {****************************************************************************
  4867. Definition Helpers
  4868. ****************************************************************************}
  4869. procedure reset_global_defs;
  4870. var
  4871. def : tstoreddef;
  4872. {$ifdef debug}
  4873. prevdef : tstoreddef;
  4874. {$endif debug}
  4875. begin
  4876. {$ifdef debug}
  4877. prevdef:=nil;
  4878. {$endif debug}
  4879. {$ifdef GDB}
  4880. pglobaltypecount:=@globaltypecount;
  4881. {$endif GDB}
  4882. def:=firstglobaldef;
  4883. while assigned(def) do
  4884. begin
  4885. {$ifdef GDB}
  4886. if assigned(def.typesym) then
  4887. ttypesym(def.typesym).isusedinstab:=false;
  4888. def.is_def_stab_written:=not_written;
  4889. {$endif GDB}
  4890. if assigned(def.rttitablesym) then
  4891. trttisym(def.rttitablesym).lab := nil;
  4892. if assigned(def.inittablesym) then
  4893. trttisym(def.inittablesym).lab := nil;
  4894. def.localrttilab[initrtti]:=nil;
  4895. def.localrttilab[fullrtti]:=nil;
  4896. {$ifdef debug}
  4897. prevdef:=def;
  4898. {$endif debug}
  4899. def:=def.nextglobal;
  4900. end;
  4901. end;
  4902. function is_interfacecom(def: tdef): boolean;
  4903. begin
  4904. is_interfacecom:=
  4905. assigned(def) and
  4906. (def.deftype=objectdef) and
  4907. (tobjectdef(def).objecttype=odt_interfacecom);
  4908. end;
  4909. function is_interfacecorba(def: tdef): boolean;
  4910. begin
  4911. is_interfacecorba:=
  4912. assigned(def) and
  4913. (def.deftype=objectdef) and
  4914. (tobjectdef(def).objecttype=odt_interfacecorba);
  4915. end;
  4916. function is_interface(def: tdef): boolean;
  4917. begin
  4918. is_interface:=
  4919. assigned(def) and
  4920. (def.deftype=objectdef) and
  4921. (tobjectdef(def).objecttype in [odt_interfacecom,odt_interfacecorba]);
  4922. end;
  4923. function is_class(def: tdef): boolean;
  4924. begin
  4925. is_class:=
  4926. assigned(def) and
  4927. (def.deftype=objectdef) and
  4928. (tobjectdef(def).objecttype=odt_class);
  4929. end;
  4930. function is_object(def: tdef): boolean;
  4931. begin
  4932. is_object:=
  4933. assigned(def) and
  4934. (def.deftype=objectdef) and
  4935. (tobjectdef(def).objecttype=odt_object);
  4936. end;
  4937. function is_cppclass(def: tdef): boolean;
  4938. begin
  4939. is_cppclass:=
  4940. assigned(def) and
  4941. (def.deftype=objectdef) and
  4942. (tobjectdef(def).objecttype=odt_cppclass);
  4943. end;
  4944. function is_class_or_interface(def: tdef): boolean;
  4945. begin
  4946. is_class_or_interface:=
  4947. assigned(def) and
  4948. (def.deftype=objectdef) and
  4949. (tobjectdef(def).objecttype in [odt_class,odt_interfacecom,odt_interfacecorba]);
  4950. end;
  4951. end.
  4952. {
  4953. $Log$
  4954. Revision 1.128 2003-02-02 19:25:54 carl
  4955. * Several bugfixes for m68k target (register alloc., opcode emission)
  4956. + VIS target
  4957. + Generic add more complete (still not verified)
  4958. Revision 1.127 2003/01/21 14:36:44 pierre
  4959. * set sizes needs to be passes in bits not bytes to stabs info
  4960. Revision 1.126 2003/01/16 22:11:33 peter
  4961. * fixed tprocdef.is_addressonly
  4962. Revision 1.125 2003/01/15 01:44:33 peter
  4963. * merged methodpointer fixes from 1.0.x
  4964. Revision 1.124 2003/01/09 21:52:37 peter
  4965. * merged some verbosity options.
  4966. * V_LineInfo is a verbosity flag to include line info
  4967. Revision 1.123 2003/01/06 21:16:52 peter
  4968. * po_addressonly added to retrieve the address of a methodpointer
  4969. only, this is used for @tclass.method which has no self pointer
  4970. Revision 1.122 2003/01/05 15:54:15 florian
  4971. + added proper support of type = type <type>; for simple types
  4972. Revision 1.121 2003/01/05 13:36:53 florian
  4973. * x86-64 compiles
  4974. + very basic support for float128 type (x86-64 only)
  4975. Revision 1.120 2003/01/02 19:49:00 peter
  4976. * update self parameter only for methodpointer and methods
  4977. Revision 1.119 2002/12/29 18:25:59 peter
  4978. * tprocdef.gettypename implemented
  4979. Revision 1.118 2002/12/27 15:23:09 peter
  4980. * write class methods in fullname
  4981. Revision 1.117 2002/12/15 19:34:31 florian
  4982. + some front end stuff for vs_hidden added
  4983. Revision 1.116 2002/12/15 11:26:02 peter
  4984. * ignore vs_hidden parameters when choosing overloaded proc
  4985. Revision 1.115 2002/12/07 14:27:09 carl
  4986. * 3% memory optimization
  4987. * changed some types
  4988. + added type checking with different size for call node and for
  4989. parameters
  4990. Revision 1.114 2002/12/01 22:05:27 carl
  4991. * no more warnings for structures over 32K since this is
  4992. handled correctly in this version of the compiler.
  4993. Revision 1.113 2002/11/27 20:04:09 peter
  4994. * tvarsym.get_push_size replaced by paramanager.push_size
  4995. Revision 1.112 2002/11/25 21:05:53 carl
  4996. * several mistakes fixed in message files
  4997. Revision 1.111 2002/11/25 18:43:33 carl
  4998. - removed the invalid if <> checking (Delphi is strange on this)
  4999. + implemented abstract warning on instance creation of class with
  5000. abstract methods.
  5001. * some error message cleanups
  5002. Revision 1.110 2002/11/25 17:43:24 peter
  5003. * splitted defbase in defutil,symutil,defcmp
  5004. * merged isconvertable and is_equal into compare_defs(_ext)
  5005. * made operator search faster by walking the list only once
  5006. Revision 1.109 2002/11/23 22:50:06 carl
  5007. * some small speed optimizations
  5008. + added several new warnings/hints
  5009. Revision 1.108 2002/11/22 22:48:10 carl
  5010. * memory optimization with tconstsym (1.5%)
  5011. Revision 1.107 2002/11/19 16:21:29 pierre
  5012. * correct several stabs generation problems
  5013. Revision 1.106 2002/11/18 17:31:59 peter
  5014. * pass proccalloption to ret_in_xxx and push_xxx functions
  5015. Revision 1.105 2002/11/17 16:31:57 carl
  5016. * memory optimization (3-4%) : cleanup of tai fields,
  5017. cleanup of tdef and tsym fields.
  5018. * make it work for m68k
  5019. Revision 1.104 2002/11/16 19:53:18 carl
  5020. * avoid Range check errors
  5021. Revision 1.103 2002/11/15 16:29:09 peter
  5022. * fixed rtti for int64 (merged)
  5023. Revision 1.102 2002/11/15 01:58:54 peter
  5024. * merged changes from 1.0.7 up to 04-11
  5025. - -V option for generating bug report tracing
  5026. - more tracing for option parsing
  5027. - errors for cdecl and high()
  5028. - win32 import stabs
  5029. - win32 records<=8 are returned in eax:edx (turned off by default)
  5030. - heaptrc update
  5031. - more info for temp management in .s file with EXTDEBUG
  5032. Revision 1.101 2002/11/09 15:31:02 carl
  5033. + align RTTI tables
  5034. Revision 1.100 2002/10/19 15:09:25 peter
  5035. + tobjectdef.members_need_inittable that is used to generate only the
  5036. inittable when it is really used. This saves a lot of useless calls
  5037. to fpc_finalize when destroying classes
  5038. Revision 1.99 2002/10/07 21:30:27 peter
  5039. * removed obsolete rangecheck stuff
  5040. Revision 1.98 2002/10/05 15:14:26 peter
  5041. * getparamangeldname for errordef
  5042. Revision 1.97 2002/10/05 12:43:28 carl
  5043. * fixes for Delphi 6 compilation
  5044. (warning : Some features do not work under Delphi)
  5045. Revision 1.96 2002/09/27 21:13:29 carl
  5046. * low-highval always checked if limit ober 2GB is reached (to avoid overflow)
  5047. Revision 1.95 2002/09/16 09:31:10 florian
  5048. * fixed currency size
  5049. Revision 1.94 2002/09/09 17:34:15 peter
  5050. * tdicationary.replace added to replace and item in a dictionary. This
  5051. is only allowed for the same name
  5052. * varsyms are inserted in symtable before the types are parsed. This
  5053. fixes the long standing "var longint : longint" bug
  5054. - consume_idlist and idstringlist removed. The loops are inserted
  5055. at the callers place and uses the symtable for duplicate id checking
  5056. Revision 1.93 2002/09/07 15:25:07 peter
  5057. * old logs removed and tabs fixed
  5058. Revision 1.92 2002/09/05 19:29:42 peter
  5059. * memdebug enhancements
  5060. Revision 1.91 2002/08/25 19:25:20 peter
  5061. * sym.insert_in_data removed
  5062. * symtable.insertvardata/insertconstdata added
  5063. * removed insert_in_data call from symtable.insert, it needs to be
  5064. called separatly. This allows to deref the address calculation
  5065. * procedures now calculate the parast addresses after the procedure
  5066. directives are parsed. This fixes the cdecl parast problem
  5067. * push_addr_param has an extra argument that specifies if cdecl is used
  5068. or not
  5069. Revision 1.90 2002/08/18 20:06:25 peter
  5070. * inlining is now also allowed in interface
  5071. * renamed write/load to ppuwrite/ppuload
  5072. * tnode storing in ppu
  5073. * nld,ncon,nbas are already updated for storing in ppu
  5074. Revision 1.89 2002/08/11 15:28:00 florian
  5075. + support of explicit type case <any ordinal type>->pointer
  5076. (delphi mode only)
  5077. Revision 1.88 2002/08/11 14:32:28 peter
  5078. * renamed current_library to objectlibrary
  5079. Revision 1.87 2002/08/11 13:24:13 peter
  5080. * saving of asmsymbols in ppu supported
  5081. * asmsymbollist global is removed and moved into a new class
  5082. tasmlibrarydata that will hold the info of a .a file which
  5083. corresponds with a single module. Added librarydata to tmodule
  5084. to keep the library info stored for the module. In the future the
  5085. objectfiles will also be stored to the tasmlibrarydata class
  5086. * all getlabel/newasmsymbol and friends are moved to the new class
  5087. Revision 1.86 2002/08/09 07:33:03 florian
  5088. * a couple of interface related fixes
  5089. Revision 1.85 2002/07/23 09:51:24 daniel
  5090. * Tried to make Tprocsym.defs protected. I didn't succeed but the cleanups
  5091. are worth comitting.
  5092. Revision 1.84 2002/07/20 11:57:57 florian
  5093. * types.pas renamed to defbase.pas because D6 contains a types
  5094. unit so this would conflicts if D6 programms are compiled
  5095. + Willamette/SSE2 instructions to assembler added
  5096. Revision 1.83 2002/07/11 14:41:30 florian
  5097. * start of the new generic parameter handling
  5098. Revision 1.82 2002/07/07 09:52:32 florian
  5099. * powerpc target fixed, very simple units can be compiled
  5100. * some basic stuff for better callparanode handling, far from being finished
  5101. Revision 1.81 2002/07/01 18:46:26 peter
  5102. * internal linker
  5103. * reorganized aasm layer
  5104. Revision 1.80 2002/07/01 16:23:54 peter
  5105. * cg64 patch
  5106. * basics for currency
  5107. * asnode updates for class and interface (not finished)
  5108. Revision 1.79 2002/05/18 13:34:18 peter
  5109. * readded missing revisions
  5110. Revision 1.78 2002/05/16 19:46:44 carl
  5111. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  5112. + try to fix temp allocation (still in ifdef)
  5113. + generic constructor calls
  5114. + start of tassembler / tmodulebase class cleanup
  5115. Revision 1.76 2002/05/12 16:53:10 peter
  5116. * moved entry and exitcode to ncgutil and cgobj
  5117. * foreach gets extra argument for passing local data to the
  5118. iterator function
  5119. * -CR checks also class typecasts at runtime by changing them
  5120. into as
  5121. * fixed compiler to cycle with the -CR option
  5122. * fixed stabs with elf writer, finally the global variables can
  5123. be watched
  5124. * removed a lot of routines from cga unit and replaced them by
  5125. calls to cgobj
  5126. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  5127. u32bit then the other is typecasted also to u32bit without giving
  5128. a rangecheck warning/error.
  5129. * fixed pascal calling method with reversing also the high tree in
  5130. the parast, detected by tcalcst3 test
  5131. Revision 1.75 2002/04/25 20:16:39 peter
  5132. * moved more routines from cga/n386util
  5133. Revision 1.74 2002/04/23 19:16:35 peter
  5134. * add pinline unit that inserts compiler supported functions using
  5135. one or more statements
  5136. * moved finalize and setlength from ninl to pinline
  5137. Revision 1.73 2002/04/21 19:02:05 peter
  5138. * removed newn and disposen nodes, the code is now directly
  5139. inlined from pexpr
  5140. * -an option that will write the secondpass nodes to the .s file, this
  5141. requires EXTDEBUG define to actually write the info
  5142. * fixed various internal errors and crashes due recent code changes
  5143. Revision 1.72 2002/04/20 21:32:25 carl
  5144. + generic FPC_CHECKPOINTER
  5145. + first parameter offset in stack now portable
  5146. * rename some constants
  5147. + move some cpu stuff to other units
  5148. - remove unused constents
  5149. * fix stacksize for some targets
  5150. * fix generic size problems which depend now on EXTEND_SIZE constant
  5151. }