symdef.inc 130 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479
  1. {
  2. $Id$
  3. Copyright (c) 1993-99 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. {****************************************************************************
  19. TDEF (base class for definitions)
  20. ****************************************************************************}
  21. const
  22. { if you change one of the following contants, }
  23. { you have also to change the typinfo unit }
  24. { and the rtl/i386,template/rttip.inc files }
  25. tkUnknown = 0;
  26. tkInteger = 1;
  27. tkChar = 2;
  28. tkEnumeration = 3;
  29. tkFloat = 4;
  30. tkSet = 5;
  31. tkMethod = 6;
  32. tkSString = 7;
  33. tkString = tkSString;
  34. tkLString = 8;
  35. tkAString = 9;
  36. tkWString = 10;
  37. tkVariant = 11;
  38. tkArray = 12;
  39. tkRecord = 13;
  40. tkInterface = 14;
  41. tkClass = 15;
  42. tkObject = 16;
  43. tkWChar = 17;
  44. tkBool = 18;
  45. otSByte = 0;
  46. otUByte = 1;
  47. otSWord = 2;
  48. otUWord = 3;
  49. otSLong = 4;
  50. otULong = 5;
  51. ftSingle = 0;
  52. ftDouble = 1;
  53. ftExtended = 2;
  54. ftComp = 3;
  55. ftCurr = 4;
  56. ftFixed16 = 5;
  57. ftFixed32 = 6;
  58. mkProcedure = 0;
  59. mkFunction = 1;
  60. mkConstructor = 2;
  61. mkDestructor = 3;
  62. mkClassProcedure= 4;
  63. mkClassFunction = 5;
  64. pfvar = 1;
  65. pfConst = 2;
  66. pfArray = 4;
  67. pfAddress = 8;
  68. pfReference = 16;
  69. pfOut = 32;
  70. constructor tdef.init;
  71. begin
  72. inherited init;
  73. deftype:=abstractdef;
  74. owner := nil;
  75. sym := nil;
  76. savesize := 0;
  77. if registerdef then
  78. symtablestack^.registerdef(@self);
  79. has_rtti:=false;
  80. has_inittable:=false;
  81. {$ifdef GDB}
  82. is_def_stab_written := false;
  83. globalnb := 0;
  84. {$endif GDB}
  85. if assigned(lastglobaldef) then
  86. begin
  87. lastglobaldef^.nextglobal := @self;
  88. previousglobal:=lastglobaldef;
  89. end
  90. else
  91. begin
  92. firstglobaldef := @self;
  93. previousglobal := nil;
  94. end;
  95. lastglobaldef := @self;
  96. nextglobal := nil;
  97. end;
  98. constructor tdef.load;
  99. begin
  100. deftype:=abstractdef;
  101. next := nil;
  102. owner := nil;
  103. has_rtti:=false;
  104. has_inittable:=false;
  105. {$ifdef GDB}
  106. is_def_stab_written := false;
  107. globalnb := 0;
  108. {$endif GDB}
  109. if assigned(lastglobaldef) then
  110. begin
  111. lastglobaldef^.nextglobal := @self;
  112. previousglobal:=lastglobaldef;
  113. end
  114. else
  115. begin
  116. firstglobaldef := @self;
  117. previousglobal:=nil;
  118. end;
  119. lastglobaldef := @self;
  120. nextglobal := nil;
  121. { load }
  122. indexnr:=readword;
  123. sym:=ptypesym(readsymref);
  124. end;
  125. destructor tdef.done;
  126. begin
  127. { first element ? }
  128. if not(assigned(previousglobal)) then
  129. begin
  130. firstglobaldef := nextglobal;
  131. if assigned(firstglobaldef) then
  132. firstglobaldef^.previousglobal:=nil;
  133. end
  134. else
  135. begin
  136. { remove reference in the element before }
  137. previousglobal^.nextglobal:=nextglobal;
  138. end;
  139. { last element ? }
  140. if not(assigned(nextglobal)) then
  141. begin
  142. lastglobaldef := previousglobal;
  143. if assigned(lastglobaldef) then
  144. lastglobaldef^.nextglobal:=nil;
  145. end
  146. else
  147. nextglobal^.previousglobal:=previousglobal;
  148. previousglobal:=nil;
  149. nextglobal:=nil;
  150. while assigned(sym) do
  151. begin
  152. sym^.definition:=nil;
  153. sym:=sym^.synonym;
  154. end;
  155. end;
  156. { used for enumdef because the symbols are
  157. inserted in the owner symtable }
  158. procedure tdef.correct_owner_symtable;
  159. var
  160. st : psymtable;
  161. begin
  162. if assigned(owner) and
  163. (owner^.symtabletype in [recordsymtable,objectsymtable]) then
  164. begin
  165. owner^.defindex^.deleteindex(@self);
  166. st:=owner;
  167. while (st^.symtabletype in [recordsymtable,objectsymtable]) do
  168. st:=st^.next;
  169. st^.registerdef(@self);
  170. end;
  171. end;
  172. function tdef.typename:string;
  173. begin
  174. if assigned(sym) then
  175. typename:=Upper(sym^.name)
  176. else
  177. typename:=gettypename;
  178. end;
  179. function tdef.gettypename : string;
  180. begin
  181. gettypename:='<unknown type>'
  182. end;
  183. function tdef.is_in_current : boolean;
  184. var
  185. p : psymtable;
  186. begin
  187. p:=owner;
  188. is_in_current:=false;
  189. while assigned(p) do
  190. begin
  191. if (p=current_module^.globalsymtable) or (p=current_module^.localsymtable)
  192. or (p^.symtabletype in [globalsymtable,staticsymtable]) then
  193. begin
  194. is_in_current:=true;
  195. exit;
  196. end
  197. else if p^.symtabletype=objectsymtable then
  198. begin
  199. if assigned(p^.defowner) then
  200. p:=pobjectdef(p^.defowner)^.owner
  201. else
  202. exit;
  203. end
  204. else
  205. exit;
  206. end;
  207. end;
  208. procedure tdef.write;
  209. begin
  210. writeword(indexnr);
  211. writesymref(sym);
  212. {$ifdef GDB}
  213. if globalnb = 0 then
  214. begin
  215. if assigned(owner) then
  216. globalnb := owner^.getnewtypecount
  217. else
  218. begin
  219. globalnb := PGlobalTypeCount^;
  220. Inc(PGlobalTypeCount^);
  221. end;
  222. end;
  223. {$endif GDB}
  224. end;
  225. function tdef.size : longint;
  226. begin
  227. size:=savesize;
  228. end;
  229. function tdef.alignment : longint;
  230. begin
  231. { normal alignment by default }
  232. alignment:=0;
  233. end;
  234. {$ifdef GDB}
  235. procedure tdef.set_globalnb;
  236. begin
  237. globalnb :=PGlobalTypeCount^;
  238. inc(PglobalTypeCount^);
  239. end;
  240. function tdef.stabstring : pchar;
  241. begin
  242. stabstring := strpnew('t'+numberstring+';');
  243. end;
  244. function tdef.numberstring : string;
  245. var table : psymtable;
  246. begin
  247. {formal def have no type !}
  248. if deftype = formaldef then
  249. begin
  250. numberstring := voiddef^.numberstring;
  251. exit;
  252. end;
  253. if (not assigned(sym)) or (not sym^.isusedinstab) then
  254. begin
  255. {set even if debuglist is not defined}
  256. if assigned(sym) then
  257. sym^.isusedinstab := true;
  258. if assigned(debuglist) and not is_def_stab_written then
  259. concatstabto(debuglist);
  260. end;
  261. if not (cs_gdb_dbx in aktglobalswitches) then
  262. begin
  263. if globalnb = 0 then
  264. set_globalnb;
  265. numberstring := tostr(globalnb);
  266. end
  267. else
  268. begin
  269. if globalnb = 0 then
  270. begin
  271. if assigned(owner) then
  272. globalnb := owner^.getnewtypecount
  273. else
  274. begin
  275. globalnb := PGlobalTypeCount^;
  276. Inc(PGlobalTypeCount^);
  277. end;
  278. end;
  279. if assigned(sym) then
  280. begin
  281. table := sym^.owner;
  282. if table^.unitid > 0 then
  283. numberstring := '('+tostr(table^.unitid)+','
  284. +tostr(sym^.definition^.globalnb)+')'
  285. else
  286. numberstring := tostr(globalnb);
  287. exit;
  288. end;
  289. numberstring := tostr(globalnb);
  290. end;
  291. end;
  292. function tdef.allstabstring : pchar;
  293. var stabchar : string[2];
  294. ss,st : pchar;
  295. sname : string;
  296. sym_line_no : longint;
  297. begin
  298. ss := stabstring;
  299. getmem(st,strlen(ss)+512);
  300. stabchar := 't';
  301. if deftype in tagtypes then
  302. stabchar := 'Tt';
  303. if assigned(sym) then
  304. begin
  305. sname := sym^.name;
  306. sym_line_no:=sym^.fileinfo.line;
  307. end
  308. else
  309. begin
  310. sname := ' ';
  311. sym_line_no:=0;
  312. end;
  313. strpcopy(st,'"'+sname+':'+stabchar+numberstring+'=');
  314. strpcopy(strecopy(strend(st),ss),'",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0');
  315. allstabstring := strnew(st);
  316. freemem(st,strlen(ss)+512);
  317. strdispose(ss);
  318. end;
  319. procedure tdef.concatstabto(asmlist : paasmoutput);
  320. var stab_str : pchar;
  321. begin
  322. if ((sym = nil) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  323. and not is_def_stab_written then
  324. begin
  325. If cs_gdb_dbx in aktglobalswitches then
  326. begin
  327. { otherwise you get two of each def }
  328. If assigned(sym) then
  329. begin
  330. if sym^.typ=typesym then
  331. sym^.isusedinstab:=true;
  332. if (sym^.owner = nil) or
  333. ((sym^.owner^.symtabletype = unitsymtable) and
  334. punitsymtable(sym^.owner)^.dbx_count_ok) then
  335. begin
  336. {with DBX we get the definition from the other objects }
  337. is_def_stab_written := true;
  338. exit;
  339. end;
  340. end;
  341. end;
  342. { to avoid infinite loops }
  343. is_def_stab_written := true;
  344. stab_str := allstabstring;
  345. if asmlist = debuglist then do_count_dbx := true;
  346. { count_dbx(stab_str); moved to GDB.PAS}
  347. asmlist^.concat(new(pai_stabs,init(stab_str)));
  348. end;
  349. end;
  350. {$endif GDB}
  351. procedure tdef.deref;
  352. begin
  353. end;
  354. procedure tdef.symderef;
  355. begin
  356. resolvesym(psym(sym));
  357. end;
  358. { rtti generation }
  359. procedure tdef.generate_rtti;
  360. begin
  361. has_rtti:=true;
  362. getdatalabel(rtti_label);
  363. write_child_rtti_data;
  364. rttilist^.concat(new(pai_symbol,init(rtti_label,0)));
  365. write_rtti_data;
  366. rttilist^.concat(new(pai_symbol_end,init(rtti_label)));
  367. end;
  368. function tdef.get_rtti_label : string;
  369. begin
  370. if not(has_rtti) then
  371. generate_rtti;
  372. get_rtti_label:=rtti_label^.name;
  373. end;
  374. { init table handling }
  375. function tdef.needs_inittable : boolean;
  376. begin
  377. needs_inittable:=false;
  378. end;
  379. procedure tdef.generate_inittable;
  380. begin
  381. has_inittable:=true;
  382. getdatalabel(inittable_label);
  383. write_child_init_data;
  384. rttilist^.concat(new(pai_label,init(inittable_label)));
  385. write_init_data;
  386. end;
  387. procedure tdef.write_init_data;
  388. begin
  389. write_rtti_data;
  390. end;
  391. procedure tdef.write_child_init_data;
  392. begin
  393. write_child_rtti_data;
  394. end;
  395. function tdef.get_inittable_label : pasmlabel;
  396. begin
  397. if not(has_inittable) then
  398. generate_inittable;
  399. get_inittable_label:=inittable_label;
  400. end;
  401. procedure tdef.write_rtti_name;
  402. var
  403. str : string;
  404. begin
  405. { name }
  406. if assigned(sym) then
  407. begin
  408. str:=sym^.name;
  409. rttilist^.concat(new(pai_string,init(chr(length(str))+str)));
  410. end
  411. else
  412. rttilist^.concat(new(pai_string,init(#0)))
  413. end;
  414. { returns true, if the definition can be published }
  415. function tdef.is_publishable : boolean;
  416. begin
  417. is_publishable:=false;
  418. end;
  419. procedure tdef.write_rtti_data;
  420. begin
  421. end;
  422. procedure tdef.write_child_rtti_data;
  423. begin
  424. end;
  425. function tdef.is_intregable : boolean;
  426. begin
  427. is_intregable:=false;
  428. case deftype of
  429. pointerdef,
  430. enumdef,
  431. procvardef :
  432. is_intregable:=true;
  433. orddef :
  434. case porddef(@self)^.typ of
  435. bool8bit,bool16bit,bool32bit,
  436. u8bit,u16bit,u32bit,
  437. s8bit,s16bit,s32bit:
  438. is_intregable:=true;
  439. end;
  440. setdef:
  441. is_intregable:=is_smallset(@self);
  442. end;
  443. end;
  444. function tdef.is_fpuregable : boolean;
  445. begin
  446. is_fpuregable:=(deftype=floatdef) and not(pfloatdef(@self)^.typ in [f32bit,f16bit]);
  447. end;
  448. {****************************************************************************
  449. TSTRINGDEF
  450. ****************************************************************************}
  451. constructor tstringdef.shortinit(l : byte);
  452. begin
  453. tdef.init;
  454. string_typ:=st_shortstring;
  455. deftype:=stringdef;
  456. len:=l;
  457. savesize:=len+1;
  458. end;
  459. constructor tstringdef.shortload;
  460. begin
  461. tdef.load;
  462. string_typ:=st_shortstring;
  463. deftype:=stringdef;
  464. len:=readbyte;
  465. savesize:=len+1;
  466. end;
  467. constructor tstringdef.longinit(l : longint);
  468. begin
  469. tdef.init;
  470. string_typ:=st_longstring;
  471. deftype:=stringdef;
  472. len:=l;
  473. savesize:=target_os.size_of_pointer;
  474. end;
  475. constructor tstringdef.longload;
  476. begin
  477. tdef.load;
  478. deftype:=stringdef;
  479. string_typ:=st_longstring;
  480. len:=readlong;
  481. savesize:=target_os.size_of_pointer;
  482. end;
  483. constructor tstringdef.ansiinit(l : longint);
  484. begin
  485. tdef.init;
  486. string_typ:=st_ansistring;
  487. deftype:=stringdef;
  488. len:=l;
  489. savesize:=target_os.size_of_pointer;
  490. end;
  491. constructor tstringdef.ansiload;
  492. begin
  493. tdef.load;
  494. deftype:=stringdef;
  495. string_typ:=st_ansistring;
  496. len:=readlong;
  497. savesize:=target_os.size_of_pointer;
  498. end;
  499. constructor tstringdef.wideinit(l : longint);
  500. begin
  501. tdef.init;
  502. string_typ:=st_widestring;
  503. deftype:=stringdef;
  504. len:=l;
  505. savesize:=target_os.size_of_pointer;
  506. end;
  507. constructor tstringdef.wideload;
  508. begin
  509. tdef.load;
  510. deftype:=stringdef;
  511. string_typ:=st_widestring;
  512. len:=readlong;
  513. savesize:=target_os.size_of_pointer;
  514. end;
  515. function tstringdef.stringtypname:string;
  516. const
  517. typname:array[tstringtype] of string[8]=(
  518. 'SHORTSTR','LONGSTR','ANSISTR','WIDESTR'
  519. );
  520. begin
  521. stringtypname:=typname[string_typ];
  522. end;
  523. function tstringdef.size : longint;
  524. begin
  525. size:=savesize;
  526. end;
  527. procedure tstringdef.write;
  528. begin
  529. tdef.write;
  530. if string_typ=st_shortstring then
  531. writebyte(len)
  532. else
  533. writelong(len);
  534. case string_typ of
  535. st_shortstring : current_ppu^.writeentry(ibshortstringdef);
  536. st_longstring : current_ppu^.writeentry(iblongstringdef);
  537. st_ansistring : current_ppu^.writeentry(ibansistringdef);
  538. st_widestring : current_ppu^.writeentry(ibwidestringdef);
  539. end;
  540. end;
  541. {$ifdef GDB}
  542. function tstringdef.stabstring : pchar;
  543. var
  544. bytest,charst,longst : string;
  545. begin
  546. case string_typ of
  547. st_shortstring:
  548. begin
  549. charst := typeglobalnumber('char');
  550. { this is what I found in stabs.texinfo but
  551. gdb 4.12 for go32 doesn't understand that !! }
  552. {$IfDef GDBknowsstrings}
  553. stabstring := strpnew('n'+charst+';'+tostr(len));
  554. {$else}
  555. bytest := typeglobalnumber('byte');
  556. stabstring := strpnew('s'+tostr(len+1)+'length:'+bytest
  557. +',0,8;st:ar'+bytest
  558. +';1;'+tostr(len)+';'+charst+',8,'+tostr(len*8)+';;');
  559. {$EndIf}
  560. end;
  561. st_longstring:
  562. begin
  563. charst := typeglobalnumber('char');
  564. { this is what I found in stabs.texinfo but
  565. gdb 4.12 for go32 doesn't understand that !! }
  566. {$IfDef GDBknowsstrings}
  567. stabstring := strpnew('n'+charst+';'+tostr(len));
  568. {$else}
  569. bytest := typeglobalnumber('byte');
  570. longst := typeglobalnumber('longint');
  571. stabstring := strpnew('s'+tostr(len+5)+'length:'+longst
  572. +',0,32;dummy:'+bytest+',32,8;st:ar'+bytest
  573. +';1;'+tostr(len)+';'+charst+',40,'+tostr(len*8)+';;');
  574. {$EndIf}
  575. end;
  576. st_ansistring:
  577. begin
  578. { an ansi string looks like a pchar easy !! }
  579. stabstring:=strpnew('*'+typeglobalnumber('char'));
  580. end;
  581. st_widestring:
  582. begin
  583. { an ansi string looks like a pchar easy !! }
  584. stabstring:=strpnew('*'+typeglobalnumber('char'));
  585. end;
  586. end;
  587. end;
  588. procedure tstringdef.concatstabto(asmlist : paasmoutput);
  589. begin
  590. inherited concatstabto(asmlist);
  591. end;
  592. {$endif GDB}
  593. function tstringdef.needs_inittable : boolean;
  594. begin
  595. needs_inittable:=string_typ in [st_ansistring,st_widestring];
  596. end;
  597. function tstringdef.gettypename : string;
  598. const
  599. names : array[tstringtype] of string[20] =
  600. ('ShortString','LongString','AnsiString','WideString');
  601. begin
  602. gettypename:=names[string_typ];
  603. end;
  604. procedure tstringdef.write_rtti_data;
  605. begin
  606. case string_typ of
  607. st_ansistring:
  608. begin
  609. rttilist^.concat(new(pai_const,init_8bit(tkAString)));
  610. write_rtti_name;
  611. end;
  612. st_widestring:
  613. begin
  614. rttilist^.concat(new(pai_const,init_8bit(tkWString)));
  615. write_rtti_name;
  616. end;
  617. st_longstring:
  618. begin
  619. rttilist^.concat(new(pai_const,init_8bit(tkLString)));
  620. write_rtti_name;
  621. end;
  622. st_shortstring:
  623. begin
  624. rttilist^.concat(new(pai_const,init_8bit(tkSString)));
  625. write_rtti_name;
  626. rttilist^.concat(new(pai_const,init_8bit(len)));
  627. end;
  628. end;
  629. end;
  630. function tstringdef.is_publishable : boolean;
  631. begin
  632. is_publishable:=true;
  633. end;
  634. {****************************************************************************
  635. TENUMDEF
  636. ****************************************************************************}
  637. constructor tenumdef.init;
  638. begin
  639. tdef.init;
  640. deftype:=enumdef;
  641. minval:=0;
  642. maxval:=0;
  643. calcsavesize;
  644. has_jumps:=false;
  645. basedef:=nil;
  646. rangenr:=0;
  647. firstenum:=nil;
  648. correct_owner_symtable;
  649. end;
  650. constructor tenumdef.init_subrange(_basedef:penumdef;_min,_max:longint);
  651. begin
  652. tdef.init;
  653. deftype:=enumdef;
  654. minval:=_min;
  655. maxval:=_max;
  656. basedef:=_basedef;
  657. calcsavesize;
  658. has_jumps:=false;
  659. rangenr:=0;
  660. firstenum:=basedef^.firstenum;
  661. while assigned(firstenum) and (penumsym(firstenum)^.value<>minval) do
  662. firstenum:=firstenum^.nextenum;
  663. correct_owner_symtable;
  664. end;
  665. constructor tenumdef.load;
  666. begin
  667. tdef.load;
  668. deftype:=enumdef;
  669. basedef:=penumdef(readdefref);
  670. minval:=readlong;
  671. maxval:=readlong;
  672. savesize:=readlong;
  673. has_jumps:=false;
  674. firstenum:=Nil;
  675. end;
  676. procedure tenumdef.calcsavesize;
  677. begin
  678. if (aktpackenum=4) or (min<0) or (max>65535) then
  679. savesize:=4
  680. else
  681. if (aktpackenum=2) or (min<0) or (max>255) then
  682. savesize:=2
  683. else
  684. savesize:=1;
  685. end;
  686. procedure tenumdef.setmax(_max:longint);
  687. begin
  688. maxval:=_max;
  689. calcsavesize;
  690. end;
  691. procedure tenumdef.setmin(_min:longint);
  692. begin
  693. minval:=_min;
  694. calcsavesize;
  695. end;
  696. function tenumdef.min:longint;
  697. begin
  698. min:=minval;
  699. end;
  700. function tenumdef.max:longint;
  701. begin
  702. max:=maxval;
  703. end;
  704. procedure tenumdef.deref;
  705. begin
  706. resolvedef(pdef(basedef));
  707. end;
  708. destructor tenumdef.done;
  709. begin
  710. inherited done;
  711. end;
  712. procedure tenumdef.write;
  713. begin
  714. tdef.write;
  715. writedefref(basedef);
  716. writelong(min);
  717. writelong(max);
  718. writelong(savesize);
  719. current_ppu^.writeentry(ibenumdef);
  720. end;
  721. function tenumdef.getrangecheckstring : string;
  722. begin
  723. if (cs_create_smart in aktmoduleswitches) then
  724. getrangecheckstring:='R_'+current_module^.modulename^+tostr(rangenr)
  725. else
  726. getrangecheckstring:='R_'+tostr(rangenr);
  727. end;
  728. procedure tenumdef.genrangecheck;
  729. begin
  730. if rangenr=0 then
  731. begin
  732. { generate two constant for bounds }
  733. getlabelnr(rangenr);
  734. if (cs_create_smart in aktmoduleswitches) then
  735. datasegment^.concat(new(pai_symbol,initname_global(getrangecheckstring,8)))
  736. else
  737. datasegment^.concat(new(pai_symbol,initname(getrangecheckstring,8)));
  738. datasegment^.concat(new(pai_const,init_32bit(min)));
  739. datasegment^.concat(new(pai_const,init_32bit(max)));
  740. end;
  741. end;
  742. {$ifdef GDB}
  743. function tenumdef.stabstring : pchar;
  744. var st,st2 : pchar;
  745. p : penumsym;
  746. s : string;
  747. memsize : word;
  748. begin
  749. memsize := memsizeinc;
  750. getmem(st,memsize);
  751. strpcopy(st,'e');
  752. p := firstenum;
  753. while assigned(p) do
  754. begin
  755. s :=p^.name+':'+tostr(p^.value)+',';
  756. { place for the ending ';' also }
  757. if (strlen(st)+length(s)+1<memsize) then
  758. strpcopy(strend(st),s)
  759. else
  760. begin
  761. getmem(st2,memsize+memsizeinc);
  762. strcopy(st2,st);
  763. freemem(st,memsize);
  764. st := st2;
  765. memsize := memsize+memsizeinc;
  766. strpcopy(strend(st),s);
  767. end;
  768. p := p^.nextenum;
  769. end;
  770. strpcopy(strend(st),';');
  771. stabstring := strnew(st);
  772. freemem(st,memsize);
  773. end;
  774. {$endif GDB}
  775. procedure tenumdef.write_child_rtti_data;
  776. begin
  777. if assigned(basedef) then
  778. basedef^.get_rtti_label;
  779. end;
  780. procedure tenumdef.write_rtti_data;
  781. var
  782. hp : penumsym;
  783. begin
  784. rttilist^.concat(new(pai_const,init_8bit(tkEnumeration)));
  785. write_rtti_name;
  786. case savesize of
  787. 1:
  788. rttilist^.concat(new(pai_const,init_8bit(otUByte)));
  789. 2:
  790. rttilist^.concat(new(pai_const,init_8bit(otUWord)));
  791. 4:
  792. rttilist^.concat(new(pai_const,init_8bit(otULong)));
  793. end;
  794. rttilist^.concat(new(pai_const,init_32bit(min)));
  795. rttilist^.concat(new(pai_const,init_32bit(max)));
  796. if assigned(basedef) then
  797. rttilist^.concat(new(pai_const_symbol,initname(basedef^.get_rtti_label)))
  798. else
  799. rttilist^.concat(new(pai_const,init_32bit(0)));
  800. hp:=firstenum;
  801. while assigned(hp) do
  802. begin
  803. rttilist^.concat(new(pai_const,init_8bit(length(hp^.name))));
  804. rttilist^.concat(new(pai_string,init(globals.lower(hp^.name))));
  805. hp:=hp^.nextenum;
  806. end;
  807. rttilist^.concat(new(pai_const,init_8bit(0)));
  808. end;
  809. function tenumdef.is_publishable : boolean;
  810. begin
  811. is_publishable:=true;
  812. end;
  813. function tenumdef.gettypename : string;
  814. begin
  815. gettypename:='<enumeration type>';
  816. end;
  817. {****************************************************************************
  818. TORDDEF
  819. ****************************************************************************}
  820. constructor torddef.init(t : tbasetype;v,b : longint);
  821. begin
  822. inherited init;
  823. deftype:=orddef;
  824. low:=v;
  825. high:=b;
  826. typ:=t;
  827. rangenr:=0;
  828. setsize;
  829. end;
  830. constructor torddef.load;
  831. begin
  832. inherited load;
  833. deftype:=orddef;
  834. typ:=tbasetype(readbyte);
  835. low:=readlong;
  836. high:=readlong;
  837. rangenr:=0;
  838. setsize;
  839. end;
  840. procedure torddef.setsize;
  841. begin
  842. if typ=uauto then
  843. begin
  844. { generate a unsigned range if high<0 and low>=0 }
  845. if (low>=0) and (high<0) then
  846. begin
  847. savesize:=4;
  848. typ:=u32bit;
  849. end
  850. else if (low>=0) and (high<=255) then
  851. begin
  852. savesize:=1;
  853. typ:=u8bit;
  854. end
  855. else if (low>=-128) and (high<=127) then
  856. begin
  857. savesize:=1;
  858. typ:=s8bit;
  859. end
  860. else if (low>=0) and (high<=65536) then
  861. begin
  862. savesize:=2;
  863. typ:=u16bit;
  864. end
  865. else if (low>=-32768) and (high<=32767) then
  866. begin
  867. savesize:=2;
  868. typ:=s16bit;
  869. end
  870. else
  871. begin
  872. savesize:=4;
  873. typ:=s32bit;
  874. end;
  875. end
  876. else
  877. begin
  878. case typ of
  879. u8bit,s8bit,
  880. uchar,bool8bit:
  881. savesize:=1;
  882. u16bit,s16bit,
  883. bool16bit:
  884. savesize:=2;
  885. s32bit,u32bit,
  886. bool32bit:
  887. savesize:=4;
  888. u64bit,s64bit:
  889. savesize:=8;
  890. else
  891. savesize:=0;
  892. end;
  893. end;
  894. { there are no entrys for range checking }
  895. rangenr:=0;
  896. end;
  897. function torddef.getrangecheckstring : string;
  898. begin
  899. if (cs_create_smart in aktmoduleswitches) then
  900. getrangecheckstring:='R_'+current_module^.modulename^+tostr(rangenr)
  901. else
  902. getrangecheckstring:='R_'+tostr(rangenr);
  903. end;
  904. procedure torddef.genrangecheck;
  905. var
  906. rangechecksize : longint;
  907. begin
  908. if rangenr=0 then
  909. begin
  910. if low<=high then
  911. rangechecksize:=8
  912. else
  913. rangechecksize:=16;
  914. { generate two constant for bounds }
  915. getlabelnr(rangenr);
  916. if (cs_create_smart in aktmoduleswitches) then
  917. datasegment^.concat(new(pai_symbol,initname_global(getrangecheckstring,rangechecksize)))
  918. else
  919. datasegment^.concat(new(pai_symbol,initname(getrangecheckstring,rangechecksize)));
  920. if low<=high then
  921. begin
  922. datasegment^.concat(new(pai_const,init_32bit(low)));
  923. datasegment^.concat(new(pai_const,init_32bit(high)));
  924. end
  925. { for u32bit we need two bounds }
  926. else
  927. begin
  928. datasegment^.concat(new(pai_const,init_32bit(low)));
  929. datasegment^.concat(new(pai_const,init_32bit($7fffffff)));
  930. datasegment^.concat(new(pai_const,init_32bit($80000000)));
  931. datasegment^.concat(new(pai_const,init_32bit(high)));
  932. end;
  933. end;
  934. end;
  935. procedure torddef.write;
  936. begin
  937. tdef.write;
  938. writebyte(byte(typ));
  939. writelong(low);
  940. writelong(high);
  941. current_ppu^.writeentry(iborddef);
  942. end;
  943. {$ifdef GDB}
  944. function torddef.stabstring : pchar;
  945. begin
  946. case typ of
  947. uvoid : stabstring := strpnew(numberstring+';');
  948. {GDB 4.12 for go32 doesn't like boolean as range for 0 to 1 !!!}
  949. {$ifdef Use_integer_types_for_boolean}
  950. bool8bit,
  951. bool16bit,
  952. bool32bit : stabstring := strpnew('r'+numberstring+';0;255;');
  953. {$else : not Use_integer_types_for_boolean}
  954. bool8bit : stabstring := strpnew('-21;');
  955. bool16bit : stabstring := strpnew('-22;');
  956. bool32bit : stabstring := strpnew('-23;');
  957. u64bit : stabstring := strpnew('-32;');
  958. s64bit : stabstring := strpnew('-31;');
  959. {$endif not Use_integer_types_for_boolean}
  960. { u32bit : stabstring := strpnew('r'+
  961. s32bitdef^.numberstring+';0;-1;'); }
  962. else
  963. stabstring := strpnew('r'+s32bitdef^.numberstring+';'+tostr(low)+';'+tostr(high)+';');
  964. end;
  965. end;
  966. {$endif GDB}
  967. procedure torddef.write_rtti_data;
  968. const
  969. trans : array[uchar..bool8bit] of byte =
  970. (otUByte,otUByte,otUWord,otULong,otSByte,otSWord,otSLong,otUByte);
  971. begin
  972. case typ of
  973. bool8bit:
  974. rttilist^.concat(new(pai_const,init_8bit(tkBool)));
  975. uchar:
  976. rttilist^.concat(new(pai_const,init_8bit(tkChar)));
  977. else
  978. rttilist^.concat(new(pai_const,init_8bit(tkInteger)));
  979. end;
  980. write_rtti_name;
  981. rttilist^.concat(new(pai_const,init_8bit(byte(trans[typ]))));
  982. rttilist^.concat(new(pai_const,init_32bit(low)));
  983. rttilist^.concat(new(pai_const,init_32bit(high)));
  984. end;
  985. function torddef.is_publishable : boolean;
  986. begin
  987. is_publishable:=typ in [uchar..bool8bit];
  988. end;
  989. function torddef.gettypename : string;
  990. const
  991. names : array[tbasetype] of string[20] = ('<unknown type>',
  992. 'untyped','Char','Byte','Word','DWord','ShortInt',
  993. 'SmallInt','LongInt','Boolean','WordBool',
  994. 'LongBool','QWord','Int64');
  995. begin
  996. gettypename:=names[typ];
  997. end;
  998. {****************************************************************************
  999. TFLOATDEF
  1000. ****************************************************************************}
  1001. constructor tfloatdef.init(t : tfloattype);
  1002. begin
  1003. inherited init;
  1004. deftype:=floatdef;
  1005. typ:=t;
  1006. setsize;
  1007. end;
  1008. constructor tfloatdef.load;
  1009. begin
  1010. inherited load;
  1011. deftype:=floatdef;
  1012. typ:=tfloattype(readbyte);
  1013. setsize;
  1014. end;
  1015. procedure tfloatdef.setsize;
  1016. begin
  1017. case typ of
  1018. f16bit : savesize:=2;
  1019. f32bit,
  1020. s32real : savesize:=4;
  1021. s64real : savesize:=8;
  1022. s80real : savesize:=extended_size;
  1023. s64comp : savesize:=8;
  1024. else
  1025. savesize:=0;
  1026. end;
  1027. end;
  1028. procedure tfloatdef.write;
  1029. begin
  1030. inherited write;
  1031. writebyte(byte(typ));
  1032. current_ppu^.writeentry(ibfloatdef);
  1033. end;
  1034. {$ifdef GDB}
  1035. function tfloatdef.stabstring : pchar;
  1036. begin
  1037. case typ of
  1038. s32real,
  1039. s64real : stabstring := strpnew('r'+
  1040. s32bitdef^.numberstring+';'+tostr(savesize)+';0;');
  1041. { for fixed real use longint instead to be able to }
  1042. { debug something at least }
  1043. f32bit:
  1044. stabstring := s32bitdef^.stabstring;
  1045. f16bit:
  1046. stabstring := strpnew('r'+s32bitdef^.numberstring+';0;'+
  1047. tostr($ffff)+';');
  1048. { found this solution in stabsread.c from GDB v4.16 }
  1049. s64comp : stabstring := strpnew('r'+
  1050. s32bitdef^.numberstring+';-'+tostr(savesize)+';0;');
  1051. {$ifdef i386}
  1052. { under dos at least you must give a size of twelve instead of 10 !! }
  1053. { this is probably do to the fact that in gcc all is pushed in 4 bytes size }
  1054. s80real : stabstring := strpnew('r'+s32bitdef^.numberstring+';12;0;');
  1055. {$endif i386}
  1056. else
  1057. internalerror(10005);
  1058. end;
  1059. end;
  1060. {$endif GDB}
  1061. procedure tfloatdef.write_rtti_data;
  1062. const
  1063. {tfloattype = (s32real,s64real,s80real,s64bit,f16bit,f32bit);}
  1064. translate : array[tfloattype] of byte =
  1065. (ftSingle,ftDouble,ftExtended,ftComp,ftFixed16,ftFixed32);
  1066. begin
  1067. rttilist^.concat(new(pai_const,init_8bit(tkFloat)));
  1068. write_rtti_name;
  1069. rttilist^.concat(new(pai_const,init_8bit(translate[typ])));
  1070. end;
  1071. function tfloatdef.is_publishable : boolean;
  1072. begin
  1073. is_publishable:=true;
  1074. end;
  1075. function tfloatdef.gettypename : string;
  1076. const
  1077. names : array[tfloattype] of string[20] = (
  1078. 'Single','Double','Extended','Comp','Fixed','Fixed16');
  1079. begin
  1080. gettypename:=names[typ];
  1081. end;
  1082. {****************************************************************************
  1083. TFILEDEF
  1084. ****************************************************************************}
  1085. constructor tfiledef.init(ft : tfiletype;tas : pdef);
  1086. begin
  1087. inherited init;
  1088. deftype:=filedef;
  1089. filetype:=ft;
  1090. typed_as:=tas;
  1091. setsize;
  1092. end;
  1093. constructor tfiledef.load;
  1094. begin
  1095. inherited load;
  1096. deftype:=filedef;
  1097. filetype:=tfiletype(readbyte);
  1098. if filetype=ft_typed then
  1099. typed_as:=readdefref
  1100. else
  1101. typed_as:=nil;
  1102. setsize;
  1103. end;
  1104. procedure tfiledef.deref;
  1105. begin
  1106. if filetype=ft_typed then
  1107. resolvedef(typed_as);
  1108. end;
  1109. procedure tfiledef.setsize;
  1110. begin
  1111. case filetype of
  1112. ft_text : savesize:=572;
  1113. ft_typed,
  1114. ft_untyped : savesize:=316;
  1115. end;
  1116. end;
  1117. procedure tfiledef.write;
  1118. begin
  1119. inherited write;
  1120. writebyte(byte(filetype));
  1121. if filetype=ft_typed then
  1122. writedefref(typed_as);
  1123. current_ppu^.writeentry(ibfiledef);
  1124. end;
  1125. {$ifdef GDB}
  1126. function tfiledef.stabstring : pchar;
  1127. begin
  1128. {$IfDef GDBknowsfiles}
  1129. case filetyp of
  1130. ft_typed : stabstring := strpnew('d'+typed_as^.numberstring{+';'});
  1131. ft_untyped : stabstring := strpnew('d'+voiddef^.numberstring{+';'});
  1132. ft_text : stabstring := strpnew('d'+cchardef^.numberstring{+';'});
  1133. end;
  1134. {$Else}
  1135. {based on
  1136. FileRec = Packed Record
  1137. Handle,
  1138. Mode,
  1139. RecSize : longint;
  1140. _private : array[1..32] of byte;
  1141. UserData : array[1..16] of byte;
  1142. name : array[0..255] of char;
  1143. End; }
  1144. { the buffer part is still missing !! (PM) }
  1145. { but the string could become too long !! }
  1146. stabstring := strpnew('s'+tostr(savesize)+
  1147. 'HANDLE:'+typeglobalnumber('longint')+',0,32;'+
  1148. 'MODE:'+typeglobalnumber('longint')+',32,32;'+
  1149. 'RECSIZE:'+typeglobalnumber('longint')+',64,32;'+
  1150. '_PRIVATE:ar'+typeglobalnumber('word')+';1;32;'+typeglobalnumber('byte')
  1151. +',96,256;'+
  1152. 'USERDATA:ar'+typeglobalnumber('word')+';1;16;'+typeglobalnumber('byte')
  1153. +',352,128;'+
  1154. 'NAME:ar'+typeglobalnumber('word')+';0;255;'+typeglobalnumber('char')
  1155. +',480,2048;;');
  1156. {$EndIf}
  1157. end;
  1158. procedure tfiledef.concatstabto(asmlist : paasmoutput);
  1159. begin
  1160. { most file defs are unnamed !!! }
  1161. if ((sym = nil) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1162. not is_def_stab_written then
  1163. begin
  1164. if assigned(typed_as) then forcestabto(asmlist,typed_as);
  1165. inherited concatstabto(asmlist);
  1166. end;
  1167. end;
  1168. {$endif GDB}
  1169. function tfiledef.gettypename : string;
  1170. begin
  1171. case filetype of
  1172. ft_untyped:
  1173. gettypename:='File';
  1174. ft_typed:
  1175. gettypename:='File Of '+typed_as^.typename;
  1176. ft_text:
  1177. gettypename:='Text'
  1178. end;
  1179. end;
  1180. {****************************************************************************
  1181. TPOINTERDEF
  1182. ****************************************************************************}
  1183. constructor tpointerdef.init(def : pdef);
  1184. begin
  1185. inherited init;
  1186. deftype:=pointerdef;
  1187. definition:=def;
  1188. is_far:=false;
  1189. savesize:=target_os.size_of_pointer;
  1190. end;
  1191. constructor tpointerdef.initfar(def : pdef);
  1192. begin
  1193. inherited init;
  1194. deftype:=pointerdef;
  1195. definition:=def;
  1196. is_far:=true;
  1197. savesize:=target_os.size_of_pointer;
  1198. end;
  1199. constructor tpointerdef.load;
  1200. begin
  1201. inherited load;
  1202. deftype:=pointerdef;
  1203. { the real address in memory is calculated later (deref) }
  1204. definition:=readdefref;
  1205. is_far:=(readbyte<>0);
  1206. savesize:=target_os.size_of_pointer;
  1207. end;
  1208. destructor tpointerdef.done;
  1209. begin
  1210. if assigned(definition) and
  1211. (definition^.deftype=forwarddef) then
  1212. begin
  1213. dispose(definition,done);
  1214. definition:=nil;
  1215. end;
  1216. inherited done;
  1217. end;
  1218. procedure tpointerdef.deref;
  1219. begin
  1220. resolvedef(definition);
  1221. end;
  1222. procedure tpointerdef.write;
  1223. begin
  1224. inherited write;
  1225. writedefref(definition);
  1226. writebyte(byte(is_far));
  1227. current_ppu^.writeentry(ibpointerdef);
  1228. end;
  1229. {$ifdef GDB}
  1230. function tpointerdef.stabstring : pchar;
  1231. begin
  1232. stabstring := strpnew('*'+definition^.numberstring);
  1233. end;
  1234. procedure tpointerdef.concatstabto(asmlist : paasmoutput);
  1235. var st,nb : string;
  1236. sym_line_no : longint;
  1237. begin
  1238. if ( (sym=nil) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1239. not is_def_stab_written then
  1240. begin
  1241. if assigned(definition) then
  1242. if definition^.deftype in [recorddef,objectdef] then
  1243. begin
  1244. is_def_stab_written := true;
  1245. {to avoid infinite recursion in record with next-like fields }
  1246. nb := definition^.numberstring;
  1247. is_def_stab_written := false;
  1248. if not definition^.is_def_stab_written then
  1249. begin
  1250. if assigned(definition^.sym) then
  1251. begin
  1252. if assigned(sym) then
  1253. begin
  1254. st := sym^.name;
  1255. sym_line_no:=sym^.fileinfo.line;
  1256. end
  1257. else
  1258. begin
  1259. st := ' ';
  1260. sym_line_no:=0;
  1261. end;
  1262. st := '"'+st+':t'+numberstring+'=*'+definition^.numberstring
  1263. +'=xs'+definition^.sym^.name+':",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0';
  1264. if asmlist = debuglist then do_count_dbx := true;
  1265. asmlist^.concat(new(pai_stabs,init(strpnew(st))));
  1266. end;
  1267. end else inherited concatstabto(asmlist);
  1268. is_def_stab_written := true;
  1269. end else
  1270. begin
  1271. { p =^p1; p1=^p problem }
  1272. is_def_stab_written := true;
  1273. forcestabto(asmlist,definition);
  1274. is_def_stab_written := false;
  1275. inherited concatstabto(asmlist);
  1276. end;
  1277. end;
  1278. end;
  1279. {$endif GDB}
  1280. function tpointerdef.gettypename : string;
  1281. begin
  1282. gettypename:='^'+definition^.typename;
  1283. end;
  1284. {****************************************************************************
  1285. TCLASSREFDEF
  1286. ****************************************************************************}
  1287. constructor tclassrefdef.init(def : pdef);
  1288. begin
  1289. inherited init(def);
  1290. deftype:=classrefdef;
  1291. definition:=def;
  1292. savesize:=target_os.size_of_pointer;
  1293. end;
  1294. constructor tclassrefdef.load;
  1295. begin
  1296. { be careful, tclassdefref inherits from tpointerdef }
  1297. tdef.load;
  1298. deftype:=classrefdef;
  1299. definition:=readdefref;
  1300. is_far:=false;
  1301. savesize:=target_os.size_of_pointer;
  1302. end;
  1303. procedure tclassrefdef.write;
  1304. begin
  1305. { be careful, tclassdefref inherits from tpointerdef }
  1306. tdef.write;
  1307. writedefref(definition);
  1308. current_ppu^.writeentry(ibclassrefdef);
  1309. end;
  1310. {$ifdef GDB}
  1311. function tclassrefdef.stabstring : pchar;
  1312. begin
  1313. stabstring:=strpnew(pvmtdef^.numberstring+';');
  1314. end;
  1315. procedure tclassrefdef.concatstabto(asmlist : paasmoutput);
  1316. begin
  1317. inherited concatstabto(asmlist);
  1318. end;
  1319. {$endif GDB}
  1320. function tclassrefdef.gettypename : string;
  1321. begin
  1322. gettypename:='Class Of '+definition^.typename;
  1323. end;
  1324. {***************************************************************************
  1325. TSETDEF
  1326. ***************************************************************************}
  1327. { For i386 smallsets work,
  1328. for m68k there are problems
  1329. can be test by compiling with -dusesmallset PM }
  1330. {$ifdef i386}
  1331. {$define usesmallset}
  1332. {$endif i386}
  1333. constructor tsetdef.init(s : pdef;high : longint);
  1334. begin
  1335. inherited init;
  1336. deftype:=setdef;
  1337. setof:=s;
  1338. {$ifdef usesmallset}
  1339. { small sets only working for i386 PM }
  1340. if high<32 then
  1341. begin
  1342. settype:=smallset;
  1343. savesize:=Sizeof(longint);
  1344. end
  1345. else
  1346. {$endif usesmallset}
  1347. if high<256 then
  1348. begin
  1349. settype:=normset;
  1350. savesize:=32;
  1351. end
  1352. else
  1353. {$ifdef testvarsets}
  1354. if high<$10000 then
  1355. begin
  1356. settype:=varset;
  1357. savesize:=4*((high+31) div 32);
  1358. end
  1359. else
  1360. {$endif testvarsets}
  1361. Message(sym_e_ill_type_decl_set);
  1362. end;
  1363. constructor tsetdef.load;
  1364. begin
  1365. inherited load;
  1366. deftype:=setdef;
  1367. setof:=readdefref;
  1368. settype:=tsettype(readbyte);
  1369. case settype of
  1370. normset : savesize:=32;
  1371. varset : savesize:=readlong;
  1372. smallset : savesize:=Sizeof(longint);
  1373. end;
  1374. end;
  1375. procedure tsetdef.write;
  1376. begin
  1377. inherited write;
  1378. writedefref(setof);
  1379. writebyte(byte(settype));
  1380. if settype=varset then
  1381. writelong(savesize);
  1382. current_ppu^.writeentry(ibsetdef);
  1383. end;
  1384. {$ifdef GDB}
  1385. function tsetdef.stabstring : pchar;
  1386. begin
  1387. { For small sets write a longint, which can at least be seen
  1388. in the current GDB's (PFV)
  1389. this is obsolete with GDBPAS !!
  1390. and anyhow creates problems with version 4.18!! PM
  1391. if settype=smallset then
  1392. stabstring := strpnew('r'+s32bitdef^.numberstring+';0;0xffffffff;')
  1393. else }
  1394. stabstring := strpnew('S'+setof^.numberstring);
  1395. end;
  1396. procedure tsetdef.concatstabto(asmlist : paasmoutput);
  1397. begin
  1398. if ( not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1399. not is_def_stab_written then
  1400. begin
  1401. if assigned(setof) then
  1402. forcestabto(asmlist,setof);
  1403. inherited concatstabto(asmlist);
  1404. end;
  1405. end;
  1406. {$endif GDB}
  1407. procedure tsetdef.deref;
  1408. begin
  1409. resolvedef(setof);
  1410. end;
  1411. procedure tsetdef.write_rtti_data;
  1412. begin
  1413. rttilist^.concat(new(pai_const,init_8bit(tkSet)));
  1414. write_rtti_name;
  1415. rttilist^.concat(new(pai_const,init_8bit(otULong)));
  1416. rttilist^.concat(new(pai_const_symbol,initname(setof^.get_rtti_label)));
  1417. end;
  1418. procedure tsetdef.write_child_rtti_data;
  1419. begin
  1420. setof^.get_rtti_label;
  1421. end;
  1422. function tsetdef.is_publishable : boolean;
  1423. begin
  1424. is_publishable:=settype=smallset;
  1425. end;
  1426. function tsetdef.gettypename : string;
  1427. begin
  1428. gettypename:='Set Of '+setof^.typename;
  1429. end;
  1430. {***************************************************************************
  1431. TFORMALDEF
  1432. ***************************************************************************}
  1433. constructor tformaldef.init;
  1434. var
  1435. stregdef : boolean;
  1436. begin
  1437. stregdef:=registerdef;
  1438. registerdef:=false;
  1439. inherited init;
  1440. deftype:=formaldef;
  1441. registerdef:=stregdef;
  1442. { formaldef must be registered at unit level !! }
  1443. if registerdef and assigned(current_module) then
  1444. if assigned(current_module^.localsymtable) then
  1445. psymtable(current_module^.localsymtable)^.registerdef(@self)
  1446. else if assigned(current_module^.globalsymtable) then
  1447. psymtable(current_module^.globalsymtable)^.registerdef(@self);
  1448. savesize:=target_os.size_of_pointer;
  1449. end;
  1450. constructor tformaldef.load;
  1451. begin
  1452. inherited load;
  1453. deftype:=formaldef;
  1454. savesize:=target_os.size_of_pointer;
  1455. end;
  1456. procedure tformaldef.write;
  1457. begin
  1458. inherited write;
  1459. current_ppu^.writeentry(ibformaldef);
  1460. end;
  1461. {$ifdef GDB}
  1462. function tformaldef.stabstring : pchar;
  1463. begin
  1464. stabstring := strpnew('formal'+numberstring+';');
  1465. end;
  1466. procedure tformaldef.concatstabto(asmlist : paasmoutput);
  1467. begin
  1468. { formaldef can't be stab'ed !}
  1469. end;
  1470. {$endif GDB}
  1471. function tformaldef.gettypename : string;
  1472. begin
  1473. gettypename:='Var';
  1474. end;
  1475. {***************************************************************************
  1476. TARRAYDEF
  1477. ***************************************************************************}
  1478. constructor tarraydef.init(l,h : longint;rd : pdef);
  1479. begin
  1480. inherited init;
  1481. deftype:=arraydef;
  1482. lowrange:=l;
  1483. highrange:=h;
  1484. rangedef:=rd;
  1485. definition:=nil;
  1486. IsVariant:=false;
  1487. IsConstructor:=false;
  1488. IsArrayOfConst:=false;
  1489. rangenr:=0;
  1490. end;
  1491. constructor tarraydef.load;
  1492. begin
  1493. inherited load;
  1494. deftype:=arraydef;
  1495. { the addresses are calculated later }
  1496. definition:=readdefref;
  1497. rangedef:=readdefref;
  1498. lowrange:=readlong;
  1499. highrange:=readlong;
  1500. IsArrayOfConst:=boolean(readbyte);
  1501. IsVariant:=false;
  1502. IsConstructor:=false;
  1503. rangenr:=0;
  1504. end;
  1505. function tarraydef.getrangecheckstring : string;
  1506. begin
  1507. if (cs_create_smart in aktmoduleswitches) then
  1508. getrangecheckstring:='R_'+current_module^.modulename^+tostr(rangenr)
  1509. else
  1510. getrangecheckstring:='R_'+tostr(rangenr);
  1511. end;
  1512. procedure tarraydef.genrangecheck;
  1513. begin
  1514. if rangenr=0 then
  1515. begin
  1516. { generates the data for range checking }
  1517. getlabelnr(rangenr);
  1518. if (cs_create_smart in aktmoduleswitches) then
  1519. datasegment^.concat(new(pai_symbol,initname_global(getrangecheckstring,8)))
  1520. else
  1521. datasegment^.concat(new(pai_symbol,initname(getrangecheckstring,8)));
  1522. datasegment^.concat(new(pai_const,init_32bit(lowrange)));
  1523. datasegment^.concat(new(pai_const,init_32bit(highrange)));
  1524. end;
  1525. end;
  1526. procedure tarraydef.deref;
  1527. begin
  1528. resolvedef(definition);
  1529. resolvedef(rangedef);
  1530. end;
  1531. procedure tarraydef.write;
  1532. begin
  1533. inherited write;
  1534. writedefref(definition);
  1535. writedefref(rangedef);
  1536. writelong(lowrange);
  1537. writelong(highrange);
  1538. writebyte(byte(IsArrayOfConst));
  1539. current_ppu^.writeentry(ibarraydef);
  1540. end;
  1541. {$ifdef GDB}
  1542. function tarraydef.stabstring : pchar;
  1543. begin
  1544. stabstring := strpnew('ar'+rangedef^.numberstring+';'
  1545. +tostr(lowrange)+';'+tostr(highrange)+';'+definition^.numberstring);
  1546. end;
  1547. procedure tarraydef.concatstabto(asmlist : paasmoutput);
  1548. begin
  1549. if (not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  1550. and not is_def_stab_written then
  1551. begin
  1552. {when array are inserted they have no definition yet !!}
  1553. if assigned(definition) then
  1554. inherited concatstabto(asmlist);
  1555. end;
  1556. end;
  1557. {$endif GDB}
  1558. function tarraydef.elesize : longint;
  1559. begin
  1560. elesize:=definition^.size;
  1561. end;
  1562. function tarraydef.size : longint;
  1563. begin
  1564. {Tarraydef.size may never be called for an open array!}
  1565. if highrange<lowrange then
  1566. internalerror(99080501);
  1567. If (elesize>0) and
  1568. (
  1569. (highrange-lowrange = $7fffffff) or
  1570. { () are needed around elesize-1 to avoid a possible
  1571. integer overflow for elesize=1 !! PM }
  1572. (($7fffffff div elesize + (elesize -1)) < (highrange - lowrange))
  1573. ) Then
  1574. Begin
  1575. Message(sym_e_segment_too_large);
  1576. size := 4
  1577. End
  1578. Else size:=(highrange-lowrange+1)*elesize;
  1579. end;
  1580. function tarraydef.alignment : longint;
  1581. begin
  1582. { alignment is the size of the elements }
  1583. alignment:=definition^.size;
  1584. end;
  1585. function tarraydef.needs_inittable : boolean;
  1586. begin
  1587. needs_inittable:=definition^.needs_inittable;
  1588. end;
  1589. procedure tarraydef.write_child_rtti_data;
  1590. begin
  1591. definition^.get_rtti_label;
  1592. end;
  1593. procedure tarraydef.write_rtti_data;
  1594. begin
  1595. rttilist^.concat(new(pai_const,init_8bit(13)));
  1596. write_rtti_name;
  1597. { size of elements }
  1598. rttilist^.concat(new(pai_const,init_32bit(definition^.size)));
  1599. { count of elements }
  1600. rttilist^.concat(new(pai_const,init_32bit(highrange-lowrange+1)));
  1601. { element type }
  1602. rttilist^.concat(new(pai_const_symbol,initname(definition^.get_rtti_label)));
  1603. end;
  1604. function tarraydef.gettypename : string;
  1605. begin
  1606. if isarrayofconst or isConstructor then
  1607. begin
  1608. if isvariant then
  1609. gettypename:='Array Of Const'
  1610. else
  1611. gettypename:='Array Of '+definition^.typename;
  1612. end
  1613. else if is_open_array(@self) then
  1614. gettypename:='Array Of '+definition^.typename
  1615. else
  1616. begin
  1617. if rangedef^.deftype=enumdef then
  1618. gettypename:='Array['+rangedef^.typename+'] Of '+definition^.typename
  1619. else
  1620. gettypename:='Array['+tostr(lowrange)+'..'+
  1621. tostr(highrange)+'] Of '+definition^.typename
  1622. end;
  1623. end;
  1624. {***************************************************************************
  1625. trecorddef
  1626. ***************************************************************************}
  1627. constructor trecorddef.init(p : psymtable);
  1628. begin
  1629. inherited init;
  1630. deftype:=recorddef;
  1631. symtable:=p;
  1632. symtable^.defowner := @self;
  1633. symtable^.dataalignment:=packrecordalignment[aktpackrecords];
  1634. end;
  1635. constructor trecorddef.load;
  1636. var
  1637. oldread_member : boolean;
  1638. begin
  1639. inherited load;
  1640. deftype:=recorddef;
  1641. savesize:=readlong;
  1642. oldread_member:=read_member;
  1643. read_member:=true;
  1644. symtable:=new(psymtable,loadas(recordsymtable));
  1645. read_member:=oldread_member;
  1646. symtable^.defowner := @self;
  1647. end;
  1648. destructor trecorddef.done;
  1649. begin
  1650. if assigned(symtable) then
  1651. dispose(symtable,done);
  1652. inherited done;
  1653. end;
  1654. var
  1655. binittable : boolean;
  1656. procedure check_rec_inittable(s : pnamedindexobject);
  1657. begin
  1658. if (psym(s)^.typ=varsym) and
  1659. ((pvarsym(s)^.definition^.deftype<>objectdef) or
  1660. not(pobjectdef(pvarsym(s)^.definition)^.is_class)) then
  1661. binittable:=pvarsym(s)^.definition^.needs_inittable;
  1662. end;
  1663. function trecorddef.needs_inittable : boolean;
  1664. var
  1665. oldb : boolean;
  1666. begin
  1667. { there are recursive calls to needs_rtti possible, }
  1668. { so we have to change to old value how else should }
  1669. { we do that ? check_rec_rtti can't be a nested }
  1670. { procedure of needs_rtti ! }
  1671. oldb:=binittable;
  1672. binittable:=false;
  1673. symtable^.foreach({$ifndef TP}@{$endif}check_rec_inittable);
  1674. needs_inittable:=binittable;
  1675. binittable:=oldb;
  1676. end;
  1677. procedure trecorddef.deref;
  1678. var
  1679. oldrecsyms : psymtable;
  1680. begin
  1681. oldrecsyms:=aktrecordsymtable;
  1682. aktrecordsymtable:=symtable;
  1683. { now dereference the definitions }
  1684. symtable^.deref;
  1685. aktrecordsymtable:=oldrecsyms;
  1686. end;
  1687. procedure trecorddef.write;
  1688. var
  1689. oldread_member : boolean;
  1690. begin
  1691. oldread_member:=read_member;
  1692. read_member:=true;
  1693. inherited write;
  1694. writelong(savesize);
  1695. current_ppu^.writeentry(ibrecorddef);
  1696. self.symtable^.writeas;
  1697. read_member:=oldread_member;
  1698. end;
  1699. function trecorddef.size:longint;
  1700. begin
  1701. size:=symtable^.datasize;
  1702. end;
  1703. function trecorddef.alignment:longint;
  1704. begin
  1705. alignment:=symtable^.dataalignment;
  1706. end;
  1707. {$ifdef GDB}
  1708. Const StabRecString : pchar = Nil;
  1709. StabRecSize : longint = 0;
  1710. RecOffset : Longint = 0;
  1711. procedure addname(p : pnamedindexobject);
  1712. var
  1713. news, newrec : pchar;
  1714. spec : string[3];
  1715. size : longint;
  1716. begin
  1717. { static variables from objects are like global objects }
  1718. if (sp_static in psym(p)^.symoptions) then
  1719. exit;
  1720. If psym(p)^.typ = varsym then
  1721. begin
  1722. if (sp_protected in psym(p)^.symoptions) then
  1723. spec:='/1'
  1724. else if (sp_private in psym(p)^.symoptions) then
  1725. spec:='/0'
  1726. else
  1727. spec:='';
  1728. { class fields are pointers PM }
  1729. if (pvarsym(p)^.definition^.deftype=objectdef) and
  1730. pobjectdef(pvarsym(p)^.definition)^.is_class then
  1731. spec:=spec+'*';
  1732. size:=pvarsym(p)^.definition^.size;
  1733. { open arrays made overflows !! }
  1734. if size>$fffffff then
  1735. size:=$fffffff;
  1736. newrec := strpnew(p^.name+':'+spec+pvarsym(p)^.definition^.numberstring
  1737. +','+tostr(pvarsym(p)^.address*8)+','
  1738. +tostr(size*8)+';');
  1739. if strlen(StabRecString) + strlen(newrec) >= StabRecSize-256 then
  1740. begin
  1741. getmem(news,stabrecsize+memsizeinc);
  1742. strcopy(news,stabrecstring);
  1743. freemem(stabrecstring,stabrecsize);
  1744. stabrecsize:=stabrecsize+memsizeinc;
  1745. stabrecstring:=news;
  1746. end;
  1747. strcat(StabRecstring,newrec);
  1748. strdispose(newrec);
  1749. {This should be used for case !!}
  1750. RecOffset := RecOffset + pvarsym(p)^.definition^.size;
  1751. end;
  1752. end;
  1753. function trecorddef.stabstring : pchar;
  1754. Var oldrec : pchar;
  1755. oldsize : longint;
  1756. begin
  1757. oldrec := stabrecstring;
  1758. oldsize:=stabrecsize;
  1759. GetMem(stabrecstring,memsizeinc);
  1760. stabrecsize:=memsizeinc;
  1761. strpcopy(stabRecString,'s'+tostr(size));
  1762. RecOffset := 0;
  1763. symtable^.foreach({$ifndef TP}@{$endif}addname);
  1764. { FPC doesn't want to convert a char to a pchar}
  1765. { is this a bug ? }
  1766. strpcopy(strend(StabRecString),';');
  1767. stabstring := strnew(StabRecString);
  1768. Freemem(stabrecstring,stabrecsize);
  1769. stabrecstring := oldrec;
  1770. stabrecsize:=oldsize;
  1771. end;
  1772. procedure trecorddef.concatstabto(asmlist : paasmoutput);
  1773. begin
  1774. if (not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1775. (not is_def_stab_written) then
  1776. inherited concatstabto(asmlist);
  1777. end;
  1778. {$endif GDB}
  1779. var
  1780. count : longint;
  1781. procedure count_inittable_fields(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1782. begin
  1783. if ((psym(sym)^.typ=varsym) and
  1784. pvarsym(sym)^.definition^.needs_inittable)
  1785. and ((pvarsym(sym)^.definition^.deftype<>objectdef) or
  1786. (not pobjectdef(pvarsym(sym)^.definition)^.is_class)) then
  1787. inc(count);
  1788. end;
  1789. procedure count_fields(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1790. begin
  1791. inc(count);
  1792. end;
  1793. procedure write_field_inittable(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1794. begin
  1795. if ((psym(sym)^.typ=varsym) and
  1796. pvarsym(sym)^.definition^.needs_inittable)
  1797. and ((pvarsym(sym)^.definition^.deftype<>objectdef) or
  1798. (not pobjectdef(pvarsym(sym)^.definition)^.is_class)) then
  1799. begin
  1800. rttilist^.concat(new(pai_const_symbol,init(pvarsym(sym)^.definition^.get_inittable_label)));
  1801. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  1802. end;
  1803. end;
  1804. procedure write_field_rtti(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1805. begin
  1806. rttilist^.concat(new(pai_const_symbol,initname(pvarsym(sym)^.definition^.get_rtti_label)));
  1807. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  1808. end;
  1809. procedure generate_child_inittable(sym:pnamedindexobject);{$ifndef fpc}far;{$endif}
  1810. begin
  1811. if (psym(sym)^.typ=varsym) and
  1812. pvarsym(sym)^.definition^.needs_inittable then
  1813. { force inittable generation }
  1814. pvarsym(sym)^.definition^.get_inittable_label;
  1815. end;
  1816. procedure generate_child_rtti(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1817. begin
  1818. pvarsym(sym)^.definition^.get_rtti_label;
  1819. end;
  1820. procedure trecorddef.write_child_rtti_data;
  1821. begin
  1822. symtable^.foreach({$ifndef TP}@{$endif}generate_child_rtti);
  1823. end;
  1824. procedure trecorddef.write_child_init_data;
  1825. begin
  1826. symtable^.foreach({$ifndef TP}@{$endif}generate_child_inittable);
  1827. end;
  1828. procedure trecorddef.write_rtti_data;
  1829. begin
  1830. rttilist^.concat(new(pai_const,init_8bit(tkrecord)));
  1831. write_rtti_name;
  1832. rttilist^.concat(new(pai_const,init_32bit(size)));
  1833. count:=0;
  1834. symtable^.foreach({$ifndef TP}@{$endif}count_fields);
  1835. rttilist^.concat(new(pai_const,init_32bit(count)));
  1836. symtable^.foreach({$ifndef TP}@{$endif}write_field_rtti);
  1837. end;
  1838. procedure trecorddef.write_init_data;
  1839. begin
  1840. rttilist^.concat(new(pai_const,init_8bit(14)));
  1841. write_rtti_name;
  1842. rttilist^.concat(new(pai_const,init_32bit(size)));
  1843. count:=0;
  1844. symtable^.foreach({$ifndef TP}@{$endif}count_inittable_fields);
  1845. rttilist^.concat(new(pai_const,init_32bit(count)));
  1846. symtable^.foreach({$ifndef TP}@{$endif}write_field_inittable);
  1847. end;
  1848. function trecorddef.gettypename : string;
  1849. begin
  1850. gettypename:='<record type>'
  1851. end;
  1852. {***************************************************************************
  1853. TABSTRACTPROCDEF
  1854. ***************************************************************************}
  1855. procedure disposepdefcoll(var para1 : pdefcoll);
  1856. var
  1857. hp : pdefcoll;
  1858. begin
  1859. hp:=para1;
  1860. while assigned(hp) do
  1861. begin
  1862. para1:=hp^.next;
  1863. dispose(hp);
  1864. hp:=para1;
  1865. end;
  1866. end;
  1867. constructor tabstractprocdef.init;
  1868. begin
  1869. inherited init;
  1870. para1:=nil;
  1871. fpu_used:=0;
  1872. proctypeoption:=potype_none;
  1873. proccalloptions:=[];
  1874. procoptions:=[];
  1875. retdef:=voiddef;
  1876. symtablelevel:=0;
  1877. savesize:=target_os.size_of_pointer;
  1878. end;
  1879. destructor tabstractprocdef.done;
  1880. begin
  1881. disposepdefcoll(para1);
  1882. inherited done;
  1883. end;
  1884. procedure tabstractprocdef.concatdef(p : pdef;vsp : tvarspez);
  1885. var
  1886. hp : pdefcoll;
  1887. begin
  1888. new(hp);
  1889. hp^.paratyp:=vsp;
  1890. hp^.datasym:=nil;
  1891. hp^.data:=p;
  1892. hp^.next:=para1;
  1893. hp^.register:=R_NO;
  1894. para1:=hp;
  1895. end;
  1896. procedure tabstractprocdef.concattypesym(p : ptypesym;vsp : tvarspez);
  1897. var
  1898. hp : pdefcoll;
  1899. begin
  1900. new(hp);
  1901. hp^.paratyp:=vsp;
  1902. hp^.datasym:=p;
  1903. hp^.data:=p^.definition;
  1904. hp^.next:=para1;
  1905. hp^.register:=R_NO;
  1906. para1:=hp;
  1907. end;
  1908. { all functions returning in FPU are
  1909. assume to use 2 FPU registers
  1910. until the function implementation
  1911. is processed PM }
  1912. procedure tabstractprocdef.test_if_fpu_result;
  1913. begin
  1914. if assigned(retdef) and is_fpu(retdef) then
  1915. fpu_used:=2;
  1916. end;
  1917. procedure tabstractprocdef.deref;
  1918. var
  1919. hp : pdefcoll;
  1920. begin
  1921. inherited deref;
  1922. resolvedef(retdef);
  1923. hp:=para1;
  1924. while assigned(hp) do
  1925. begin
  1926. if assigned(hp^.datasym) then
  1927. begin
  1928. resolvesym(psym(hp^.datasym));
  1929. hp^.data:=hp^.datasym^.definition;
  1930. end
  1931. else
  1932. resolvedef(hp^.data);
  1933. hp:=hp^.next;
  1934. end;
  1935. end;
  1936. constructor tabstractprocdef.load;
  1937. var
  1938. last,hp : pdefcoll;
  1939. count,i : word;
  1940. begin
  1941. inherited load;
  1942. retdef:=readdefref;
  1943. fpu_used:=readbyte;
  1944. proctypeoption:=tproctypeoption(readlong);
  1945. readsmallset(proccalloptions);
  1946. readsmallset(procoptions);
  1947. count:=readword;
  1948. para1:=nil;
  1949. savesize:=target_os.size_of_pointer;
  1950. for i:=1 to count do
  1951. begin
  1952. new(hp);
  1953. hp^.paratyp:=tvarspez(readbyte);
  1954. { hp^.register:=tregister(readbyte); }
  1955. hp^.register:=R_NO;
  1956. hp^.data:=readdefref;
  1957. hp^.datasym:=ptypesym(readsymref);
  1958. hp^.next:=nil;
  1959. if para1=nil then
  1960. para1:=hp
  1961. else
  1962. last^.next:=hp;
  1963. last:=hp;
  1964. end;
  1965. end;
  1966. procedure tabstractprocdef.write;
  1967. var
  1968. count : word;
  1969. hp : pdefcoll;
  1970. begin
  1971. inherited write;
  1972. writedefref(retdef);
  1973. current_ppu^.do_interface_crc:=false;
  1974. writebyte(fpu_used);
  1975. writelong(ord(proctypeoption));
  1976. writesmallset(proccalloptions);
  1977. writesmallset(procoptions);
  1978. hp:=para1;
  1979. count:=0;
  1980. while assigned(hp) do
  1981. begin
  1982. inc(count);
  1983. hp:=hp^.next;
  1984. end;
  1985. writeword(count);
  1986. hp:=para1;
  1987. while assigned(hp) do
  1988. begin
  1989. writebyte(byte(hp^.paratyp));
  1990. { writebyte(byte(hp^.register)); }
  1991. if assigned(hp^.datasym) then
  1992. begin
  1993. writedefref(nil);
  1994. writesymref(psym(hp^.datasym));
  1995. end
  1996. else
  1997. begin
  1998. writedefref(hp^.data);
  1999. writesymref(nil);
  2000. end;
  2001. hp:=hp^.next;
  2002. end;
  2003. end;
  2004. function tabstractprocdef.para_size : longint;
  2005. var
  2006. pdc : pdefcoll;
  2007. l : longint;
  2008. begin
  2009. l:=0;
  2010. pdc:=para1;
  2011. while assigned(pdc) do
  2012. begin
  2013. case pdc^.paratyp of
  2014. vs_var : inc(l,target_os.size_of_pointer);
  2015. vs_value,
  2016. vs_const : if push_addr_param(pdc^.data) then
  2017. inc(l,target_os.size_of_pointer)
  2018. else
  2019. inc(l,align(pdc^.data^.size,target_os.stackalignment));
  2020. end;
  2021. pdc:=pdc^.next;
  2022. end;
  2023. para_size:=l;
  2024. end;
  2025. function tabstractprocdef.demangled_paras : string;
  2026. var s : string;
  2027. procedure doconcat(p : pdefcoll);
  2028. begin
  2029. if assigned(p^.next) then
  2030. doconcat(p^.next)
  2031. else
  2032. s:='(';
  2033. if assigned(p^.data^.sym) then
  2034. s:=s+p^.data^.sym^.name
  2035. else if p^.paratyp=vs_var then
  2036. s:=s+'var'
  2037. else if p^.paratyp=vs_const then
  2038. s:=s+'const';
  2039. if p<>para1 then
  2040. s:=s+','
  2041. else
  2042. s:=s+')';
  2043. end;
  2044. begin
  2045. s:='';
  2046. { a recursive solution is the easiest way to inverse the parameter }
  2047. { collection }
  2048. if assigned(para1) then
  2049. doconcat(para1);
  2050. demangled_paras:=s;
  2051. end;
  2052. {$ifdef GDB}
  2053. function tabstractprocdef.stabstring : pchar;
  2054. begin
  2055. stabstring := strpnew('abstractproc'+numberstring+';');
  2056. end;
  2057. procedure tabstractprocdef.concatstabto(asmlist : paasmoutput);
  2058. begin
  2059. if (not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  2060. and not is_def_stab_written then
  2061. begin
  2062. if assigned(retdef) then forcestabto(asmlist,retdef);
  2063. inherited concatstabto(asmlist);
  2064. end;
  2065. end;
  2066. {$endif GDB}
  2067. {***************************************************************************
  2068. TPROCDEF
  2069. ***************************************************************************}
  2070. constructor tprocdef.init;
  2071. begin
  2072. inherited init;
  2073. deftype:=procdef;
  2074. _mangledname:=nil;
  2075. nextoverloaded:=nil;
  2076. fileinfo:=aktfilepos;
  2077. extnumber:=-1;
  2078. localst:=new(psymtable,init(localsymtable));
  2079. parast:=new(psymtable,init(parasymtable));
  2080. localst^.defowner:=@self;
  2081. parast^.defowner:=@self;
  2082. { this is used by insert
  2083. to check same names in parast and localst }
  2084. localst^.next:=parast;
  2085. defref:=nil;
  2086. crossref:=nil;
  2087. lastwritten:=nil;
  2088. refcount:=0;
  2089. if (cs_browser in aktmoduleswitches) and make_ref then
  2090. begin
  2091. defref:=new(pref,init(defref,@tokenpos));
  2092. inc(refcount);
  2093. end;
  2094. lastref:=defref;
  2095. { first, we assume that all registers are used }
  2096. {$ifdef newcg}
  2097. usedregisters:=[firstreg..lastreg];
  2098. {$else newcg}
  2099. {$ifdef i386}
  2100. usedregisters:=$ff;
  2101. {$endif i386}
  2102. {$ifdef m68k}
  2103. usedregisters:=$FFFF;
  2104. {$endif}
  2105. {$endif newcg}
  2106. forwarddef:=true;
  2107. interfacedef:=false;
  2108. _class := nil;
  2109. code:=nil;
  2110. count:=false;
  2111. is_used:=false;
  2112. end;
  2113. constructor tprocdef.load;
  2114. var
  2115. s : string;
  2116. begin
  2117. inherited load;
  2118. deftype:=procdef;
  2119. {$ifdef newcg}
  2120. readnormalset(usedregisters);
  2121. {$else newcg}
  2122. {$ifdef i386}
  2123. usedregisters:=readbyte;
  2124. {$endif i386}
  2125. {$ifdef m68k}
  2126. usedregisters:=readword;
  2127. {$endif}
  2128. {$endif newcg}
  2129. s:=readstring;
  2130. setstring(_mangledname,s);
  2131. extnumber:=readlong;
  2132. nextoverloaded:=pprocdef(readdefref);
  2133. _class := pobjectdef(readdefref);
  2134. readposinfo(fileinfo);
  2135. if (cs_link_deffile in aktglobalswitches) and
  2136. (tf_need_export in target_info.flags) and
  2137. (po_exports in procoptions) then
  2138. deffile.AddExport(mangledname);
  2139. parast:=nil;
  2140. localst:=nil;
  2141. forwarddef:=false;
  2142. interfacedef:=false;
  2143. lastref:=nil;
  2144. lastwritten:=nil;
  2145. defref:=nil;
  2146. refcount:=0;
  2147. count:=true;
  2148. is_used:=false;
  2149. end;
  2150. Const local_symtable_index : longint = $8001;
  2151. procedure tprocdef.load_references;
  2152. var
  2153. pos : tfileposinfo;
  2154. {$ifndef NOLOCALBROWSER}
  2155. pdo : pobjectdef;
  2156. {$endif ndef NOLOCALBROWSER}
  2157. move_last : boolean;
  2158. begin
  2159. move_last:=lastwritten=lastref;
  2160. while (not current_ppu^.endofentry) do
  2161. begin
  2162. readposinfo(pos);
  2163. inc(refcount);
  2164. lastref:=new(pref,init(lastref,@pos));
  2165. lastref^.is_written:=true;
  2166. if refcount=1 then
  2167. defref:=lastref;
  2168. end;
  2169. if move_last then
  2170. lastwritten:=lastref;
  2171. if ((current_module^.flags and uf_local_browser)<>0)
  2172. and is_in_current then
  2173. begin
  2174. {$ifndef NOLOCALBROWSER}
  2175. pdo:=_class;
  2176. new(parast,loadas(parasymtable));
  2177. parast^.next:=owner;
  2178. parast^.load_browser;
  2179. new(localst,loadas(localsymtable));
  2180. localst^.next:=parast;
  2181. localst^.load_browser;
  2182. {$endif ndef NOLOCALBROWSER}
  2183. end;
  2184. end;
  2185. function tprocdef.write_references : boolean;
  2186. var
  2187. ref : pref;
  2188. {$ifndef NOLOCALBROWSER}
  2189. pdo : pobjectdef;
  2190. {$endif ndef NOLOCALBROWSER}
  2191. move_last : boolean;
  2192. begin
  2193. move_last:=lastwritten=lastref;
  2194. if move_last and (((current_module^.flags and uf_local_browser)=0)
  2195. or not is_in_current) then
  2196. exit;
  2197. { write address of this symbol }
  2198. writedefref(@self);
  2199. { write refs }
  2200. if assigned(lastwritten) then
  2201. ref:=lastwritten
  2202. else
  2203. ref:=defref;
  2204. while assigned(ref) do
  2205. begin
  2206. if ref^.moduleindex=current_module^.unit_index then
  2207. begin
  2208. writeposinfo(ref^.posinfo);
  2209. ref^.is_written:=true;
  2210. if move_last then
  2211. lastwritten:=ref;
  2212. end
  2213. else if not ref^.is_written then
  2214. move_last:=false
  2215. else if move_last then
  2216. lastwritten:=ref;
  2217. ref:=ref^.nextref;
  2218. end;
  2219. current_ppu^.writeentry(ibdefref);
  2220. write_references:=true;
  2221. if ((current_module^.flags and uf_local_browser)<>0)
  2222. and is_in_current then
  2223. begin
  2224. {$ifndef NOLOCALBROWSER}
  2225. pdo:=_class;
  2226. if (owner^.symtabletype<>localsymtable) then
  2227. while assigned(pdo) do
  2228. begin
  2229. if pdo^.symtable<>aktrecordsymtable then
  2230. begin
  2231. pdo^.symtable^.unitid:=local_symtable_index;
  2232. inc(local_symtable_index);
  2233. end;
  2234. pdo:=pdo^.childof;
  2235. end;
  2236. { we need TESTLOCALBROWSER para and local symtables
  2237. PPU files are then easier to read PM }
  2238. if not assigned(parast) then
  2239. parast:=new(psymtable,init(parasymtable));
  2240. parast^.writeas;
  2241. parast^.unitid:=local_symtable_index;
  2242. inc(local_symtable_index);
  2243. parast^.write_browser;
  2244. if not assigned(localst) then
  2245. localst:=new(psymtable,init(localsymtable));
  2246. localst^.writeas;
  2247. localst^.unitid:=local_symtable_index;
  2248. inc(local_symtable_index);
  2249. localst^.write_browser;
  2250. { decrement for }
  2251. local_symtable_index:=local_symtable_index-2;
  2252. pdo:=_class;
  2253. if (owner^.symtabletype<>localsymtable) then
  2254. while assigned(pdo) do
  2255. begin
  2256. if pdo^.symtable<>aktrecordsymtable then
  2257. dec(local_symtable_index);
  2258. pdo:=pdo^.childof;
  2259. end;
  2260. {$endif ndef NOLOCALBROWSER}
  2261. end;
  2262. end;
  2263. {$ifdef BrowserLog}
  2264. procedure tprocdef.add_to_browserlog;
  2265. begin
  2266. if assigned(defref) then
  2267. begin
  2268. browserlog.AddLog('***'+mangledname);
  2269. browserlog.AddLogRefs(defref);
  2270. if (current_module^.flags and uf_local_browser)<>0 then
  2271. begin
  2272. if assigned(parast) then
  2273. parast^.writebrowserlog;
  2274. if assigned(localst) then
  2275. localst^.writebrowserlog;
  2276. end;
  2277. end;
  2278. end;
  2279. {$endif BrowserLog}
  2280. destructor tprocdef.done;
  2281. begin
  2282. if assigned(defref) then
  2283. dispose(defref,done);
  2284. if assigned(parast) then
  2285. dispose(parast,done);
  2286. if assigned(localst) and (localst^.symtabletype<>staticsymtable) then
  2287. dispose(localst,done);
  2288. if (pocall_inline in proccalloptions) and assigned(code) then
  2289. disposetree(ptree(code));
  2290. if (po_msgstr in procoptions) then
  2291. strdispose(messageinf.str);
  2292. if
  2293. {$ifdef tp}
  2294. not(use_big) and
  2295. {$endif}
  2296. assigned(_mangledname) then
  2297. globals.strdispose(_mangledname);
  2298. inherited done;
  2299. end;
  2300. procedure tprocdef.write;
  2301. begin
  2302. inherited write;
  2303. current_ppu^.do_interface_crc:=false;
  2304. { set all registers to used for simplified compilation PM }
  2305. if simplify_ppu then
  2306. begin
  2307. {$ifdef newcg}
  2308. usedregisters:=[firstreg..lastreg];
  2309. {$else newcg}
  2310. {$ifdef i386}
  2311. usedregisters:=$ff;
  2312. {$endif i386}
  2313. {$ifdef m68k}
  2314. usedregisters:=$ffff;
  2315. {$endif}
  2316. {$endif newcg}
  2317. end;
  2318. {$ifdef newcg}
  2319. writenormalset(usedregisters);
  2320. {$else newcg}
  2321. {$ifdef i386}
  2322. writebyte(usedregisters);
  2323. {$endif i386}
  2324. {$ifdef m68k}
  2325. writeword(usedregisters);
  2326. {$endif}
  2327. {$endif newcg}
  2328. current_ppu^.do_interface_crc:=true;
  2329. writestring(mangledname);
  2330. writelong(extnumber);
  2331. if (proctypeoption<>potype_operator) then
  2332. writedefref(nextoverloaded)
  2333. else
  2334. begin
  2335. { only write the overloads from the same unit }
  2336. if assigned(nextoverloaded) and
  2337. (nextoverloaded^.owner=owner) then
  2338. writedefref(nextoverloaded)
  2339. else
  2340. writedefref(nil);
  2341. end;
  2342. writedefref(_class);
  2343. writeposinfo(fileinfo);
  2344. if (pocall_inline in proccalloptions) then
  2345. begin
  2346. { we need to save
  2347. - the para and the local symtable
  2348. - the code ptree !! PM
  2349. writesymtable(parast);
  2350. writesymtable(localst);
  2351. writeptree(ptree(code));
  2352. }
  2353. end;
  2354. current_ppu^.writeentry(ibprocdef);
  2355. end;
  2356. function tprocdef.haspara:boolean;
  2357. begin
  2358. haspara:=assigned(aktprocsym^.definition^.parast^.symindex^.first);
  2359. end;
  2360. {$ifdef GDB}
  2361. procedure addparaname(p : psym);
  2362. var vs : char;
  2363. begin
  2364. if pvarsym(p)^.varspez = vs_value then vs := '1'
  2365. else vs := '0';
  2366. strpcopy(strend(StabRecString),p^.name+':'+pvarsym(p)^.definition^.numberstring+','+vs+';');
  2367. end;
  2368. function tprocdef.stabstring : pchar;
  2369. var param : pdefcoll;
  2370. i : word;
  2371. oldrec : pchar;
  2372. begin
  2373. oldrec := stabrecstring;
  2374. getmem(StabRecString,1024);
  2375. param := para1;
  2376. i := 0;
  2377. while assigned(param) do
  2378. begin
  2379. inc(i);
  2380. param := param^.next;
  2381. end;
  2382. strpcopy(StabRecString,'f'+retdef^.numberstring);
  2383. if i>0 then
  2384. begin
  2385. strpcopy(strend(StabRecString),','+tostr(i)+';');
  2386. (* confuse gdb !! PM
  2387. if assigned(parast) then
  2388. parast^.foreach({$ifndef TP}@{$endif}addparaname)
  2389. else
  2390. begin
  2391. param := para1;
  2392. i := 0;
  2393. while assigned(param) do
  2394. begin
  2395. inc(i);
  2396. if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
  2397. {Here we have lost the parameter names !!}
  2398. {using lower case parameters }
  2399. strpcopy(strend(stabrecstring),'p'+tostr(i)
  2400. +':'+param^.data^.numberstring+','+vartyp+';');
  2401. param := param^.next;
  2402. end;
  2403. end; *)
  2404. {strpcopy(strend(StabRecString),';');}
  2405. end;
  2406. stabstring := strnew(stabrecstring);
  2407. freemem(stabrecstring,1024);
  2408. stabrecstring := oldrec;
  2409. end;
  2410. procedure tprocdef.concatstabto(asmlist : paasmoutput);
  2411. begin
  2412. end;
  2413. {$endif GDB}
  2414. procedure tprocdef.deref;
  2415. begin
  2416. inherited deref;
  2417. resolvedef(pdef(nextoverloaded));
  2418. resolvedef(pdef(_class));
  2419. end;
  2420. function tprocdef.mangledname : string;
  2421. {$ifdef tp}
  2422. var
  2423. oldpos : longint;
  2424. s : string;
  2425. b : byte;
  2426. {$endif tp}
  2427. begin
  2428. {$ifndef Delphi}
  2429. {$ifdef tp}
  2430. if use_big then
  2431. begin
  2432. symbolstream.seek(longint(_mangledname));
  2433. symbolstream.read(b,1);
  2434. symbolstream.read(s[1],b);
  2435. s[0]:=chr(b);
  2436. mangledname:=s;
  2437. end
  2438. else
  2439. {$endif}
  2440. {$endif Delphi}
  2441. mangledname:=strpas(_mangledname);
  2442. if count then
  2443. is_used:=true;
  2444. end;
  2445. function tprocdef.procname: string;
  2446. var
  2447. s : string;
  2448. l : longint;
  2449. begin
  2450. s:=mangledname;
  2451. { delete leading $$'s }
  2452. l:=pos('$$',s);
  2453. while l<>0 do
  2454. begin
  2455. delete(s,1,l+1);
  2456. l:=pos('$$',s);
  2457. end;
  2458. { delete leading _$'s }
  2459. l:=pos('_$',s);
  2460. while l<>0 do
  2461. begin
  2462. delete(s,1,l+1);
  2463. l:=pos('_$',s);
  2464. end;
  2465. l:=pos('$',s);
  2466. if l=0 then
  2467. procname:=s
  2468. else
  2469. procname:=Copy(s,1,l-1);
  2470. end;
  2471. {$IfDef GDB}
  2472. function tprocdef.cplusplusmangledname : string;
  2473. var
  2474. s,s2 : string;
  2475. param : pdefcoll;
  2476. begin
  2477. s := sym^.name;
  2478. if _class <> nil then
  2479. begin
  2480. s2 := _class^.objname^;
  2481. s := s+'__'+tostr(length(s2))+s2;
  2482. end else s := s + '_';
  2483. param := para1;
  2484. while assigned(param) do
  2485. begin
  2486. s2 := param^.data^.sym^.name;
  2487. s := s+tostr(length(s2))+s2;
  2488. param := param^.next;
  2489. end;
  2490. cplusplusmangledname:=s;
  2491. end;
  2492. {$EndIf GDB}
  2493. procedure tprocdef.setmangledname(const s : string);
  2494. begin
  2495. if {$ifdef tp}not(use_big) and{$endif} (assigned(_mangledname)) then
  2496. strdispose(_mangledname);
  2497. setstring(_mangledname,s);
  2498. if assigned(parast) then
  2499. begin
  2500. stringdispose(parast^.name);
  2501. parast^.name:=stringdup('args of '+s);
  2502. end;
  2503. if assigned(localst) then
  2504. begin
  2505. stringdispose(localst^.name);
  2506. localst^.name:=stringdup('locals of '+s);
  2507. end;
  2508. end;
  2509. {***************************************************************************
  2510. TPROCVARDEF
  2511. ***************************************************************************}
  2512. constructor tprocvardef.init;
  2513. begin
  2514. inherited init;
  2515. deftype:=procvardef;
  2516. end;
  2517. constructor tprocvardef.load;
  2518. begin
  2519. inherited load;
  2520. deftype:=procvardef;
  2521. end;
  2522. procedure tprocvardef.write;
  2523. begin
  2524. { here we cannot get a real good value so just give something }
  2525. { plausible (PM) }
  2526. { a more secure way would be
  2527. to allways store in a temp }
  2528. if is_fpu(retdef) then
  2529. fpu_used:=2
  2530. else
  2531. fpu_used:=0;
  2532. inherited write;
  2533. current_ppu^.writeentry(ibprocvardef);
  2534. end;
  2535. function tprocvardef.size : longint;
  2536. begin
  2537. if (po_methodpointer in procoptions) then
  2538. size:=2*target_os.size_of_pointer
  2539. else
  2540. size:=target_os.size_of_pointer;
  2541. end;
  2542. {$ifdef GDB}
  2543. function tprocvardef.stabstring : pchar;
  2544. var
  2545. nss : pchar;
  2546. i : word;
  2547. param : pdefcoll;
  2548. begin
  2549. i := 0;
  2550. param := para1;
  2551. while assigned(param) do
  2552. begin
  2553. inc(i);
  2554. param := param^.next;
  2555. end;
  2556. getmem(nss,1024);
  2557. { it is not a function but a function pointer !! (PM) }
  2558. strpcopy(nss,'*f'+retdef^.numberstring{+','+tostr(i)}+';');
  2559. param := para1;
  2560. i := 0;
  2561. { this confuses gdb !!
  2562. we should use 'F' instead of 'f' but
  2563. as we use c++ language mode
  2564. it does not like that either
  2565. Please do not remove this part
  2566. might be used once
  2567. gdb for pascal is ready PM }
  2568. (* while assigned(param) do
  2569. begin
  2570. inc(i);
  2571. if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
  2572. {Here we have lost the parameter names !!}
  2573. pst := strpnew('p'+tostr(i)+':'+param^.data^.numberstring+','+vartyp+';');
  2574. strcat(nss,pst);
  2575. strdispose(pst);
  2576. param := param^.next;
  2577. end; *)
  2578. {strpcopy(strend(nss),';');}
  2579. stabstring := strnew(nss);
  2580. freemem(nss,1024);
  2581. end;
  2582. procedure tprocvardef.concatstabto(asmlist : paasmoutput);
  2583. begin
  2584. if ( not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  2585. and not is_def_stab_written then
  2586. inherited concatstabto(asmlist);
  2587. is_def_stab_written:=true;
  2588. end;
  2589. {$endif GDB}
  2590. procedure tprocvardef.write_rtti_data;
  2591. var
  2592. pdc, pdc2, pdcbefore : pdefcoll;
  2593. methodkind, paracount, paraspec : byte;
  2594. begin
  2595. if po_methodpointer in procoptions then
  2596. begin
  2597. { write method id and name }
  2598. rttilist^.concat(new(pai_const,init_8bit(tkmethod)));
  2599. write_rtti_name;
  2600. { write kind of method (can only be function or procedure)}
  2601. if retdef = pdef(voiddef) then { ### typecast shoudln't be necessary! (sg) }
  2602. methodkind := mkProcedure
  2603. else
  2604. methodkind := mkFunction;
  2605. rttilist^.concat(new(pai_const,init_8bit(methodkind)));
  2606. { get # of parameters }
  2607. paracount:=0;
  2608. pdc:=para1;
  2609. while assigned(pdc) do
  2610. begin
  2611. inc(paracount);
  2612. pdc:=pdc^.next;
  2613. end;
  2614. rttilist^.concat(new(pai_const,init_8bit(paracount)));
  2615. { write parameter info. The parameters must be written in reverse order
  2616. if this method uses right to left parameter pushing! }
  2617. pdc:=para1;
  2618. if assigned(pdc) and not (pocall_leftright in proccalloptions) then
  2619. while assigned(pdc^.next) do pdc := pdc^.next;
  2620. while assigned(pdc) do
  2621. begin
  2622. case pdc^.paratyp of
  2623. vs_value: paraspec := 0;
  2624. vs_const: paraspec := pfConst;
  2625. vs_var : paraspec := pfVar;
  2626. end;
  2627. { write flags for current parameter }
  2628. rttilist^.concat(new(pai_const,init_8bit(paraspec)));
  2629. { write name of current parameter ### how can I get this??? (sg)}
  2630. rttilist^.concat(new(pai_const,init_8bit(0)));
  2631. { write name of type of current parameter }
  2632. pdc^.data^.write_rtti_name;
  2633. if pocall_leftright in proccalloptions then
  2634. pdc:=pdc^.next
  2635. else
  2636. begin
  2637. { find previous argument }
  2638. pdcbefore := nil;
  2639. pdc2 := para1;
  2640. while pdc2 <> pdc do
  2641. begin
  2642. pdcbefore := pdc2;
  2643. pdc2 := pdc2^.next;
  2644. end;
  2645. pdc := pdcbefore;
  2646. end;
  2647. end;
  2648. { write name of result type }
  2649. retdef^.write_rtti_name;
  2650. end;
  2651. end;
  2652. procedure tprocvardef.write_child_rtti_data;
  2653. begin
  2654. {!!!!!!!!}
  2655. end;
  2656. function tprocvardef.is_publishable : boolean;
  2657. begin
  2658. is_publishable:=(po_methodpointer in procoptions);
  2659. end;
  2660. function tprocvardef.gettypename : string;
  2661. begin
  2662. if assigned(retdef) and
  2663. (retdef<>pdef(voiddef)) then
  2664. gettypename:='<procedure variable type of function'+demangled_paras+':'+retdef^.gettypename+'>'
  2665. else
  2666. gettypename:='<procedure variable type of procedure'+demangled_paras+'>';
  2667. end;
  2668. {***************************************************************************
  2669. TOBJECTDEF
  2670. ***************************************************************************}
  2671. {$ifdef GDB}
  2672. const
  2673. vtabletype : word = 0;
  2674. vtableassigned : boolean = false;
  2675. {$endif GDB}
  2676. constructor tobjectdef.init(const n : string;c : pobjectdef);
  2677. begin
  2678. tdef.init;
  2679. deftype:=objectdef;
  2680. objectoptions:=[];
  2681. childof:=nil;
  2682. symtable:=new(psymtable,init(objectsymtable));
  2683. symtable^.name := stringdup(n);
  2684. { create space for vmt !! }
  2685. vmt_offset:=0;
  2686. symtable^.datasize:=0;
  2687. symtable^.defowner:=@self;
  2688. symtable^.dataalignment:=packrecordalignment[aktpackrecords];
  2689. set_parent(c);
  2690. objname:=stringdup(n);
  2691. end;
  2692. constructor tobjectdef.load;
  2693. var
  2694. oldread_member : boolean;
  2695. begin
  2696. tdef.load;
  2697. deftype:=objectdef;
  2698. savesize:=readlong;
  2699. vmt_offset:=readlong;
  2700. objname:=stringdup(readstring);
  2701. childof:=pobjectdef(readdefref);
  2702. readsmallset(objectoptions);
  2703. oldread_member:=read_member;
  2704. read_member:=true;
  2705. symtable:=new(psymtable,loadas(objectsymtable));
  2706. read_member:=oldread_member;
  2707. symtable^.defowner:=@self;
  2708. symtable^.name := stringdup(objname^);
  2709. { handles the predefined class tobject }
  2710. { the last TOBJECT which is loaded gets }
  2711. { it ! }
  2712. if (childof=nil) and
  2713. is_class and
  2714. (objname^='TOBJECT') then
  2715. class_tobject:=@self;
  2716. has_rtti:=true;
  2717. end;
  2718. destructor tobjectdef.done;
  2719. begin
  2720. if assigned(symtable) then
  2721. dispose(symtable,done);
  2722. if (oo_is_forward in objectoptions) then
  2723. Message1(sym_e_class_forward_not_resolved,objname^);
  2724. stringdispose(objname);
  2725. tdef.done;
  2726. end;
  2727. procedure tobjectdef.write;
  2728. var
  2729. oldread_member : boolean;
  2730. begin
  2731. tdef.write;
  2732. writelong(size);
  2733. writelong(vmt_offset);
  2734. writestring(objname^);
  2735. writedefref(childof);
  2736. writesmallset(objectoptions);
  2737. current_ppu^.writeentry(ibobjectdef);
  2738. oldread_member:=read_member;
  2739. read_member:=true;
  2740. symtable^.writeas;
  2741. read_member:=oldread_member;
  2742. end;
  2743. procedure tobjectdef.deref;
  2744. var
  2745. oldrecsyms : psymtable;
  2746. begin
  2747. resolvedef(pdef(childof));
  2748. oldrecsyms:=aktrecordsymtable;
  2749. aktrecordsymtable:=symtable;
  2750. symtable^.deref;
  2751. aktrecordsymtable:=oldrecsyms;
  2752. end;
  2753. procedure tobjectdef.set_parent( c : pobjectdef);
  2754. begin
  2755. { nothing to do if the parent was not forward !}
  2756. if assigned(childof) then
  2757. exit;
  2758. childof:=c;
  2759. { some options are inherited !! }
  2760. if assigned(c) then
  2761. begin
  2762. objectoptions:=objectoptions+(c^.objectoptions*
  2763. [oo_has_virtual,oo_has_private,oo_has_protected,oo_has_constructor,oo_has_destructor]);
  2764. { add the data of the anchestor class }
  2765. inc(symtable^.datasize,c^.symtable^.datasize);
  2766. if (oo_has_vmt in objectoptions) and
  2767. (oo_has_vmt in c^.objectoptions) then
  2768. dec(symtable^.datasize,target_os.size_of_pointer);
  2769. { if parent has a vmt field then
  2770. the offset is the same for the child PM }
  2771. if (oo_has_vmt in c^.objectoptions) or is_class then
  2772. begin
  2773. vmt_offset:=c^.vmt_offset;
  2774. {$ifdef INCLUDEOK}
  2775. include(objectoptions,oo_has_vmt);
  2776. {$else}
  2777. objectoptions:=objectoptions+[oo_has_vmt];
  2778. {$endif}
  2779. end;
  2780. end;
  2781. savesize := symtable^.datasize;
  2782. end;
  2783. procedure tobjectdef.insertvmt;
  2784. begin
  2785. if (oo_has_vmt in objectoptions) then
  2786. internalerror(12345)
  2787. else
  2788. begin
  2789. { first round up to multiple of 4 }
  2790. if (symtable^.dataalignment=2) then
  2791. begin
  2792. if (symtable^.datasize and 1)<>0 then
  2793. inc(symtable^.datasize);
  2794. end
  2795. else
  2796. if (symtable^.dataalignment>=4) then
  2797. begin
  2798. if (symtable^.datasize mod 4) <> 0 then
  2799. inc(symtable^.datasize,4-(symtable^.datasize mod 4));
  2800. end;
  2801. vmt_offset:=symtable^.datasize;
  2802. inc(symtable^.datasize,target_os.size_of_pointer);
  2803. {$ifdef INCLUDEOK}
  2804. include(objectoptions,oo_has_vmt);
  2805. {$else}
  2806. objectoptions:=objectoptions+[oo_has_vmt];
  2807. {$endif}
  2808. end;
  2809. end;
  2810. procedure tobjectdef.check_forwards;
  2811. begin
  2812. symtable^.check_forwards;
  2813. if (oo_is_forward in objectoptions) then
  2814. begin
  2815. { ok, in future, the forward can be resolved }
  2816. Message1(sym_e_class_forward_not_resolved,objname^);
  2817. {$ifdef INCLUDEOK}
  2818. exclude(objectoptions,oo_is_forward);
  2819. {$else}
  2820. objectoptions:=objectoptions-[oo_is_forward];
  2821. {$endif}
  2822. end;
  2823. end;
  2824. { true, if self inherits from d (or if they are equal) }
  2825. function tobjectdef.is_related(d : pobjectdef) : boolean;
  2826. var
  2827. hp : pobjectdef;
  2828. begin
  2829. hp:=@self;
  2830. while assigned(hp) do
  2831. begin
  2832. if hp=d then
  2833. begin
  2834. is_related:=true;
  2835. exit;
  2836. end;
  2837. hp:=hp^.childof;
  2838. end;
  2839. is_related:=false;
  2840. end;
  2841. function tobjectdef.size : longint;
  2842. begin
  2843. if (oo_is_class in objectoptions) then
  2844. size:=target_os.size_of_pointer
  2845. else
  2846. size:=symtable^.datasize;
  2847. end;
  2848. function tobjectdef.alignment:longint;
  2849. begin
  2850. alignment:=symtable^.dataalignment;
  2851. end;
  2852. function tobjectdef.vmtmethodoffset(index:longint):longint;
  2853. begin
  2854. { for offset of methods for classes, see rtl/inc/objpash.inc }
  2855. if is_class then
  2856. vmtmethodoffset:=(index+12)*target_os.size_of_pointer
  2857. else
  2858. vmtmethodoffset:=(index+3)*target_os.size_of_pointer;
  2859. end;
  2860. function tobjectdef.vmt_mangledname : string;
  2861. {DM: I get a nil pointer on the owner name. I don't know if this
  2862. mayhappen, and I have therefore fixed the problem by doing nil pointer
  2863. checks.}
  2864. var
  2865. s1,s2:string;
  2866. begin
  2867. if not(oo_has_vmt in objectoptions) then
  2868. Message1(parser_object_has_no_vmt,objname^);
  2869. if owner^.name=nil then
  2870. s1:=''
  2871. else
  2872. s1:=owner^.name^;
  2873. if objname=nil then
  2874. s2:=''
  2875. else
  2876. s2:=objname^;
  2877. vmt_mangledname:='VMT_'+s1+'$_'+s2;
  2878. end;
  2879. function tobjectdef.rtti_name : string;
  2880. var
  2881. s1,s2:string;
  2882. begin
  2883. if owner^.name=nil then
  2884. s1:=''
  2885. else
  2886. s1:=owner^.name^;
  2887. if objname=nil then
  2888. s2:=''
  2889. else
  2890. s2:=objname^;
  2891. rtti_name:='RTTI_'+s1+'$_'+s2;
  2892. end;
  2893. function tobjectdef.is_class : boolean;
  2894. begin
  2895. is_class:=(oo_is_class in objectoptions);
  2896. end;
  2897. {$ifdef GDB}
  2898. procedure addprocname(p :pnamedindexobject);
  2899. var virtualind,argnames : string;
  2900. news, newrec : pchar;
  2901. pd,ipd : pprocdef;
  2902. lindex : longint;
  2903. para : pdefcoll;
  2904. arglength : byte;
  2905. sp : char;
  2906. begin
  2907. If psym(p)^.typ = procsym then
  2908. begin
  2909. pd := pprocsym(p)^.definition;
  2910. { this will be used for full implementation of object stabs
  2911. not yet done }
  2912. ipd := pd;
  2913. while assigned(ipd^.nextoverloaded) do ipd := ipd^.nextoverloaded;
  2914. if (po_virtualmethod in pd^.procoptions) then
  2915. begin
  2916. lindex := pd^.extnumber;
  2917. {doesnt seem to be necessary
  2918. lindex := lindex or $80000000;}
  2919. virtualind := '*'+tostr(lindex)+';'+ipd^._class^.numberstring+';'
  2920. end else virtualind := '.';
  2921. { arguments are not listed here }
  2922. {we don't need another definition}
  2923. para := pd^.para1;
  2924. { used by gdbpas to recognize constructor and destructors }
  2925. if (pd^.proctypeoption=potype_constructor) then
  2926. argnames:='__ct__'
  2927. else if (pd^.proctypeoption=potype_destructor) then
  2928. argnames:='__dt__'
  2929. else
  2930. argnames := '';
  2931. while assigned(para) do
  2932. begin
  2933. if para^.data^.deftype = formaldef then
  2934. begin
  2935. if para^.paratyp=vs_var then
  2936. argnames := argnames+'3var'
  2937. else if para^.paratyp=vs_const then
  2938. argnames:=argnames+'5const';
  2939. end
  2940. else
  2941. begin
  2942. { if the arg definition is like (v: ^byte;..
  2943. there is no sym attached to data !!! }
  2944. if assigned(para^.data^.sym) then
  2945. begin
  2946. arglength := length(para^.data^.sym^.name);
  2947. argnames := argnames + tostr(arglength)+para^.data^.sym^.name;
  2948. end
  2949. else
  2950. begin
  2951. argnames:=argnames+'11unnamedtype';
  2952. end;
  2953. end;
  2954. para := para^.next;
  2955. end;
  2956. ipd^.is_def_stab_written := true;
  2957. { here 2A must be changed for private and protected }
  2958. { 0 is private 1 protected and 2 public }
  2959. if (sp_private in psym(p)^.symoptions) then sp:='0'
  2960. else if (sp_protected in psym(p)^.symoptions) then sp:='1'
  2961. else sp:='2';
  2962. newrec := strpnew(p^.name+'::'+ipd^.numberstring
  2963. +'=##'+pd^.retdef^.numberstring+';:'+argnames+';'+sp+'A'
  2964. +virtualind+';');
  2965. { get spare place for a string at the end }
  2966. if strlen(StabRecString) + strlen(newrec) >= StabRecSize-256 then
  2967. begin
  2968. getmem(news,stabrecsize+memsizeinc);
  2969. strcopy(news,stabrecstring);
  2970. freemem(stabrecstring,stabrecsize);
  2971. stabrecsize:=stabrecsize+memsizeinc;
  2972. stabrecstring:=news;
  2973. end;
  2974. strcat(StabRecstring,newrec);
  2975. {freemem(newrec,memsizeinc); }
  2976. strdispose(newrec);
  2977. {This should be used for case !!}
  2978. RecOffset := RecOffset + pd^.size;
  2979. end;
  2980. end;
  2981. function tobjectdef.stabstring : pchar;
  2982. var anc : pobjectdef;
  2983. oldrec : pchar;
  2984. oldrecsize : longint;
  2985. str_end : string;
  2986. begin
  2987. oldrec := stabrecstring;
  2988. oldrecsize:=stabrecsize;
  2989. stabrecsize:=memsizeinc;
  2990. GetMem(stabrecstring,stabrecsize);
  2991. strpcopy(stabRecString,'s'+tostr(symtable^.datasize));
  2992. if assigned(childof) then
  2993. {only one ancestor not virtual, public, at base offset 0 }
  2994. { !1 , 0 2 0 , }
  2995. strpcopy(strend(stabrecstring),'!1,020,'+childof^.numberstring+';');
  2996. {virtual table to implement yet}
  2997. RecOffset := 0;
  2998. symtable^.foreach({$ifndef TP}@{$endif}addname);
  2999. if (oo_has_vmt in objectoptions) then
  3000. if not assigned(childof) or not(oo_has_vmt in childof^.objectoptions) then
  3001. begin
  3002. strpcopy(strend(stabrecstring),'$vf'+numberstring+':'+typeglobalnumber('vtblarray')
  3003. +','+tostr(vmt_offset*8)+';');
  3004. end;
  3005. symtable^.foreach({$ifndef TP}@{$endif}addprocname);
  3006. if (oo_has_vmt in objectoptions) then
  3007. begin
  3008. anc := @self;
  3009. while assigned(anc^.childof) and (oo_has_vmt in anc^.childof^.objectoptions) do
  3010. anc := anc^.childof;
  3011. str_end:=';~%'+anc^.numberstring+';';
  3012. end
  3013. else
  3014. str_end:=';';
  3015. strpcopy(strend(stabrecstring),str_end);
  3016. stabstring := strnew(StabRecString);
  3017. freemem(stabrecstring,stabrecsize);
  3018. stabrecstring := oldrec;
  3019. stabrecsize:=oldrecsize;
  3020. end;
  3021. {$endif GDB}
  3022. procedure tobjectdef.write_child_init_data;
  3023. begin
  3024. symtable^.foreach({$ifndef TP}@{$endif}generate_child_inittable);
  3025. end;
  3026. procedure tobjectdef.write_init_data;
  3027. begin
  3028. if is_class then
  3029. rttilist^.concat(new(pai_const,init_8bit(tkclass)))
  3030. else
  3031. rttilist^.concat(new(pai_const,init_8bit(tkobject)));
  3032. { generate the name }
  3033. rttilist^.concat(new(pai_const,init_8bit(length(objname^))));
  3034. rttilist^.concat(new(pai_string,init(objname^)));
  3035. rttilist^.concat(new(pai_const,init_32bit(size)));
  3036. count:=0;
  3037. symtable^.foreach({$ifndef TP}@{$endif}count_inittable_fields);
  3038. rttilist^.concat(new(pai_const,init_32bit(count)));
  3039. symtable^.foreach({$ifndef TP}@{$endif}write_field_inittable);
  3040. end;
  3041. function tobjectdef.needs_inittable : boolean;
  3042. var
  3043. oldb : boolean;
  3044. begin
  3045. { there are recursive calls to needs_inittable possible, }
  3046. { so we have to change to old value how else should }
  3047. { we do that ? check_rec_rtti can't be a nested }
  3048. { procedure of needs_rtti ! }
  3049. oldb:=binittable;
  3050. binittable:=false;
  3051. symtable^.foreach({$ifndef TP}@{$endif}check_rec_inittable);
  3052. needs_inittable:=binittable;
  3053. binittable:=oldb;
  3054. end;
  3055. procedure count_published_properties(sym:pnamedindexobject);
  3056. {$ifndef fpc}far;{$endif}
  3057. begin
  3058. if needs_prop_entry(psym(sym)) then
  3059. inc(count);
  3060. end;
  3061. procedure write_property_info(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  3062. var
  3063. proctypesinfo : byte;
  3064. procedure writeproc(sym : ppropsymlist;def : pdef;shiftvalue : byte);
  3065. var
  3066. typvalue : byte;
  3067. hp : ppropsymlist;
  3068. address : longint;
  3069. begin
  3070. if not(assigned(sym) and assigned(sym^.sym)) then
  3071. begin
  3072. rttilist^.concat(new(pai_const,init_32bit(1)));
  3073. typvalue:=3;
  3074. end
  3075. else if sym^.sym^.typ=varsym then
  3076. begin
  3077. address:=0;
  3078. hp:=sym;
  3079. while assigned(hp) do
  3080. begin
  3081. inc(address,pvarsym(hp^.sym)^.address);
  3082. hp:=hp^.next;
  3083. end;
  3084. rttilist^.concat(new(pai_const,init_32bit(address)));
  3085. typvalue:=0;
  3086. end
  3087. else
  3088. begin
  3089. if not(po_virtualmethod in pprocdef(def)^.procoptions) then
  3090. begin
  3091. rttilist^.concat(new(pai_const_symbol,initname(pprocdef(def)^.mangledname)));
  3092. typvalue:=1;
  3093. end
  3094. else
  3095. begin
  3096. { virtual method, write vmt offset }
  3097. rttilist^.concat(new(pai_const,init_32bit(
  3098. pprocdef(def)^._class^.vmtmethodoffset(pprocdef(def)^.extnumber))));
  3099. typvalue:=2;
  3100. end;
  3101. end;
  3102. proctypesinfo:=proctypesinfo or (typvalue shl shiftvalue);
  3103. end;
  3104. begin
  3105. if needs_prop_entry(psym(sym)) then
  3106. case psym(sym)^.typ of
  3107. varsym:
  3108. begin
  3109. if not(pvarsym(sym)^.definition^.deftype=objectdef) or
  3110. not(pobjectdef(pvarsym(sym)^.definition)^.is_class) then
  3111. internalerror(1509992);
  3112. { access to implicit class property as field }
  3113. proctypesinfo:=(0 shl 0) or (0 shl 2) or (0 shl 4);
  3114. rttilist^.concat(new(pai_const_symbol,initname(pvarsym(sym)^.definition^.get_rtti_label)));
  3115. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  3116. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  3117. { per default stored }
  3118. rttilist^.concat(new(pai_const,init_32bit(1)));
  3119. { index as well as ... }
  3120. rttilist^.concat(new(pai_const,init_32bit(0)));
  3121. { default value are zero }
  3122. rttilist^.concat(new(pai_const,init_32bit(0)));
  3123. rttilist^.concat(new(pai_const,init_16bit(count)));
  3124. inc(count);
  3125. rttilist^.concat(new(pai_const,init_8bit(proctypesinfo)));
  3126. rttilist^.concat(new(pai_const,init_8bit(length(pvarsym(sym)^.name))));
  3127. rttilist^.concat(new(pai_string,init(pvarsym(sym)^.name)));
  3128. end;
  3129. propertysym:
  3130. begin
  3131. if ppo_indexed in ppropertysym(sym)^.propoptions then
  3132. proctypesinfo:=$40
  3133. else
  3134. proctypesinfo:=0;
  3135. rttilist^.concat(new(pai_const_symbol,initname(ppropertysym(sym)^.proptype^.get_rtti_label)));
  3136. writeproc(ppropertysym(sym)^.readaccesssym,ppropertysym(sym)^.readaccessdef,0);
  3137. writeproc(ppropertysym(sym)^.writeaccesssym,ppropertysym(sym)^.writeaccessdef,2);
  3138. { isn't it stored ? }
  3139. if not(ppo_stored in ppropertysym(sym)^.propoptions) then
  3140. begin
  3141. rttilist^.concat(new(pai_const,init_32bit(0)));
  3142. proctypesinfo:=proctypesinfo or (3 shl 4);
  3143. end
  3144. else
  3145. writeproc(ppropertysym(sym)^.storedsym,ppropertysym(sym)^.storeddef,4);
  3146. rttilist^.concat(new(pai_const,init_32bit(ppropertysym(sym)^.index)));
  3147. rttilist^.concat(new(pai_const,init_32bit(ppropertysym(sym)^.default)));
  3148. rttilist^.concat(new(pai_const,init_16bit(count)));
  3149. inc(count);
  3150. rttilist^.concat(new(pai_const,init_8bit(proctypesinfo)));
  3151. rttilist^.concat(new(pai_const,init_8bit(length(ppropertysym(sym)^.name))));
  3152. rttilist^.concat(new(pai_string,init(ppropertysym(sym)^.name)));
  3153. end;
  3154. else internalerror(1509992);
  3155. end;
  3156. end;
  3157. procedure generate_published_child_rtti(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  3158. begin
  3159. if needs_prop_entry(psym(sym)) then
  3160. case psym(sym)^.typ of
  3161. varsym:
  3162. pvarsym(sym)^.definition^.get_rtti_label;
  3163. propertysym:
  3164. ppropertysym(sym)^.proptype^.get_rtti_label;
  3165. else internalerror(1509991);
  3166. end;
  3167. end;
  3168. procedure tobjectdef.write_child_rtti_data;
  3169. begin
  3170. symtable^.foreach({$ifndef TP}@{$endif}generate_published_child_rtti);
  3171. end;
  3172. procedure tobjectdef.generate_rtti;
  3173. begin
  3174. has_rtti:=true;
  3175. getdatalabel(rtti_label);
  3176. write_child_rtti_data;
  3177. rttilist^.concat(new(pai_symbol,initname_global(rtti_name,0)));
  3178. rttilist^.concat(new(pai_label,init(rtti_label)));
  3179. write_rtti_data;
  3180. rttilist^.concat(new(pai_symbol_end,initname(rtti_name)));
  3181. end;
  3182. function tobjectdef.next_free_name_index : longint;
  3183. var
  3184. i : longint;
  3185. begin
  3186. if assigned(childof) and (oo_can_have_published in childof^.objectoptions) then
  3187. i:=childof^.next_free_name_index
  3188. else
  3189. i:=0;
  3190. count:=0;
  3191. symtable^.foreach({$ifndef TP}@{$endif}count_published_properties);
  3192. next_free_name_index:=i+count;
  3193. end;
  3194. procedure tobjectdef.write_rtti_data;
  3195. begin
  3196. if is_class then
  3197. rttilist^.concat(new(pai_const,init_8bit(tkclass)))
  3198. else
  3199. rttilist^.concat(new(pai_const,init_8bit(tkobject)));
  3200. { generate the name }
  3201. rttilist^.concat(new(pai_const,init_8bit(length(objname^))));
  3202. rttilist^.concat(new(pai_string,init(objname^)));
  3203. { write class type }
  3204. rttilist^.concat(new(pai_const_symbol,initname(vmt_mangledname)));
  3205. { write owner typeinfo }
  3206. if assigned(childof) and (oo_can_have_published in childof^.objectoptions) then
  3207. rttilist^.concat(new(pai_const_symbol,initname(childof^.get_rtti_label)))
  3208. else
  3209. rttilist^.concat(new(pai_const,init_32bit(0)));
  3210. { count total number of properties }
  3211. if assigned(childof) and (oo_can_have_published in childof^.objectoptions) then
  3212. count:=childof^.next_free_name_index
  3213. else
  3214. count:=0;
  3215. { write it }
  3216. symtable^.foreach({$ifndef TP}@{$endif}count_published_properties);
  3217. rttilist^.concat(new(pai_const,init_16bit(count)));
  3218. { write unit name }
  3219. if assigned(owner^.name) then
  3220. begin
  3221. rttilist^.concat(new(pai_const,init_8bit(length(owner^.name^))));
  3222. rttilist^.concat(new(pai_string,init(owner^.name^)));
  3223. end
  3224. else
  3225. rttilist^.concat(new(pai_const,init_8bit(0)));
  3226. { write published properties count }
  3227. count:=0;
  3228. symtable^.foreach({$ifndef TP}@{$endif}count_published_properties);
  3229. rttilist^.concat(new(pai_const,init_16bit(count)));
  3230. { count is used to write nameindex }
  3231. { but we need an offset of the owner }
  3232. { to give each property an own slot }
  3233. if assigned(childof) and (oo_can_have_published in childof^.objectoptions) then
  3234. count:=childof^.next_free_name_index
  3235. else
  3236. count:=0;
  3237. symtable^.foreach({$ifndef TP}@{$endif}write_property_info);
  3238. end;
  3239. function tobjectdef.is_publishable : boolean;
  3240. begin
  3241. is_publishable:=is_class;
  3242. end;
  3243. function tobjectdef.get_rtti_label : string;
  3244. begin
  3245. get_rtti_label:=rtti_name;
  3246. end;
  3247. {****************************************************************************
  3248. TFORWARDDEF
  3249. ****************************************************************************}
  3250. constructor tforwarddef.init(const s:string);
  3251. var
  3252. oldregisterdef : boolean;
  3253. begin
  3254. { never register the forwarddefs, they are disposed at the
  3255. end of the type declaration block }
  3256. oldregisterdef:=registerdef;
  3257. registerdef:=false;
  3258. inherited init;
  3259. registerdef:=oldregisterdef;
  3260. deftype:=forwarddef;
  3261. tosymname:=s;
  3262. end;
  3263. function tforwarddef.gettypename:string;
  3264. begin
  3265. gettypename:='unresolved forward to '+tosymname;
  3266. end;
  3267. {****************************************************************************
  3268. TERRORDEF
  3269. ****************************************************************************}
  3270. constructor terrordef.init;
  3271. begin
  3272. inherited init;
  3273. deftype:=errordef;
  3274. end;
  3275. {$ifdef GDB}
  3276. function terrordef.stabstring : pchar;
  3277. begin
  3278. stabstring:=strpnew('error'+numberstring);
  3279. end;
  3280. {$endif GDB}
  3281. function terrordef.gettypename:string;
  3282. begin
  3283. gettypename:='<erroneous type>';
  3284. end;
  3285. {
  3286. $Log$
  3287. Revision 1.167 1999-10-01 08:02:48 peter
  3288. * forward type declaration rewritten
  3289. Revision 1.166 1999/09/26 21:30:21 peter
  3290. + constant pointer support which can happend with typecasting like
  3291. const p=pointer(1)
  3292. * better procvar parsing in typed consts
  3293. Revision 1.165 1999/09/20 16:39:02 peter
  3294. * cs_create_smart instead of cs_smartlink
  3295. * -CX is create smartlink
  3296. * -CD is create dynamic, but does nothing atm.
  3297. Revision 1.164 1999/09/15 22:09:26 florian
  3298. + rtti is now automatically generated for published classes, i.e.
  3299. they are handled like an implicit property
  3300. Revision 1.163 1999/09/15 20:35:44 florian
  3301. * small fix to operator overloading when in MMX mode
  3302. + the compiler uses now fldz and fld1 if possible
  3303. + some fixes to floating point registers
  3304. + some math. functions (arctan, ln, sin, cos, sqrt, sqr, pi) are now inlined
  3305. * .... ???
  3306. Revision 1.162 1999/09/12 08:48:09 florian
  3307. * bugs 593 and 607 fixed
  3308. * some other potential bugs with array constructors fixed
  3309. * for classes compiled in $M+ and it's childs, the default access method
  3310. is now published
  3311. * fixed copyright message (it is now 1993-99)
  3312. Revision 1.161 1999/09/10 18:48:09 florian
  3313. * some bug fixes (e.g. must_be_valid and procinfo.funcret_is_valid)
  3314. * most things for stored properties fixed
  3315. Revision 1.160 1999/09/02 17:07:40 florian
  3316. * problems with -Or fixed: tdef.isfpuregable was wrong!
  3317. Revision 1.159 1999/08/27 10:52:19 pierre
  3318. + simplify_ppu code added :
  3319. sets all registers used at PPU writing
  3320. * tprocdef mangledname writing is CRC relevant
  3321. Revision 1.158 1999/08/27 10:24:34 michael
  3322. + Inittables should not contain fields which are classes
  3323. Revision 1.157 1999/08/26 21:13:58 peter
  3324. * array elementsize of 0 doesn't crash anymore
  3325. Revision 1.156 1999/08/17 13:58:56 michael
  3326. RTTI writing patch
  3327. Revision 1.155 1999/08/16 16:26:04 pierre
  3328. * error in stabs for tclassrefdef corrected
  3329. Revision 1.154 1999/08/14 00:38:58 peter
  3330. * hack to support property with record fields
  3331. Revision 1.153 1999/08/13 21:33:11 peter
  3332. * support for array constructors extended and more error checking
  3333. Revision 1.152 1999/08/13 14:24:18 pierre
  3334. + stabs for classes and classref working,
  3335. a class still needs an ^ to get that content of it,
  3336. but the class fields inside a class don't result into an
  3337. infinite loop anymore!
  3338. Revision 1.151 1999/08/12 14:31:20 peter
  3339. * long line fix
  3340. Revision 1.150 1999/08/11 08:56:53 michael
  3341. * RTTI fix from Sebastian Guenther
  3342. Revision 1.149 1999/08/10 13:22:08 pierre
  3343. * vmtmethodoffset made cross target compatible
  3344. Revision 1.148 1999/08/10 12:32:13 pierre
  3345. * avoid overflow in tarraydef.size
  3346. Revision 1.147 1999/08/09 22:19:55 peter
  3347. * classes vmt changed to only positive addresses
  3348. * sharedlib creation is working
  3349. Revision 1.146 1999/08/07 14:21:00 florian
  3350. * some small problems fixed
  3351. Revision 1.145 1999/08/07 13:36:54 daniel
  3352. * Recommitted the arraydef overflow bugfix.
  3353. Revision 1.143 1999/08/06 11:13:30 peter
  3354. * fixed message which was wrong styled
  3355. Revision 1.142 1999/08/05 22:41:34 daniel
  3356. *** empty log message ***
  3357. Revision 1.141 1999/08/05 16:53:13 peter
  3358. * V_Fatal=1, all other V_ are also increased
  3359. * Check for local procedure when assigning procvar
  3360. * fixed comment parsing because directives
  3361. * oldtp mode directives better supported
  3362. * added some messages to errore.msg
  3363. Revision 1.140 1999/08/04 13:03:07 jonas
  3364. * all tokens now start with an underscore
  3365. * PowerPC compiles!!
  3366. Revision 1.139 1999/08/03 22:03:14 peter
  3367. * moved bitmask constants to sets
  3368. * some other type/const renamings
  3369. Revision 1.138 1999/08/02 21:29:02 florian
  3370. * the main branch psub.pas is now used for
  3371. newcg compiler
  3372. Revision 1.137 1999/07/31 22:37:17 michael
  3373. * Fix of initialization information generation
  3374. Revision 1.136 1999/07/29 20:54:07 peter
  3375. * write .size also
  3376. Revision 1.135 1999/07/27 23:42:18 peter
  3377. * indirect type referencing is now allowed
  3378. Revision 1.134 1999/07/23 23:07:03 peter
  3379. * fixed stabs for record which still used savesize
  3380. Revision 1.133 1999/07/23 16:05:28 peter
  3381. * alignment is now saved in the symtable
  3382. * C alignment added for records
  3383. * PPU version increased to solve .12 <-> .13 probs
  3384. Revision 1.132 1999/07/18 14:47:32 florian
  3385. * bug 487 fixed, (inc(<property>) isn't allowed)
  3386. * more fixes to compile with Delphi
  3387. Revision 1.131 1999/07/06 21:48:27 florian
  3388. * a lot bug fixes:
  3389. - po_external isn't any longer necessary for procedure compatibility
  3390. - m_tp_procvar is in -Sd now available
  3391. - error messages of procedure variables improved
  3392. - return values with init./finalization fixed
  3393. - data types with init./finalization aren't any longer allowed in variant
  3394. record
  3395. Revision 1.130 1999/06/22 16:24:44 pierre
  3396. * local browser stuff corrected
  3397. Revision 1.129 1999/06/02 22:44:21 pierre
  3398. * previous wrong log corrected
  3399. Revision 1.128 1999/06/02 22:25:52 pierre
  3400. * changed $ifdef FPC @ into $ifndef TP
  3401. Revision 1.127 1999/06/02 10:26:50 florian
  3402. * corrected order of parameter type for -vb
  3403. Revision 1.126 1999/06/02 10:11:50 florian
  3404. * make cycle fixed i.e. compilation with 0.99.10
  3405. * some fixes for qword
  3406. * start of register calling conventions
  3407. Revision 1.125 1999/06/01 14:45:56 peter
  3408. * @procvar is now always needed for FPC
  3409. Revision 1.124 1999/05/31 16:42:33 peter
  3410. * interfacedef flag for procdef if it's defined in the interface, to
  3411. make a difference with 'forward;' directive forwarddef. Fixes 253
  3412. Revision 1.123 1999/05/27 19:45:02 peter
  3413. * removed oldasm
  3414. * plabel -> pasmlabel
  3415. * -a switches to source writing automaticly
  3416. * assembler readers OOPed
  3417. * asmsymbol automaticly external
  3418. * jumptables and other label fixes for asm readers
  3419. Revision 1.122 1999/05/23 18:42:14 florian
  3420. * better error recovering in typed constants
  3421. * some problems with arrays of const fixed, some problems
  3422. due my previous
  3423. - the location type of array constructor is now LOC_MEM
  3424. - the pushing of high fixed
  3425. - parameter copying fixed
  3426. - zero temp. allocation removed
  3427. * small problem in the assembler writers fixed:
  3428. ref to nil wasn't written correctly
  3429. Revision 1.121 1999/05/21 13:55:19 peter
  3430. * NEWLAB for label as symbol
  3431. Revision 1.120 1999/05/20 22:22:43 pierre
  3432. + added synonym filed for ttypesym
  3433. allows a clean disposal of tdefs and related ttypesyms
  3434. Revision 1.119 1999/05/19 16:48:26 florian
  3435. * tdef.typename: returns a now a proper type name for the most types
  3436. Revision 1.118 1999/05/19 12:08:11 florian
  3437. * tobject wasn't set as default anchestor, was a problem with the new ppu
  3438. handling
  3439. Revision 1.117 1999/05/17 21:57:15 florian
  3440. * new temporary ansistring handling
  3441. Revision 1.116 1999/05/16 02:26:51 peter
  3442. * fixed loading of classrefdef
  3443. Revision 1.115 1999/05/14 17:52:26 peter
  3444. * new deref code
  3445. Revision 1.114 1999/05/13 21:59:41 peter
  3446. * removed oldppu code
  3447. * warning if objpas is loaded from uses
  3448. * first things for new deref writing
  3449. Revision 1.113 1999/05/12 00:19:58 peter
  3450. * removed R_DEFAULT_SEG
  3451. * uniform float names
  3452. Revision 1.112 1999/05/08 19:52:35 peter
  3453. + MessagePos() which is enhanced Message() function but also gets the
  3454. position info
  3455. * Removed comp warnings
  3456. Revision 1.111 1999/05/07 11:06:37 florian
  3457. * enumeration type names are now written in lowercase (rtti)
  3458. Revision 1.110 1999/05/06 09:05:28 peter
  3459. * generic write_float and str_float
  3460. * fixed constant float conversions
  3461. Revision 1.109 1999/05/05 10:05:56 florian
  3462. * a delphi compiled compiler recompiles ppc
  3463. Revision 1.108 1999/04/28 22:30:52 pierre
  3464. * delete -> deleteindex in tdef.correct_owner_symtable
  3465. Revision 1.107 1999/04/28 06:02:11 florian
  3466. * changes of Bruessel:
  3467. + message handler can now take an explicit self
  3468. * typinfo fixed: sometimes the type names weren't written
  3469. * the type checking for pointer comparisations and subtraction
  3470. and are now more strict (was also buggy)
  3471. * small bug fix to link.pas to support compiling on another
  3472. drive
  3473. * probable bug in popt386 fixed: call/jmp => push/jmp
  3474. transformation didn't count correctly the jmp references
  3475. + threadvar support
  3476. * warning if ln/sqrt gets an invalid constant argument
  3477. Revision 1.106 1999/04/26 18:30:01 peter
  3478. * farpointerdef moved into pointerdef.is_far
  3479. Revision 1.105 1999/04/26 13:31:47 peter
  3480. * release storenumber,double_checksum
  3481. Revision 1.104 1999/04/21 09:43:50 peter
  3482. * storenumber works
  3483. * fixed some typos in double_checksum
  3484. + incompatible types type1 and type2 message (with storenumber)
  3485. Revision 1.103 1999/04/19 09:28:20 peter
  3486. * fixed crash when writing overload operator to ppu
  3487. Revision 1.102 1999/04/17 22:01:28 pierre
  3488. * typo error fix in STORENUMBER code
  3489. Revision 1.101 1999/04/14 09:14:58 peter
  3490. * first things to store the symbol/def number in the ppu
  3491. Revision 1.100 1999/04/08 15:57:51 peter
  3492. + subrange checking for readln()
  3493. Revision 1.99 1999/04/07 15:39:32 pierre
  3494. + double_checksum code added
  3495. Revision 1.98 1999/03/06 17:24:16 peter
  3496. * reset savesize in tdef.init
  3497. Revision 1.97 1999/03/01 13:45:04 pierre
  3498. + added staticppusymtable symtable type for local browsing
  3499. Revision 1.96 1999/02/25 21:02:52 peter
  3500. * ag386bin updates
  3501. + coff writer
  3502. Revision 1.95 1999/02/23 18:29:23 pierre
  3503. * win32 compilation error fix
  3504. + some work for local browser (not cl=omplete yet)
  3505. Revision 1.94 1999/02/22 20:13:38 florian
  3506. + first implementation of message keyword
  3507. Revision 1.93 1999/02/22 13:07:07 pierre
  3508. + -b and -bl options work !
  3509. + cs_local_browser ($L+) is disabled if cs_browser ($Y+)
  3510. is not enabled when quitting global section
  3511. * local vars and procedures are not yet stored into PPU
  3512. Revision 1.92 1999/02/17 10:14:20 peter
  3513. * set the first enumsym also for subrange types
  3514. Revision 1.91 1999/02/08 09:51:21 pierre
  3515. * gdb info for local functions was wrong
  3516. Revision 1.90 1999/01/26 09:57:29 pierre
  3517. * open arrays stabs changed
  3518. Revision 1.89 1999/01/22 17:29:30 pierre
  3519. * overflow in addname for open arrays removed
  3520. Revision 1.88 1999/01/20 14:18:39 pierre
  3521. * bugs related to mangledname solved
  3522. - linux external without name
  3523. -external procs already used
  3524. (added count and is_used boolean fiels in tprocvar)
  3525. Revision 1.87 1999/01/19 10:56:05 pierre
  3526. typeof(object) without vmt generates an error instead of an internalerror
  3527. Revision 1.86 1999/01/12 14:25:32 peter
  3528. + BrowserLog for browser.log generation
  3529. + BrowserCol for browser info in TCollections
  3530. * released all other UseBrowser
  3531. Revision 1.85 1998/12/30 22:15:52 peter
  3532. + farpointer type
  3533. * absolutesym now also stores if its far
  3534. Revision 1.84 1998/12/30 13:41:12 peter
  3535. * released valuepara
  3536. Revision 1.83 1998/12/21 14:03:08 pierre
  3537. * procvar stabs correction
  3538. Revision 1.82 1998/12/19 00:23:52 florian
  3539. * ansistring memory leaks fixed
  3540. Revision 1.81 1998/12/11 08:57:22 pierre
  3541. * internal gdb types for booleans and 64bit integers
  3542. Revision 1.80 1998/12/10 09:47:26 florian
  3543. + basic operations with int64/qord (compiler with -dint64)
  3544. + rtti of enumerations extended: names are now written
  3545. Revision 1.79 1998/12/08 10:18:12 peter
  3546. + -gh for heaptrc unit
  3547. Revision 1.78 1998/12/08 09:06:30 pierre
  3548. + constructor destructor info for gdbpas
  3549. Revision 1.77 1998/12/01 23:37:39 pierre
  3550. * function type problem for gdb fix
  3551. Revision 1.76 1998/11/29 21:45:48 florian
  3552. * problem with arrays with init tables fixed
  3553. Revision 1.75 1998/11/29 12:45:59 peter
  3554. * hack for arraydef.size overflow
  3555. Revision 1.74 1998/11/27 14:50:47 peter
  3556. + open strings, $P switch support
  3557. Revision 1.73 1998/11/26 14:47:00 michael
  3558. + Fixed RTTI constants
  3559. Revision 1.72 1998/11/25 14:35:28 florian
  3560. * writting of rtti for properties fixed
  3561. Revision 1.71 1998/11/20 15:35:59 florian
  3562. * problems with rtti fixed, hope it works
  3563. Revision 1.70 1998/11/18 15:44:16 peter
  3564. * VALUEPARA for tp7 compatible value parameters
  3565. Revision 1.69 1998/11/10 17:54:56 peter
  3566. * removed warning
  3567. Revision 1.68 1998/11/05 23:34:36 peter
  3568. * don't dispose staticsymtable (caused crash under tp7 after a fatal
  3569. error)
  3570. Revision 1.67 1998/11/05 12:02:56 peter
  3571. * released useansistring
  3572. * removed -Sv, its now available in fpc modes
  3573. Revision 1.66 1998/10/26 22:58:22 florian
  3574. * new introduded problem with classes fix, the parent class wasn't set
  3575. correct, if the class was defined forward before
  3576. Revision 1.65 1998/10/26 14:19:28 pierre
  3577. + added options -lS and -lT for source and target os output
  3578. (to have a easier way to test OS_SOURCE abd OS_TARGET in makefiles)
  3579. * several problems with rtti data
  3580. (type of sym was not checked)
  3581. assumed to be varsym when they could be procsym or property syms !!
  3582. Revision 1.64 1998/10/22 17:11:21 pierre
  3583. + terminated the include exclude implementation for i386
  3584. * enums inside records fixed
  3585. Revision 1.63 1998/10/20 09:32:56 peter
  3586. * removed some unused vars
  3587. Revision 1.62 1998/10/20 08:06:58 pierre
  3588. * several memory corruptions due to double freemem solved
  3589. => never use p^.loc.location:=p^.left^.loc.location;
  3590. + finally I added now by default
  3591. that ra386dir translates global and unit symbols
  3592. + added a first field in tsymtable and
  3593. a nextsym field in tsym
  3594. (this allows to obtain ordered type info for
  3595. records and objects in gdb !)
  3596. Revision 1.61 1998/10/19 08:55:05 pierre
  3597. * wrong stabs info corrected once again !!
  3598. + variable vmt offset with vmt field only if required
  3599. implemented now !!!
  3600. Revision 1.60 1998/10/16 13:12:53 pierre
  3601. * added vmt_offsets in destructors code also !!!
  3602. * vmt_offset code for m68k
  3603. Revision 1.59 1998/10/16 08:51:51 peter
  3604. + target_os.stackalignment
  3605. + stack can be aligned at 2 or 4 byte boundaries
  3606. Revision 1.58 1998/10/15 15:13:30 pierre
  3607. + added oo_hasconstructor and oo_hasdestructor
  3608. for objects options
  3609. Revision 1.57 1998/10/14 15:54:20 pierre
  3610. * smallsets are not entirely implemented for
  3611. m68k added a ifdef usesmallset
  3612. that is allways defined for i386
  3613. (enables testing for m68k)
  3614. Revision 1.56 1998/10/09 11:47:56 pierre
  3615. * still more memory leaks fixes !!
  3616. Revision 1.55 1998/10/06 17:16:55 pierre
  3617. * some memory leaks fixed (thanks to Peter for heaptrc !)
  3618. Revision 1.54 1998/10/05 21:33:28 peter
  3619. * fixed 161,165,166,167,168
  3620. Revision 1.53 1998/10/05 12:48:39 pierre
  3621. * wrong handling of range check for arrays fixed
  3622. Revision 1.52 1998/10/02 07:20:38 florian
  3623. * range checking in units doesn't work if the units are smartlinked, fixed
  3624. Revision 1.51 1998/09/25 12:01:41 florian
  3625. * tobjectdef.symtable.datasize was set to savesize, this is wrong now
  3626. because the symtable size is read from the ppu file
  3627. Revision 1.50 1998/09/23 15:46:40 florian
  3628. * problem with with and classes fixed
  3629. Revision 1.49 1998/09/23 12:03:55 peter
  3630. * overloading fix for array of const
  3631. Revision 1.48 1998/09/22 15:37:23 peter
  3632. + array of const start
  3633. Revision 1.47 1998/09/21 15:46:01 michael
  3634. Applied florians fix for check_rec_inittable
  3635. Revision 1.46 1998/09/21 08:45:21 pierre
  3636. + added vmt_offset in tobjectdef.write for fututre use
  3637. (first steps to have objects without vmt if no virtual !!)
  3638. + added fpu_used field for tabstractprocdef :
  3639. sets this level to 2 if the functions return with value in FPU
  3640. (is then set to correct value at parsing of implementation)
  3641. THIS MIGHT refuse some code with FPU expression too complex
  3642. that were accepted before and even in some cases
  3643. that don't overflow in fact
  3644. ( like if f : float; is a forward that finally in implementation
  3645. only uses one fpu register !!)
  3646. Nevertheless I think that it will improve security on
  3647. FPU operations !!
  3648. * most other changes only for UseBrowser code
  3649. (added symtable references for record and objects)
  3650. local switch for refs to args and local of each function
  3651. (static symtable still missing)
  3652. UseBrowser still not stable and probably broken by
  3653. the definition hash array !!
  3654. Revision 1.45 1998/09/20 08:31:29 florian
  3655. + bit 6 of tpropinfo.propprocs is set, if the property contains a
  3656. constant index
  3657. Revision 1.44 1998/09/19 15:23:58 florian
  3658. * rtti for ordtypes corrected
  3659. Revision 1.43 1998/09/18 17:12:40 florian
  3660. * problem with writing of class references fixed
  3661. Revision 1.42 1998/09/17 13:41:20 pierre
  3662. sizeof(TPOINT) problem
  3663. Revision 1.40.2.2 1998/09/17 08:42:33 pierre
  3664. TPOINT sizeof fix
  3665. Revision 1.41 1998/09/15 17:39:30 jonas
  3666. + bugfix from bugfix branch
  3667. Revision 1.40.2.1 1998/09/15 17:35:32 jonas
  3668. * chenged string_typ in tstringdef.wideload from ansistring to widestring
  3669. Revision 1.40 1998/09/09 15:34:00 peter
  3670. * removed warnings
  3671. Revision 1.39 1998/09/08 10:23:44 pierre
  3672. * name field of filedef corrected
  3673. Revision 1.38 1998/09/07 23:10:23 florian
  3674. * a lot of stuff fixed regarding rtti and publishing of properties,
  3675. basics should now work
  3676. Revision 1.37 1998/09/07 19:33:24 florian
  3677. + some stuff for property rtti added:
  3678. - NameIndex of the TPropInfo record is now written correctly
  3679. - the DEFAULT/NODEFAULT keyword is supported now
  3680. - the default value and the storedsym/def are now written to
  3681. the PPU fiel
  3682. Revision 1.36 1998/09/07 17:37:01 florian
  3683. * first fixes for published properties
  3684. Revision 1.35 1998/09/06 22:42:02 florian
  3685. + rtti genreation for properties added
  3686. Revision 1.34 1998/09/04 18:15:02 peter
  3687. * filedef updated
  3688. Revision 1.33 1998/09/03 17:08:49 pierre
  3689. * better lines for stabs
  3690. (no scroll back to if before else part
  3691. no return to case line at jump outside case)
  3692. + source lines also if not in order
  3693. Revision 1.32 1998/09/03 16:03:20 florian
  3694. + rtti generation
  3695. * init table generation changed
  3696. Revision 1.31 1998/09/02 15:14:28 peter
  3697. * enum packing changed from len to max
  3698. Revision 1.30 1998/09/01 17:37:29 peter
  3699. * removed debug writeln :(
  3700. Revision 1.29 1998/09/01 12:53:25 peter
  3701. + aktpackenum
  3702. Revision 1.28 1998/09/01 07:54:22 pierre
  3703. * UseBrowser a little updated (might still be buggy !!)
  3704. * bug in psub.pas in function specifier removed
  3705. * stdcall allowed in interface and in implementation
  3706. (FPC will not yet complain if it is missing in either part
  3707. because stdcall is only a dummy !!)
  3708. Revision 1.27 1998/08/28 12:51:43 florian
  3709. + ansistring to pchar type cast fixed
  3710. Revision 1.26 1998/08/25 12:42:44 pierre
  3711. * CDECL changed to CVAR for variables
  3712. specifications are read in structures also
  3713. + started adding GPC compatibility mode ( option -Sp)
  3714. * names changed to lowercase
  3715. Revision 1.25 1998/08/23 21:04:38 florian
  3716. + rtti generation for classes added
  3717. + new/dispose do now also a call to INITIALIZE/FINALIZE, if necessaray
  3718. Revision 1.24 1998/08/20 12:53:26 peter
  3719. * object_options are always written for object syms
  3720. Revision 1.23 1998/08/19 00:42:42 peter
  3721. + subrange types for enums
  3722. + checking for bounds type with ranges
  3723. Revision 1.22 1998/08/17 10:10:10 peter
  3724. - removed OLDPPU
  3725. Revision 1.21 1998/08/10 14:50:28 peter
  3726. + localswitches, moduleswitches, globalswitches splitting
  3727. Revision 1.20 1998/07/18 22:54:30 florian
  3728. * some ansi/wide/longstring support fixed:
  3729. o parameter passing
  3730. o returning as result from functions
  3731. Revision 1.19 1998/07/14 14:47:05 peter
  3732. * released NEWINPUT
  3733. Revision 1.18 1998/07/10 10:51:04 peter
  3734. * m68k updates
  3735. Revision 1.16 1998/07/07 11:20:13 peter
  3736. + NEWINPUT for a better inputfile and scanner object
  3737. Revision 1.15 1998/06/24 14:48:37 peter
  3738. * ifdef newppu -> ifndef oldppu
  3739. Revision 1.14 1998/06/16 08:56:31 peter
  3740. + targetcpu
  3741. * cleaner pmodules for newppu
  3742. Revision 1.13 1998/06/15 15:38:09 pierre
  3743. * small bug in systems.pas corrected
  3744. + operators in different units better hanlded
  3745. Revision 1.12 1998/06/15 14:30:12 daniel
  3746. * Reverted my changes.
  3747. Revision 1.10 1998/06/13 00:10:16 peter
  3748. * working browser and newppu
  3749. * some small fixes against crashes which occured in bp7 (but not in
  3750. fpc?!)
  3751. Revision 1.9 1998/06/12 14:10:37 michael
  3752. * Fixed wrong code for ansistring
  3753. Revision 1.8 1998/06/11 10:11:58 peter
  3754. * -gb works again
  3755. Revision 1.7 1998/06/07 15:30:25 florian
  3756. + first working rtti
  3757. + data init/final. for local variables
  3758. Revision 1.6 1998/06/05 14:37:37 pierre
  3759. * fixes for inline for operators
  3760. * inline procedure more correctly restricted
  3761. Revision 1.5 1998/06/04 23:52:01 peter
  3762. * m68k compiles
  3763. + .def file creation moved to gendef.pas so it could also be used
  3764. for win32
  3765. Revision 1.4 1998/06/04 09:55:45 pierre
  3766. * demangled name of procsym reworked to become independant of the mangling
  3767. scheme
  3768. Revision 1.3 1998/06/03 22:49:03 peter
  3769. + wordbool,longbool
  3770. * rename bis,von -> high,low
  3771. * moved some systemunit loading/creating to psystem.pas
  3772. Revision 1.2 1998/05/31 14:13:37 peter
  3773. * fixed call bugs with assembler readers
  3774. + OPR_SYMBOL to hold a symbol in the asm parser
  3775. * fixed staticsymtable vars which were acessed through %ebp instead of
  3776. name
  3777. Revision 1.1 1998/05/27 19:45:09 peter
  3778. * symtable.pas splitted into includefiles
  3779. * symtable adapted for $ifndef OLDPPU
  3780. }