symdef.inc 120 KB

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