symdef.inc 85 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046
  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_ansistring;
  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_32bit(low)));
  795. rttilist^.concat(new(pai_const,init_32bit(high)));
  796. end;
  797. function torddef.is_publishable : boolean;
  798. begin
  799. is_publishable:=typ in [uchar..bool8bit];
  800. end;
  801. {*************************************************************************************************************************
  802. TFLOATDEF
  803. ****************************************************************************}
  804. constructor tfloatdef.init(t : tfloattype);
  805. begin
  806. tdef.init;
  807. deftype:=floatdef;
  808. typ:=t;
  809. setsize;
  810. end;
  811. constructor tfloatdef.load;
  812. begin
  813. tdef.load;
  814. deftype:=floatdef;
  815. typ:=tfloattype(readbyte);
  816. setsize;
  817. end;
  818. procedure tfloatdef.setsize;
  819. begin
  820. case typ of
  821. f16bit:
  822. savesize:=2;
  823. f32bit,s32real:
  824. savesize:=4;
  825. s64real:
  826. savesize:=8;
  827. s64bit:
  828. savesize:=8;
  829. s80real:
  830. savesize:=extended_size;
  831. else savesize:=0;
  832. end;
  833. end;
  834. procedure tfloatdef.write;
  835. begin
  836. tdef.write;
  837. writebyte(byte(typ));
  838. current_ppu^.writeentry(ibfloatdef);
  839. end;
  840. {$ifdef GDB}
  841. function tfloatdef.stabstring : pchar;
  842. begin
  843. case typ of
  844. s32real,
  845. s64real : stabstring := strpnew('r'+
  846. s32bitdef^.numberstring+';'+tostr(savesize)+';0;');
  847. { for fixed real use longint instead to be able to }
  848. { debug something at least }
  849. f32bit:
  850. stabstring := s32bitdef^.stabstring;
  851. f16bit:
  852. stabstring := strpnew('r'+s32bitdef^.numberstring+';0;'+
  853. tostr($ffff)+';');
  854. { found this solution in stabsread.c from GDB v4.16 }
  855. s64bit : stabstring := strpnew('r'+
  856. s32bitdef^.numberstring+';-'+tostr(savesize)+';0;');
  857. {$ifdef i386}
  858. { under dos at least you must give a size of twelve instead of 10 !! }
  859. { this is probably do to the fact that in gcc all is pushed in 4 bytes size }
  860. s80real : stabstring := strpnew('r'+s32bitdef^.numberstring+';12;0;');
  861. {$endif i386}
  862. else
  863. internalerror(10005);
  864. end;
  865. end;
  866. {$endif GDB}
  867. procedure tfloatdef.write_rtti_data;
  868. const
  869. translate : array[tfloattype] of byte =
  870. (ftFixed32,ftSingle,ftDouble,ftExtended,ftComp,ftFixed16);
  871. begin
  872. rttilist^.concat(new(pai_const,init_8bit(tkFloat)));
  873. rttilist^.concat(new(pai_const,init_8bit(translate[typ])));
  874. end;
  875. function tfloatdef.is_publishable : boolean;
  876. begin
  877. is_publishable:=true;
  878. end;
  879. {*************************************************************************************************************************
  880. TFILEDEF
  881. ****************************************************************************}
  882. constructor tfiledef.init(ft : tfiletype;tas : pdef);
  883. begin
  884. inherited init;
  885. deftype:=filedef;
  886. filetype:=ft;
  887. typed_as:=tas;
  888. setsize;
  889. end;
  890. constructor tfiledef.load;
  891. begin
  892. tdef.load;
  893. deftype:=filedef;
  894. filetype:=tfiletype(readbyte);
  895. if filetype=ft_typed then
  896. typed_as:=readdefref
  897. else
  898. typed_as:=nil;
  899. setsize;
  900. end;
  901. procedure tfiledef.deref;
  902. begin
  903. if filetype=ft_typed then
  904. resolvedef(typed_as);
  905. end;
  906. procedure tfiledef.setsize;
  907. begin
  908. case filetype of
  909. ft_text : savesize:=572;
  910. ft_typed,
  911. ft_untyped : savesize:=316;
  912. end;
  913. end;
  914. procedure tfiledef.write;
  915. begin
  916. tdef.write;
  917. writebyte(byte(filetype));
  918. if filetype=ft_typed then
  919. writedefref(typed_as);
  920. current_ppu^.writeentry(ibfiledef);
  921. end;
  922. {$ifdef GDB}
  923. function tfiledef.stabstring : pchar;
  924. var Handlebitsize,namesize : longint;
  925. Handledef :string;
  926. begin
  927. {$IfDef GDBknowsfiles}
  928. case filetyp of
  929. ft_typed : stabstring := strpnew('d'+typed_as^.numberstring{+';'});
  930. ft_untyped : stabstring := strpnew('d'+voiddef^.numberstring{+';'});
  931. ft_text : stabstring := strpnew('d'+cchardef^.numberstring{+';'});
  932. end;
  933. {$Else }
  934. {based on
  935. FileRec = Packed Record
  936. Handle,
  937. Mode,
  938. RecSize : longint;
  939. _private : array[1..32] of byte;
  940. UserData : array[1..16] of byte;
  941. name : array[0..255] of char;
  942. End; }
  943. { the buffer part is still missing !! (PM) }
  944. { but the string could become too long !! }
  945. stabstring := strpnew('s'+tostr(savesize)+
  946. 'HANDLE:'+typeglobalnumber('longint')+',0,32;'+
  947. 'MODE:'+typeglobalnumber('longint')+',32,32;'+
  948. 'RECSIZE:'+typeglobalnumber('longint')+',64,32;'+
  949. '_PRIVATE:ar'+typeglobalnumber('word')+';1;32;'+typeglobalnumber('byte')
  950. +',92,256;'+
  951. 'USERDATA:ar'+typeglobalnumber('word')+';1;16;'+typeglobalnumber('byte')
  952. +',348,128;'+
  953. 'NAME:ar'+typeglobalnumber('word')+';0;255;'+typeglobalnumber('char')
  954. +',476,2048;;');
  955. {$EndIf}
  956. end;
  957. procedure tfiledef.concatstabto(asmlist : paasmoutput);
  958. begin
  959. { most file defs are unnamed !!! }
  960. if ((sym = nil) or sym^.isusedinstab or use_dbx) and not is_def_stab_written then
  961. begin
  962. if assigned(typed_as) then forcestabto(asmlist,typed_as);
  963. inherited concatstabto(asmlist);
  964. end;
  965. end;
  966. {$endif GDB}
  967. {*************************************************************************************************************************
  968. TPOINTERDEF
  969. ****************************************************************************}
  970. constructor tpointerdef.init(def : pdef);
  971. begin
  972. inherited init;
  973. deftype:=pointerdef;
  974. definition:=def;
  975. savesize:=Sizeof(pointer);
  976. end;
  977. constructor tpointerdef.load;
  978. begin
  979. tdef.load;
  980. deftype:=pointerdef;
  981. { the real address in memory is calculated later (deref) }
  982. definition:=readdefref;
  983. savesize:=Sizeof(pointer);
  984. end;
  985. procedure tpointerdef.deref;
  986. begin
  987. resolvedef(definition);
  988. end;
  989. procedure tpointerdef.write;
  990. begin
  991. tdef.write;
  992. writedefref(definition);
  993. current_ppu^.writeentry(ibpointerdef);
  994. end;
  995. {$ifdef GDB}
  996. function tpointerdef.stabstring : pchar;
  997. begin
  998. stabstring := strpnew('*'+definition^.numberstring);
  999. end;
  1000. procedure tpointerdef.concatstabto(asmlist : paasmoutput);
  1001. var st,nb : string;
  1002. sym_line_no : longint;
  1003. begin
  1004. if ( (sym=nil) or sym^.isusedinstab or use_dbx) and not is_def_stab_written then
  1005. begin
  1006. if assigned(definition) then
  1007. if definition^.deftype in [recorddef,objectdef] then
  1008. begin
  1009. is_def_stab_written := true;
  1010. {to avoid infinite recursion in record with next-like fields }
  1011. nb := definition^.numberstring;
  1012. is_def_stab_written := false;
  1013. if not definition^.is_def_stab_written then
  1014. begin
  1015. if assigned(definition^.sym) then
  1016. begin
  1017. if assigned(sym) then
  1018. begin
  1019. st := sym^.name;
  1020. sym_line_no:=sym^.fileinfo.line;
  1021. end
  1022. else
  1023. begin
  1024. st := ' ';
  1025. sym_line_no:=0;
  1026. end;
  1027. st := '"'+st+':t'+numberstring+'=*'+definition^.numberstring
  1028. +'=xs'+definition^.sym^.name+':",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0';
  1029. if asmlist = debuglist then do_count_dbx := true;
  1030. asmlist^.concat(new(pai_stabs,init(strpnew(st))));
  1031. end;
  1032. end else inherited concatstabto(asmlist);
  1033. is_def_stab_written := true;
  1034. end else
  1035. begin
  1036. forcestabto(asmlist,definition);
  1037. inherited concatstabto(asmlist);
  1038. end;
  1039. end;
  1040. end;
  1041. {$endif GDB}
  1042. {*************************************************************************************************************************
  1043. TCLASSREFDEF
  1044. ****************************************************************************}
  1045. constructor tclassrefdef.init(def : pdef);
  1046. begin
  1047. inherited init(def);
  1048. deftype:=classrefdef;
  1049. definition:=def;
  1050. savesize:=Sizeof(pointer);
  1051. end;
  1052. constructor tclassrefdef.load;
  1053. begin
  1054. inherited load;
  1055. deftype:=classrefdef;
  1056. end;
  1057. procedure tclassrefdef.write;
  1058. begin
  1059. tdef.write;
  1060. writedefref(definition);
  1061. current_ppu^.writeentry(ibclassrefdef);
  1062. end;
  1063. {$ifdef GDB}
  1064. function tclassrefdef.stabstring : pchar;
  1065. begin
  1066. stabstring:=strpnew('');
  1067. end;
  1068. procedure tclassrefdef.concatstabto(asmlist : paasmoutput);
  1069. begin
  1070. end;
  1071. {$endif GDB}
  1072. {***********************************************************************************
  1073. TSETDEF
  1074. ***************************************************************************}
  1075. constructor tsetdef.init(s : pdef;high : longint);
  1076. begin
  1077. inherited init;
  1078. deftype:=setdef;
  1079. setof:=s;
  1080. if high<32 then
  1081. begin
  1082. settype:=smallset;
  1083. savesize:=Sizeof(longint);
  1084. end
  1085. else
  1086. if high<256 then
  1087. begin
  1088. settype:=normset;
  1089. savesize:=32;
  1090. end
  1091. else
  1092. {$ifdef testvarsets}
  1093. if high<$10000 then
  1094. begin
  1095. settype:=varset;
  1096. savesize:=4*((high+31) div 32);
  1097. end
  1098. else
  1099. {$endif testvarsets}
  1100. Message(sym_e_ill_type_decl_set);
  1101. end;
  1102. constructor tsetdef.load;
  1103. begin
  1104. tdef.load;
  1105. deftype:=setdef;
  1106. setof:=readdefref;
  1107. settype:=tsettype(readbyte);
  1108. case settype of
  1109. normset : savesize:=32;
  1110. varset : savesize:=readlong;
  1111. smallset : savesize:=Sizeof(longint);
  1112. end;
  1113. end;
  1114. procedure tsetdef.write;
  1115. begin
  1116. tdef.write;
  1117. writedefref(setof);
  1118. writebyte(byte(settype));
  1119. if settype=varset then
  1120. writelong(savesize);
  1121. current_ppu^.writeentry(ibsetdef);
  1122. end;
  1123. {$ifdef GDB}
  1124. function tsetdef.stabstring : pchar;
  1125. begin
  1126. stabstring := strpnew('S'+setof^.numberstring);
  1127. end;
  1128. procedure tsetdef.concatstabto(asmlist : paasmoutput);
  1129. begin
  1130. if ( not assigned(sym) or sym^.isusedinstab or use_dbx) and
  1131. not is_def_stab_written then
  1132. begin
  1133. if assigned(setof) then
  1134. forcestabto(asmlist,setof);
  1135. inherited concatstabto(asmlist);
  1136. end;
  1137. end;
  1138. {$endif GDB}
  1139. procedure tsetdef.deref;
  1140. begin
  1141. resolvedef(setof);
  1142. end;
  1143. procedure tsetdef.write_rtti_data;
  1144. begin
  1145. rttilist^.concat(new(pai_const,init_8bit(tkSet)));
  1146. rttilist^.concat(new(pai_const,init_8bit(otULong)));
  1147. rttilist^.concat(new(pai_const,init_symbol(strpnew(lab2str(setof^.get_rtti_label)))));
  1148. end;
  1149. procedure tsetdef.write_child_rtti_data;
  1150. begin
  1151. setof^.get_rtti_label;
  1152. end;
  1153. function tsetdef.is_publishable : boolean;
  1154. begin
  1155. is_publishable:=settype=smallset;
  1156. end;
  1157. {***********************************************************************************
  1158. TFORMALDEF
  1159. ***************************************************************************}
  1160. constructor tformaldef.init;
  1161. begin
  1162. inherited init;
  1163. deftype:=formaldef;
  1164. savesize:=Sizeof(pointer);
  1165. end;
  1166. constructor tformaldef.load;
  1167. begin
  1168. tdef.load;
  1169. deftype:=formaldef;
  1170. savesize:=Sizeof(pointer);
  1171. end;
  1172. procedure tformaldef.write;
  1173. begin
  1174. tdef.write;
  1175. current_ppu^.writeentry(ibformaldef);
  1176. end;
  1177. {$ifdef GDB}
  1178. function tformaldef.stabstring : pchar;
  1179. begin
  1180. stabstring := strpnew('formal'+numberstring+';');
  1181. end;
  1182. procedure tformaldef.concatstabto(asmlist : paasmoutput);
  1183. begin
  1184. { formaldef can't be stab'ed !}
  1185. end;
  1186. {$endif GDB}
  1187. {***********************************************************************************
  1188. TARRAYDEF
  1189. ***************************************************************************}
  1190. constructor tarraydef.init(l,h : longint;rd : pdef);
  1191. begin
  1192. tdef.init;
  1193. deftype:=arraydef;
  1194. lowrange:=l;
  1195. highrange:=h;
  1196. rangedef:=rd;
  1197. rangenr:=0;
  1198. definition:=nil;
  1199. end;
  1200. constructor tarraydef.load;
  1201. begin
  1202. tdef.load;
  1203. deftype:=arraydef;
  1204. { the addresses are calculated later }
  1205. definition:=readdefref;
  1206. rangedef:=readdefref;
  1207. lowrange:=readlong;
  1208. highrange:=readlong;
  1209. rangenr:=0;
  1210. end;
  1211. procedure tarraydef.genrangecheck;
  1212. begin
  1213. if rangenr=0 then
  1214. begin
  1215. { generates the data for range checking }
  1216. getlabelnr(rangenr);
  1217. datasegment^.concat(new(pai_symbol,init('R_'+tostr(rangenr))));
  1218. datasegment^.concat(new(pai_const,init_32bit(lowrange)));
  1219. datasegment^.concat(new(pai_const,init_32bit(highrange)));
  1220. end;
  1221. end;
  1222. procedure tarraydef.deref;
  1223. begin
  1224. resolvedef(definition);
  1225. resolvedef(rangedef);
  1226. end;
  1227. procedure tarraydef.write;
  1228. begin
  1229. tdef.write;
  1230. writedefref(definition);
  1231. writedefref(rangedef);
  1232. writelong(lowrange);
  1233. writelong(highrange);
  1234. current_ppu^.writeentry(ibarraydef);
  1235. end;
  1236. {$ifdef GDB}
  1237. function tarraydef.stabstring : pchar;
  1238. begin
  1239. stabstring := strpnew('ar'+rangedef^.numberstring+';'
  1240. +tostr(lowrange)+';'+tostr(highrange)+';'+definition^.numberstring);
  1241. end;
  1242. procedure tarraydef.concatstabto(asmlist : paasmoutput);
  1243. begin
  1244. if (not assigned(sym) or sym^.isusedinstab or use_dbx)
  1245. and not is_def_stab_written then
  1246. begin
  1247. {when array are inserted they have no definition yet !!}
  1248. if assigned(definition) then
  1249. inherited concatstabto(asmlist);
  1250. end;
  1251. end;
  1252. {$endif GDB}
  1253. function tarraydef.elesize : longint;
  1254. begin
  1255. elesize:=definition^.size;
  1256. end;
  1257. function tarraydef.size : longint;
  1258. begin
  1259. size:=(highrange-lowrange+1)*elesize;
  1260. end;
  1261. function tarraydef.needs_inittable : boolean;
  1262. begin
  1263. needs_inittable:=definition^.needs_inittable;
  1264. end;
  1265. procedure tarraydef.write_child_rtti_table;
  1266. begin
  1267. definition^.get_rtti_label;
  1268. end;
  1269. procedure tarraydef.write_rtti_data;
  1270. begin
  1271. rttilist^.concat(new(pai_const,init_8bit(13)));
  1272. writename;
  1273. { size of elements }
  1274. rttilist^.concat(new(pai_const,init_32bit(definition^.size)));
  1275. { count of elements }
  1276. rttilist^.concat(new(pai_const,init_32bit(highrange-lowrange+1)));
  1277. { element type }
  1278. rttilist^.concat(new(pai_const,init_symbol(strpnew(lab2str(definition^.get_rtti_label)))));
  1279. end;
  1280. {***********************************************************************************
  1281. TRECDEF
  1282. ***************************************************************************}
  1283. constructor trecdef.init(p : psymtable);
  1284. begin
  1285. tdef.init;
  1286. deftype:=recorddef;
  1287. symtable:=p;
  1288. savesize:=symtable^.datasize;
  1289. symtable^.defowner := @self;
  1290. end;
  1291. constructor trecdef.load;
  1292. var
  1293. oldread_member : boolean;
  1294. begin
  1295. tdef.load;
  1296. deftype:=recorddef;
  1297. savesize:=readlong;
  1298. oldread_member:=read_member;
  1299. read_member:=true;
  1300. symtable:=new(psymtable,loadasstruct(recordsymtable));
  1301. read_member:=oldread_member;
  1302. symtable^.defowner := @self;
  1303. end;
  1304. destructor trecdef.done;
  1305. begin
  1306. if assigned(symtable) then dispose(symtable,done);
  1307. inherited done;
  1308. end;
  1309. var
  1310. binittable : boolean;
  1311. procedure check_rec_inittable(s : psym);
  1312. begin
  1313. if (s^.typ=varsym) and (pvarsym(s)^.definition^.needs_inittable) then
  1314. binittable:=true;
  1315. end;
  1316. function trecdef.needs_inittable : boolean;
  1317. var
  1318. oldb : boolean;
  1319. begin
  1320. { there are recursive calls to needs_rtti possible, }
  1321. { so we have to change to old value how else should }
  1322. { we do that ? check_rec_rtti can't be a nested }
  1323. { procedure of needs_rtti ! }
  1324. oldb:=binittable;
  1325. binittable:=false;
  1326. symtable^.foreach(check_rec_inittable);
  1327. needs_inittable:=binittable;
  1328. binittable:=oldb;
  1329. end;
  1330. procedure trecdef.deref;
  1331. var
  1332. hp : pdef;
  1333. oldrecsyms : psymtable;
  1334. begin
  1335. oldrecsyms:=aktrecordsymtable;
  1336. aktrecordsymtable:=symtable;
  1337. { now dereference the definitions }
  1338. hp:=symtable^.rootdef;
  1339. while assigned(hp) do
  1340. begin
  1341. hp^.deref;
  1342. { set owner }
  1343. hp^.owner:=symtable;
  1344. hp:=hp^.next;
  1345. end;
  1346. {$ifdef tp}
  1347. symtable^.foreach(derefsym);
  1348. {$else}
  1349. symtable^.foreach(@derefsym);
  1350. {$endif}
  1351. aktrecordsymtable:=oldrecsyms;
  1352. end;
  1353. procedure trecdef.write;
  1354. var
  1355. oldread_member : boolean;
  1356. begin
  1357. oldread_member:=read_member;
  1358. read_member:=true;
  1359. tdef.write;
  1360. writelong(savesize);
  1361. current_ppu^.writeentry(ibrecorddef);
  1362. self.symtable^.writeasstruct;
  1363. read_member:=oldread_member;
  1364. end;
  1365. {$ifdef GDB}
  1366. Const StabRecString : pchar = Nil;
  1367. StabRecSize : longint = 0;
  1368. RecOffset : Longint = 0;
  1369. procedure addname(p : psym);
  1370. var
  1371. news, newrec : pchar;
  1372. begin
  1373. { static variables from objects are like global objects }
  1374. if ((p^.properties and sp_static)<>0) then
  1375. exit;
  1376. If p^.typ = varsym then
  1377. begin
  1378. newrec := strpnew(p^.name+':'+pvarsym(p)^.definition^.numberstring
  1379. +','+tostr(pvarsym(p)^.address*8)+','
  1380. +tostr(pvarsym(p)^.definition^.size*8)+';');
  1381. if strlen(StabRecString) + strlen(newrec) >= StabRecSize-256 then
  1382. begin
  1383. getmem(news,stabrecsize+memsizeinc);
  1384. strcopy(news,stabrecstring);
  1385. freemem(stabrecstring,stabrecsize);
  1386. stabrecsize:=stabrecsize+memsizeinc;
  1387. stabrecstring:=news;
  1388. end;
  1389. strcat(StabRecstring,newrec);
  1390. strdispose(newrec);
  1391. {This should be used for case !!}
  1392. RecOffset := RecOffset + pvarsym(p)^.definition^.size;
  1393. end;
  1394. end;
  1395. function trecdef.stabstring : pchar;
  1396. Var oldrec : pchar;
  1397. oldsize : longint;
  1398. begin
  1399. oldrec := stabrecstring;
  1400. oldsize:=stabrecsize;
  1401. GetMem(stabrecstring,memsizeinc);
  1402. stabrecsize:=memsizeinc;
  1403. strpcopy(stabRecString,'s'+tostr(savesize));
  1404. RecOffset := 0;
  1405. {$ifdef tp}
  1406. symtable^.foreach(addname);
  1407. {$else}
  1408. symtable^.foreach(@addname);
  1409. {$endif}
  1410. { FPC doesn't want to convert a char to a pchar}
  1411. { is this a bug ? }
  1412. strpcopy(strend(StabRecString),';');
  1413. stabstring := strnew(StabRecString);
  1414. Freemem(stabrecstring,stabrecsize);
  1415. stabrecstring := oldrec;
  1416. stabrecsize:=oldsize;
  1417. end;
  1418. procedure trecdef.concatstabto(asmlist : paasmoutput);
  1419. begin
  1420. if (not assigned(sym) or sym^.isusedinstab or use_dbx) and
  1421. (not is_def_stab_written) then
  1422. inherited concatstabto(asmlist);
  1423. end;
  1424. {$endif GDB}
  1425. var
  1426. count : longint;
  1427. procedure count_inittable_fields(sym : psym);{$ifndef fpc}far;{$endif}
  1428. begin
  1429. if pvarsym(sym)^.definition^.needs_inittable then
  1430. inc(count);
  1431. end;
  1432. procedure count_fields(sym : psym);{$ifndef fpc}far;{$endif}
  1433. begin
  1434. inc(count);
  1435. end;
  1436. procedure write_field_inittable(sym : psym);{$ifndef fpc}far;{$endif}
  1437. begin
  1438. if pvarsym(sym)^.definition^.needs_inittable then
  1439. begin
  1440. rttilist^.concat(new(pai_const,init_symbol(strpnew(lab2str(pvarsym(sym)^.definition^.get_inittable_label)))));
  1441. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  1442. end;
  1443. end;
  1444. procedure write_field_rtti(sym : psym);{$ifndef fpc}far;{$endif}
  1445. begin
  1446. rttilist^.concat(new(pai_const,init_symbol(strpnew(lab2str(pvarsym(sym)^.definition^.get_rtti_label)))));
  1447. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  1448. end;
  1449. procedure generate_child_inittable(sym : psym);{$ifndef fpc}far;{$endif}
  1450. begin
  1451. if (sym^.typ=varsym) and pvarsym(sym)^.definition^.needs_inittable then
  1452. { force inittable generation }
  1453. pvarsym(sym)^.definition^.get_inittable_label;
  1454. end;
  1455. procedure generate_child_rtti(sym : psym);{$ifndef fpc}far;{$endif}
  1456. begin
  1457. pvarsym(sym)^.definition^.get_rtti_label;
  1458. end;
  1459. procedure trecdef.write_child_rtti_data;
  1460. begin
  1461. symtable^.foreach(generate_child_rtti);
  1462. end;
  1463. procedure trecdef.write_child_init_data;
  1464. begin
  1465. symtable^.foreach(generate_child_inittable);
  1466. end;
  1467. procedure trecdef.write_rtti_data;
  1468. begin
  1469. rttilist^.concat(new(pai_const,init_8bit(14)));
  1470. writename;
  1471. rttilist^.concat(new(pai_const,init_32bit(size)));
  1472. count:=0;
  1473. symtable^.foreach(count_fields);
  1474. rttilist^.concat(new(pai_const,init_32bit(count)));
  1475. symtable^.foreach(write_field_rtti);
  1476. end;
  1477. procedure trecdef.write_init_data;
  1478. begin
  1479. rttilist^.concat(new(pai_const,init_8bit(14)));
  1480. writename;
  1481. rttilist^.concat(new(pai_const,init_32bit(size)));
  1482. count:=0;
  1483. symtable^.foreach(count_inittable_fields);
  1484. rttilist^.concat(new(pai_const,init_32bit(count)));
  1485. symtable^.foreach(write_field_inittable);
  1486. end;
  1487. {***********************************************************************************
  1488. TABSTRACTPROCDEF
  1489. ***************************************************************************}
  1490. constructor tabstractprocdef.init;
  1491. begin
  1492. inherited init;
  1493. para1:=nil;
  1494. {$ifdef StoreFPULevel}
  1495. fpu_used:=255;
  1496. {$endif StoreFPULevel}
  1497. options:=0;
  1498. retdef:=voiddef;
  1499. savesize:=Sizeof(pointer);
  1500. end;
  1501. destructor tabstractprocdef.done;
  1502. var
  1503. hp : pdefcoll;
  1504. begin
  1505. hp:=para1;
  1506. while assigned(hp) do
  1507. begin
  1508. para1:=hp^.next;
  1509. dispose(hp);
  1510. hp:=para1;
  1511. end;
  1512. inherited done;
  1513. end;
  1514. procedure tabstractprocdef.concatdef(p : pdef;vsp : tvarspez);
  1515. var
  1516. hp : pdefcoll;
  1517. begin
  1518. new(hp);
  1519. hp^.paratyp:=vsp;
  1520. hp^.data:=p;
  1521. hp^.next:=para1;
  1522. para1:=hp;
  1523. end;
  1524. procedure tabstractprocdef.deref;
  1525. var
  1526. hp : pdefcoll;
  1527. begin
  1528. inherited deref;
  1529. resolvedef(retdef);
  1530. hp:=para1;
  1531. while assigned(hp) do
  1532. begin
  1533. resolvedef(hp^.data);
  1534. hp:=hp^.next;
  1535. end;
  1536. end;
  1537. constructor tabstractprocdef.load;
  1538. var
  1539. last,hp : pdefcoll;
  1540. count,i : word;
  1541. begin
  1542. tdef.load;
  1543. retdef:=readdefref;
  1544. {$ifdef StoreFPULevel}
  1545. fpu_used:=readbyte;
  1546. {$endif StoreFPULevel}
  1547. options:=readlong;
  1548. count:=readword;
  1549. para1:=nil;
  1550. savesize:=Sizeof(pointer);
  1551. for i:=1 to count do
  1552. begin
  1553. new(hp);
  1554. hp^.paratyp:=tvarspez(readbyte);
  1555. hp^.data:=readdefref;
  1556. hp^.next:=nil;
  1557. if para1=nil then
  1558. para1:=hp
  1559. else
  1560. last^.next:=hp;
  1561. last:=hp;
  1562. end;
  1563. end;
  1564. function tabstractprocdef.para_size : longint;
  1565. var
  1566. pdc : pdefcoll;
  1567. l : longint;
  1568. begin
  1569. l:=0;
  1570. pdc:=para1;
  1571. while assigned(pdc) do
  1572. begin
  1573. case pdc^.paratyp of
  1574. vs_value :
  1575. l:=l+pdc^.data^.size+(pdc^.data^.size mod 2);
  1576. vs_var :
  1577. l:=l+sizeof(pointer);
  1578. vs_const :
  1579. if dont_copy_const_param(pdc^.data) then
  1580. l:=l+sizeof(pointer)
  1581. else
  1582. l:=l+pdc^.data^.size+(pdc^.data^.size mod 2);
  1583. end;
  1584. pdc:=pdc^.next;
  1585. end;
  1586. para_size:=l;
  1587. end;
  1588. procedure tabstractprocdef.write;
  1589. var
  1590. count : word;
  1591. hp : pdefcoll;
  1592. begin
  1593. tdef.write;
  1594. writedefref(retdef);
  1595. {$ifdef StoreFPULevel}
  1596. writebyte(fpu_used);
  1597. {$endif StoreFPULevel}
  1598. writelong(options);
  1599. hp:=para1;
  1600. count:=0;
  1601. while assigned(hp) do
  1602. begin
  1603. inc(count);
  1604. hp:=hp^.next;
  1605. end;
  1606. writeword(count);
  1607. hp:=para1;
  1608. while assigned(hp) do
  1609. begin
  1610. writebyte(byte(hp^.paratyp));
  1611. writedefref(hp^.data);
  1612. hp:=hp^.next;
  1613. end;
  1614. end;
  1615. function tabstractprocdef.demangled_paras : string;
  1616. var s : string;
  1617. p : pdefcoll;
  1618. begin
  1619. s:='';
  1620. p:=para1;
  1621. if assigned(p) then
  1622. begin
  1623. s:=s+'(';
  1624. while assigned(p) do
  1625. begin
  1626. if assigned(p^.data^.sym) then
  1627. s:=s+p^.data^.sym^.name
  1628. else if p^.paratyp=vs_var then
  1629. s:=s+'var'
  1630. else if p^.paratyp=vs_const then
  1631. s:=s+'const';
  1632. p:=p^.next;
  1633. if assigned(p) then
  1634. s:=s+','
  1635. else
  1636. s:=s+')';
  1637. end;
  1638. end;
  1639. demangled_paras:=s;
  1640. end;
  1641. {$ifdef GDB}
  1642. function tabstractprocdef.stabstring : pchar;
  1643. begin
  1644. stabstring := strpnew('abstractproc'+numberstring+';');
  1645. end;
  1646. procedure tabstractprocdef.concatstabto(asmlist : paasmoutput);
  1647. begin
  1648. if (not assigned(sym) or sym^.isusedinstab or use_dbx)
  1649. and not is_def_stab_written then
  1650. begin
  1651. if assigned(retdef) then forcestabto(asmlist,retdef);
  1652. inherited concatstabto(asmlist);
  1653. end;
  1654. end;
  1655. {$endif GDB}
  1656. {***********************************************************************************
  1657. TPROCDEF
  1658. ***************************************************************************}
  1659. constructor tprocdef.init;
  1660. begin
  1661. inherited init;
  1662. deftype:=procdef;
  1663. _mangledname:=nil;
  1664. nextoverloaded:=nil;
  1665. extnumber:=-1;
  1666. localst:=new(psymtable,init(localsymtable));
  1667. parast:=new(psymtable,init(parasymtable));
  1668. { this is used by insert
  1669. to check same names in parast and localst }
  1670. localst^.next:=parast;
  1671. {$ifdef UseBrowser}
  1672. defref:=nil;
  1673. lastwritten:=nil;
  1674. refcount:=0;
  1675. if (cs_browser in aktmoduleswitches) and make_ref then
  1676. begin
  1677. defref:=new(pref,init(defref,@tokenpos));
  1678. inc(refcount);
  1679. end;
  1680. lastref:=defref;
  1681. {$endif UseBrowser}
  1682. { first, we assume, that all registers are used }
  1683. {$ifdef i386}
  1684. usedregisters:=$ff;
  1685. {$endif i386}
  1686. {$ifdef m68k}
  1687. usedregisters:=$FFFF;
  1688. {$endif}
  1689. {$ifdef alpha}
  1690. usedregisters_int:=$ffffffff;
  1691. usedregisters_fpu:=$ffffffff;
  1692. {$endif alpha}
  1693. forwarddef:=true;
  1694. _class := nil;
  1695. code:=nil;
  1696. end;
  1697. constructor tprocdef.load;
  1698. var
  1699. s : string;
  1700. begin
  1701. { deftype:=procdef; this is at the wrong place !! }
  1702. inherited load;
  1703. deftype:=procdef;
  1704. {$ifdef i386}
  1705. usedregisters:=readbyte;
  1706. {$endif i386}
  1707. {$ifdef m68k}
  1708. usedregisters:=readword;
  1709. {$endif}
  1710. {$ifdef alpha}
  1711. usedregisters_int:=readlong;
  1712. usedregisters_fpu:=readlong;
  1713. {$endif alpha}
  1714. s:=readstring;
  1715. setstring(_mangledname,s);
  1716. extnumber:=readlong;
  1717. nextoverloaded:=pprocdef(readdefref);
  1718. _class := pobjectdef(readdefref);
  1719. if (cs_link_deffile in aktglobalswitches) and ((options and poexports)<>0) then
  1720. deffile.AddExport(mangledname);
  1721. parast:=nil;
  1722. localst:=nil;
  1723. forwarddef:=false;
  1724. {$ifdef UseBrowser}
  1725. lastref:=nil;
  1726. lastwritten:=nil;
  1727. defref:=nil;
  1728. refcount:=0;
  1729. {$endif UseBrowser}
  1730. end;
  1731. {$ifdef UseBrowser}
  1732. procedure tprocdef.load_references;
  1733. var
  1734. pos : tfileposinfo;
  1735. begin
  1736. while (not current_ppu^.endofentry) do
  1737. begin
  1738. readposinfo(pos);
  1739. inc(refcount);
  1740. lastref:=new(pref,init(lastref,@pos));
  1741. if refcount=1 then
  1742. defref:=lastref;
  1743. end;
  1744. end;
  1745. procedure tprocdef.write_references;
  1746. var
  1747. ref : pref;
  1748. begin
  1749. if lastwritten=lastref then
  1750. exit;
  1751. { write address of this symbol }
  1752. writedefref(@self);
  1753. { write refs }
  1754. if assigned(lastwritten) then
  1755. ref:=lastwritten
  1756. else
  1757. ref:=defref;
  1758. while assigned(ref) do
  1759. begin
  1760. writeposinfo(ref^.posinfo);
  1761. ref:=ref^.nextref;
  1762. end;
  1763. current_ppu^.writeentry(ibdefref);
  1764. lastwritten:=lastref;
  1765. end;
  1766. procedure tprocdef.add_to_browserlog;
  1767. begin
  1768. if assigned(defref) then
  1769. begin
  1770. Browse.AddLog('***'+mangledname);
  1771. Browse.AddLogRefs(defref);
  1772. if assigned(parast) then
  1773. parast^.writebrowserlog;
  1774. if assigned(localst) then
  1775. localst^.writebrowserlog;
  1776. end;
  1777. end;
  1778. {$endif UseBrowser}
  1779. destructor tprocdef.done;
  1780. begin
  1781. {$ifdef UseBrowser}
  1782. if assigned(defref) then
  1783. dispose(defref,done);
  1784. {$endif UseBrowser}
  1785. if assigned(parast) then
  1786. dispose(parast,done);
  1787. if assigned(localst) then
  1788. dispose(localst,done);
  1789. if
  1790. {$ifdef tp}
  1791. not(use_big) and
  1792. {$endif}
  1793. assigned(_mangledname) then
  1794. strdispose(_mangledname);
  1795. inherited done;
  1796. end;
  1797. procedure tprocdef.write;
  1798. begin
  1799. inherited write;
  1800. {$ifdef i386}
  1801. writebyte(usedregisters);
  1802. {$endif i386}
  1803. {$ifdef m68k}
  1804. writeword(usedregisters);
  1805. {$endif}
  1806. {$ifdef alpha}
  1807. writelong(usedregisters_int);
  1808. writelong(usedregisters_fpu);
  1809. {$endif alpha}
  1810. writestring(mangledname);
  1811. writelong(extnumber);
  1812. if (options and pooperator) = 0 then
  1813. writedefref(nextoverloaded)
  1814. else
  1815. begin
  1816. { only write the overloads from the same unit }
  1817. if nextoverloaded^.owner=owner then
  1818. writedefref(nextoverloaded)
  1819. else
  1820. writedefref(nil);
  1821. end;
  1822. writedefref(_class);
  1823. if (options and poinline) <> 0 then
  1824. begin
  1825. { we need to save
  1826. - the para and the local symtable
  1827. - the code ptree !! PM
  1828. writesymtable(parast);
  1829. writesymtable(localst);
  1830. writeptree(ptree(code));
  1831. }
  1832. end;
  1833. current_ppu^.writeentry(ibprocdef);
  1834. end;
  1835. {$ifdef GDB}
  1836. procedure addparaname(p : psym);
  1837. var vs : char;
  1838. begin
  1839. if pvarsym(p)^.varspez = vs_value then vs := '1'
  1840. else vs := '0';
  1841. strpcopy(strend(StabRecString),p^.name+':'+pvarsym(p)^.definition^.numberstring+','+vs+';');
  1842. end;
  1843. function tprocdef.stabstring : pchar;
  1844. var param : pdefcoll;
  1845. i : word;
  1846. vartyp : char;
  1847. oldrec : pchar;
  1848. begin
  1849. oldrec := stabrecstring;
  1850. getmem(StabRecString,1024);
  1851. param := para1;
  1852. i := 0;
  1853. while assigned(param) do
  1854. begin
  1855. inc(i);
  1856. param := param^.next;
  1857. end;
  1858. strpcopy(StabRecString,'f'+retdef^.numberstring);
  1859. if i>0 then
  1860. begin
  1861. strpcopy(strend(StabRecString),','+tostr(i)+';');
  1862. if assigned(parast) then
  1863. {$IfDef TP}
  1864. parast^.foreach(addparaname)
  1865. {$Else}
  1866. parast^.foreach(@addparaname)
  1867. {$EndIf}
  1868. else
  1869. begin
  1870. param := para1;
  1871. i := 0;
  1872. while assigned(param) do
  1873. begin
  1874. inc(i);
  1875. if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
  1876. {Here we have lost the parameter names !!}
  1877. {using lower case parameters }
  1878. strpcopy(strend(stabrecstring),'p'+tostr(i)
  1879. +':'+param^.data^.numberstring+','+vartyp+';');
  1880. param := param^.next;
  1881. end;
  1882. end;
  1883. {strpcopy(strend(StabRecString),';');}
  1884. end;
  1885. stabstring := strnew(stabrecstring);
  1886. freemem(stabrecstring,1024);
  1887. stabrecstring := oldrec;
  1888. end;
  1889. procedure tprocdef.concatstabto(asmlist : paasmoutput);
  1890. begin
  1891. end;
  1892. {$endif GDB}
  1893. procedure tprocdef.deref;
  1894. begin
  1895. inherited deref;
  1896. resolvedef(pdef(nextoverloaded));
  1897. resolvedef(pdef(_class));
  1898. end;
  1899. function tprocdef.mangledname : string;
  1900. {$ifdef tp}
  1901. var
  1902. oldpos : longint;
  1903. s : string;
  1904. b : byte;
  1905. {$endif tp}
  1906. begin
  1907. {$ifdef tp}
  1908. if use_big then
  1909. begin
  1910. symbolstream.seek(longint(_mangledname));
  1911. symbolstream.read(b,1);
  1912. symbolstream.read(s[1],b);
  1913. s[0]:=chr(b);
  1914. mangledname:=s;
  1915. end
  1916. else
  1917. {$endif}
  1918. mangledname:=strpas(_mangledname);
  1919. end;
  1920. {$IfDef GDB}
  1921. function tprocdef.cplusplusmangledname : string;
  1922. var
  1923. s,s2 : string;
  1924. param : pdefcoll;
  1925. begin
  1926. s := sym^.name;
  1927. if _class <> nil then
  1928. begin
  1929. s2 := _class^.name^;
  1930. s := s+'__'+tostr(length(s2))+s2;
  1931. end else s := s + '_';
  1932. param := para1;
  1933. while assigned(param) do
  1934. begin
  1935. s2 := param^.data^.sym^.name;
  1936. s := s+tostr(length(s2))+s2;
  1937. param := param^.next;
  1938. end;
  1939. cplusplusmangledname:=s;
  1940. end;
  1941. {$EndIf GDB}
  1942. procedure tprocdef.setmangledname(const s : string);
  1943. begin
  1944. if {$ifdef tp}not(use_big) and{$endif} (assigned(_mangledname)) then
  1945. strdispose(_mangledname);
  1946. setstring(_mangledname,s);
  1947. {$ifdef UseBrowser}
  1948. if assigned(parast) then
  1949. begin
  1950. stringdispose(parast^.name);
  1951. parast^.name:=stringdup('args of '+s);
  1952. end;
  1953. if assigned(localst) then
  1954. begin
  1955. stringdispose(localst^.name);
  1956. localst^.name:=stringdup('locals of '+s);
  1957. end;
  1958. {$endif UseBrowser}
  1959. end;
  1960. {***********************************************************************************
  1961. TPROCVARDEF
  1962. ***************************************************************************}
  1963. constructor tprocvardef.init;
  1964. begin
  1965. inherited init;
  1966. deftype:=procvardef;
  1967. end;
  1968. constructor tprocvardef.load;
  1969. begin
  1970. inherited load;
  1971. deftype:=procvardef;
  1972. end;
  1973. procedure tprocvardef.write;
  1974. begin
  1975. { here we cannot get a real good value so just give something }
  1976. { plausible (PM) }
  1977. {$ifdef StoreFPULevel}
  1978. if is_fpu(retdef) then
  1979. fpu_used:=2
  1980. else
  1981. fpu_used:=0;
  1982. {$endif StoreFPULevel}
  1983. inherited write;
  1984. current_ppu^.writeentry(ibprocvardef);
  1985. end;
  1986. function tprocvardef.size : longint;
  1987. begin
  1988. if (options and pomethodpointer)=0 then
  1989. size:=sizeof(pointer)
  1990. else
  1991. size:=2*sizeof(pointer);
  1992. end;
  1993. {$ifdef GDB}
  1994. function tprocvardef.stabstring : pchar;
  1995. var
  1996. nss : pchar;
  1997. i : word;
  1998. vartyp : char;
  1999. pst : pchar;
  2000. param : pdefcoll;
  2001. begin
  2002. i := 0;
  2003. param := para1;
  2004. while assigned(param) do
  2005. begin
  2006. inc(i);
  2007. param := param^.next;
  2008. end;
  2009. getmem(nss,1024);
  2010. strpcopy(nss,'f'+retdef^.numberstring+','+tostr(i)+';');
  2011. param := para1;
  2012. i := 0;
  2013. while assigned(param) do
  2014. begin
  2015. inc(i);
  2016. if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
  2017. {Here we have lost the parameter names !!}
  2018. pst := strpnew('p'+tostr(i)+':'+param^.data^.numberstring+','+vartyp+';');
  2019. strcat(nss,pst);
  2020. strdispose(pst);
  2021. param := param^.next;
  2022. end;
  2023. {strpcopy(strend(nss),';');}
  2024. stabstring := strnew(nss);
  2025. freemem(nss,1024);
  2026. end;
  2027. procedure tprocvardef.concatstabto(asmlist : paasmoutput);
  2028. begin
  2029. if ( not assigned(sym) or sym^.isusedinstab or use_dbx)
  2030. and not is_def_stab_written then
  2031. inherited concatstabto(asmlist);
  2032. is_def_stab_written:=true;
  2033. end;
  2034. {$endif GDB}
  2035. procedure tprocvardef.write_rtti_data;
  2036. begin
  2037. {!!!!!!!}
  2038. end;
  2039. procedure tprocvardef.write_child_rtti_data;
  2040. begin
  2041. {!!!!!!!!}
  2042. end;
  2043. function tprocvardef.is_publishable : boolean;
  2044. begin
  2045. is_publishable:=(options and pomethodpointer)<>0;
  2046. end;
  2047. {***************************************************************************
  2048. TOBJECTDEF
  2049. ***************************************************************************}
  2050. {$ifdef GDB}
  2051. const
  2052. vtabletype : word = 0;
  2053. vtableassigned : boolean = false;
  2054. {$endif GDB}
  2055. constructor tobjectdef.init(const n : string;c : pobjectdef);
  2056. begin
  2057. tdef.init;
  2058. deftype:=objectdef;
  2059. childof:=c;
  2060. options:=0;
  2061. { privatesyms:=new(psymtable,init(objectsymtable));
  2062. protectedsyms:=new(psymtable,init(objectsymtable)); }
  2063. publicsyms:=new(psymtable,init(objectsymtable));
  2064. publicsyms^.name := stringdup(n);
  2065. { add the data of the anchestor class }
  2066. if assigned(childof) then
  2067. begin
  2068. publicsyms^.datasize:=
  2069. publicsyms^.datasize-4+childof^.publicsyms^.datasize;
  2070. end;
  2071. name:=stringdup(n);
  2072. savesize := publicsyms^.datasize;
  2073. publicsyms^.defowner:=@self;
  2074. end;
  2075. constructor tobjectdef.load;
  2076. var
  2077. oldread_member : boolean;
  2078. begin
  2079. tdef.load;
  2080. deftype:=objectdef;
  2081. savesize:=readlong;
  2082. name:=stringdup(readstring);
  2083. childof:=pobjectdef(readdefref);
  2084. options:=readlong;
  2085. oldread_member:=read_member;
  2086. read_member:=true;
  2087. object_options:=true;
  2088. publicsyms:=new(psymtable,loadasstruct(objectsymtable));
  2089. object_options:=false;
  2090. read_member:=oldread_member;
  2091. publicsyms^.defowner:=@self;
  2092. publicsyms^.datasize:=savesize;
  2093. publicsyms^.name := stringdup(name^);
  2094. { handles the predefined class tobject }
  2095. { the last TOBJECT which is loaded gets }
  2096. { it ! }
  2097. if (name^='TOBJECT') and not(cs_compilesystem in aktmoduleswitches) and
  2098. isclass and (childof=pointer($ffffffff)) then
  2099. class_tobject:=@self;
  2100. end;
  2101. procedure tobjectdef.check_forwards;
  2102. begin
  2103. publicsyms^.check_forwards;
  2104. if (options and oo_isforward)<>0 then
  2105. begin
  2106. { ok, in future, the forward can be resolved }
  2107. Message1(sym_e_class_forward_not_resolved,name^);
  2108. options:=options and not(oo_isforward);
  2109. end;
  2110. end;
  2111. destructor tobjectdef.done;
  2112. begin
  2113. {!!!!
  2114. if assigned(privatesyms) then
  2115. dispose(privatesyms,done);
  2116. if assigned(protectedsyms) then
  2117. dispose(protectedsyms,done); }
  2118. if assigned(publicsyms) then
  2119. dispose(publicsyms,done);
  2120. if (options and oo_isforward)<>0 then
  2121. Message1(sym_e_class_forward_not_resolved,name^);
  2122. stringdispose(name);
  2123. tdef.done;
  2124. end;
  2125. { true, if self inherits from d (or if they are equal) }
  2126. function tobjectdef.isrelated(d : pobjectdef) : boolean;
  2127. var
  2128. hp : pobjectdef;
  2129. begin
  2130. hp:=@self;
  2131. while assigned(hp) do
  2132. begin
  2133. if hp=d then
  2134. begin
  2135. isrelated:=true;
  2136. exit;
  2137. end;
  2138. hp:=hp^.childof;
  2139. end;
  2140. isrelated:=false;
  2141. end;
  2142. function tobjectdef.size : longint;
  2143. begin
  2144. if (options and oois_class)<>0 then
  2145. size:=sizeof(pointer)
  2146. else
  2147. size:=publicsyms^.datasize;
  2148. end;
  2149. procedure tobjectdef.deref;
  2150. var
  2151. hp : pdef;
  2152. oldrecsyms : psymtable;
  2153. begin
  2154. resolvedef(pdef(childof));
  2155. oldrecsyms:=aktrecordsymtable;
  2156. aktrecordsymtable:=publicsyms;
  2157. { nun die Definitionen dereferenzieren }
  2158. hp:=publicsyms^.rootdef;
  2159. while assigned(hp) do
  2160. begin
  2161. hp^.deref;
  2162. { set owner }
  2163. hp^.owner:=publicsyms;
  2164. hp:=hp^.next;
  2165. end;
  2166. {$ifdef tp}
  2167. publicsyms^.foreach(derefsym);
  2168. {$else}
  2169. publicsyms^.foreach(@derefsym);
  2170. {$endif}
  2171. aktrecordsymtable:=oldrecsyms;
  2172. end;
  2173. function tobjectdef.vmt_mangledname : string;
  2174. {DM: I get a nil pointer on the owner name. I don't know if this
  2175. mayhappen, and I have therefore fixed the problem by doing nil pointer
  2176. checks.}
  2177. var s1,s2:string;
  2178. begin
  2179. if owner^.name=nil then
  2180. s1:=''
  2181. else
  2182. s1:=owner^.name^;
  2183. if name=nil then
  2184. s2:=''
  2185. else
  2186. s2:=name^;
  2187. vmt_mangledname:='VMT_'+s1+'$_'+s2;
  2188. end;
  2189. function tobjectdef.rtti_name : string;
  2190. var
  2191. s1,s2:string;
  2192. begin
  2193. if owner^.name=nil then
  2194. s1:=''
  2195. else
  2196. s1:=owner^.name^;
  2197. if name=nil then
  2198. s2:=''
  2199. else
  2200. s2:=name^;
  2201. rtti_name:='RTTI_'+s1+'$_'+s2;
  2202. end;
  2203. function tobjectdef.isclass : boolean;
  2204. begin
  2205. isclass:=(options and oois_class)<>0;
  2206. end;
  2207. procedure tobjectdef.write;
  2208. var
  2209. oldread_member : boolean;
  2210. begin
  2211. tdef.write;
  2212. writelong(size);
  2213. writestring(name^);
  2214. writedefref(childof);
  2215. writelong(options);
  2216. current_ppu^.writeentry(ibobjectdef);
  2217. oldread_member:=read_member;
  2218. read_member:=true;
  2219. object_options:=true;
  2220. publicsyms^.writeasstruct;
  2221. object_options:=false;
  2222. read_member:=oldread_member;
  2223. end;
  2224. {$ifdef GDB}
  2225. procedure addprocname(p :psym);
  2226. var virtualind,argnames : string;
  2227. news, newrec : pchar;
  2228. pd,ipd : pprocdef;
  2229. lindex : longint;
  2230. para : pdefcoll;
  2231. arglength : byte;
  2232. sp : char;
  2233. begin
  2234. If p^.typ = procsym then
  2235. begin
  2236. pd := pprocsym(p)^.definition;
  2237. { this will be used for full implementation of object stabs
  2238. not yet done }
  2239. ipd := pd;
  2240. while assigned(ipd^.nextoverloaded) do ipd := ipd^.nextoverloaded;
  2241. if (pd^.options and povirtualmethod) <> 0 then
  2242. begin
  2243. lindex := pd^.extnumber;
  2244. {doesnt seem to be necessary
  2245. lindex := lindex or $80000000;}
  2246. virtualind := '*'+tostr(lindex)+';'+ipd^._class^.numberstring+';'
  2247. end else virtualind := '.';
  2248. { arguments are not listed here }
  2249. {we don't need another definition}
  2250. para := pd^.para1;
  2251. argnames := '';
  2252. while assigned(para) do
  2253. begin
  2254. if para^.data^.deftype = formaldef then
  2255. begin
  2256. if para^.paratyp=vs_var then
  2257. argnames := argnames+'3var'
  2258. else if para^.paratyp=vs_const then
  2259. argnames:=argnames+'5const';
  2260. end
  2261. else
  2262. begin
  2263. { if the arg definition is like (v: ^byte;..
  2264. there is no sym attached to data !!! }
  2265. if assigned(para^.data^.sym) then
  2266. begin
  2267. arglength := length(para^.data^.sym^.name);
  2268. argnames := argnames + tostr(arglength)+para^.data^.sym^.name;
  2269. end
  2270. else
  2271. begin
  2272. argnames:=argnames+'11unnamedtype';
  2273. end;
  2274. end;
  2275. para := para^.next;
  2276. end;
  2277. ipd^.is_def_stab_written := true;
  2278. { here 2A must be changed for private and protected }
  2279. { 0 is private 1 protected and 2 public }
  2280. if (p^.properties and sp_private)<>0 then sp:='0'
  2281. else if (p^.properties and sp_protected)<>0 then sp:='1'
  2282. else sp:='2';
  2283. newrec := strpnew(p^.name+'::'+ipd^.numberstring
  2284. +'=##'+pd^.retdef^.numberstring+';:'+argnames+';'+sp+'A'
  2285. +virtualind+';');
  2286. { get spare place for a string at the end }
  2287. if strlen(StabRecString) + strlen(newrec) >= StabRecSize-256 then
  2288. begin
  2289. getmem(news,stabrecsize+memsizeinc);
  2290. strcopy(news,stabrecstring);
  2291. freemem(stabrecstring,stabrecsize);
  2292. stabrecsize:=stabrecsize+memsizeinc;
  2293. stabrecstring:=news;
  2294. end;
  2295. strcat(StabRecstring,newrec);
  2296. {freemem(newrec,memsizeinc); }
  2297. strdispose(newrec);
  2298. {This should be used for case !!}
  2299. RecOffset := RecOffset + pd^.size;
  2300. end;
  2301. end;
  2302. function tobjectdef.stabstring : pchar;
  2303. var anc : pobjectdef;
  2304. oldrec : pchar;
  2305. oldrecsize : longint;
  2306. str_end : string;
  2307. begin
  2308. oldrec := stabrecstring;
  2309. oldrecsize:=stabrecsize;
  2310. stabrecsize:=memsizeinc;
  2311. GetMem(stabrecstring,stabrecsize);
  2312. strpcopy(stabRecString,'s'+tostr(size));
  2313. if assigned(childof) then
  2314. {only one ancestor not virtual, public, at base offset 0 }
  2315. { !1 , 0 2 0 , }
  2316. strpcopy(strend(stabrecstring),'!1,020,'+childof^.numberstring+';');
  2317. {virtual table to implement yet}
  2318. RecOffset := 0;
  2319. {$ifdef tp}
  2320. publicsyms^.foreach(addname);
  2321. {$else}
  2322. publicsyms^.foreach(@addname);
  2323. {$endif tp}
  2324. if (options and oo_hasvirtual) <> 0 then
  2325. if not assigned(childof) or ((childof^.options and oo_hasvirtual) = 0) then
  2326. begin
  2327. str_end:='$vf'+numberstring+':'+typeglobalnumber('vtblarray')+',0;';
  2328. strpcopy(strend(stabrecstring),'$vf'+numberstring+':'+typeglobalnumber('vtblarray')+',0;');
  2329. end;
  2330. {$ifdef tp}
  2331. publicsyms^.foreach(addprocname);
  2332. {$else}
  2333. publicsyms^.foreach(@addprocname);
  2334. {$endif tp }
  2335. if (options and oo_hasvirtual) <> 0 then
  2336. begin
  2337. anc := @self;
  2338. while assigned(anc^.childof) and ((anc^.childof^.options and oo_hasvirtual) <> 0) do
  2339. anc := anc^.childof;
  2340. str_end:=';~%'+anc^.numberstring+';';
  2341. end
  2342. else
  2343. str_end:=';';
  2344. strpcopy(strend(stabrecstring),str_end);
  2345. stabstring := strnew(StabRecString);
  2346. freemem(stabrecstring,stabrecsize);
  2347. stabrecstring := oldrec;
  2348. stabrecsize:=oldrecsize;
  2349. end;
  2350. {$endif GDB}
  2351. procedure tobjectdef.write_child_init_data;
  2352. begin
  2353. end;
  2354. procedure tobjectdef.write_init_data;
  2355. begin
  2356. if isclass then
  2357. rttilist^.concat(new(pai_const,init_8bit(tkclass)))
  2358. else
  2359. rttilist^.concat(new(pai_const,init_8bit(tkobject)));
  2360. { generate the name }
  2361. rttilist^.concat(new(pai_const,init_8bit(length(name^))));
  2362. rttilist^.concat(new(pai_string,init(name^)));
  2363. rttilist^.concat(new(pai_const,init_32bit(size)));
  2364. count:=0;
  2365. publicsyms^.foreach(count_inittable_fields);
  2366. rttilist^.concat(new(pai_const,init_32bit(count)));
  2367. publicsyms^.foreach(write_field_inittable);
  2368. end;
  2369. function tobjectdef.needs_inittable : boolean;
  2370. var
  2371. oldb : boolean;
  2372. begin
  2373. { there are recursive calls to needs_inittable possible, }
  2374. { so we have to change to old value how else should }
  2375. { we do that ? check_rec_rtti can't be a nested }
  2376. { procedure of needs_rtti ! }
  2377. oldb:=binittable;
  2378. binittable:=false;
  2379. publicsyms^.foreach(check_rec_inittable);
  2380. needs_inittable:=binittable;
  2381. binittable:=oldb;
  2382. end;
  2383. procedure count_published_properties(sym : psym);{$ifndef fpc}far;{$endif}
  2384. begin
  2385. if (sym^.typ=propertysym) and ((sym^.properties and sp_published)<>0) then
  2386. inc(count);
  2387. end;
  2388. procedure write_property_info(sym : psym);{$ifndef fpc}far;{$endif}
  2389. var
  2390. proctypesinfo : byte;
  2391. procedure writeproc(sym : psym;def : pdef;shiftvalue : byte);
  2392. var
  2393. typvalue : byte;
  2394. begin
  2395. if not(assigned(sym)) then
  2396. begin
  2397. rttilist^.concat(new(pai_const,init_32bit(1)));
  2398. typvalue:=3;
  2399. end
  2400. else if sym^.typ=varsym then
  2401. begin
  2402. rttilist^.concat(new(pai_const,init_32bit(
  2403. pvarsym(sym)^.address)));
  2404. typvalue:=0;
  2405. end
  2406. else
  2407. begin
  2408. if (pprocdef(def)^.options and povirtualmethod)=0 then
  2409. begin
  2410. rttilist^.concat(new(pai_const,init_symbol(strpnew(pprocdef(def)^.mangledname))));
  2411. typvalue:=1;
  2412. end
  2413. else
  2414. begin
  2415. { virtual method, write vmt offset }
  2416. rttilist^.concat(new(pai_const,init_32bit(pprocdef(def)^.extnumber*4+12)));
  2417. typvalue:=2;
  2418. end;
  2419. end;
  2420. proctypesinfo:=proctypesinfo or (typvalue shl shiftvalue);
  2421. end;
  2422. begin
  2423. proctypesinfo:=0;
  2424. if (sym^.typ=propertysym) and ((sym^.properties and sp_published)<>0) then
  2425. begin
  2426. rttilist^.concat(new(pai_const,init_symbol(strpnew(lab2str(ppropertysym(sym)^.proptype^.get_rtti_label)))));
  2427. writeproc(ppropertysym(sym)^.readaccesssym,ppropertysym(sym)^.readaccessdef,0);
  2428. writeproc(ppropertysym(sym)^.writeaccesssym,ppropertysym(sym)^.writeaccessdef,2);
  2429. { isn't it stored ? }
  2430. if (ppropertysym(sym)^.options and ppo_stored)=0 then
  2431. begin
  2432. rttilist^.concat(new(pai_const,init_32bit(1)));
  2433. proctypesinfo:=proctypesinfo or (3 shl 4);
  2434. end
  2435. else
  2436. writeproc(ppropertysym(sym)^.storedsym,ppropertysym(sym)^.storeddef,4);
  2437. rttilist^.concat(new(pai_const,init_32bit(ppropertysym(sym)^.index)));
  2438. rttilist^.concat(new(pai_const,init_32bit(ppropertysym(sym)^.default)));
  2439. rttilist^.concat(new(pai_const,init_16bit(count)));
  2440. inc(count);
  2441. rttilist^.concat(new(pai_const,init_8bit(proctypesinfo)));
  2442. rttilist^.concat(new(pai_const,init_8bit(length(ppropertysym(sym)^.name))));
  2443. rttilist^.concat(new(pai_string,init(ppropertysym(sym)^.name)));
  2444. end;
  2445. end;
  2446. procedure generate_published_child_rtti(sym : psym);{$ifndef fpc}far;{$endif}
  2447. begin
  2448. if (sym^.typ=propertysym) and ((sym^.properties and sp_published)<>0) then
  2449. ppropertysym(sym)^.proptype^.get_rtti_label;
  2450. end;
  2451. procedure tobjectdef.write_child_rtti_data;
  2452. begin
  2453. publicsyms^.foreach(generate_published_child_rtti);
  2454. end;
  2455. procedure tobjectdef.generate_rtti;
  2456. begin
  2457. has_rtti:=true;
  2458. getlabel(rtti_label);
  2459. write_child_rtti_data;
  2460. rttilist^.concat(new(pai_symbol,init_global(rtti_name)));
  2461. rttilist^.concat(new(pai_label,init(rtti_label)));
  2462. write_rtti_data;
  2463. end;
  2464. function tobjectdef.next_free_name_index : longint;
  2465. var
  2466. i : longint;
  2467. begin
  2468. if assigned(childof) and ((childof^.options and oo_can_have_published)<>0) then
  2469. i:=childof^.next_free_name_index
  2470. else
  2471. i:=0;
  2472. count:=0;
  2473. publicsyms^.foreach(count_published_properties);
  2474. next_free_name_index:=i+count;
  2475. end;
  2476. procedure tobjectdef.write_rtti_data;
  2477. begin
  2478. if isclass then
  2479. rttilist^.concat(new(pai_const,init_8bit(tkclass)))
  2480. else
  2481. rttilist^.concat(new(pai_const,init_8bit(tkobject)));
  2482. { generate the name }
  2483. rttilist^.concat(new(pai_const,init_8bit(length(name^))));
  2484. rttilist^.concat(new(pai_string,init(name^)));
  2485. { write class type }
  2486. rttilist^.concat(new(pai_const,init_symbol(strpnew(vmt_mangledname))));
  2487. { write owner typeinfo }
  2488. if assigned(childof) and ((childof^.options and oo_can_have_published)<>0) then
  2489. rttilist^.concat(new(pai_const,init_symbol(strpnew(lab2str(childof^.get_rtti_label)))))
  2490. else
  2491. rttilist^.concat(new(pai_const,init_32bit(0)));
  2492. { write published properties count }
  2493. count:=0;
  2494. publicsyms^.foreach(count_published_properties);
  2495. rttilist^.concat(new(pai_const,init_16bit(count)));
  2496. { write unit name }
  2497. if assigned(owner^.name) then
  2498. begin
  2499. rttilist^.concat(new(pai_const,init_8bit(length(owner^.name^))));
  2500. rttilist^.concat(new(pai_string,init(owner^.name^)));
  2501. end
  2502. else
  2503. rttilist^.concat(new(pai_const,init_8bit(0)));
  2504. { count is used to write nameindex }
  2505. { but we need an offset of the owner }
  2506. { to give each property an own slot }
  2507. if assigned(childof) and ((childof^.options and oo_can_have_published)<>0) then
  2508. count:=childof^.next_free_name_index
  2509. else
  2510. count:=0;
  2511. publicsyms^.foreach(write_property_info);
  2512. end;
  2513. function tobjectdef.is_publishable : boolean;
  2514. begin
  2515. is_publishable:=isclass;
  2516. end;
  2517. {****************************************************************************
  2518. TERRORDEF
  2519. ****************************************************************************}
  2520. constructor terrordef.init;
  2521. begin
  2522. tdef.init;
  2523. deftype:=errordef;
  2524. end;
  2525. {$ifdef GDB}
  2526. function terrordef.stabstring : pchar;
  2527. begin
  2528. stabstring:=strpnew('error'+numberstring);
  2529. end;
  2530. {$endif GDB}
  2531. {
  2532. $Log$
  2533. Revision 1.38 1998-09-07 23:10:23 florian
  2534. * a lot of stuff fixed regarding rtti and publishing of properties,
  2535. basics should now work
  2536. Revision 1.37 1998/09/07 19:33:24 florian
  2537. + some stuff for property rtti added:
  2538. - NameIndex of the TPropInfo record is now written correctly
  2539. - the DEFAULT/NODEFAULT keyword is supported now
  2540. - the default value and the storedsym/def are now written to
  2541. the PPU fiel
  2542. Revision 1.36 1998/09/07 17:37:01 florian
  2543. * first fixes for published properties
  2544. Revision 1.35 1998/09/06 22:42:02 florian
  2545. + rtti genreation for properties added
  2546. Revision 1.34 1998/09/04 18:15:02 peter
  2547. * filedef updated
  2548. Revision 1.33 1998/09/03 17:08:49 pierre
  2549. * better lines for stabs
  2550. (no scroll back to if before else part
  2551. no return to case line at jump outside case)
  2552. + source lines also if not in order
  2553. Revision 1.32 1998/09/03 16:03:20 florian
  2554. + rtti generation
  2555. * init table generation changed
  2556. Revision 1.31 1998/09/02 15:14:28 peter
  2557. * enum packing changed from len to max
  2558. Revision 1.30 1998/09/01 17:37:29 peter
  2559. * removed debug writeln :(
  2560. Revision 1.29 1998/09/01 12:53:25 peter
  2561. + aktpackenum
  2562. Revision 1.28 1998/09/01 07:54:22 pierre
  2563. * UseBrowser a little updated (might still be buggy !!)
  2564. * bug in psub.pas in function specifier removed
  2565. * stdcall allowed in interface and in implementation
  2566. (FPC will not yet complain if it is missing in either part
  2567. because stdcall is only a dummy !!)
  2568. Revision 1.27 1998/08/28 12:51:43 florian
  2569. + ansistring to pchar type cast fixed
  2570. Revision 1.26 1998/08/25 12:42:44 pierre
  2571. * CDECL changed to CVAR for variables
  2572. specifications are read in structures also
  2573. + started adding GPC compatibility mode ( option -Sp)
  2574. * names changed to lowercase
  2575. Revision 1.25 1998/08/23 21:04:38 florian
  2576. + rtti generation for classes added
  2577. + new/dispose do now also a call to INITIALIZE/FINALIZE, if necessaray
  2578. Revision 1.24 1998/08/20 12:53:26 peter
  2579. * object_options are always written for object syms
  2580. Revision 1.23 1998/08/19 00:42:42 peter
  2581. + subrange types for enums
  2582. + checking for bounds type with ranges
  2583. Revision 1.22 1998/08/17 10:10:10 peter
  2584. - removed OLDPPU
  2585. Revision 1.21 1998/08/10 14:50:28 peter
  2586. + localswitches, moduleswitches, globalswitches splitting
  2587. Revision 1.20 1998/07/18 22:54:30 florian
  2588. * some ansi/wide/longstring support fixed:
  2589. o parameter passing
  2590. o returning as result from functions
  2591. Revision 1.19 1998/07/14 14:47:05 peter
  2592. * released NEWINPUT
  2593. Revision 1.18 1998/07/10 10:51:04 peter
  2594. * m68k updates
  2595. Revision 1.16 1998/07/07 11:20:13 peter
  2596. + NEWINPUT for a better inputfile and scanner object
  2597. Revision 1.15 1998/06/24 14:48:37 peter
  2598. * ifdef newppu -> ifndef oldppu
  2599. Revision 1.14 1998/06/16 08:56:31 peter
  2600. + targetcpu
  2601. * cleaner pmodules for newppu
  2602. Revision 1.13 1998/06/15 15:38:09 pierre
  2603. * small bug in systems.pas corrected
  2604. + operators in different units better hanlded
  2605. Revision 1.12 1998/06/15 14:30:12 daniel
  2606. * Reverted my changes.
  2607. Revision 1.10 1998/06/13 00:10:16 peter
  2608. * working browser and newppu
  2609. * some small fixes against crashes which occured in bp7 (but not in
  2610. fpc?!)
  2611. Revision 1.9 1998/06/12 14:10:37 michael
  2612. * Fixed wrong code for ansistring
  2613. Revision 1.8 1998/06/11 10:11:58 peter
  2614. * -gb works again
  2615. Revision 1.7 1998/06/07 15:30:25 florian
  2616. + first working rtti
  2617. + data init/final. for local variables
  2618. Revision 1.6 1998/06/05 14:37:37 pierre
  2619. * fixes for inline for operators
  2620. * inline procedure more correctly restricted
  2621. Revision 1.5 1998/06/04 23:52:01 peter
  2622. * m68k compiles
  2623. + .def file creation moved to gendef.pas so it could also be used
  2624. for win32
  2625. Revision 1.4 1998/06/04 09:55:45 pierre
  2626. * demangled name of procsym reworked to become independant of the mangling
  2627. scheme
  2628. Revision 1.3 1998/06/03 22:49:03 peter
  2629. + wordbool,longbool
  2630. * rename bis,von -> high,low
  2631. * moved some systemunit loading/creating to psystem.pas
  2632. Revision 1.2 1998/05/31 14:13:37 peter
  2633. * fixed call bugs with assembler readers
  2634. + OPR_SYMBOL to hold a symbol in the asm parser
  2635. * fixed staticsymtable vars which were acessed through %ebp instead of
  2636. name
  2637. Revision 1.1 1998/05/27 19:45:09 peter
  2638. * symtable.pas splitted into includefiles
  2639. * symtable adapted for $ifndef OLDPPU
  2640. }