symdef.inc 108 KB

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