symdef.inc 106 KB

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