symdef.inc 110 KB

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