symdef.inc 121 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 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. tkInt64 = 19;
  46. tkQWord = 20;
  47. otSByte = 0;
  48. otUByte = 1;
  49. otSWord = 2;
  50. otUWord = 3;
  51. otSLong = 4;
  52. otULong = 5;
  53. ftSingle = 0;
  54. ftDouble = 1;
  55. ftExtended = 2;
  56. ftComp = 3;
  57. ftCurr = 4;
  58. ftFixed16 = 5;
  59. ftFixed32 = 6;
  60. mkProcedure = 0;
  61. mkFunction = 1;
  62. mkConstructor = 2;
  63. mkDestructor = 3;
  64. mkClassProcedure= 4;
  65. mkClassFunction = 5;
  66. pfvar = 1;
  67. pfConst = 2;
  68. pfArray = 4;
  69. pfAddress = 8;
  70. pfReference = 16;
  71. pfOut = 32;
  72. constructor tdef.init;
  73. begin
  74. inherited init;
  75. deftype:=abstractdef;
  76. owner := nil;
  77. typesym := nil;
  78. savesize := 0;
  79. if registerdef then
  80. symtablestack^.registerdef(@self);
  81. has_rtti:=false;
  82. has_inittable:=false;
  83. {$ifdef GDB}
  84. is_def_stab_written := false;
  85. globalnb := 0;
  86. {$endif GDB}
  87. if assigned(lastglobaldef) then
  88. begin
  89. lastglobaldef^.nextglobal := @self;
  90. previousglobal:=lastglobaldef;
  91. end
  92. else
  93. begin
  94. firstglobaldef := @self;
  95. previousglobal := nil;
  96. end;
  97. lastglobaldef := @self;
  98. nextglobal := nil;
  99. end;
  100. constructor tdef.load;
  101. begin
  102. deftype:=abstractdef;
  103. next := nil;
  104. owner := nil;
  105. has_rtti:=false;
  106. has_inittable:=false;
  107. {$ifdef GDB}
  108. is_def_stab_written := false;
  109. globalnb := 0;
  110. {$endif GDB}
  111. if assigned(lastglobaldef) then
  112. begin
  113. lastglobaldef^.nextglobal := @self;
  114. previousglobal:=lastglobaldef;
  115. end
  116. else
  117. begin
  118. firstglobaldef := @self;
  119. previousglobal:=nil;
  120. end;
  121. lastglobaldef := @self;
  122. nextglobal := nil;
  123. { load }
  124. indexnr:=readword;
  125. typesym:=ptypesym(readsymref);
  126. end;
  127. destructor tdef.done;
  128. begin
  129. { first element ? }
  130. if not(assigned(previousglobal)) then
  131. begin
  132. firstglobaldef := nextglobal;
  133. if assigned(firstglobaldef) then
  134. firstglobaldef^.previousglobal:=nil;
  135. end
  136. else
  137. begin
  138. { remove reference in the element before }
  139. previousglobal^.nextglobal:=nextglobal;
  140. end;
  141. { last element ? }
  142. if not(assigned(nextglobal)) then
  143. begin
  144. lastglobaldef := previousglobal;
  145. if assigned(lastglobaldef) then
  146. lastglobaldef^.nextglobal:=nil;
  147. end
  148. else
  149. nextglobal^.previousglobal:=previousglobal;
  150. previousglobal:=nil;
  151. nextglobal:=nil;
  152. {$ifdef SYNONYM}
  153. while assigned(typesym) do
  154. begin
  155. typesym^.restype.setdef(nil);
  156. typesym:=typesym^.synonym;
  157. end;
  158. {$endif}
  159. end;
  160. { used for enumdef because the symbols are
  161. inserted in the owner symtable }
  162. procedure tdef.correct_owner_symtable;
  163. var
  164. st : psymtable;
  165. begin
  166. if assigned(owner) and
  167. (owner^.symtabletype in [recordsymtable,objectsymtable]) then
  168. begin
  169. owner^.defindex^.deleteindex(@self);
  170. st:=owner;
  171. while (st^.symtabletype in [recordsymtable,objectsymtable]) do
  172. st:=st^.next;
  173. st^.registerdef(@self);
  174. end;
  175. end;
  176. function tdef.typename:string;
  177. begin
  178. if assigned(typesym) then
  179. typename:=Upper(typesym^.name)
  180. else
  181. typename:=gettypename;
  182. end;
  183. function tdef.gettypename : string;
  184. begin
  185. gettypename:='<unknown type>'
  186. end;
  187. function tdef.is_in_current : boolean;
  188. var
  189. p : psymtable;
  190. begin
  191. p:=owner;
  192. is_in_current:=false;
  193. while assigned(p) do
  194. begin
  195. if (p=current_module^.globalsymtable) or (p=current_module^.localsymtable)
  196. or (p^.symtabletype in [globalsymtable,staticsymtable]) then
  197. begin
  198. is_in_current:=true;
  199. exit;
  200. end
  201. else if p^.symtabletype in [localsymtable,parasymtable,objectsymtable] then
  202. begin
  203. if assigned(p^.defowner) then
  204. p:=pobjectdef(p^.defowner)^.owner
  205. else
  206. exit;
  207. end
  208. else
  209. exit;
  210. end;
  211. end;
  212. procedure tdef.write;
  213. begin
  214. writeword(indexnr);
  215. writesymref(typesym);
  216. {$ifdef GDB}
  217. if globalnb = 0 then
  218. begin
  219. if assigned(owner) then
  220. globalnb := owner^.getnewtypecount
  221. else
  222. begin
  223. globalnb := PGlobalTypeCount^;
  224. Inc(PGlobalTypeCount^);
  225. end;
  226. end;
  227. {$endif GDB}
  228. end;
  229. function tdef.size : longint;
  230. begin
  231. size:=savesize;
  232. end;
  233. function tdef.alignment : longint;
  234. begin
  235. { normal alignment by default }
  236. alignment:=0;
  237. end;
  238. {$ifdef GDB}
  239. procedure tdef.set_globalnb;
  240. begin
  241. globalnb :=PGlobalTypeCount^;
  242. inc(PglobalTypeCount^);
  243. end;
  244. function tdef.stabstring : pchar;
  245. begin
  246. stabstring := strpnew('t'+numberstring+';');
  247. end;
  248. function tdef.numberstring : string;
  249. var table : psymtable;
  250. begin
  251. {formal def have no type !}
  252. if deftype = formaldef then
  253. begin
  254. numberstring := voiddef^.numberstring;
  255. exit;
  256. end;
  257. if (not assigned(typesym)) or (not typesym^.isusedinstab) then
  258. begin
  259. {set even if debuglist is not defined}
  260. if assigned(typesym) then
  261. typesym^.isusedinstab := true;
  262. if assigned(debuglist) and not is_def_stab_written then
  263. concatstabto(debuglist);
  264. end;
  265. if not (cs_gdb_dbx in aktglobalswitches) then
  266. begin
  267. if globalnb = 0 then
  268. set_globalnb;
  269. numberstring := tostr(globalnb);
  270. end
  271. else
  272. begin
  273. if globalnb = 0 then
  274. begin
  275. if assigned(owner) then
  276. globalnb := owner^.getnewtypecount
  277. else
  278. begin
  279. globalnb := PGlobalTypeCount^;
  280. Inc(PGlobalTypeCount^);
  281. end;
  282. end;
  283. if assigned(typesym) then
  284. begin
  285. table := typesym^.owner;
  286. if table^.unitid > 0 then
  287. numberstring := '('+tostr(table^.unitid)+','+tostr(typesym^.restype.def^.globalnb)+')'
  288. else
  289. numberstring := tostr(globalnb);
  290. exit;
  291. end;
  292. numberstring := tostr(globalnb);
  293. end;
  294. end;
  295. function tdef.allstabstring : pchar;
  296. var stabchar : string[2];
  297. ss,st : pchar;
  298. sname : string;
  299. sym_line_no : longint;
  300. begin
  301. ss := stabstring;
  302. getmem(st,strlen(ss)+512);
  303. stabchar := 't';
  304. if deftype in tagtypes then
  305. stabchar := 'Tt';
  306. if assigned(typesym) then
  307. begin
  308. sname := typesym^.name;
  309. sym_line_no:=typesym^.fileinfo.line;
  310. end
  311. else
  312. begin
  313. sname := ' ';
  314. sym_line_no:=0;
  315. end;
  316. strpcopy(st,'"'+sname+':'+stabchar+numberstring+'=');
  317. strpcopy(strecopy(strend(st),ss),'",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0');
  318. allstabstring := strnew(st);
  319. freemem(st,strlen(ss)+512);
  320. strdispose(ss);
  321. end;
  322. procedure tdef.concatstabto(asmlist : paasmoutput);
  323. var stab_str : pchar;
  324. begin
  325. if ((typesym = nil) or typesym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  326. and not is_def_stab_written then
  327. begin
  328. If cs_gdb_dbx in aktglobalswitches then
  329. begin
  330. { otherwise you get two of each def }
  331. If assigned(typesym) then
  332. begin
  333. if typesym^.typ=symconst.typesym then
  334. typesym^.isusedinstab:=true;
  335. if (typesym^.owner = nil) or
  336. ((typesym^.owner^.symtabletype = unitsymtable) and
  337. punitsymtable(typesym^.owner)^.dbx_count_ok) then
  338. begin
  339. {with DBX we get the definition from the other objects }
  340. is_def_stab_written := true;
  341. exit;
  342. end;
  343. end;
  344. end;
  345. { to avoid infinite loops }
  346. is_def_stab_written := true;
  347. stab_str := allstabstring;
  348. asmlist^.concat(new(pai_stabs,init(stab_str)));
  349. end;
  350. end;
  351. {$endif GDB}
  352. procedure tdef.deref;
  353. begin
  354. resolvesym(psym(typesym));
  355. end;
  356. { rtti generation }
  357. procedure tdef.generate_rtti;
  358. begin
  359. if not has_rtti then
  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. end;
  369. function tdef.get_rtti_label : string;
  370. begin
  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(typesym) then
  407. begin
  408. str:=typesym^.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. inherited deref;
  707. resolvedef(pdef(basedef));
  708. end;
  709. destructor tenumdef.done;
  710. begin
  711. inherited done;
  712. end;
  713. procedure tenumdef.write;
  714. begin
  715. tdef.write;
  716. writedefref(basedef);
  717. writelong(min);
  718. writelong(max);
  719. writelong(savesize);
  720. current_ppu^.writeentry(ibenumdef);
  721. end;
  722. function tenumdef.getrangecheckstring : string;
  723. begin
  724. if (cs_create_smart in aktmoduleswitches) then
  725. getrangecheckstring:='R_'+current_module^.modulename^+tostr(rangenr)
  726. else
  727. getrangecheckstring:='R_'+tostr(rangenr);
  728. end;
  729. procedure tenumdef.genrangecheck;
  730. begin
  731. if rangenr=0 then
  732. begin
  733. { generate two constant for bounds }
  734. getlabelnr(rangenr);
  735. if (cs_create_smart in aktmoduleswitches) then
  736. datasegment^.concat(new(pai_symbol,initname_global(getrangecheckstring,8)))
  737. else
  738. datasegment^.concat(new(pai_symbol,initname(getrangecheckstring,8)));
  739. datasegment^.concat(new(pai_const,init_32bit(min)));
  740. datasegment^.concat(new(pai_const,init_32bit(max)));
  741. end;
  742. end;
  743. {$ifdef GDB}
  744. function tenumdef.stabstring : pchar;
  745. var st,st2 : pchar;
  746. p : penumsym;
  747. s : string;
  748. memsize : word;
  749. begin
  750. memsize := memsizeinc;
  751. getmem(st,memsize);
  752. strpcopy(st,'e');
  753. p := firstenum;
  754. while assigned(p) do
  755. begin
  756. s :=p^.name+':'+tostr(p^.value)+',';
  757. { place for the ending ';' also }
  758. if (strlen(st)+length(s)+1<memsize) then
  759. strpcopy(strend(st),s)
  760. else
  761. begin
  762. getmem(st2,memsize+memsizeinc);
  763. strcopy(st2,st);
  764. freemem(st,memsize);
  765. st := st2;
  766. memsize := memsize+memsizeinc;
  767. strpcopy(strend(st),s);
  768. end;
  769. p := p^.nextenum;
  770. end;
  771. strpcopy(strend(st),';');
  772. stabstring := strnew(st);
  773. freemem(st,memsize);
  774. end;
  775. {$endif GDB}
  776. procedure tenumdef.write_child_rtti_data;
  777. begin
  778. if assigned(basedef) then
  779. basedef^.get_rtti_label;
  780. end;
  781. procedure tenumdef.write_rtti_data;
  782. var
  783. hp : penumsym;
  784. begin
  785. rttilist^.concat(new(pai_const,init_8bit(tkEnumeration)));
  786. write_rtti_name;
  787. case savesize of
  788. 1:
  789. rttilist^.concat(new(pai_const,init_8bit(otUByte)));
  790. 2:
  791. rttilist^.concat(new(pai_const,init_8bit(otUWord)));
  792. 4:
  793. rttilist^.concat(new(pai_const,init_8bit(otULong)));
  794. end;
  795. rttilist^.concat(new(pai_const,init_32bit(min)));
  796. rttilist^.concat(new(pai_const,init_32bit(max)));
  797. if assigned(basedef) then
  798. rttilist^.concat(new(pai_const_symbol,initname(basedef^.get_rtti_label)))
  799. else
  800. rttilist^.concat(new(pai_const,init_32bit(0)));
  801. hp:=firstenum;
  802. while assigned(hp) do
  803. begin
  804. rttilist^.concat(new(pai_const,init_8bit(length(hp^.name))));
  805. rttilist^.concat(new(pai_string,init(globals.lower(hp^.name))));
  806. hp:=hp^.nextenum;
  807. end;
  808. rttilist^.concat(new(pai_const,init_8bit(0)));
  809. end;
  810. function tenumdef.is_publishable : boolean;
  811. begin
  812. is_publishable:=true;
  813. end;
  814. function tenumdef.gettypename : string;
  815. begin
  816. gettypename:='<enumeration type>';
  817. end;
  818. {****************************************************************************
  819. TORDDEF
  820. ****************************************************************************}
  821. constructor torddef.init(t : tbasetype;v,b : longint);
  822. begin
  823. inherited init;
  824. deftype:=orddef;
  825. low:=v;
  826. high:=b;
  827. typ:=t;
  828. rangenr:=0;
  829. setsize;
  830. end;
  831. constructor torddef.load;
  832. begin
  833. inherited load;
  834. deftype:=orddef;
  835. typ:=tbasetype(readbyte);
  836. low:=readlong;
  837. high:=readlong;
  838. rangenr:=0;
  839. setsize;
  840. end;
  841. procedure torddef.setsize;
  842. begin
  843. if typ=uauto then
  844. begin
  845. { generate a unsigned range if high<0 and low>=0 }
  846. if (low>=0) and (high<0) then
  847. begin
  848. savesize:=4;
  849. typ:=u32bit;
  850. end
  851. else if (low>=0) and (high<=255) then
  852. begin
  853. savesize:=1;
  854. typ:=u8bit;
  855. end
  856. else if (low>=-128) and (high<=127) then
  857. begin
  858. savesize:=1;
  859. typ:=s8bit;
  860. end
  861. else if (low>=0) and (high<=65536) then
  862. begin
  863. savesize:=2;
  864. typ:=u16bit;
  865. end
  866. else if (low>=-32768) and (high<=32767) then
  867. begin
  868. savesize:=2;
  869. typ:=s16bit;
  870. end
  871. else
  872. begin
  873. savesize:=4;
  874. typ:=s32bit;
  875. end;
  876. end
  877. else
  878. begin
  879. case typ of
  880. u8bit,s8bit,
  881. uchar,bool8bit:
  882. savesize:=1;
  883. u16bit,s16bit,
  884. bool16bit,uwidechar:
  885. savesize:=2;
  886. s32bit,u32bit,
  887. bool32bit:
  888. savesize:=4;
  889. u64bit,s64bit:
  890. savesize:=8;
  891. else
  892. savesize:=0;
  893. end;
  894. end;
  895. { there are no entrys for range checking }
  896. rangenr:=0;
  897. end;
  898. function torddef.getrangecheckstring : string;
  899. begin
  900. if (cs_create_smart in aktmoduleswitches) then
  901. getrangecheckstring:='R_'+current_module^.modulename^+tostr(rangenr)
  902. else
  903. getrangecheckstring:='R_'+tostr(rangenr);
  904. end;
  905. procedure torddef.genrangecheck;
  906. var
  907. rangechecksize : longint;
  908. begin
  909. if rangenr=0 then
  910. begin
  911. if low<=high then
  912. rangechecksize:=8
  913. else
  914. rangechecksize:=16;
  915. { generate two constant for bounds }
  916. getlabelnr(rangenr);
  917. if (cs_create_smart in aktmoduleswitches) then
  918. datasegment^.concat(new(pai_symbol,initname_global(getrangecheckstring,rangechecksize)))
  919. else
  920. datasegment^.concat(new(pai_symbol,initname(getrangecheckstring,rangechecksize)));
  921. if low<=high then
  922. begin
  923. datasegment^.concat(new(pai_const,init_32bit(low)));
  924. datasegment^.concat(new(pai_const,init_32bit(high)));
  925. end
  926. { for u32bit we need two bounds }
  927. else
  928. begin
  929. datasegment^.concat(new(pai_const,init_32bit(low)));
  930. datasegment^.concat(new(pai_const,init_32bit($7fffffff)));
  931. datasegment^.concat(new(pai_const,init_32bit($80000000)));
  932. datasegment^.concat(new(pai_const,init_32bit(high)));
  933. end;
  934. end;
  935. end;
  936. procedure torddef.write;
  937. begin
  938. tdef.write;
  939. writebyte(byte(typ));
  940. writelong(low);
  941. writelong(high);
  942. current_ppu^.writeentry(iborddef);
  943. end;
  944. {$ifdef GDB}
  945. function torddef.stabstring : pchar;
  946. begin
  947. case typ of
  948. uvoid : stabstring := strpnew(numberstring+';');
  949. {GDB 4.12 for go32 doesn't like boolean as range for 0 to 1 !!!}
  950. {$ifdef Use_integer_types_for_boolean}
  951. bool8bit,
  952. bool16bit,
  953. bool32bit : stabstring := strpnew('r'+numberstring+';0;255;');
  954. {$else : not Use_integer_types_for_boolean}
  955. bool8bit : stabstring := strpnew('-21;');
  956. bool16bit : stabstring := strpnew('-22;');
  957. bool32bit : stabstring := strpnew('-23;');
  958. u64bit : stabstring := strpnew('-32;');
  959. s64bit : stabstring := strpnew('-31;');
  960. {$endif not Use_integer_types_for_boolean}
  961. { u32bit : stabstring := strpnew('r'+
  962. s32bitdef^.numberstring+';0;-1;'); }
  963. else
  964. stabstring := strpnew('r'+s32bitdef^.numberstring+';'+tostr(low)+';'+tostr(high)+';');
  965. end;
  966. end;
  967. {$endif GDB}
  968. procedure torddef.write_rtti_data;
  969. procedure dointeger;
  970. const
  971. trans : array[uchar..bool8bit] of byte =
  972. (otUByte,otUByte,otUWord,otULong,otSByte,otSWord,otSLong,otUByte);
  973. begin
  974. write_rtti_name;
  975. rttilist^.concat(new(pai_const,init_8bit(byte(trans[typ]))));
  976. rttilist^.concat(new(pai_const,init_32bit(low)));
  977. rttilist^.concat(new(pai_const,init_32bit(high)));
  978. end;
  979. begin
  980. case typ of
  981. s64bit :
  982. begin
  983. rttilist^.concat(new(pai_const,init_8bit(tkInt64)));
  984. write_rtti_name;
  985. { low }
  986. rttilist^.concat(new(pai_const,init_32bit($0)));
  987. rttilist^.concat(new(pai_const,init_32bit($8000)));
  988. { high }
  989. rttilist^.concat(new(pai_const,init_32bit($ffff)));
  990. rttilist^.concat(new(pai_const,init_32bit($7fff)));
  991. end;
  992. u64bit :
  993. begin
  994. rttilist^.concat(new(pai_const,init_8bit(tkQWord)));
  995. write_rtti_name;
  996. { low }
  997. rttilist^.concat(new(pai_const,init_32bit($0)));
  998. rttilist^.concat(new(pai_const,init_32bit($0)));
  999. { high }
  1000. rttilist^.concat(new(pai_const,init_32bit($0)));
  1001. rttilist^.concat(new(pai_const,init_32bit($8000)));
  1002. end;
  1003. bool8bit:
  1004. begin
  1005. rttilist^.concat(new(pai_const,init_8bit(tkBool)));
  1006. dointeger;
  1007. end;
  1008. uchar:
  1009. begin
  1010. rttilist^.concat(new(pai_const,init_8bit(tkWChar)));
  1011. dointeger;
  1012. end;
  1013. uwidechar:
  1014. begin
  1015. rttilist^.concat(new(pai_const,init_8bit(tkChar)));
  1016. dointeger;
  1017. end;
  1018. else
  1019. begin
  1020. rttilist^.concat(new(pai_const,init_8bit(tkInteger)));
  1021. dointeger;
  1022. end;
  1023. end;
  1024. end;
  1025. function torddef.is_publishable : boolean;
  1026. begin
  1027. is_publishable:=typ in [uchar..bool8bit];
  1028. end;
  1029. function torddef.gettypename : string;
  1030. const
  1031. names : array[tbasetype] of string[20] = ('<unknown type>',
  1032. 'untyped','Char','Byte','Word','DWord','ShortInt',
  1033. 'SmallInt','LongInt','Boolean','WordBool',
  1034. 'LongBool','QWord','Int64','WideChar');
  1035. begin
  1036. gettypename:=names[typ];
  1037. end;
  1038. {****************************************************************************
  1039. TFLOATDEF
  1040. ****************************************************************************}
  1041. constructor tfloatdef.init(t : tfloattype);
  1042. begin
  1043. inherited init;
  1044. deftype:=floatdef;
  1045. typ:=t;
  1046. setsize;
  1047. end;
  1048. constructor tfloatdef.load;
  1049. begin
  1050. inherited load;
  1051. deftype:=floatdef;
  1052. typ:=tfloattype(readbyte);
  1053. setsize;
  1054. end;
  1055. procedure tfloatdef.setsize;
  1056. begin
  1057. case typ of
  1058. f16bit : savesize:=2;
  1059. f32bit,
  1060. s32real : savesize:=4;
  1061. s64real : savesize:=8;
  1062. s80real : savesize:=extended_size;
  1063. s64comp : savesize:=8;
  1064. else
  1065. savesize:=0;
  1066. end;
  1067. end;
  1068. procedure tfloatdef.write;
  1069. begin
  1070. inherited write;
  1071. writebyte(byte(typ));
  1072. current_ppu^.writeentry(ibfloatdef);
  1073. end;
  1074. {$ifdef GDB}
  1075. function tfloatdef.stabstring : pchar;
  1076. begin
  1077. case typ of
  1078. s32real,
  1079. s64real : stabstring := strpnew('r'+
  1080. s32bitdef^.numberstring+';'+tostr(savesize)+';0;');
  1081. { for fixed real use longint instead to be able to }
  1082. { debug something at least }
  1083. f32bit:
  1084. stabstring := s32bitdef^.stabstring;
  1085. f16bit:
  1086. stabstring := strpnew('r'+s32bitdef^.numberstring+';0;'+
  1087. tostr($ffff)+';');
  1088. { found this solution in stabsread.c from GDB v4.16 }
  1089. s64comp : stabstring := strpnew('r'+
  1090. s32bitdef^.numberstring+';-'+tostr(savesize)+';0;');
  1091. {$ifdef i386}
  1092. { under dos at least you must give a size of twelve instead of 10 !! }
  1093. { this is probably do to the fact that in gcc all is pushed in 4 bytes size }
  1094. s80real : stabstring := strpnew('r'+s32bitdef^.numberstring+';12;0;');
  1095. {$endif i386}
  1096. else
  1097. internalerror(10005);
  1098. end;
  1099. end;
  1100. {$endif GDB}
  1101. procedure tfloatdef.write_rtti_data;
  1102. const
  1103. {tfloattype = (s32real,s64real,s80real,s64bit,f16bit,f32bit);}
  1104. translate : array[tfloattype] of byte =
  1105. (ftSingle,ftDouble,ftExtended,ftComp,ftFixed16,ftFixed32);
  1106. begin
  1107. rttilist^.concat(new(pai_const,init_8bit(tkFloat)));
  1108. write_rtti_name;
  1109. rttilist^.concat(new(pai_const,init_8bit(translate[typ])));
  1110. end;
  1111. function tfloatdef.is_publishable : boolean;
  1112. begin
  1113. is_publishable:=true;
  1114. end;
  1115. function tfloatdef.gettypename : string;
  1116. const
  1117. names : array[tfloattype] of string[20] = (
  1118. 'Single','Double','Extended','Comp','Fixed','Fixed16');
  1119. begin
  1120. gettypename:=names[typ];
  1121. end;
  1122. {****************************************************************************
  1123. TFILEDEF
  1124. ****************************************************************************}
  1125. constructor tfiledef.inittext;
  1126. begin
  1127. inherited init;
  1128. deftype:=filedef;
  1129. filetyp:=ft_text;
  1130. typedfiletype.reset;
  1131. setsize;
  1132. end;
  1133. constructor tfiledef.inituntyped;
  1134. begin
  1135. inherited init;
  1136. deftype:=filedef;
  1137. filetyp:=ft_untyped;
  1138. typedfiletype.reset;
  1139. setsize;
  1140. end;
  1141. constructor tfiledef.inittyped(const tt : ttype);
  1142. begin
  1143. inherited init;
  1144. deftype:=filedef;
  1145. filetyp:=ft_typed;
  1146. typedfiletype:=tt;
  1147. setsize;
  1148. end;
  1149. constructor tfiledef.inittypeddef(p : pdef);
  1150. begin
  1151. inherited init;
  1152. deftype:=filedef;
  1153. filetyp:=ft_typed;
  1154. typedfiletype.setdef(p);
  1155. setsize;
  1156. end;
  1157. constructor tfiledef.load;
  1158. begin
  1159. inherited load;
  1160. deftype:=filedef;
  1161. filetyp:=tfiletyp(readbyte);
  1162. if filetyp=ft_typed then
  1163. typedfiletype.load
  1164. else
  1165. typedfiletype.reset;
  1166. setsize;
  1167. end;
  1168. procedure tfiledef.deref;
  1169. begin
  1170. inherited deref;
  1171. if filetyp=ft_typed then
  1172. typedfiletype.resolve;
  1173. end;
  1174. procedure tfiledef.setsize;
  1175. begin
  1176. case filetyp of
  1177. ft_text :
  1178. savesize:=572;
  1179. ft_typed,
  1180. ft_untyped :
  1181. savesize:=316;
  1182. end;
  1183. end;
  1184. procedure tfiledef.write;
  1185. begin
  1186. inherited write;
  1187. writebyte(byte(filetyp));
  1188. if filetyp=ft_typed then
  1189. typedfiletype.write;
  1190. current_ppu^.writeentry(ibfiledef);
  1191. end;
  1192. {$ifdef GDB}
  1193. function tfiledef.stabstring : pchar;
  1194. begin
  1195. {$IfDef GDBknowsfiles}
  1196. case filetyp of
  1197. ft_typed :
  1198. stabstring := strpnew('d'+typedfiletype.def^.numberstring{+';'});
  1199. ft_untyped :
  1200. stabstring := strpnew('d'+voiddef^.numberstring{+';'});
  1201. ft_text :
  1202. stabstring := strpnew('d'+cchardef^.numberstring{+';'});
  1203. end;
  1204. {$Else}
  1205. {based on
  1206. FileRec = Packed Record
  1207. Handle,
  1208. Mode,
  1209. RecSize : longint;
  1210. _private : array[1..32] of byte;
  1211. UserData : array[1..16] of byte;
  1212. name : array[0..255] of char;
  1213. End; }
  1214. { the buffer part is still missing !! (PM) }
  1215. { but the string could become too long !! }
  1216. stabstring := strpnew('s'+tostr(savesize)+
  1217. 'HANDLE:'+typeglobalnumber('longint')+',0,32;'+
  1218. 'MODE:'+typeglobalnumber('longint')+',32,32;'+
  1219. 'RECSIZE:'+typeglobalnumber('longint')+',64,32;'+
  1220. '_PRIVATE:ar'+typeglobalnumber('word')+';1;32;'+typeglobalnumber('byte')
  1221. +',96,256;'+
  1222. 'USERDATA:ar'+typeglobalnumber('word')+';1;16;'+typeglobalnumber('byte')
  1223. +',352,128;'+
  1224. 'NAME:ar'+typeglobalnumber('word')+';0;255;'+typeglobalnumber('char')
  1225. +',480,2048;;');
  1226. {$EndIf}
  1227. end;
  1228. procedure tfiledef.concatstabto(asmlist : paasmoutput);
  1229. begin
  1230. { most file defs are unnamed !!! }
  1231. if ((typesym = nil) or typesym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1232. not is_def_stab_written then
  1233. begin
  1234. if assigned(typedfiletype.def) then forcestabto(asmlist,typedfiletype.def);
  1235. inherited concatstabto(asmlist);
  1236. end;
  1237. end;
  1238. {$endif GDB}
  1239. function tfiledef.gettypename : string;
  1240. begin
  1241. case filetyp of
  1242. ft_untyped:
  1243. gettypename:='File';
  1244. ft_typed:
  1245. gettypename:='File Of '+typedfiletype.def^.typename;
  1246. ft_text:
  1247. gettypename:='Text'
  1248. end;
  1249. end;
  1250. {****************************************************************************
  1251. TPOINTERDEF
  1252. ****************************************************************************}
  1253. constructor tpointerdef.init(const tt : ttype);
  1254. begin
  1255. tdef.init;
  1256. deftype:=pointerdef;
  1257. pointertype:=tt;
  1258. is_far:=false;
  1259. savesize:=target_os.size_of_pointer;
  1260. end;
  1261. constructor tpointerdef.initfar(const tt : ttype);
  1262. begin
  1263. tdef.init;
  1264. deftype:=pointerdef;
  1265. pointertype:=tt;
  1266. is_far:=true;
  1267. savesize:=target_os.size_of_pointer;
  1268. end;
  1269. constructor tpointerdef.initdef(p : pdef);
  1270. var
  1271. t : ttype;
  1272. begin
  1273. t.setdef(p);
  1274. tpointerdef.init(t);
  1275. end;
  1276. constructor tpointerdef.initfardef(p : pdef);
  1277. var
  1278. t : ttype;
  1279. begin
  1280. t.setdef(p);
  1281. tpointerdef.initfar(t);
  1282. end;
  1283. constructor tpointerdef.load;
  1284. begin
  1285. tdef.load;
  1286. deftype:=pointerdef;
  1287. pointertype.load;
  1288. is_far:=(readbyte<>0);
  1289. savesize:=target_os.size_of_pointer;
  1290. end;
  1291. destructor tpointerdef.done;
  1292. begin
  1293. if assigned(pointertype.def) and
  1294. (pointertype.def^.deftype=forwarddef) then
  1295. begin
  1296. dispose(pointertype.def,done);
  1297. pointertype.reset;
  1298. end;
  1299. inherited done;
  1300. end;
  1301. procedure tpointerdef.deref;
  1302. begin
  1303. inherited deref;
  1304. pointertype.resolve;
  1305. end;
  1306. procedure tpointerdef.write;
  1307. begin
  1308. inherited write;
  1309. pointertype.write;
  1310. writebyte(byte(is_far));
  1311. current_ppu^.writeentry(ibpointerdef);
  1312. end;
  1313. {$ifdef GDB}
  1314. function tpointerdef.stabstring : pchar;
  1315. begin
  1316. stabstring := strpnew('*'+pointertype.def^.numberstring);
  1317. end;
  1318. procedure tpointerdef.concatstabto(asmlist : paasmoutput);
  1319. var st,nb : string;
  1320. sym_line_no : longint;
  1321. begin
  1322. if assigned(pointertype.def) and
  1323. (pointertype.def^.deftype=forwarddef) then
  1324. exit;
  1325. if ( (typesym=nil) or typesym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1326. not is_def_stab_written then
  1327. begin
  1328. if assigned(pointertype.def) then
  1329. if pointertype.def^.deftype in [recorddef,objectdef] then
  1330. begin
  1331. is_def_stab_written := true;
  1332. nb:=pointertype.def^.numberstring;
  1333. {to avoid infinite recursion in record with next-like fields }
  1334. is_def_stab_written := false;
  1335. if not pointertype.def^.is_def_stab_written then
  1336. begin
  1337. if assigned(pointertype.def^.typesym) then
  1338. begin
  1339. if assigned(typesym) then
  1340. begin
  1341. st := typesym^.name;
  1342. sym_line_no:=typesym^.fileinfo.line;
  1343. end
  1344. else
  1345. begin
  1346. st := ' ';
  1347. sym_line_no:=0;
  1348. end;
  1349. st := '"'+st+':t'+numberstring+'=*'+nb
  1350. +'=xs'+pointertype.def^.typesym^.name+':",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0';
  1351. asmlist^.concat(new(pai_stabs,init(strpnew(st))));
  1352. end;
  1353. end else inherited concatstabto(asmlist);
  1354. is_def_stab_written := true;
  1355. end else
  1356. begin
  1357. { p =^p1; p1=^p problem }
  1358. is_def_stab_written := true;
  1359. forcestabto(asmlist,pointertype.def);
  1360. is_def_stab_written := false;
  1361. inherited concatstabto(asmlist);
  1362. end;
  1363. end;
  1364. end;
  1365. {$endif GDB}
  1366. function tpointerdef.gettypename : string;
  1367. begin
  1368. gettypename:='^'+pointertype.def^.typename;
  1369. end;
  1370. {****************************************************************************
  1371. TCLASSREFDEF
  1372. ****************************************************************************}
  1373. constructor tclassrefdef.init(def : pdef);
  1374. begin
  1375. inherited initdef(def);
  1376. deftype:=classrefdef;
  1377. end;
  1378. constructor tclassrefdef.load;
  1379. begin
  1380. { be careful, tclassdefref inherits from tpointerdef }
  1381. tdef.load;
  1382. deftype:=classrefdef;
  1383. pointertype.load;
  1384. is_far:=false;
  1385. savesize:=target_os.size_of_pointer;
  1386. end;
  1387. procedure tclassrefdef.write;
  1388. begin
  1389. { be careful, tclassdefref inherits from tpointerdef }
  1390. tdef.write;
  1391. pointertype.write;
  1392. current_ppu^.writeentry(ibclassrefdef);
  1393. end;
  1394. {$ifdef GDB}
  1395. function tclassrefdef.stabstring : pchar;
  1396. begin
  1397. stabstring:=strpnew(pvmtdef^.numberstring+';');
  1398. end;
  1399. procedure tclassrefdef.concatstabto(asmlist : paasmoutput);
  1400. begin
  1401. inherited concatstabto(asmlist);
  1402. end;
  1403. {$endif GDB}
  1404. function tclassrefdef.gettypename : string;
  1405. begin
  1406. gettypename:='Class Of '+pointertype.def^.typename;
  1407. end;
  1408. {***************************************************************************
  1409. TSETDEF
  1410. ***************************************************************************}
  1411. { For i386 smallsets work,
  1412. for m68k there are problems
  1413. can be test by compiling with -dusesmallset PM }
  1414. {$ifdef i386}
  1415. {$define usesmallset}
  1416. {$endif i386}
  1417. constructor tsetdef.init(s : pdef;high : longint);
  1418. begin
  1419. inherited init;
  1420. deftype:=setdef;
  1421. elementtype.setdef(s);
  1422. {$ifdef usesmallset}
  1423. { small sets only working for i386 PM }
  1424. if high<32 then
  1425. begin
  1426. settype:=smallset;
  1427. {$ifdef testvarsets}
  1428. if aktsetalloc=0 THEN { $PACKSET Fixed?}
  1429. {$endif}
  1430. savesize:=Sizeof(longint)
  1431. {$ifdef testvarsets}
  1432. else {No, use $PACKSET VALUE for rounding}
  1433. savesize:=aktsetalloc*((high+aktsetalloc*8-1) DIV (aktsetalloc*8))
  1434. {$endif}
  1435. ;
  1436. end
  1437. else
  1438. {$endif usesmallset}
  1439. if high<256 then
  1440. begin
  1441. settype:=normset;
  1442. savesize:=32;
  1443. end
  1444. else
  1445. {$ifdef testvarsets}
  1446. if high<$10000 then
  1447. begin
  1448. settype:=varset;
  1449. savesize:=4*((high+31) div 32);
  1450. end
  1451. else
  1452. {$endif testvarsets}
  1453. Message(sym_e_ill_type_decl_set);
  1454. end;
  1455. constructor tsetdef.load;
  1456. begin
  1457. inherited load;
  1458. deftype:=setdef;
  1459. elementtype.load;
  1460. settype:=tsettype(readbyte);
  1461. case settype of
  1462. normset : savesize:=32;
  1463. varset : savesize:=readlong;
  1464. smallset : savesize:=Sizeof(longint);
  1465. end;
  1466. end;
  1467. destructor tsetdef.done;
  1468. begin
  1469. inherited done;
  1470. end;
  1471. procedure tsetdef.write;
  1472. begin
  1473. inherited write;
  1474. elementtype.write;
  1475. writebyte(byte(settype));
  1476. if settype=varset then
  1477. writelong(savesize);
  1478. current_ppu^.writeentry(ibsetdef);
  1479. end;
  1480. {$ifdef GDB}
  1481. function tsetdef.stabstring : pchar;
  1482. begin
  1483. { For small sets write a longint, which can at least be seen
  1484. in the current GDB's (PFV)
  1485. this is obsolete with GDBPAS !!
  1486. and anyhow creates problems with version 4.18!! PM
  1487. if settype=smallset then
  1488. stabstring := strpnew('r'+s32bitdef^.numberstring+';0;0xffffffff;')
  1489. else }
  1490. stabstring := strpnew('S'+elementtype.def^.numberstring);
  1491. end;
  1492. procedure tsetdef.concatstabto(asmlist : paasmoutput);
  1493. begin
  1494. if ( not assigned(typesym) or typesym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1495. not is_def_stab_written then
  1496. begin
  1497. if assigned(elementtype.def) then
  1498. forcestabto(asmlist,elementtype.def);
  1499. inherited concatstabto(asmlist);
  1500. end;
  1501. end;
  1502. {$endif GDB}
  1503. procedure tsetdef.deref;
  1504. begin
  1505. inherited deref;
  1506. elementtype.resolve;
  1507. end;
  1508. procedure tsetdef.write_rtti_data;
  1509. begin
  1510. rttilist^.concat(new(pai_const,init_8bit(tkSet)));
  1511. write_rtti_name;
  1512. rttilist^.concat(new(pai_const,init_8bit(otULong)));
  1513. rttilist^.concat(new(pai_const_symbol,initname(elementtype.def^.get_rtti_label)));
  1514. end;
  1515. procedure tsetdef.write_child_rtti_data;
  1516. begin
  1517. elementtype.def^.get_rtti_label;
  1518. end;
  1519. function tsetdef.is_publishable : boolean;
  1520. begin
  1521. is_publishable:=settype=smallset;
  1522. end;
  1523. function tsetdef.gettypename : string;
  1524. begin
  1525. gettypename:='Set Of '+elementtype.def^.typename;
  1526. end;
  1527. {***************************************************************************
  1528. TFORMALDEF
  1529. ***************************************************************************}
  1530. constructor tformaldef.init;
  1531. var
  1532. stregdef : boolean;
  1533. begin
  1534. stregdef:=registerdef;
  1535. registerdef:=false;
  1536. inherited init;
  1537. deftype:=formaldef;
  1538. registerdef:=stregdef;
  1539. { formaldef must be registered at unit level !! }
  1540. if registerdef and assigned(current_module) then
  1541. if assigned(current_module^.localsymtable) then
  1542. psymtable(current_module^.localsymtable)^.registerdef(@self)
  1543. else if assigned(current_module^.globalsymtable) then
  1544. psymtable(current_module^.globalsymtable)^.registerdef(@self);
  1545. savesize:=target_os.size_of_pointer;
  1546. end;
  1547. constructor tformaldef.load;
  1548. begin
  1549. inherited load;
  1550. deftype:=formaldef;
  1551. savesize:=target_os.size_of_pointer;
  1552. end;
  1553. procedure tformaldef.write;
  1554. begin
  1555. inherited write;
  1556. current_ppu^.writeentry(ibformaldef);
  1557. end;
  1558. {$ifdef GDB}
  1559. function tformaldef.stabstring : pchar;
  1560. begin
  1561. stabstring := strpnew('formal'+numberstring+';');
  1562. end;
  1563. procedure tformaldef.concatstabto(asmlist : paasmoutput);
  1564. begin
  1565. { formaldef can't be stab'ed !}
  1566. end;
  1567. {$endif GDB}
  1568. function tformaldef.gettypename : string;
  1569. begin
  1570. gettypename:='Var';
  1571. end;
  1572. {***************************************************************************
  1573. TARRAYDEF
  1574. ***************************************************************************}
  1575. constructor tarraydef.init(l,h : longint;rd : pdef);
  1576. begin
  1577. inherited init;
  1578. deftype:=arraydef;
  1579. lowrange:=l;
  1580. highrange:=h;
  1581. rangetype.setdef(rd);
  1582. elementtype.reset;
  1583. IsVariant:=false;
  1584. IsConstructor:=false;
  1585. IsArrayOfConst:=false;
  1586. rangenr:=0;
  1587. end;
  1588. constructor tarraydef.load;
  1589. begin
  1590. inherited load;
  1591. deftype:=arraydef;
  1592. { the addresses are calculated later }
  1593. elementtype.load;
  1594. rangetype.load;
  1595. lowrange:=readlong;
  1596. highrange:=readlong;
  1597. IsArrayOfConst:=boolean(readbyte);
  1598. IsVariant:=false;
  1599. IsConstructor:=false;
  1600. rangenr:=0;
  1601. end;
  1602. function tarraydef.getrangecheckstring : string;
  1603. begin
  1604. if (cs_create_smart in aktmoduleswitches) then
  1605. getrangecheckstring:='R_'+current_module^.modulename^+tostr(rangenr)
  1606. else
  1607. getrangecheckstring:='R_'+tostr(rangenr);
  1608. end;
  1609. procedure tarraydef.genrangecheck;
  1610. begin
  1611. if rangenr=0 then
  1612. begin
  1613. { generates the data for range checking }
  1614. getlabelnr(rangenr);
  1615. if (cs_create_smart in aktmoduleswitches) then
  1616. datasegment^.concat(new(pai_symbol,initname_global(getrangecheckstring,8)))
  1617. else
  1618. datasegment^.concat(new(pai_symbol,initname(getrangecheckstring,8)));
  1619. if lowrange<=highrange then
  1620. begin
  1621. datasegment^.concat(new(pai_const,init_32bit(lowrange)));
  1622. datasegment^.concat(new(pai_const,init_32bit(highrange)));
  1623. end
  1624. { for big arrays we need two bounds }
  1625. else
  1626. begin
  1627. datasegment^.concat(new(pai_const,init_32bit(lowrange)));
  1628. datasegment^.concat(new(pai_const,init_32bit($7fffffff)));
  1629. datasegment^.concat(new(pai_const,init_32bit($80000000)));
  1630. datasegment^.concat(new(pai_const,init_32bit(highrange)));
  1631. end;
  1632. end;
  1633. end;
  1634. procedure tarraydef.deref;
  1635. begin
  1636. inherited deref;
  1637. elementtype.resolve;
  1638. rangetype.resolve;
  1639. end;
  1640. procedure tarraydef.write;
  1641. begin
  1642. inherited write;
  1643. elementtype.write;
  1644. rangetype.write;
  1645. writelong(lowrange);
  1646. writelong(highrange);
  1647. writebyte(byte(IsArrayOfConst));
  1648. current_ppu^.writeentry(ibarraydef);
  1649. end;
  1650. {$ifdef GDB}
  1651. function tarraydef.stabstring : pchar;
  1652. begin
  1653. stabstring := strpnew('ar'+rangetype.def^.numberstring+';'
  1654. +tostr(lowrange)+';'+tostr(highrange)+';'+elementtype.def^.numberstring);
  1655. end;
  1656. procedure tarraydef.concatstabto(asmlist : paasmoutput);
  1657. begin
  1658. if (not assigned(typesym) or typesym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  1659. and not is_def_stab_written then
  1660. begin
  1661. {when array are inserted they have no definition yet !!}
  1662. if assigned(elementtype.def) then
  1663. inherited concatstabto(asmlist);
  1664. end;
  1665. end;
  1666. {$endif GDB}
  1667. function tarraydef.elesize : longint;
  1668. begin
  1669. if isconstructor or is_open_array(@self) then
  1670. begin
  1671. { strings are stored by address only }
  1672. case elementtype.def^.deftype of
  1673. stringdef :
  1674. elesize:=4;
  1675. else
  1676. elesize:=elementtype.def^.size;
  1677. end;
  1678. end
  1679. else
  1680. elesize:=elementtype.def^.size;
  1681. end;
  1682. function tarraydef.size : longint;
  1683. begin
  1684. {Tarraydef.size may never be called for an open array!}
  1685. if highrange<lowrange then
  1686. internalerror(99080501);
  1687. If (elesize>0) and
  1688. (
  1689. (highrange-lowrange = $7fffffff) or
  1690. { () are needed around elesize-1 to avoid a possible
  1691. integer overflow for elesize=1 !! PM }
  1692. (($7fffffff div elesize + (elesize -1)) < (highrange - lowrange))
  1693. ) Then
  1694. Begin
  1695. Message(sym_e_segment_too_large);
  1696. size := 4
  1697. End
  1698. Else size:=(highrange-lowrange+1)*elesize;
  1699. end;
  1700. function tarraydef.alignment : longint;
  1701. begin
  1702. { alignment is the size of the elements }
  1703. alignment:=elesize;
  1704. end;
  1705. function tarraydef.needs_inittable : boolean;
  1706. begin
  1707. needs_inittable:=elementtype.def^.needs_inittable;
  1708. end;
  1709. procedure tarraydef.write_child_rtti_data;
  1710. begin
  1711. elementtype.def^.get_rtti_label;
  1712. end;
  1713. procedure tarraydef.write_rtti_data;
  1714. begin
  1715. rttilist^.concat(new(pai_const,init_8bit(tkarray)));
  1716. write_rtti_name;
  1717. { size of elements }
  1718. rttilist^.concat(new(pai_const,init_32bit(elesize)));
  1719. { count of elements }
  1720. rttilist^.concat(new(pai_const,init_32bit(highrange-lowrange+1)));
  1721. { element type }
  1722. rttilist^.concat(new(pai_const_symbol,initname(elementtype.def^.get_rtti_label)));
  1723. end;
  1724. function tarraydef.gettypename : string;
  1725. begin
  1726. if isarrayofconst or isConstructor then
  1727. begin
  1728. if isvariant then
  1729. gettypename:='Array Of Const'
  1730. else
  1731. gettypename:='Array Of '+elementtype.def^.typename;
  1732. end
  1733. else if is_open_array(@self) then
  1734. gettypename:='Array Of '+elementtype.def^.typename
  1735. else
  1736. begin
  1737. if rangetype.def^.deftype=enumdef then
  1738. gettypename:='Array['+rangetype.def^.typename+'] Of '+elementtype.def^.typename
  1739. else
  1740. gettypename:='Array['+tostr(lowrange)+'..'+
  1741. tostr(highrange)+'] Of '+elementtype.def^.typename
  1742. end;
  1743. end;
  1744. {***************************************************************************
  1745. trecorddef
  1746. ***************************************************************************}
  1747. constructor trecorddef.init(p : psymtable);
  1748. begin
  1749. inherited init;
  1750. deftype:=recorddef;
  1751. symtable:=p;
  1752. symtable^.defowner := @self;
  1753. symtable^.dataalignment:=packrecordalignment[aktpackrecords];
  1754. end;
  1755. constructor trecorddef.load;
  1756. var
  1757. oldread_member : boolean;
  1758. begin
  1759. inherited load;
  1760. deftype:=recorddef;
  1761. savesize:=readlong;
  1762. oldread_member:=read_member;
  1763. read_member:=true;
  1764. symtable:=new(psymtable,loadas(recordsymtable));
  1765. read_member:=oldread_member;
  1766. symtable^.defowner := @self;
  1767. end;
  1768. destructor trecorddef.done;
  1769. begin
  1770. if assigned(symtable) then
  1771. dispose(symtable,done);
  1772. inherited done;
  1773. end;
  1774. var
  1775. binittable : boolean;
  1776. procedure check_rec_inittable(s : pnamedindexobject);
  1777. begin
  1778. if (not binittable) and
  1779. (psym(s)^.typ=varsym) and
  1780. assigned(pvarsym(s)^.vartype.def) then
  1781. begin
  1782. if ((pvarsym(s)^.vartype.def^.deftype<>objectdef) or
  1783. not(pobjectdef(pvarsym(s)^.vartype.def)^.is_class)) then
  1784. binittable:=pvarsym(s)^.vartype.def^.needs_inittable;
  1785. end;
  1786. end;
  1787. function trecorddef.needs_inittable : boolean;
  1788. var
  1789. oldb : boolean;
  1790. begin
  1791. { there are recursive calls to needs_rtti possible, }
  1792. { so we have to change to old value how else should }
  1793. { we do that ? check_rec_rtti can't be a nested }
  1794. { procedure of needs_rtti ! }
  1795. oldb:=binittable;
  1796. binittable:=false;
  1797. symtable^.foreach({$ifndef TP}@{$endif}check_rec_inittable);
  1798. needs_inittable:=binittable;
  1799. binittable:=oldb;
  1800. end;
  1801. procedure trecorddef.deref;
  1802. var
  1803. oldrecsyms : psymtable;
  1804. begin
  1805. inherited deref;
  1806. oldrecsyms:=aktrecordsymtable;
  1807. aktrecordsymtable:=symtable;
  1808. { now dereference the definitions }
  1809. symtable^.deref;
  1810. aktrecordsymtable:=oldrecsyms;
  1811. end;
  1812. procedure trecorddef.write;
  1813. var
  1814. oldread_member : boolean;
  1815. begin
  1816. oldread_member:=read_member;
  1817. read_member:=true;
  1818. inherited write;
  1819. writelong(savesize);
  1820. current_ppu^.writeentry(ibrecorddef);
  1821. self.symtable^.writeas;
  1822. read_member:=oldread_member;
  1823. end;
  1824. function trecorddef.size:longint;
  1825. begin
  1826. size:=symtable^.datasize;
  1827. end;
  1828. function trecorddef.alignment:longint;
  1829. var
  1830. l : longint;
  1831. hp : pvarsym;
  1832. begin
  1833. { also check the first symbol for it's size, because a
  1834. packed record has dataalignment of 1, but the first
  1835. sym could be a longint which should be aligned on 4 bytes,
  1836. this is compatible with C record packing (PFV) }
  1837. hp:=pvarsym(symtable^.symindex^.first);
  1838. if assigned(hp) then
  1839. begin
  1840. l:=hp^.vartype.def^.size;
  1841. if l>symtable^.dataalignment then
  1842. begin
  1843. if l>=4 then
  1844. alignment:=4
  1845. else
  1846. if l>=2 then
  1847. alignment:=2
  1848. else
  1849. alignment:=1;
  1850. end
  1851. else
  1852. alignment:=symtable^.dataalignment;
  1853. end
  1854. else
  1855. alignment:=symtable^.dataalignment;
  1856. end;
  1857. {$ifdef GDB}
  1858. Const StabRecString : pchar = Nil;
  1859. StabRecSize : longint = 0;
  1860. RecOffset : Longint = 0;
  1861. procedure addname(p : pnamedindexobject);
  1862. var
  1863. news, newrec : pchar;
  1864. spec : string[3];
  1865. size : longint;
  1866. begin
  1867. { static variables from objects are like global objects }
  1868. if (sp_static in psym(p)^.symoptions) then
  1869. exit;
  1870. If psym(p)^.typ = varsym then
  1871. begin
  1872. if (sp_protected in psym(p)^.symoptions) then
  1873. spec:='/1'
  1874. else if (sp_private in psym(p)^.symoptions) then
  1875. spec:='/0'
  1876. else
  1877. spec:='';
  1878. { class fields are pointers PM }
  1879. if not assigned(pvarsym(p)^.vartype.def) then
  1880. writeln(pvarsym(p)^.name);
  1881. if (pvarsym(p)^.vartype.def^.deftype=objectdef) and
  1882. pobjectdef(pvarsym(p)^.vartype.def)^.is_class then
  1883. spec:=spec+'*';
  1884. size:=pvarsym(p)^.vartype.def^.size;
  1885. { open arrays made overflows !! }
  1886. if size>$fffffff then
  1887. size:=$fffffff;
  1888. newrec := strpnew(p^.name+':'+spec+pvarsym(p)^.vartype.def^.numberstring
  1889. +','+tostr(pvarsym(p)^.address*8)+','
  1890. +tostr(size*8)+';');
  1891. if strlen(StabRecString) + strlen(newrec) >= StabRecSize-256 then
  1892. begin
  1893. getmem(news,stabrecsize+memsizeinc);
  1894. strcopy(news,stabrecstring);
  1895. freemem(stabrecstring,stabrecsize);
  1896. stabrecsize:=stabrecsize+memsizeinc;
  1897. stabrecstring:=news;
  1898. end;
  1899. strcat(StabRecstring,newrec);
  1900. strdispose(newrec);
  1901. {This should be used for case !!}
  1902. RecOffset := RecOffset + pvarsym(p)^.vartype.def^.size;
  1903. end;
  1904. end;
  1905. function trecorddef.stabstring : pchar;
  1906. Var oldrec : pchar;
  1907. oldsize : longint;
  1908. begin
  1909. oldrec := stabrecstring;
  1910. oldsize:=stabrecsize;
  1911. GetMem(stabrecstring,memsizeinc);
  1912. stabrecsize:=memsizeinc;
  1913. strpcopy(stabRecString,'s'+tostr(size));
  1914. RecOffset := 0;
  1915. symtable^.foreach({$ifndef TP}@{$endif}addname);
  1916. { FPC doesn't want to convert a char to a pchar}
  1917. { is this a bug ? }
  1918. strpcopy(strend(StabRecString),';');
  1919. stabstring := strnew(StabRecString);
  1920. Freemem(stabrecstring,stabrecsize);
  1921. stabrecstring := oldrec;
  1922. stabrecsize:=oldsize;
  1923. end;
  1924. procedure trecorddef.concatstabto(asmlist : paasmoutput);
  1925. begin
  1926. if (not assigned(typesym) or typesym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1927. (not is_def_stab_written) then
  1928. inherited concatstabto(asmlist);
  1929. end;
  1930. {$endif GDB}
  1931. var
  1932. count : longint;
  1933. procedure count_inittable_fields(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1934. begin
  1935. if ((psym(sym)^.typ=varsym) and
  1936. pvarsym(sym)^.vartype.def^.needs_inittable)
  1937. and ((pvarsym(sym)^.vartype.def^.deftype<>objectdef) or
  1938. (not pobjectdef(pvarsym(sym)^.vartype.def)^.is_class)) then
  1939. inc(count);
  1940. end;
  1941. procedure count_fields(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1942. begin
  1943. inc(count);
  1944. end;
  1945. procedure write_field_inittable(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1946. begin
  1947. if ((psym(sym)^.typ=varsym) and
  1948. pvarsym(sym)^.vartype.def^.needs_inittable) and
  1949. ((pvarsym(sym)^.vartype.def^.deftype<>objectdef) or
  1950. (not pobjectdef(pvarsym(sym)^.vartype.def)^.is_class)) then
  1951. begin
  1952. rttilist^.concat(new(pai_const_symbol,init(pvarsym(sym)^.vartype.def^.get_inittable_label)));
  1953. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  1954. end;
  1955. end;
  1956. procedure write_field_rtti(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1957. begin
  1958. rttilist^.concat(new(pai_const_symbol,initname(pvarsym(sym)^.vartype.def^.get_rtti_label)));
  1959. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  1960. end;
  1961. procedure generate_child_inittable(sym:pnamedindexobject);{$ifndef fpc}far;{$endif}
  1962. begin
  1963. if (psym(sym)^.typ=varsym) and
  1964. pvarsym(sym)^.vartype.def^.needs_inittable then
  1965. { force inittable generation }
  1966. pvarsym(sym)^.vartype.def^.get_inittable_label;
  1967. end;
  1968. procedure generate_child_rtti(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1969. begin
  1970. pvarsym(sym)^.vartype.def^.get_rtti_label;
  1971. end;
  1972. procedure trecorddef.write_child_rtti_data;
  1973. begin
  1974. symtable^.foreach({$ifndef TP}@{$endif}generate_child_rtti);
  1975. end;
  1976. procedure trecorddef.write_child_init_data;
  1977. begin
  1978. symtable^.foreach({$ifndef TP}@{$endif}generate_child_inittable);
  1979. end;
  1980. procedure trecorddef.write_rtti_data;
  1981. begin
  1982. rttilist^.concat(new(pai_const,init_8bit(tkrecord)));
  1983. write_rtti_name;
  1984. rttilist^.concat(new(pai_const,init_32bit(size)));
  1985. count:=0;
  1986. symtable^.foreach({$ifndef TP}@{$endif}count_fields);
  1987. rttilist^.concat(new(pai_const,init_32bit(count)));
  1988. symtable^.foreach({$ifndef TP}@{$endif}write_field_rtti);
  1989. end;
  1990. procedure trecorddef.write_init_data;
  1991. begin
  1992. rttilist^.concat(new(pai_const,init_8bit(tkrecord)));
  1993. write_rtti_name;
  1994. rttilist^.concat(new(pai_const,init_32bit(size)));
  1995. count:=0;
  1996. symtable^.foreach({$ifndef TP}@{$endif}count_inittable_fields);
  1997. rttilist^.concat(new(pai_const,init_32bit(count)));
  1998. symtable^.foreach({$ifndef TP}@{$endif}write_field_inittable);
  1999. end;
  2000. function trecorddef.gettypename : string;
  2001. begin
  2002. gettypename:='<record type>'
  2003. end;
  2004. {***************************************************************************
  2005. TABSTRACTPROCDEF
  2006. ***************************************************************************}
  2007. constructor tabstractprocdef.init;
  2008. begin
  2009. inherited init;
  2010. new(para,init);
  2011. fpu_used:=0;
  2012. proctypeoption:=potype_none;
  2013. proccalloptions:=[];
  2014. procoptions:=[];
  2015. rettype.setdef(voiddef);
  2016. symtablelevel:=0;
  2017. savesize:=target_os.size_of_pointer;
  2018. end;
  2019. destructor tabstractprocdef.done;
  2020. begin
  2021. dispose(para,done);
  2022. inherited done;
  2023. end;
  2024. procedure tabstractprocdef.concatpara(tt:ttype;vsp : tvarspez);
  2025. var
  2026. hp : pparaitem;
  2027. begin
  2028. new(hp,init);
  2029. hp^.paratyp:=vsp;
  2030. hp^.paratype:=tt;
  2031. hp^.register:=R_NO;
  2032. para^.insert(hp);
  2033. end;
  2034. { all functions returning in FPU are
  2035. assume to use 2 FPU registers
  2036. until the function implementation
  2037. is processed PM }
  2038. procedure tabstractprocdef.test_if_fpu_result;
  2039. begin
  2040. if assigned(rettype.def) and is_fpu(rettype.def) then
  2041. fpu_used:=2;
  2042. end;
  2043. procedure tabstractprocdef.deref;
  2044. var
  2045. hp : pparaitem;
  2046. begin
  2047. inherited deref;
  2048. rettype.resolve;
  2049. hp:=pparaitem(para^.first);
  2050. while assigned(hp) do
  2051. begin
  2052. hp^.paratype.resolve;
  2053. hp:=pparaitem(hp^.next);
  2054. end;
  2055. end;
  2056. constructor tabstractprocdef.load;
  2057. var
  2058. hp : pparaitem;
  2059. count,i : word;
  2060. begin
  2061. inherited load;
  2062. new(para,init);
  2063. rettype.load;
  2064. fpu_used:=readbyte;
  2065. proctypeoption:=tproctypeoption(readlong);
  2066. readsmallset(proccalloptions);
  2067. readsmallset(procoptions);
  2068. count:=readword;
  2069. savesize:=target_os.size_of_pointer;
  2070. for i:=1 to count do
  2071. begin
  2072. new(hp,init);
  2073. hp^.paratyp:=tvarspez(readbyte);
  2074. { hp^.register:=tregister(readbyte); }
  2075. hp^.register:=R_NO;
  2076. hp^.paratype.load;
  2077. para^.concat(hp);
  2078. end;
  2079. end;
  2080. procedure tabstractprocdef.write;
  2081. var
  2082. hp : pparaitem;
  2083. begin
  2084. inherited write;
  2085. rettype.write;
  2086. current_ppu^.do_interface_crc:=false;
  2087. writebyte(fpu_used);
  2088. writelong(ord(proctypeoption));
  2089. writesmallset(proccalloptions);
  2090. writesmallset(procoptions);
  2091. writeword(para^.count);
  2092. hp:=pparaitem(para^.first);
  2093. while assigned(hp) do
  2094. begin
  2095. writebyte(byte(hp^.paratyp));
  2096. { writebyte(byte(hp^.register)); }
  2097. hp^.paratype.write;
  2098. hp:=pparaitem(hp^.next);
  2099. end;
  2100. end;
  2101. function tabstractprocdef.para_size(alignsize:longint) : longint;
  2102. var
  2103. pdc : pparaitem;
  2104. l : longint;
  2105. begin
  2106. l:=0;
  2107. pdc:=pparaitem(para^.first);
  2108. while assigned(pdc) do
  2109. begin
  2110. case pdc^.paratyp of
  2111. vs_var : inc(l,target_os.size_of_pointer);
  2112. vs_value,
  2113. vs_const : if push_addr_param(pdc^.paratype.def) then
  2114. inc(l,target_os.size_of_pointer)
  2115. else
  2116. inc(l,pdc^.paratype.def^.size);
  2117. end;
  2118. l:=align(l,alignsize);
  2119. pdc:=pparaitem(pdc^.next);
  2120. end;
  2121. para_size:=l;
  2122. end;
  2123. function tabstractprocdef.demangled_paras : string;
  2124. var
  2125. s : string;
  2126. hp : pparaitem;
  2127. begin
  2128. s:='(';
  2129. hp:=pparaitem(para^.last);
  2130. while assigned(hp) do
  2131. begin
  2132. if assigned(hp^.paratype.def^.typesym) then
  2133. s:=s+hp^.paratype.def^.typesym^.name
  2134. else if hp^.paratyp=vs_var then
  2135. s:=s+'var'
  2136. else if hp^.paratyp=vs_const then
  2137. s:=s+'const';
  2138. hp:=pparaitem(hp^.previous);
  2139. if assigned(hp) then
  2140. s:=s+',';
  2141. end;
  2142. s:=s+')';
  2143. demangled_paras:=s;
  2144. end;
  2145. function tabstractprocdef.proccalloption2str : string;
  2146. type
  2147. tproccallopt=record
  2148. mask : tproccalloption;
  2149. str : string[30];
  2150. end;
  2151. const
  2152. proccallopts=12;
  2153. proccallopt : array[1..proccallopts] of tproccallopt=(
  2154. (mask:pocall_none; str:''),
  2155. (mask:pocall_clearstack; str:'ClearStack'),
  2156. (mask:pocall_leftright; str:'LeftRight'),
  2157. (mask:pocall_cdecl; str:'Cdecl'),
  2158. (mask:pocall_register; str:'Register'),
  2159. (mask:pocall_stdcall; str:'StdCall'),
  2160. (mask:pocall_safecall; str:'SafeCall'),
  2161. (mask:pocall_palmossyscall;str:'PalmOSSysCall'),
  2162. (mask:pocall_system; str:'System'),
  2163. (mask:pocall_inline; str:'Inline'),
  2164. (mask:pocall_internproc; str:'InternProc'),
  2165. (mask:pocall_internconst; str:'InternConst')
  2166. );
  2167. var
  2168. s : string;
  2169. i : longint;
  2170. first : boolean;
  2171. begin
  2172. s:='';
  2173. first:=true;
  2174. for i:=1to proccallopts do
  2175. if (proccallopt[i].mask in proccalloptions) then
  2176. begin
  2177. if first then
  2178. first:=false
  2179. else
  2180. s:=s+';';
  2181. s:=s+proccallopt[i].str;
  2182. end;
  2183. proccalloption2str:=s;
  2184. end;
  2185. {$ifdef GDB}
  2186. function tabstractprocdef.stabstring : pchar;
  2187. begin
  2188. stabstring := strpnew('abstractproc'+numberstring+';');
  2189. end;
  2190. procedure tabstractprocdef.concatstabto(asmlist : paasmoutput);
  2191. begin
  2192. if (not assigned(typesym) or typesym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  2193. and not is_def_stab_written then
  2194. begin
  2195. if assigned(rettype.def) then forcestabto(asmlist,rettype.def);
  2196. inherited concatstabto(asmlist);
  2197. end;
  2198. end;
  2199. {$endif GDB}
  2200. {***************************************************************************
  2201. TPROCDEF
  2202. ***************************************************************************}
  2203. constructor tprocdef.init;
  2204. begin
  2205. inherited init;
  2206. deftype:=procdef;
  2207. _mangledname:=nil;
  2208. nextoverloaded:=nil;
  2209. fileinfo:=aktfilepos;
  2210. extnumber:=-1;
  2211. localst:=new(psymtable,init(localsymtable));
  2212. parast:=new(psymtable,init(parasymtable));
  2213. localst^.defowner:=@self;
  2214. parast^.defowner:=@self;
  2215. { this is used by insert
  2216. to check same names in parast and localst }
  2217. localst^.next:=parast;
  2218. defref:=nil;
  2219. crossref:=nil;
  2220. lastwritten:=nil;
  2221. refcount:=0;
  2222. if (cs_browser in aktmoduleswitches) and make_ref then
  2223. begin
  2224. defref:=new(pref,init(defref,@tokenpos));
  2225. inc(refcount);
  2226. end;
  2227. lastref:=defref;
  2228. { first, we assume that all registers are used }
  2229. {$ifdef newcg}
  2230. usedregisters:=[firstreg..lastreg];
  2231. {$else newcg}
  2232. {$ifdef i386}
  2233. usedregisters:=$ff;
  2234. {$endif i386}
  2235. {$ifdef m68k}
  2236. usedregisters:=$FFFF;
  2237. {$endif}
  2238. {$endif newcg}
  2239. forwarddef:=true;
  2240. interfacedef:=false;
  2241. _class := nil;
  2242. code:=nil;
  2243. count:=false;
  2244. is_used:=false;
  2245. end;
  2246. constructor tprocdef.load;
  2247. var
  2248. s : string;
  2249. begin
  2250. inherited load;
  2251. deftype:=procdef;
  2252. {$ifdef newcg}
  2253. readnormalset(usedregisters);
  2254. {$else newcg}
  2255. {$ifdef i386}
  2256. usedregisters:=readbyte;
  2257. {$endif i386}
  2258. {$ifdef m68k}
  2259. usedregisters:=readword;
  2260. {$endif}
  2261. {$endif newcg}
  2262. s:=readstring;
  2263. setstring(_mangledname,s);
  2264. extnumber:=readlong;
  2265. nextoverloaded:=pprocdef(readdefref);
  2266. _class := pobjectdef(readdefref);
  2267. readposinfo(fileinfo);
  2268. if (cs_link_deffile in aktglobalswitches) and
  2269. (tf_need_export in target_info.flags) and
  2270. (po_exports in procoptions) then
  2271. deffile.AddExport(mangledname);
  2272. parast:=nil;
  2273. localst:=nil;
  2274. forwarddef:=false;
  2275. interfacedef:=false;
  2276. lastref:=nil;
  2277. lastwritten:=nil;
  2278. defref:=nil;
  2279. refcount:=0;
  2280. count:=true;
  2281. is_used:=false;
  2282. end;
  2283. Const local_symtable_index : longint = $8001;
  2284. procedure tprocdef.load_references;
  2285. var
  2286. pos : tfileposinfo;
  2287. {$ifndef NOLOCALBROWSER}
  2288. oldsymtablestack,
  2289. st : psymtable;
  2290. {$endif ndef NOLOCALBROWSER}
  2291. move_last : boolean;
  2292. begin
  2293. move_last:=lastwritten=lastref;
  2294. while (not current_ppu^.endofentry) do
  2295. begin
  2296. readposinfo(pos);
  2297. inc(refcount);
  2298. lastref:=new(pref,init(lastref,@pos));
  2299. lastref^.is_written:=true;
  2300. if refcount=1 then
  2301. defref:=lastref;
  2302. end;
  2303. if move_last then
  2304. lastwritten:=lastref;
  2305. if ((current_module^.flags and uf_local_browser)<>0)
  2306. and is_in_current then
  2307. begin
  2308. {$ifndef NOLOCALBROWSER}
  2309. oldsymtablestack:=symtablestack;
  2310. st:=aktlocalsymtable;
  2311. new(parast,loadas(parasymtable));
  2312. parast^.defowner:=@self;
  2313. aktlocalsymtable:=parast;
  2314. parast^.deref;
  2315. parast^.next:=owner;
  2316. parast^.load_browser;
  2317. aktlocalsymtable:=st;
  2318. new(localst,loadas(localsymtable));
  2319. localst^.defowner:=@self;
  2320. aktlocalsymtable:=localst;
  2321. symtablestack:=parast;
  2322. localst^.deref;
  2323. localst^.next:=parast;
  2324. localst^.load_browser;
  2325. aktlocalsymtable:=st;
  2326. symtablestack:=oldsymtablestack;
  2327. {$endif ndef NOLOCALBROWSER}
  2328. end;
  2329. end;
  2330. function tprocdef.write_references : boolean;
  2331. var
  2332. ref : pref;
  2333. {$ifndef NOLOCALBROWSER}
  2334. st : psymtable;
  2335. pdo : pobjectdef;
  2336. {$endif ndef NOLOCALBROWSER}
  2337. move_last : boolean;
  2338. begin
  2339. move_last:=lastwritten=lastref;
  2340. if move_last and (((current_module^.flags and uf_local_browser)=0)
  2341. or not is_in_current) then
  2342. exit;
  2343. { write address of this symbol }
  2344. writedefref(@self);
  2345. { write refs }
  2346. if assigned(lastwritten) then
  2347. ref:=lastwritten
  2348. else
  2349. ref:=defref;
  2350. while assigned(ref) do
  2351. begin
  2352. if ref^.moduleindex=current_module^.unit_index then
  2353. begin
  2354. writeposinfo(ref^.posinfo);
  2355. ref^.is_written:=true;
  2356. if move_last then
  2357. lastwritten:=ref;
  2358. end
  2359. else if not ref^.is_written then
  2360. move_last:=false
  2361. else if move_last then
  2362. lastwritten:=ref;
  2363. ref:=ref^.nextref;
  2364. end;
  2365. current_ppu^.writeentry(ibdefref);
  2366. write_references:=true;
  2367. if ((current_module^.flags and uf_local_browser)<>0)
  2368. and is_in_current then
  2369. begin
  2370. {$ifndef NOLOCALBROWSER}
  2371. pdo:=_class;
  2372. if (owner^.symtabletype<>localsymtable) then
  2373. while assigned(pdo) do
  2374. begin
  2375. if pdo^.symtable<>aktrecordsymtable then
  2376. begin
  2377. pdo^.symtable^.unitid:=local_symtable_index;
  2378. inc(local_symtable_index);
  2379. end;
  2380. pdo:=pdo^.childof;
  2381. end;
  2382. { we need TESTLOCALBROWSER para and local symtables
  2383. PPU files are then easier to read PM }
  2384. if not assigned(parast) then
  2385. parast:=new(psymtable,init(parasymtable));
  2386. parast^.defowner:=@self;
  2387. st:=aktlocalsymtable;
  2388. aktlocalsymtable:=parast;
  2389. parast^.writeas;
  2390. parast^.unitid:=local_symtable_index;
  2391. inc(local_symtable_index);
  2392. parast^.write_browser;
  2393. if not assigned(localst) then
  2394. localst:=new(psymtable,init(localsymtable));
  2395. localst^.defowner:=@self;
  2396. aktlocalsymtable:=localst;
  2397. localst^.writeas;
  2398. localst^.unitid:=local_symtable_index;
  2399. inc(local_symtable_index);
  2400. localst^.write_browser;
  2401. aktlocalsymtable:=st;
  2402. { decrement for }
  2403. local_symtable_index:=local_symtable_index-2;
  2404. pdo:=_class;
  2405. if (owner^.symtabletype<>localsymtable) then
  2406. while assigned(pdo) do
  2407. begin
  2408. if pdo^.symtable<>aktrecordsymtable then
  2409. dec(local_symtable_index);
  2410. pdo:=pdo^.childof;
  2411. end;
  2412. {$endif ndef NOLOCALBROWSER}
  2413. end;
  2414. end;
  2415. {$ifdef BrowserLog}
  2416. procedure tprocdef.add_to_browserlog;
  2417. begin
  2418. if assigned(defref) then
  2419. begin
  2420. browserlog.AddLog('***'+mangledname);
  2421. browserlog.AddLogRefs(defref);
  2422. if (current_module^.flags and uf_local_browser)<>0 then
  2423. begin
  2424. if assigned(parast) then
  2425. parast^.writebrowserlog;
  2426. if assigned(localst) then
  2427. localst^.writebrowserlog;
  2428. end;
  2429. end;
  2430. end;
  2431. {$endif BrowserLog}
  2432. destructor tprocdef.done;
  2433. begin
  2434. if assigned(defref) then
  2435. begin
  2436. defref^.freechain;
  2437. dispose(defref,done);
  2438. end;
  2439. if assigned(parast) then
  2440. dispose(parast,done);
  2441. if assigned(localst) and (localst^.symtabletype<>staticsymtable) then
  2442. dispose(localst,done);
  2443. if (pocall_inline in proccalloptions) and assigned(code) then
  2444. disposetree(ptree(code));
  2445. if (po_msgstr in procoptions) then
  2446. strdispose(messageinf.str);
  2447. if
  2448. {$ifdef tp}
  2449. not(use_big) and
  2450. {$endif}
  2451. assigned(_mangledname) then
  2452. strdispose(_mangledname);
  2453. inherited done;
  2454. end;
  2455. procedure tprocdef.write;
  2456. begin
  2457. inherited write;
  2458. current_ppu^.do_interface_crc:=false;
  2459. { set all registers to used for simplified compilation PM }
  2460. if simplify_ppu then
  2461. begin
  2462. {$ifdef newcg}
  2463. usedregisters:=[firstreg..lastreg];
  2464. {$else newcg}
  2465. {$ifdef i386}
  2466. usedregisters:=$ff;
  2467. {$endif i386}
  2468. {$ifdef m68k}
  2469. usedregisters:=$ffff;
  2470. {$endif}
  2471. {$endif newcg}
  2472. end;
  2473. {$ifdef newcg}
  2474. writenormalset(usedregisters);
  2475. {$else newcg}
  2476. {$ifdef i386}
  2477. writebyte(usedregisters);
  2478. {$endif i386}
  2479. {$ifdef m68k}
  2480. writeword(usedregisters);
  2481. {$endif}
  2482. {$endif newcg}
  2483. current_ppu^.do_interface_crc:=true;
  2484. writestring(mangledname);
  2485. writelong(extnumber);
  2486. if (proctypeoption<>potype_operator) then
  2487. writedefref(nextoverloaded)
  2488. else
  2489. begin
  2490. { only write the overloads from the same unit }
  2491. if assigned(nextoverloaded) and
  2492. (nextoverloaded^.owner=owner) then
  2493. writedefref(nextoverloaded)
  2494. else
  2495. writedefref(nil);
  2496. end;
  2497. writedefref(_class);
  2498. writeposinfo(fileinfo);
  2499. if (pocall_inline in proccalloptions) then
  2500. begin
  2501. { we need to save
  2502. - the para and the local symtable
  2503. - the code ptree !! PM
  2504. writesymtable(parast);
  2505. writesymtable(localst);
  2506. writeptree(ptree(code));
  2507. }
  2508. end;
  2509. current_ppu^.writeentry(ibprocdef);
  2510. end;
  2511. function tprocdef.haspara:boolean;
  2512. begin
  2513. haspara:=assigned(aktprocsym^.definition^.parast^.symindex^.first);
  2514. end;
  2515. {$ifdef GDB}
  2516. procedure addparaname(p : psym);
  2517. var vs : char;
  2518. begin
  2519. if pvarsym(p)^.varspez = vs_value then vs := '1'
  2520. else vs := '0';
  2521. strpcopy(strend(StabRecString),p^.name+':'+pvarsym(p)^.vartype.def^.numberstring+','+vs+';');
  2522. end;
  2523. function tprocdef.stabstring : pchar;
  2524. var
  2525. i : longint;
  2526. oldrec : pchar;
  2527. begin
  2528. oldrec := stabrecstring;
  2529. getmem(StabRecString,1024);
  2530. strpcopy(StabRecString,'f'+rettype.def^.numberstring);
  2531. i:=para^.count;
  2532. if i>0 then
  2533. begin
  2534. strpcopy(strend(StabRecString),','+tostr(i)+';');
  2535. (* confuse gdb !! PM
  2536. if assigned(parast) then
  2537. parast^.foreach({$ifndef TP}@{$endif}addparaname)
  2538. else
  2539. begin
  2540. param := para1;
  2541. i := 0;
  2542. while assigned(param) do
  2543. begin
  2544. inc(i);
  2545. if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
  2546. {Here we have lost the parameter names !!}
  2547. {using lower case parameters }
  2548. strpcopy(strend(stabrecstring),'p'+tostr(i)
  2549. +':'+param^.paratype.def^.numberstring+','+vartyp+';');
  2550. param := param^.next;
  2551. end;
  2552. end; *)
  2553. {strpcopy(strend(StabRecString),';');}
  2554. end;
  2555. stabstring := strnew(stabrecstring);
  2556. freemem(stabrecstring,1024);
  2557. stabrecstring := oldrec;
  2558. end;
  2559. procedure tprocdef.concatstabto(asmlist : paasmoutput);
  2560. begin
  2561. end;
  2562. {$endif GDB}
  2563. procedure tprocdef.deref;
  2564. begin
  2565. inherited deref;
  2566. resolvedef(pdef(nextoverloaded));
  2567. resolvedef(pdef(_class));
  2568. end;
  2569. function tprocdef.mangledname : string;
  2570. {$ifdef tp}
  2571. var
  2572. oldpos : longint;
  2573. s : string;
  2574. b : byte;
  2575. {$endif tp}
  2576. begin
  2577. {$ifndef Delphi}
  2578. {$ifdef tp}
  2579. if use_big then
  2580. begin
  2581. symbolstream.seek(longint(_mangledname));
  2582. symbolstream.read(b,1);
  2583. symbolstream.read(s[1],b);
  2584. s[0]:=chr(b);
  2585. mangledname:=s;
  2586. end
  2587. else
  2588. {$endif}
  2589. {$endif Delphi}
  2590. mangledname:=strpas(_mangledname);
  2591. if count then
  2592. is_used:=true;
  2593. end;
  2594. function tprocdef.procname: string;
  2595. var
  2596. s : string;
  2597. l : longint;
  2598. begin
  2599. s:=mangledname;
  2600. { delete leading $$'s }
  2601. l:=pos('$$',s);
  2602. while l<>0 do
  2603. begin
  2604. delete(s,1,l+1);
  2605. l:=pos('$$',s);
  2606. end;
  2607. { delete leading _$'s }
  2608. l:=pos('_$',s);
  2609. while l<>0 do
  2610. begin
  2611. delete(s,1,l+1);
  2612. l:=pos('_$',s);
  2613. end;
  2614. l:=pos('$',s);
  2615. if l=0 then
  2616. procname:=s
  2617. else
  2618. procname:=Copy(s,1,l-1);
  2619. end;
  2620. {$IfDef GDB}
  2621. function tprocdef.cplusplusmangledname : string;
  2622. var
  2623. s,s2 : string;
  2624. param : pparaitem;
  2625. begin
  2626. s := typesym^.name;
  2627. if _class <> nil then
  2628. begin
  2629. s2 := _class^.objname^;
  2630. s := s+'__'+tostr(length(s2))+s2;
  2631. end else s := s + '_';
  2632. param := pparaitem(para^.first);
  2633. while assigned(param) do
  2634. begin
  2635. s2 := param^.paratype.def^.typesym^.name;
  2636. s := s+tostr(length(s2))+s2;
  2637. param := pparaitem(param^.next);
  2638. end;
  2639. cplusplusmangledname:=s;
  2640. end;
  2641. {$EndIf GDB}
  2642. procedure tprocdef.setmangledname(const s : string);
  2643. begin
  2644. if {$ifdef tp}not(use_big) and{$endif} (assigned(_mangledname)) then
  2645. strdispose(_mangledname);
  2646. setstring(_mangledname,s);
  2647. if assigned(parast) then
  2648. begin
  2649. stringdispose(parast^.name);
  2650. parast^.name:=stringdup('args of '+s);
  2651. end;
  2652. if assigned(localst) then
  2653. begin
  2654. stringdispose(localst^.name);
  2655. localst^.name:=stringdup('locals of '+s);
  2656. end;
  2657. end;
  2658. {***************************************************************************
  2659. TPROCVARDEF
  2660. ***************************************************************************}
  2661. constructor tprocvardef.init;
  2662. begin
  2663. inherited init;
  2664. deftype:=procvardef;
  2665. end;
  2666. constructor tprocvardef.load;
  2667. begin
  2668. inherited load;
  2669. deftype:=procvardef;
  2670. end;
  2671. procedure tprocvardef.write;
  2672. begin
  2673. { here we cannot get a real good value so just give something }
  2674. { plausible (PM) }
  2675. { a more secure way would be
  2676. to allways store in a temp }
  2677. if is_fpu(rettype.def) then
  2678. fpu_used:=2
  2679. else
  2680. fpu_used:=0;
  2681. inherited write;
  2682. current_ppu^.writeentry(ibprocvardef);
  2683. end;
  2684. function tprocvardef.size : longint;
  2685. begin
  2686. if (po_methodpointer in procoptions) then
  2687. size:=2*target_os.size_of_pointer
  2688. else
  2689. size:=target_os.size_of_pointer;
  2690. end;
  2691. {$ifdef GDB}
  2692. function tprocvardef.stabstring : pchar;
  2693. var
  2694. nss : pchar;
  2695. { i : longint; }
  2696. begin
  2697. { i := para^.count; }
  2698. getmem(nss,1024);
  2699. { it is not a function but a function pointer !! (PM) }
  2700. strpcopy(nss,'*f'+rettype.def^.numberstring{+','+tostr(i)}+';');
  2701. { this confuses gdb !!
  2702. we should use 'F' instead of 'f' but
  2703. as we use c++ language mode
  2704. it does not like that either
  2705. Please do not remove this part
  2706. might be used once
  2707. gdb for pascal is ready PM }
  2708. (*
  2709. param := para1;
  2710. i := 0;
  2711. while assigned(param) do
  2712. begin
  2713. inc(i);
  2714. if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
  2715. {Here we have lost the parameter names !!}
  2716. pst := strpnew('p'+tostr(i)+':'+param^.paratype.def^.numberstring+','+vartyp+';');
  2717. strcat(nss,pst);
  2718. strdispose(pst);
  2719. param := param^.next;
  2720. end; *)
  2721. {strpcopy(strend(nss),';');}
  2722. stabstring := strnew(nss);
  2723. freemem(nss,1024);
  2724. end;
  2725. procedure tprocvardef.concatstabto(asmlist : paasmoutput);
  2726. begin
  2727. if ( not assigned(typesym) or typesym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  2728. and not is_def_stab_written then
  2729. inherited concatstabto(asmlist);
  2730. is_def_stab_written:=true;
  2731. end;
  2732. {$endif GDB}
  2733. procedure tprocvardef.write_rtti_data;
  2734. var
  2735. pdc : pparaitem;
  2736. methodkind, paraspec : byte;
  2737. begin
  2738. if po_methodpointer in procoptions then
  2739. begin
  2740. { write method id and name }
  2741. rttilist^.concat(new(pai_const,init_8bit(tkmethod)));
  2742. write_rtti_name;
  2743. { write kind of method (can only be function or procedure)}
  2744. if rettype.def = pdef(voiddef) then { ### typecast shoudln't be necessary! (sg) }
  2745. methodkind := mkProcedure
  2746. else
  2747. methodkind := mkFunction;
  2748. rttilist^.concat(new(pai_const,init_8bit(methodkind)));
  2749. { get # of parameters }
  2750. rttilist^.concat(new(pai_const,init_8bit(para^.count)));
  2751. { write parameter info. The parameters must be written in reverse order
  2752. if this method uses right to left parameter pushing! }
  2753. if (pocall_leftright in proccalloptions) then
  2754. pdc:=pparaitem(para^.last)
  2755. else
  2756. pdc:=pparaitem(para^.first);
  2757. while assigned(pdc) do
  2758. begin
  2759. case pdc^.paratyp of
  2760. vs_value: paraspec := 0;
  2761. vs_const: paraspec := pfConst;
  2762. vs_var : paraspec := pfVar;
  2763. end;
  2764. { write flags for current parameter }
  2765. rttilist^.concat(new(pai_const,init_8bit(paraspec)));
  2766. { write name of current parameter ### how can I get this??? (sg)}
  2767. rttilist^.concat(new(pai_const,init_8bit(0)));
  2768. { write name of type of current parameter }
  2769. pdc^.paratype.def^.write_rtti_name;
  2770. if (pocall_leftright in proccalloptions) then
  2771. pdc:=pparaitem(pdc^.previous)
  2772. else
  2773. pdc:=pparaitem(pdc^.next);
  2774. end;
  2775. { write name of result type }
  2776. rettype.def^.write_rtti_name;
  2777. end;
  2778. end;
  2779. procedure tprocvardef.write_child_rtti_data;
  2780. begin
  2781. {!!!!!!!!}
  2782. end;
  2783. function tprocvardef.is_publishable : boolean;
  2784. begin
  2785. is_publishable:=(po_methodpointer in procoptions);
  2786. end;
  2787. function tprocvardef.gettypename : string;
  2788. begin
  2789. if assigned(rettype.def) and
  2790. (rettype.def<>pdef(voiddef)) then
  2791. gettypename:='<procedure variable type of function'+demangled_paras+
  2792. ':'+rettype.def^.gettypename+';'+proccalloption2str+'>'
  2793. else
  2794. gettypename:='<procedure variable type of procedure'+demangled_paras+
  2795. ';'+proccalloption2str+'>';
  2796. end;
  2797. {***************************************************************************
  2798. TOBJECTDEF
  2799. ***************************************************************************}
  2800. {$ifdef GDB}
  2801. const
  2802. vtabletype : word = 0;
  2803. vtableassigned : boolean = false;
  2804. {$endif GDB}
  2805. constructor tobjectdef.init(const n : string;c : pobjectdef);
  2806. begin
  2807. tdef.init;
  2808. deftype:=objectdef;
  2809. objectoptions:=[];
  2810. childof:=nil;
  2811. symtable:=new(psymtable,init(objectsymtable));
  2812. symtable^.name := stringdup(n);
  2813. { create space for vmt !! }
  2814. vmt_offset:=0;
  2815. symtable^.datasize:=0;
  2816. symtable^.defowner:=@self;
  2817. symtable^.dataalignment:=packrecordalignment[aktpackrecords];
  2818. set_parent(c);
  2819. objname:=stringdup(n);
  2820. end;
  2821. constructor tobjectdef.load;
  2822. var
  2823. oldread_member : boolean;
  2824. begin
  2825. tdef.load;
  2826. deftype:=objectdef;
  2827. savesize:=readlong;
  2828. vmt_offset:=readlong;
  2829. objname:=stringdup(readstring);
  2830. childof:=pobjectdef(readdefref);
  2831. readsmallset(objectoptions);
  2832. has_rtti:=boolean(readbyte);
  2833. oldread_member:=read_member;
  2834. read_member:=true;
  2835. symtable:=new(psymtable,loadas(objectsymtable));
  2836. read_member:=oldread_member;
  2837. symtable^.defowner:=@self;
  2838. symtable^.name := stringdup(objname^);
  2839. { handles the predefined class tobject }
  2840. { the last TOBJECT which is loaded gets }
  2841. { it ! }
  2842. if (childof=nil) and
  2843. is_class and
  2844. (objname^='TOBJECT') then
  2845. class_tobject:=@self;
  2846. end;
  2847. destructor tobjectdef.done;
  2848. begin
  2849. if assigned(symtable) then
  2850. dispose(symtable,done);
  2851. if (oo_is_forward in objectoptions) then
  2852. Message1(sym_e_class_forward_not_resolved,objname^);
  2853. stringdispose(objname);
  2854. tdef.done;
  2855. end;
  2856. procedure tobjectdef.write;
  2857. var
  2858. oldread_member : boolean;
  2859. begin
  2860. tdef.write;
  2861. writelong(size);
  2862. writelong(vmt_offset);
  2863. writestring(objname^);
  2864. writedefref(childof);
  2865. writesmallset(objectoptions);
  2866. writebyte(byte(has_rtti));
  2867. current_ppu^.writeentry(ibobjectdef);
  2868. oldread_member:=read_member;
  2869. read_member:=true;
  2870. symtable^.writeas;
  2871. read_member:=oldread_member;
  2872. end;
  2873. procedure tobjectdef.deref;
  2874. var
  2875. oldrecsyms : psymtable;
  2876. begin
  2877. inherited deref;
  2878. resolvedef(pdef(childof));
  2879. oldrecsyms:=aktrecordsymtable;
  2880. aktrecordsymtable:=symtable;
  2881. symtable^.deref;
  2882. aktrecordsymtable:=oldrecsyms;
  2883. end;
  2884. procedure tobjectdef.set_parent( c : pobjectdef);
  2885. begin
  2886. { nothing to do if the parent was not forward !}
  2887. if assigned(childof) then
  2888. exit;
  2889. childof:=c;
  2890. { some options are inherited !! }
  2891. if assigned(c) then
  2892. begin
  2893. objectoptions:=objectoptions+(c^.objectoptions*
  2894. [oo_has_virtual,oo_has_private,oo_has_protected,oo_has_constructor,oo_has_destructor]);
  2895. { add the data of the anchestor class }
  2896. inc(symtable^.datasize,c^.symtable^.datasize);
  2897. if (oo_has_vmt in objectoptions) and
  2898. (oo_has_vmt in c^.objectoptions) then
  2899. dec(symtable^.datasize,target_os.size_of_pointer);
  2900. { if parent has a vmt field then
  2901. the offset is the same for the child PM }
  2902. if (oo_has_vmt in c^.objectoptions) or is_class then
  2903. begin
  2904. vmt_offset:=c^.vmt_offset;
  2905. {$ifdef INCLUDEOK}
  2906. include(objectoptions,oo_has_vmt);
  2907. {$else}
  2908. objectoptions:=objectoptions+[oo_has_vmt];
  2909. {$endif}
  2910. end;
  2911. end;
  2912. savesize := symtable^.datasize;
  2913. end;
  2914. procedure tobjectdef.insertvmt;
  2915. begin
  2916. if (oo_has_vmt in objectoptions) then
  2917. internalerror(12345)
  2918. else
  2919. begin
  2920. { first round up to multiple of 4 }
  2921. if (symtable^.dataalignment=2) then
  2922. begin
  2923. if (symtable^.datasize and 1)<>0 then
  2924. inc(symtable^.datasize);
  2925. end
  2926. else
  2927. if (symtable^.dataalignment>=4) then
  2928. begin
  2929. if (symtable^.datasize mod 4) <> 0 then
  2930. inc(symtable^.datasize,4-(symtable^.datasize mod 4));
  2931. end;
  2932. vmt_offset:=symtable^.datasize;
  2933. inc(symtable^.datasize,target_os.size_of_pointer);
  2934. include(objectoptions,oo_has_vmt);
  2935. end;
  2936. end;
  2937. procedure tobjectdef.check_forwards;
  2938. begin
  2939. symtable^.check_forwards;
  2940. if (oo_is_forward in objectoptions) then
  2941. begin
  2942. { ok, in future, the forward can be resolved }
  2943. Message1(sym_e_class_forward_not_resolved,objname^);
  2944. {$ifdef INCLUDEOK}
  2945. exclude(objectoptions,oo_is_forward);
  2946. {$else}
  2947. objectoptions:=objectoptions-[oo_is_forward];
  2948. {$endif}
  2949. end;
  2950. end;
  2951. { true, if self inherits from d (or if they are equal) }
  2952. function tobjectdef.is_related(d : pobjectdef) : boolean;
  2953. var
  2954. hp : pobjectdef;
  2955. begin
  2956. hp:=@self;
  2957. while assigned(hp) do
  2958. begin
  2959. if hp=d then
  2960. begin
  2961. is_related:=true;
  2962. exit;
  2963. end;
  2964. hp:=hp^.childof;
  2965. end;
  2966. is_related:=false;
  2967. end;
  2968. var
  2969. sd : pprocdef;
  2970. procedure _searchdestructor(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  2971. var
  2972. p : pprocdef;
  2973. begin
  2974. { if we found already a destructor, then we exit }
  2975. if assigned(sd) then
  2976. exit;
  2977. if psym(sym)^.typ=procsym then
  2978. begin
  2979. p:=pprocsym(sym)^.definition;
  2980. while assigned(p) do
  2981. begin
  2982. if p^.proctypeoption=potype_destructor then
  2983. begin
  2984. sd:=p;
  2985. exit;
  2986. end;
  2987. p:=p^.nextoverloaded;
  2988. end;
  2989. end;
  2990. end;
  2991. function tobjectdef.searchdestructor : pprocdef;
  2992. var
  2993. o : pobjectdef;
  2994. begin
  2995. searchdestructor:=nil;
  2996. o:=@self;
  2997. sd:=nil;
  2998. while assigned(o) do
  2999. begin
  3000. symtable^.foreach({$ifndef TP}@{$endif}_searchdestructor);
  3001. if assigned(sd) then
  3002. begin
  3003. searchdestructor:=sd;
  3004. exit;
  3005. end;
  3006. o:=o^.childof;
  3007. end;
  3008. end;
  3009. function tobjectdef.size : longint;
  3010. begin
  3011. if (oo_is_class in objectoptions) then
  3012. size:=target_os.size_of_pointer
  3013. else
  3014. size:=symtable^.datasize;
  3015. end;
  3016. function tobjectdef.alignment:longint;
  3017. begin
  3018. alignment:=symtable^.dataalignment;
  3019. end;
  3020. function tobjectdef.vmtmethodoffset(index:longint):longint;
  3021. begin
  3022. { for offset of methods for classes, see rtl/inc/objpash.inc }
  3023. if is_class then
  3024. vmtmethodoffset:=(index+12)*target_os.size_of_pointer
  3025. else
  3026. {$ifdef WITHDMT}
  3027. vmtmethodoffset:=(index+4)*target_os.size_of_pointer;
  3028. {$else WITHDMT}
  3029. vmtmethodoffset:=(index+3)*target_os.size_of_pointer;
  3030. {$endif WITHDMT}
  3031. end;
  3032. function tobjectdef.vmt_mangledname : string;
  3033. {DM: I get a nil pointer on the owner name. I don't know if this
  3034. mayhappen, and I have therefore fixed the problem by doing nil pointer
  3035. checks.}
  3036. var
  3037. s1,s2:string;
  3038. begin
  3039. if not(oo_has_vmt in objectoptions) then
  3040. Message1(parser_object_has_no_vmt,objname^);
  3041. if owner^.name=nil then
  3042. s1:=''
  3043. else
  3044. s1:=owner^.name^;
  3045. if objname=nil then
  3046. s2:=''
  3047. else
  3048. s2:=objname^;
  3049. vmt_mangledname:='VMT_'+s1+'$_'+s2;
  3050. end;
  3051. function tobjectdef.rtti_name : string;
  3052. var
  3053. s1,s2:string;
  3054. begin
  3055. if owner^.name=nil then
  3056. s1:=''
  3057. else
  3058. s1:=owner^.name^;
  3059. if objname=nil then
  3060. s2:=''
  3061. else
  3062. s2:=objname^;
  3063. rtti_name:='RTTI_'+s1+'$_'+s2;
  3064. end;
  3065. function tobjectdef.is_class : boolean;
  3066. begin
  3067. is_class:=(oo_is_class in objectoptions);
  3068. end;
  3069. {$ifdef GDB}
  3070. procedure addprocname(p :pnamedindexobject);
  3071. var virtualind,argnames : string;
  3072. news, newrec : pchar;
  3073. pd,ipd : pprocdef;
  3074. lindex : longint;
  3075. para : pparaitem;
  3076. arglength : byte;
  3077. sp : char;
  3078. begin
  3079. If psym(p)^.typ = procsym then
  3080. begin
  3081. pd := pprocsym(p)^.definition;
  3082. { this will be used for full implementation of object stabs
  3083. not yet done }
  3084. ipd := pd;
  3085. while assigned(ipd^.nextoverloaded) do ipd := ipd^.nextoverloaded;
  3086. if (po_virtualmethod in pd^.procoptions) then
  3087. begin
  3088. lindex := pd^.extnumber;
  3089. {doesnt seem to be necessary
  3090. lindex := lindex or $80000000;}
  3091. virtualind := '*'+tostr(lindex)+';'+ipd^._class^.numberstring+';'
  3092. end else virtualind := '.';
  3093. { used by gdbpas to recognize constructor and destructors }
  3094. if (pd^.proctypeoption=potype_constructor) then
  3095. argnames:='__ct__'
  3096. else if (pd^.proctypeoption=potype_destructor) then
  3097. argnames:='__dt__'
  3098. else
  3099. argnames := '';
  3100. { arguments are not listed here }
  3101. {we don't need another definition}
  3102. para := pparaitem(pd^.para^.first);
  3103. while assigned(para) do
  3104. begin
  3105. if para^.paratype.def^.deftype = formaldef then
  3106. begin
  3107. if para^.paratyp=vs_var then
  3108. argnames := argnames+'3var'
  3109. else if para^.paratyp=vs_const then
  3110. argnames:=argnames+'5const';
  3111. end
  3112. else
  3113. begin
  3114. { if the arg definition is like (v: ^byte;..
  3115. there is no sym attached to data !!! }
  3116. if assigned(para^.paratype.def^.typesym) then
  3117. begin
  3118. arglength := length(para^.paratype.def^.typesym^.name);
  3119. argnames := argnames + tostr(arglength)+para^.paratype.def^.typesym^.name;
  3120. end
  3121. else
  3122. begin
  3123. argnames:=argnames+'11unnamedtype';
  3124. end;
  3125. end;
  3126. para := pparaitem(para^.next);
  3127. end;
  3128. ipd^.is_def_stab_written := true;
  3129. { here 2A must be changed for private and protected }
  3130. { 0 is private 1 protected and 2 public }
  3131. if (sp_private in psym(p)^.symoptions) then sp:='0'
  3132. else if (sp_protected in psym(p)^.symoptions) then sp:='1'
  3133. else sp:='2';
  3134. newrec := strpnew(p^.name+'::'+ipd^.numberstring
  3135. +'=##'+pd^.rettype.def^.numberstring+';:'+argnames+';'+sp+'A'
  3136. +virtualind+';');
  3137. { get spare place for a string at the end }
  3138. if strlen(StabRecString) + strlen(newrec) >= StabRecSize-256 then
  3139. begin
  3140. getmem(news,stabrecsize+memsizeinc);
  3141. strcopy(news,stabrecstring);
  3142. freemem(stabrecstring,stabrecsize);
  3143. stabrecsize:=stabrecsize+memsizeinc;
  3144. stabrecstring:=news;
  3145. end;
  3146. strcat(StabRecstring,newrec);
  3147. {freemem(newrec,memsizeinc); }
  3148. strdispose(newrec);
  3149. {This should be used for case !!}
  3150. RecOffset := RecOffset + pd^.size;
  3151. end;
  3152. end;
  3153. function tobjectdef.stabstring : pchar;
  3154. var anc : pobjectdef;
  3155. oldrec : pchar;
  3156. oldrecsize : longint;
  3157. str_end : string;
  3158. begin
  3159. oldrec := stabrecstring;
  3160. oldrecsize:=stabrecsize;
  3161. stabrecsize:=memsizeinc;
  3162. GetMem(stabrecstring,stabrecsize);
  3163. strpcopy(stabRecString,'s'+tostr(symtable^.datasize));
  3164. if assigned(childof) then
  3165. {only one ancestor not virtual, public, at base offset 0 }
  3166. { !1 , 0 2 0 , }
  3167. strpcopy(strend(stabrecstring),'!1,020,'+childof^.numberstring+';');
  3168. {virtual table to implement yet}
  3169. RecOffset := 0;
  3170. symtable^.foreach({$ifndef TP}@{$endif}addname);
  3171. if (oo_has_vmt in objectoptions) then
  3172. if not assigned(childof) or not(oo_has_vmt in childof^.objectoptions) then
  3173. begin
  3174. strpcopy(strend(stabrecstring),'$vf'+numberstring+':'+typeglobalnumber('vtblarray')
  3175. +','+tostr(vmt_offset*8)+';');
  3176. end;
  3177. symtable^.foreach({$ifndef TP}@{$endif}addprocname);
  3178. if (oo_has_vmt in objectoptions) then
  3179. begin
  3180. anc := @self;
  3181. while assigned(anc^.childof) and (oo_has_vmt in anc^.childof^.objectoptions) do
  3182. anc := anc^.childof;
  3183. str_end:=';~%'+anc^.numberstring+';';
  3184. end
  3185. else
  3186. str_end:=';';
  3187. strpcopy(strend(stabrecstring),str_end);
  3188. stabstring := strnew(StabRecString);
  3189. freemem(stabrecstring,stabrecsize);
  3190. stabrecstring := oldrec;
  3191. stabrecsize:=oldrecsize;
  3192. end;
  3193. {$endif GDB}
  3194. procedure tobjectdef.write_child_init_data;
  3195. begin
  3196. symtable^.foreach({$ifndef TP}@{$endif}generate_child_inittable);
  3197. end;
  3198. procedure tobjectdef.write_init_data;
  3199. begin
  3200. if is_class then
  3201. rttilist^.concat(new(pai_const,init_8bit(tkclass)))
  3202. else
  3203. rttilist^.concat(new(pai_const,init_8bit(tkobject)));
  3204. { generate the name }
  3205. rttilist^.concat(new(pai_const,init_8bit(length(objname^))));
  3206. rttilist^.concat(new(pai_string,init(objname^)));
  3207. rttilist^.concat(new(pai_const,init_32bit(size)));
  3208. count:=0;
  3209. symtable^.foreach({$ifndef TP}@{$endif}count_inittable_fields);
  3210. rttilist^.concat(new(pai_const,init_32bit(count)));
  3211. symtable^.foreach({$ifndef TP}@{$endif}write_field_inittable);
  3212. end;
  3213. function tobjectdef.needs_inittable : boolean;
  3214. var
  3215. oldb : boolean;
  3216. begin
  3217. if is_class then
  3218. needs_inittable:=false
  3219. else
  3220. begin
  3221. { there are recursive calls to needs_inittable possible, }
  3222. { so we have to change to old value how else should }
  3223. { we do that ? check_rec_rtti can't be a nested }
  3224. { procedure of needs_rtti ! }
  3225. oldb:=binittable;
  3226. binittable:=false;
  3227. symtable^.foreach({$ifndef TP}@{$endif}check_rec_inittable);
  3228. needs_inittable:=binittable;
  3229. binittable:=oldb;
  3230. end;
  3231. end;
  3232. procedure count_published_properties(sym:pnamedindexobject);
  3233. {$ifndef fpc}far;{$endif}
  3234. begin
  3235. if needs_prop_entry(psym(sym)) and
  3236. (psym(sym)^.typ<>varsym) then
  3237. inc(count);
  3238. end;
  3239. procedure write_property_info(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  3240. var
  3241. proctypesinfo : byte;
  3242. procedure writeproc(proc : psymlist; shiftvalue : byte);
  3243. var
  3244. typvalue : byte;
  3245. hp : psymlistitem;
  3246. address : longint;
  3247. begin
  3248. if not(assigned(proc) and assigned(proc^.firstsym)) then
  3249. begin
  3250. rttilist^.concat(new(pai_const,init_32bit(1)));
  3251. typvalue:=3;
  3252. end
  3253. else if proc^.firstsym^.sym^.typ=varsym then
  3254. begin
  3255. address:=0;
  3256. hp:=proc^.firstsym;
  3257. while assigned(hp) do
  3258. begin
  3259. inc(address,pvarsym(hp^.sym)^.address);
  3260. hp:=hp^.next;
  3261. end;
  3262. rttilist^.concat(new(pai_const,init_32bit(address)));
  3263. typvalue:=0;
  3264. end
  3265. else
  3266. begin
  3267. if not(po_virtualmethod in pprocdef(proc^.def)^.procoptions) then
  3268. begin
  3269. rttilist^.concat(new(pai_const_symbol,initname(pprocdef(proc^.def)^.mangledname)));
  3270. typvalue:=1;
  3271. end
  3272. else
  3273. begin
  3274. { virtual method, write vmt offset }
  3275. rttilist^.concat(new(pai_const,init_32bit(
  3276. pprocdef(proc^.def)^._class^.vmtmethodoffset(pprocdef(proc^.def)^.extnumber))));
  3277. typvalue:=2;
  3278. end;
  3279. end;
  3280. proctypesinfo:=proctypesinfo or (typvalue shl shiftvalue);
  3281. end;
  3282. begin
  3283. if needs_prop_entry(psym(sym)) then
  3284. case psym(sym)^.typ of
  3285. varsym:
  3286. begin
  3287. {$ifdef dummy}
  3288. if not(pvarsym(sym)^.vartype.def^.deftype=objectdef) or
  3289. not(pobjectdef(pvarsym(sym)^.vartype.def)^.is_class) then
  3290. internalerror(1509992);
  3291. { access to implicit class property as field }
  3292. proctypesinfo:=(0 shl 0) or (0 shl 2) or (0 shl 4);
  3293. rttilist^.concat(new(pai_const_symbol,initname(pvarsym(sym)^.vartype.def^.get_rtti_label)));
  3294. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  3295. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  3296. { per default stored }
  3297. rttilist^.concat(new(pai_const,init_32bit(1)));
  3298. { index as well as ... }
  3299. rttilist^.concat(new(pai_const,init_32bit(0)));
  3300. { default value are zero }
  3301. rttilist^.concat(new(pai_const,init_32bit(0)));
  3302. rttilist^.concat(new(pai_const,init_16bit(count)));
  3303. inc(count);
  3304. rttilist^.concat(new(pai_const,init_8bit(proctypesinfo)));
  3305. rttilist^.concat(new(pai_const,init_8bit(length(pvarsym(sym)^.name))));
  3306. rttilist^.concat(new(pai_string,init(pvarsym(sym)^.name)));
  3307. {$endif dummy}
  3308. end;
  3309. propertysym:
  3310. begin
  3311. if ppo_indexed in ppropertysym(sym)^.propoptions then
  3312. proctypesinfo:=$40
  3313. else
  3314. proctypesinfo:=0;
  3315. rttilist^.concat(new(pai_const_symbol,initname(ppropertysym(sym)^.proptype.def^.get_rtti_label)));
  3316. writeproc(ppropertysym(sym)^.readaccess,0);
  3317. writeproc(ppropertysym(sym)^.writeaccess,2);
  3318. { isn't it stored ? }
  3319. if not(ppo_stored in ppropertysym(sym)^.propoptions) then
  3320. begin
  3321. rttilist^.concat(new(pai_const,init_32bit(0)));
  3322. proctypesinfo:=proctypesinfo or (3 shl 4);
  3323. end
  3324. else
  3325. writeproc(ppropertysym(sym)^.storedaccess,4);
  3326. rttilist^.concat(new(pai_const,init_32bit(ppropertysym(sym)^.index)));
  3327. rttilist^.concat(new(pai_const,init_32bit(ppropertysym(sym)^.default)));
  3328. rttilist^.concat(new(pai_const,init_16bit(count)));
  3329. inc(count);
  3330. rttilist^.concat(new(pai_const,init_8bit(proctypesinfo)));
  3331. rttilist^.concat(new(pai_const,init_8bit(length(ppropertysym(sym)^.name))));
  3332. rttilist^.concat(new(pai_string,init(ppropertysym(sym)^.name)));
  3333. end;
  3334. else internalerror(1509992);
  3335. end;
  3336. end;
  3337. procedure generate_published_child_rtti(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  3338. begin
  3339. if needs_prop_entry(psym(sym)) then
  3340. case psym(sym)^.typ of
  3341. varsym:
  3342. ;
  3343. { now ignored:
  3344. pvarsym(sym)^.vartype.def^.get_rtti_label;
  3345. }
  3346. propertysym:
  3347. ppropertysym(sym)^.proptype.def^.get_rtti_label;
  3348. else
  3349. internalerror(1509991);
  3350. end;
  3351. end;
  3352. procedure tobjectdef.write_child_rtti_data;
  3353. begin
  3354. symtable^.foreach({$ifndef TP}@{$endif}generate_published_child_rtti);
  3355. end;
  3356. procedure tobjectdef.generate_rtti;
  3357. begin
  3358. if not has_rtti then
  3359. begin
  3360. has_rtti:=true;
  3361. getdatalabel(rtti_label);
  3362. write_child_rtti_data;
  3363. rttilist^.concat(new(pai_symbol,initname_global(rtti_name,0)));
  3364. rttilist^.concat(new(pai_label,init(rtti_label)));
  3365. write_rtti_data;
  3366. rttilist^.concat(new(pai_symbol_end,initname(rtti_name)));
  3367. end;
  3368. end;
  3369. type
  3370. tclasslistitem = object(tlinkedlist_item)
  3371. index : longint;
  3372. p : pobjectdef;
  3373. end;
  3374. pclasslistitem = ^tclasslistitem;
  3375. var
  3376. classtablelist : tlinkedlist;
  3377. tablecount : longint;
  3378. function searchclasstablelist(p : pobjectdef) : pclasslistitem;
  3379. var
  3380. hp : pclasslistitem;
  3381. begin
  3382. hp:=pclasslistitem(classtablelist.first);
  3383. while assigned(hp) do
  3384. if hp^.p=p then
  3385. begin
  3386. searchclasstablelist:=hp;
  3387. exit;
  3388. end
  3389. else
  3390. hp:=pclasslistitem(hp^.next);
  3391. searchclasstablelist:=nil;
  3392. end;
  3393. procedure count_published_fields(sym:pnamedindexobject);
  3394. {$ifndef fpc}far;{$endif}
  3395. var
  3396. hp : pclasslistitem;
  3397. begin
  3398. if needs_prop_entry(psym(sym)) and
  3399. (psym(sym)^.typ=varsym) then
  3400. begin
  3401. if pvarsym(sym)^.vartype.def^.deftype<>objectdef then
  3402. internalerror(0206001);
  3403. hp:=searchclasstablelist(pobjectdef(pvarsym(sym)^.vartype.def));
  3404. if not(assigned(hp)) then
  3405. begin
  3406. hp:=new(pclasslistitem,init);
  3407. hp^.p:=pobjectdef(pvarsym(sym)^.vartype.def);
  3408. hp^.index:=tablecount;
  3409. classtablelist.concat(hp);
  3410. inc(tablecount);
  3411. end;
  3412. inc(count);
  3413. end;
  3414. end;
  3415. procedure writefields(sym:pnamedindexobject);
  3416. {$ifndef fpc}far;{$endif}
  3417. var
  3418. hp : pclasslistitem;
  3419. begin
  3420. if needs_prop_entry(psym(sym)) and
  3421. (psym(sym)^.typ=varsym) then
  3422. begin
  3423. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  3424. hp:=searchclasstablelist(pobjectdef(pvarsym(sym)^.vartype.def));
  3425. if not(assigned(hp)) then
  3426. internalerror(0206002);
  3427. rttilist^.concat(new(pai_const,init_32bit(hp^.index)));
  3428. rttilist^.concat(new(pai_const,init_8bit(length(pvarsym(sym)^.name))));
  3429. rttilist^.concat(new(pai_string,init(pvarsym(sym)^.name)));
  3430. end;
  3431. end;
  3432. function tobjectdef.generate_field_table : pasmlabel;
  3433. var
  3434. fieldtable,
  3435. classtable : pasmlabel;
  3436. hp : pclasslistitem;
  3437. begin
  3438. classtablelist.init;
  3439. getlabel(fieldtable);
  3440. getlabel(classtable);
  3441. count:=0;
  3442. tablecount:=0;
  3443. symtable^.foreach({$ifdef FPC}@{$endif}count_published_fields);
  3444. rttilist^.concat(new(pai_label,init(fieldtable)));
  3445. rttilist^.concat(new(pai_const,init_16bit(count)));
  3446. rttilist^.concat(new(pai_const_symbol,init(classtable)));
  3447. symtable^.foreach({$ifdef FPC}@{$endif}writefields);
  3448. { generate the class table }
  3449. rttilist^.concat(new(pai_label,init(classtable)));
  3450. rttilist^.concat(new(pai_const,init_16bit(tablecount)));
  3451. hp:=pclasslistitem(classtablelist.first);
  3452. while assigned(hp) do
  3453. begin
  3454. rttilist^.concat(new(pai_const_symbol,initname(pobjectdef(hp^.p)^.vmt_mangledname)));
  3455. hp:=pclasslistitem(hp^.next);
  3456. end;
  3457. generate_field_table:=fieldtable;
  3458. classtablelist.done;
  3459. end;
  3460. function tobjectdef.next_free_name_index : longint;
  3461. var
  3462. i : longint;
  3463. begin
  3464. if assigned(childof) and (oo_can_have_published in childof^.objectoptions) then
  3465. i:=childof^.next_free_name_index
  3466. else
  3467. i:=0;
  3468. count:=0;
  3469. symtable^.foreach({$ifndef TP}@{$endif}count_published_properties);
  3470. next_free_name_index:=i+count;
  3471. end;
  3472. procedure tobjectdef.write_rtti_data;
  3473. begin
  3474. if is_class then
  3475. rttilist^.concat(new(pai_const,init_8bit(tkclass)))
  3476. else
  3477. rttilist^.concat(new(pai_const,init_8bit(tkobject)));
  3478. { generate the name }
  3479. rttilist^.concat(new(pai_const,init_8bit(length(objname^))));
  3480. rttilist^.concat(new(pai_string,init(objname^)));
  3481. { write class type }
  3482. rttilist^.concat(new(pai_const_symbol,initname(vmt_mangledname)));
  3483. { write owner typeinfo }
  3484. if assigned(childof) and (oo_can_have_published in childof^.objectoptions) then
  3485. rttilist^.concat(new(pai_const_symbol,initname(childof^.get_rtti_label)))
  3486. else
  3487. rttilist^.concat(new(pai_const,init_32bit(0)));
  3488. { count total number of properties }
  3489. if assigned(childof) and (oo_can_have_published in childof^.objectoptions) then
  3490. count:=childof^.next_free_name_index
  3491. else
  3492. count:=0;
  3493. { write it }
  3494. symtable^.foreach({$ifndef TP}@{$endif}count_published_properties);
  3495. rttilist^.concat(new(pai_const,init_16bit(count)));
  3496. { write unit name }
  3497. if assigned(owner^.name) then
  3498. begin
  3499. rttilist^.concat(new(pai_const,init_8bit(length(owner^.name^))));
  3500. rttilist^.concat(new(pai_string,init(owner^.name^)));
  3501. end
  3502. else
  3503. rttilist^.concat(new(pai_const,init_8bit(0)));
  3504. { write published properties count }
  3505. count:=0;
  3506. symtable^.foreach({$ifndef TP}@{$endif}count_published_properties);
  3507. rttilist^.concat(new(pai_const,init_16bit(count)));
  3508. { count is used to write nameindex }
  3509. { but we need an offset of the owner }
  3510. { to give each property an own slot }
  3511. if assigned(childof) and (oo_can_have_published in childof^.objectoptions) then
  3512. count:=childof^.next_free_name_index
  3513. else
  3514. count:=0;
  3515. symtable^.foreach({$ifndef TP}@{$endif}write_property_info);
  3516. end;
  3517. function tobjectdef.is_publishable : boolean;
  3518. begin
  3519. is_publishable:=is_class;
  3520. end;
  3521. function tobjectdef.get_rtti_label : string;
  3522. begin
  3523. generate_rtti;
  3524. get_rtti_label:=rtti_name;
  3525. end;
  3526. {****************************************************************************
  3527. TFORWARDDEF
  3528. ****************************************************************************}
  3529. constructor tforwarddef.init(const s:string;const pos : tfileposinfo);
  3530. var
  3531. oldregisterdef : boolean;
  3532. begin
  3533. { never register the forwarddefs, they are disposed at the
  3534. end of the type declaration block }
  3535. oldregisterdef:=registerdef;
  3536. registerdef:=false;
  3537. inherited init;
  3538. registerdef:=oldregisterdef;
  3539. deftype:=forwarddef;
  3540. tosymname:=s;
  3541. forwardpos:=pos;
  3542. end;
  3543. function tforwarddef.gettypename:string;
  3544. begin
  3545. gettypename:='unresolved forward to '+tosymname;
  3546. end;
  3547. {****************************************************************************
  3548. TERRORDEF
  3549. ****************************************************************************}
  3550. constructor terrordef.init;
  3551. begin
  3552. inherited init;
  3553. deftype:=errordef;
  3554. end;
  3555. {$ifdef GDB}
  3556. function terrordef.stabstring : pchar;
  3557. begin
  3558. stabstring:=strpnew('error'+numberstring);
  3559. end;
  3560. {$endif GDB}
  3561. function terrordef.gettypename:string;
  3562. begin
  3563. gettypename:='<erroneous type>';
  3564. end;
  3565. {
  3566. $Log$
  3567. Revision 1.202 2000-06-22 20:01:57 peter
  3568. * int64,qword rtti support
  3569. Revision 1.201 2000/06/18 18:11:32 peter
  3570. * C record packing fixed to also check first entry of the record
  3571. if bigger than the recordalignment itself
  3572. * variant record alignment uses alignment per variant and saves the
  3573. highest alignment value
  3574. Revision 1.200 2000/06/02 18:48:47 florian
  3575. + fieldtable support for classes
  3576. Revision 1.199 2000/04/01 14:17:08 peter
  3577. * arraydef.elesize returns 4 when strings are found in an openarray,
  3578. arrayconstructor. Since only the pointers to the strings are stored
  3579. Revision 1.198 2000/04/01 11:44:56 peter
  3580. * fixed rtti info for record
  3581. Revision 1.197 2000/03/01 12:35:45 pierre
  3582. * fix for bug 855
  3583. Revision 1.196 2000/02/14 20:58:43 marco
  3584. * Basic structures for new sethandling implemented.
  3585. Revision 1.195 2000/02/11 13:53:49 pierre
  3586. * avoid stack overflow in tref.done (bug 846)
  3587. Revision 1.194 2000/02/09 13:23:04 peter
  3588. * log truncated
  3589. Revision 1.193 2000/02/05 14:33:32 florian
  3590. * fixed init table generation for classes and arrays
  3591. Revision 1.192 2000/02/04 20:00:22 florian
  3592. * an exception in a construcor calls now the destructor (this applies only
  3593. to classes)
  3594. Revision 1.191 2000/01/30 23:29:06 peter
  3595. * fixed dup rtti writing for classes
  3596. Revision 1.190 2000/01/28 23:17:53 florian
  3597. * virtual XXXX; support for objects, only if -dWITHDMT is defined
  3598. Revision 1.189 2000/01/26 12:02:29 peter
  3599. * abstractprocdef.para_size needs alignment parameter
  3600. * secondcallparan gets para_alignment size instead of dword_align
  3601. Revision 1.188 2000/01/23 16:35:31 peter
  3602. * localbrowser loading of absolute fixed. It needed a symtablestack
  3603. which was not setup correctly
  3604. Revision 1.187 2000/01/09 23:16:06 peter
  3605. * added st_default stringtype
  3606. * genstringconstnode extended with stringtype parameter using st_default
  3607. will do the old behaviour
  3608. Revision 1.186 2000/01/07 01:14:39 peter
  3609. * updated copyright to 2000
  3610. Revision 1.185 2000/01/03 19:26:03 peter
  3611. * fixed resolving of ttypesym which are reference from object/record
  3612. fields.
  3613. Revision 1.184 1999/12/31 14:24:34 peter
  3614. * fixed rtti generation for classes with no published section
  3615. Revision 1.183 1999/12/23 12:19:42 peter
  3616. * check_rec_inittable fix from sg
  3617. Revision 1.182 1999/12/19 17:00:27 peter
  3618. * has_rtti should be saved in the ppu for objects
  3619. Revision 1.181 1999/12/18 14:55:21 florian
  3620. * very basic widestring support
  3621. Revision 1.180 1999/12/06 18:21:03 peter
  3622. * support !ENVVAR for long commandlines
  3623. * win32/go32v2 write short pathnames to link.res so c:\Program Files\ is
  3624. finally supported as installdir.
  3625. Revision 1.179 1999/12/01 12:42:33 peter
  3626. * fixed bug 698
  3627. * removed some notes about unused vars
  3628. Revision 1.178 1999/12/01 10:26:38 pierre
  3629. * restore the correct way for stabs of forward defs
  3630. Revision 1.177 1999/11/30 10:40:54 peter
  3631. + ttype, tsymlist
  3632. Revision 1.176 1999/11/09 23:35:49 pierre
  3633. + better reference pos for forward defs
  3634. Revision 1.175 1999/11/07 23:57:36 pierre
  3635. + higher level browser
  3636. Revision 1.174 1999/11/06 14:34:26 peter
  3637. * truncated log to 20 revs
  3638. }