symdef.inc 107 KB

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