symdef.inc 102 KB

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