symdef.inc 85 KB

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