symdef.inc 124 KB

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