symdef.inc 120 KB

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