symdef.inc 107 KB

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