symdef.inc 114 KB

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