symdef.inc 113 KB

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