2
0

symdef.inc 132 KB

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