symdef.inc 111 KB

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