symdef.inc 108 KB

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