ppudump.pp 119 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958
  1. {
  2. Copyright (c) 1998-2013 by the FPC Development Team
  3. Dumps the contents of a FPC unit file (PPU File)
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************}
  16. program ppudump;
  17. {$i fpcdefs.inc}
  18. {$H+}
  19. {$define IN_PPUDUMP}
  20. uses
  21. { do NOT add symconst or globtype to make merging easier }
  22. { do include symconst and globtype now before splitting 2.5 PM 2011-06-15 }
  23. SysUtils,
  24. constexp,
  25. symconst,
  26. ppu,
  27. entfile,
  28. systems,
  29. globals,
  30. globtype,
  31. widestr,
  32. tokens,
  33. version,
  34. ppuout,
  35. ppujson,
  36. ppuxml;
  37. const
  38. Title = 'PPU-Analyser';
  39. Copyright = 'Copyright (c) 1998-2013 by the Free Pascal Development Team';
  40. { verbosity }
  41. v_none = $0;
  42. v_header = $1;
  43. v_defs = $2;
  44. v_syms = $4;
  45. v_interface = $8;
  46. v_implementation = $10;
  47. // v_browser = $20;
  48. v_all = $ff;
  49. { not needed anymore $i systems.inc }
  50. { List of all supported cpus }
  51. const
  52. CpuTxt : array[tsystemcpu] of string[9]=
  53. (
  54. { 0 } 'none',
  55. { 1 } 'i386',
  56. { 2 } 'm68k',
  57. { 3 } 'alpha',
  58. { 4 } 'powerpc',
  59. { 5 } 'sparc',
  60. { 6 } 'vis',
  61. { 7 } 'ia64',
  62. { 8 } 'x86_64',
  63. { 9 } 'mipseb',
  64. { 10 } 'arm',
  65. { 11 } 'powerpc64',
  66. { 12 } 'avr',
  67. { 13 } 'mipsel',
  68. { 14 } 'jvm',
  69. { 15 } 'i8086',
  70. { 16 } 'aarch64'
  71. );
  72. { List of all supported system-cpu couples }
  73. const
  74. Targets : array[tsystem] of string[18]=(
  75. { 0 } 'none',
  76. { 1 } 'GO32V1 (obsolete)',
  77. { 2 } 'GO32V2',
  78. { 3 } 'Linux-i386',
  79. { 4 } 'OS/2',
  80. { 5 } 'Win32',
  81. { 6 } 'FreeBSD-i386',
  82. { 7 } 'Amiga',
  83. { 8 } 'Atari',
  84. { 9 } 'MacOS-m68k',
  85. { 10 } 'Linux-m68k',
  86. { 11 } 'PalmOS-m68k',
  87. { 12 } 'Linux-alpha',
  88. { 13 } 'Linux-ppc',
  89. { 14 } 'MacOS-ppc',
  90. { 15 } 'Solaris-i386',
  91. { 16 } 'BeOS-i386',
  92. { 17 } 'NetBSD-i386',
  93. { 18 } 'NetBSD-m68k',
  94. { 19 } 'Netware-i386-clib',
  95. { 20 } 'Qnx-i386',
  96. { 21 } 'WDOSX-i386',
  97. { 22 } 'Solaris-sparc',
  98. { 23 } 'Linux-sparc',
  99. { 24 } 'OpenBSD-i386',
  100. { 25 } 'OpenBSD-m68k',
  101. { 26 } 'Linux-x86-64',
  102. { 27 } 'Darwin-ppc',
  103. { 28 } 'OS/2 via EMX',
  104. { 29 } 'NetBSD-powerpc',
  105. { 30 } 'OpenBSD-powerpc',
  106. { 31 } 'Linux-arm',
  107. { 32 } 'Watcom-i386',
  108. { 33 } 'MorphOS-powerpc',
  109. { 34 } 'FreeBSD-x86-64',
  110. { 35 } 'Netware-i386-libc',
  111. { 36 } 'Amiga-PowerPC',
  112. { 37 } 'Win64-x64',
  113. { 38 } 'WinCE-ARM',
  114. { 39 } 'Win64-iA64',
  115. { 40 } 'WinCE-i386',
  116. { 41 } 'Linux-x64',
  117. { 42 } 'GBA-arm',
  118. { 43 } 'Linux-powerpc64',
  119. { 44 } 'Darwin-i386',
  120. { 45 } 'PalmOS-arm',
  121. { 46 } 'Darwin-powerpc64',
  122. { 47 } 'NDS-arm',
  123. { 48 } 'Embedded-i386',
  124. { 49 } 'Embedded-m68k',
  125. { 50 } 'Embedded-alpha',
  126. { 51 } 'Embedded-powerpc',
  127. { 52 } 'Embedded-sparc',
  128. { 53 } 'Embedded-vm',
  129. { 54 } 'Embedded-iA64',
  130. { 55 } 'Embedded-x64',
  131. { 56 } 'Embedded-mips',
  132. { 57 } 'Embedded-arm',
  133. { 58 } 'Embedded-powerpc64',
  134. { 59 } 'Symbian-i386',
  135. { 60 } 'Symbian-arm',
  136. { 61 } 'Darwin-x64',
  137. { 62 } 'Embedded-avr',
  138. { 63 } 'Haiku-i386',
  139. { 64 } 'Darwin-ARM',
  140. { 65 } 'Solaris-x86-64',
  141. { 66 } 'Linux-MIPS',
  142. { 67 } 'Linux-MIPSel',
  143. { 68 } 'NativeNT-i386',
  144. { 69 } 'iPhoneSim-i386',
  145. { 70 } 'Wii-powerpc',
  146. { 71 } 'OpenBSD-x86-64',
  147. { 72 } 'NetBSD-x86-64',
  148. { 73 } 'AIX-powerpc',
  149. { 74 } 'AIX-powerpc64',
  150. { 75 } 'Java-JVM',
  151. { 76 } 'Android-JVM',
  152. { 77 } 'Android-arm',
  153. { 78 } 'Android-i386',
  154. { 79 } 'MSDOS-i8086',
  155. { 80 } 'Android-MIPSel',
  156. { 81 } 'Embedded-mipseb',
  157. { 82 } 'Embedded-mipsel',
  158. { 83 } 'AROS-i386',
  159. { 84 } 'AROS-x86-64',
  160. { 85 } 'DragonFly-x86-64',
  161. { 86 } 'Darwin-AArch64',
  162. { 87 } 'iPhoneSim-x86-64',
  163. { 88 } 'Linux-AArch64',
  164. { 89 } 'Win16',
  165. { 90 } 'Embedded-i8086'
  166. );
  167. const
  168. { in widestr, we have the following definition
  169. type
  170. tcompilerwidechar = word;
  171. thus widecharsize seems to always be 2 bytes }
  172. widecharsize : longint = 2;
  173. cpu : tsystemcpu = cpu_no;
  174. { This type is defined in scanner.pas unit }
  175. type
  176. tspecialgenerictoken = (
  177. ST_LOADSETTINGS,
  178. ST_LINE,
  179. ST_COLUMN,
  180. ST_FILEINDEX,
  181. ST_LOADMESSAGES);
  182. var
  183. ppufile : tppufile;
  184. ppuversion : dword;
  185. space : string;
  186. verbose : longint;
  187. derefdata : pbyte;
  188. derefdatalen : longint;
  189. pout: TPpuOutput;
  190. nostdout: boolean;
  191. UnitList: TPpuContainerDef;
  192. CurUnit: TPpuUnitDef;
  193. SkipVersionCheck: boolean;
  194. {****************************************************************************
  195. Helper Routines
  196. ****************************************************************************}
  197. {****************************************************************************
  198. Routine to read 80-bit reals
  199. ****************************************************************************
  200. }
  201. {$PUSH}
  202. {$WARN 6018 OFF} { Turn off unreachable code warning }
  203. { On platforms with sizeof(ext) <> 10 the code below will cause an unreachable
  204. code warning, which will cause compilation failures with -Sew (KB) }
  205. type
  206. TSplit80bitReal = packed record
  207. case byte of
  208. 0: (bytes: Array[0..9] of byte);
  209. 1: (words: Array[0..4] of word);
  210. 2: (cards: Array[0..1] of cardinal; w: word);
  211. end;
  212. const
  213. maxDigits = 17;
  214. function Real80bitToStr(var e : TSplit80bitReal) : string;
  215. var
  216. Temp : string;
  217. new : TSplit80bitReal;
  218. fraczero, expmaximal, sign, outside_double : boolean;
  219. exp : smallint;
  220. ext : extended;
  221. d : double;
  222. i : longint;
  223. mantval : qword;
  224. begin
  225. if ppufile.change_endian then
  226. begin
  227. for i:=0 to 9 do
  228. new.bytes[i]:=e.bytes[9-i];
  229. e:=new;
  230. end;
  231. if sizeof(ext)=10 then
  232. begin
  233. ext:=pextended(@e)^;
  234. str(ext,result);
  235. exit;
  236. end;
  237. { extended, format (MSB): 1 Sign bit, 15 bit exponent, 64 bit mantissa }
  238. sign := (e.w and $8000) <> 0;
  239. expMaximal := (e.w and $7fff) = 32767;
  240. exp:=(e.w and $7fff) - 16383 - 63;
  241. fraczero := (e.cards[0] = 0) and
  242. ((e.cards[1] and $7fffffff) = 0);
  243. mantval := qword(e.cards[0]) or (qword(e.cards[1]) shl 32);
  244. if expMaximal then
  245. if fraczero then
  246. if sign then
  247. temp := '-Inf'
  248. else temp := '+Inf'
  249. else temp := 'Nan'
  250. else
  251. begin
  252. d:=double(mantval);
  253. if sign then
  254. d:=-d;
  255. outside_double:=false;
  256. Try
  257. if exp > 0 then
  258. begin
  259. for i:=1 to exp do
  260. d:=d *2.0;
  261. end
  262. else if exp < 0 then
  263. begin
  264. for i:=1 to -exp do
  265. d:=d /2.0;
  266. end;
  267. Except
  268. outside_double:=true;
  269. end;
  270. if (mantval<>0) and (d=0.0) then
  271. outside_double:=true;
  272. if outside_double then
  273. Temp:='Extended value outside double bound'
  274. else
  275. system.str(d,temp);
  276. end;
  277. result:=temp;
  278. end;
  279. {$POP}
  280. const has_errors : boolean = false;
  281. has_warnings : boolean = false;
  282. has_more_infos : boolean = false;
  283. procedure SetHasErrors;
  284. begin
  285. has_errors:=true;
  286. end;
  287. Procedure WriteError(const S : string);
  288. Begin
  289. system.Writeln(StdErr, S);
  290. SetHasErrors;
  291. End;
  292. Procedure WriteWarning(const S : string);
  293. var
  294. ss: string;
  295. Begin
  296. ss:='!! Warning: ' + S;
  297. if nostdout then
  298. system.Writeln(StdErr, ss)
  299. else
  300. system.Writeln(ss);
  301. has_warnings:=true;
  302. End;
  303. procedure Write(const s: string);
  304. begin
  305. if nostdout then exit;
  306. system.write(s);
  307. end;
  308. procedure Write(const params: array of const);
  309. var
  310. i: integer;
  311. { Last vtType define in rtl/inc/objpash.inc }
  312. const
  313. max_vttype = vtUnicodeString;
  314. begin
  315. if nostdout then exit;
  316. for i:=Low(params) to High(params) do
  317. { All vtType in
  318. vtInteger = 0;
  319. vtBoolean = 1;
  320. vtChar = 2;
  321. vtExtended = 3;
  322. vtString = 4;
  323. vtPointer = 5;
  324. vtPChar = 6;
  325. vtObject = 7;
  326. vtClass = 8;
  327. vtWideChar = 9;
  328. vtPWideChar = 10;
  329. vtAnsiString32 = 11; called vtAnsiString in objpas unit
  330. vtCurrency = 12;
  331. vtVariant = 13;
  332. vtInterface = 14;
  333. vtWideString = 15;
  334. vtInt64 = 16;
  335. vtQWord = 17;
  336. vtUnicodeString = 18;
  337. // vtAnsiString16 = 19; not yet used
  338. // vtAnsiString64 = 20; not yet used
  339. }
  340. with TVarRec(params[i]) do
  341. case VType of
  342. vtInteger: system.write(VInteger);
  343. vtBoolean: system.write(VBoolean);
  344. vtChar: system.write(VChar);
  345. vtExtended: system.write(VExtended^);
  346. vtString: system.write(VString^);
  347. vtPointer:
  348. begin
  349. { Not sure the display will be correct
  350. if sizeof pointer is not native }
  351. WriteWarning('Pointer constant');
  352. end;
  353. vtPChar: system.write(VPChar);
  354. vtObject:
  355. begin
  356. { Not sure the display will be correct
  357. if sizeof pointer is not native }
  358. WriteWarning('Object constant');
  359. end;
  360. vtClass:
  361. begin
  362. { Not sure the display will be correct
  363. if sizeof pointer is not native }
  364. WriteWarning('Class constant');
  365. end;
  366. vtWideChar: system.write(VWideChar);
  367. vtPWideChar:
  368. begin
  369. WriteWarning('PWideChar constant');
  370. end;
  371. vtAnsiString: system.write(ansistring(VAnsiString));
  372. vtCurrency : system.write(VCurrency^);
  373. vtVariant :
  374. begin
  375. { Not sure the display will be correct
  376. if sizeof pointer is not native }
  377. WriteWarning('Variant constant');
  378. end;
  379. vtInterface :
  380. begin
  381. { Not sure the display will be correct
  382. if sizeof pointer is not native }
  383. WriteWarning('Interface constant');
  384. end;
  385. vtWideString : system.write(widestring(VWideString));
  386. vtInt64: system.write(VInt64^);
  387. vtQWord: system.write(VQWord^);
  388. vtUnicodeString : system.write(unicodestring(VUnicodeString));
  389. else
  390. begin
  391. system.writeln;
  392. system.writeln('Unsupported var type: ', VType);
  393. Halt(10);
  394. end;
  395. end;
  396. end;
  397. procedure Writeln(const s: string = '');
  398. begin
  399. if nostdout then exit;
  400. system.writeln(s);
  401. end;
  402. procedure Writeln(const params: array of const);
  403. begin
  404. if nostdout then exit;
  405. Write(params);
  406. system.writeln;
  407. end;
  408. Procedure HasMoreInfos;
  409. begin
  410. Writeln('!! Entry has more information stored');
  411. has_more_infos:=true;
  412. end;
  413. function Unknown(const st : string; val :longint) : string;
  414. Begin
  415. Unknown:='<!! Unknown'+st+' value '+tostr(val)+'>';
  416. SetHasErrors;
  417. end;
  418. function ToStr(w:longint):String;
  419. begin
  420. Str(w,ToStr);
  421. end;
  422. Function Target2Str(w:longint):string;
  423. begin
  424. if w<=ord(high(tsystem)) then
  425. Target2Str:=Targets[tsystem(w)]
  426. else
  427. Target2Str:=Unknown('target',w);
  428. end;
  429. Function Cpu2Str(w:longint):string;
  430. begin
  431. if w<=ord(high(tsystemcpu)) then
  432. begin
  433. cpu:=tsystemcpu(w);
  434. Cpu2Str:=CpuTxt[cpu];
  435. end
  436. else
  437. Cpu2Str:=Unknown('cpu',w);
  438. end;
  439. Function Varspez2Str(w:longint):string;
  440. const
  441. { in symconst unit
  442. tvarspez = (vs_value,vs_const,vs_var,vs_out,vs_constref); }
  443. varspezstr : array[tvarspez] of string[8]=('Value','Const','Var','Out','ConstRef','Final');
  444. begin
  445. if w<=ord(high(varspezstr)) then
  446. Varspez2Str:=varspezstr[tvarspez(w)]
  447. else
  448. Varspez2Str:=Unknown('varspez',w);
  449. end;
  450. Function VarRegable2Str(w:longint):string;
  451. { tvarregable type is defined in symconst unit }
  452. const
  453. varregableStr : array[tvarregable] of string[6]=('None','IntReg','FPUReg','MMReg','Addr');
  454. begin
  455. if w<=ord(high(varregablestr)) then
  456. Varregable2Str:=varregablestr[tvarregable(w)]
  457. else
  458. Varregable2Str:=Unknown('regable',w);
  459. end;
  460. Function Visibility2Str(w:longint):string;
  461. const
  462. { tvisibility type is defined in symconst unit }
  463. visibilityName : array[tvisibility] of string[16] = (
  464. 'hidden','strict private','private','strict protected','protected',
  465. 'public','published','<none>'
  466. );
  467. begin
  468. if w<=ord(high(visibilityName)) then
  469. result:=visibilityName[tvisibility(w)]
  470. else
  471. result:=Unknown('visibility',w);
  472. end;
  473. Function IntfEntryType2Str(w:longint):string;
  474. const
  475. { tinterfaceentrytype type is defined in symconst unit }
  476. Name : array[tinterfaceentrytype] of string = (
  477. 'standard','virtual method result','static method result','field value','virtual method class',
  478. 'static method class','field value class'
  479. );
  480. begin
  481. if w<=ord(high(Name)) then
  482. result:=Name[tinterfaceentrytype(w)]
  483. else
  484. result:=Unknown('entry type',w);
  485. end;
  486. Function Synthetic2Str(w: byte): string;
  487. const
  488. syntheticName : array[tsynthetickind] of string[length('jvm procvar intf constructor')] = (
  489. '<none>','anon inherited','jvm clone','record deep copy',
  490. 'record initilializer', 'empty routine', 'typed const initializer',
  491. 'callthough', 'callthrough if not abstract', 'jvm enum values',
  492. 'jvm enum valueof', 'jvm enum class constructor',
  493. 'jvm enum jumps constructor', 'jvm enum fpcordinal',
  494. 'jvm enum fpcvalueof', 'jvm enum long2set',
  495. 'jvm enum bitset2set', 'jvm enum set2set',
  496. 'jvm procvar invoke', 'jvm procvar intf constructor',
  497. 'jvm virtual class method', 'jvm field getter', 'jvm field setter',
  498. 'block invoke','interface wrapper','call parameterless routine');
  499. begin
  500. if w<=ord(high(syntheticName)) then
  501. result:=syntheticName[tsynthetickind(w)]
  502. else
  503. result:=Unknown('synthetickind',w);
  504. end;
  505. function PPUFlags2Str(flags:longint):string;
  506. type
  507. tflagopt=record
  508. mask : longint;
  509. str : string[30];
  510. end;
  511. const
  512. flagopts=28;
  513. flagopt : array[1..flagopts] of tflagopt=(
  514. (mask: $1 ;str:'init'),
  515. (mask: $2 ;str:'final'),
  516. (mask: $4 ;str:'big_endian'),
  517. (mask: $8 ;str:'dbx'),
  518. // (mask: $10 ;str:'browser'),
  519. (mask: $20 ;str:'in_library'),
  520. (mask: $40 ;str:'smart_linked'),
  521. (mask: $80 ;str:'static_linked'),
  522. (mask: $100 ;str:'shared_linked'),
  523. // (mask: $200 ;str:'local_browser'),
  524. (mask: $400 ;str:'no_link'),
  525. (mask: $800 ;str:'has_resources'),
  526. (mask: $1000 ;str:'little_endian'),
  527. (mask: $2000 ;str:'release'),
  528. (mask: $4000 ;str:'local_threadvars'),
  529. (mask: $8000 ;str:'fpu_emulation_on'),
  530. (mask: $210000 ;str:'has_debug_info'),
  531. (mask: $10000 ;str:'stabs_debug_info'),
  532. (mask: $200000 ;str:'dwarf_debug_info'),
  533. (mask: $20000 ;str:'local_symtable'),
  534. (mask: $40000 ;str:'uses_variants'),
  535. (mask: $80000 ;str:'has_resourcefiles'),
  536. (mask: $100000 ;str:'has_exports'),
  537. (mask: $400000 ;str:'has_wideinits'),
  538. (mask: $800000 ;str:'has_classinits'),
  539. (mask: $1000000 ;str:'has_resstrinits'),
  540. (mask: $2000000 ;str:'i8086_far_code'),
  541. (mask: $4000000 ;str:'i8086_far_data'),
  542. (mask: $8000000 ;str:'i8086_huge_data'),
  543. (mask: $10000000;str:'i8086_cs_equals_ds')
  544. );
  545. var
  546. i,ntflags : longint;
  547. first : boolean;
  548. s : string;
  549. begin
  550. s:='';
  551. if flags<>0 then
  552. begin
  553. ntflags:=flags;
  554. first:=true;
  555. for i:=1to flagopts do
  556. if (flags and flagopt[i].mask)<>0 then
  557. begin
  558. if first then
  559. first:=false
  560. else
  561. s:=s+', ';
  562. s:=s+flagopt[i].str;
  563. ntflags:=ntflags and (not flagopt[i].mask);
  564. end;
  565. end
  566. else
  567. s:='none';
  568. if ntflags<>0 then
  569. begin
  570. s:=s+' unknown '+hexstr(ntflags,8);
  571. SetHasErrors;
  572. end;
  573. PPUFlags2Str:=s;
  574. end;
  575. Function L0(l:longint):string;
  576. {
  577. return the string of value l, if l<10 then insert a zero, so
  578. the string is always at least 2 chars '01','02',etc
  579. }
  580. var
  581. s : string;
  582. begin
  583. Str(l,s);
  584. if l<10 then
  585. s:='0'+s;
  586. L0:=s;
  587. end;
  588. function filetimestring( t : longint) : string;
  589. {
  590. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  591. }
  592. var
  593. DT : TDateTime;
  594. hsec : word;
  595. Year,Month,Day: Word;
  596. hour,min,sec : word;
  597. begin
  598. if t=-1 then
  599. begin
  600. Result := 'Not Found';
  601. SetHasErrors;
  602. exit;
  603. end;
  604. DT := FileDateToDateTime(t);
  605. DecodeTime(DT,hour,min,sec,hsec);
  606. DecodeDate(DT,year,month,day);
  607. Result := L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  608. end;
  609. {****************************************************************************
  610. Read Routines
  611. ****************************************************************************}
  612. procedure readrecsymtableoptions;
  613. var
  614. usefieldalignment : shortint;
  615. begin
  616. if ppufile.readentry<>ibrecsymtableoptions then
  617. begin
  618. SetHasErrors;
  619. exit;
  620. end;
  621. writeln([space,' recordalignment: ',shortint(ppufile.getbyte)]);
  622. usefieldalignment:=shortint(ppufile.getbyte);
  623. writeln([space,' usefieldalignment: ',usefieldalignment]);
  624. writeln([space,' recordalignmin: ',shortint(ppufile.getbyte)]);
  625. if (usefieldalignment=C_alignment) then
  626. writeln([space,' fieldalignment: ',shortint(ppufile.getbyte)]);
  627. end;
  628. procedure readsymtableoptions(const s: string);
  629. type
  630. tsymtblopt=record
  631. mask : tsymtableoption;
  632. str : string[30];
  633. end;
  634. const
  635. symtblopts=ord(high(tsymtableoption)) + 1;
  636. symtblopt : array[1..symtblopts] of tsymtblopt=(
  637. (mask:sto_has_helper; str:'Has helper'),
  638. (mask:sto_has_generic; str:'Has generic'),
  639. (mask:sto_has_operator; str:'Has operator'),
  640. (mask:sto_needs_init_final;str:'Needs init final table')
  641. );
  642. var
  643. options : tsymtableoptions;
  644. first : boolean;
  645. i : integer;
  646. begin
  647. if ppufile.readentry<>ibsymtableoptions then
  648. begin
  649. SetHasErrors;
  650. exit;
  651. end;
  652. ppufile.getsmallset(options);
  653. if space<>'' then
  654. writeln([space,'------ ',s,' ------']);
  655. write([space,'Symtable options: ']);
  656. if options<>[] then
  657. begin
  658. first:=true;
  659. for i:=1 to symtblopts do
  660. if (symtblopt[i].mask in options) then
  661. begin
  662. if first then
  663. first:=false
  664. else
  665. write(', ');
  666. write(symtblopt[i].str);
  667. end;
  668. end
  669. else
  670. write('none');
  671. writeln;
  672. end;
  673. procedure readdefinitions(const s:string; ParentDef: TPpuContainerDef); forward;
  674. procedure readsymbols(const s:string; ParentDef: TPpuContainerDef = nil); forward;
  675. procedure readsymtable(const s: string; ParentDef: TPpuContainerDef = nil);
  676. begin
  677. readsymtableoptions(s);
  678. readdefinitions(s, ParentDef);
  679. readsymbols(s, ParentDef);
  680. end;
  681. Procedure ReadLinkContainer(const prefix:string);
  682. {
  683. Read a serie of strings and write to the screen starting every line
  684. with prefix
  685. }
  686. function maskstr(m:longint):string;
  687. { link options are in globtype unit
  688. const
  689. link_none = $0;
  690. link_always = $1;
  691. link_static = $2;
  692. link_smart = $4;
  693. link_shared = $8; }
  694. var
  695. s : string;
  696. begin
  697. s:='';
  698. if (m and link_always)<>0 then
  699. s:=s+'always ';
  700. if (m and link_static)<>0 then
  701. s:=s+'static ';
  702. if (m and link_smart)<>0 then
  703. s:=s+'smart ';
  704. if (m and link_shared)<>0 then
  705. s:=s+'shared ';
  706. maskstr:=s;
  707. end;
  708. var
  709. s : string;
  710. m : longint;
  711. begin
  712. while not ppufile.endofentry do
  713. begin
  714. s:=ppufile.getstring;
  715. m:=ppufile.getlongint;
  716. WriteLn([prefix,s,' (',maskstr(m),')']);
  717. end;
  718. end;
  719. Procedure ReadContainer(const prefix:string);
  720. {
  721. Read a serie of strings and write to the screen starting every line
  722. with prefix
  723. }
  724. begin
  725. while not ppufile.endofentry do
  726. WriteLn([prefix,ppufile.getstring]);
  727. end;
  728. procedure ReadLoadUnit;
  729. var
  730. ucrc,uintfcrc, indcrc : cardinal;
  731. un: TPpuUnitDef;
  732. begin
  733. while not ppufile.EndOfEntry do
  734. begin
  735. un:=TPpuUnitDef.Create(CurUnit.UsedUnits);
  736. un.Name:=ppufile.getstring;
  737. write(['Uses unit: ',un.Name]);
  738. ucrc:=cardinal(ppufile.getlongint);
  739. uintfcrc:=cardinal(ppufile.getlongint);
  740. indcrc:=cardinal(ppufile.getlongint);
  741. writeln([' (Crc: ',hexstr(ucrc,8),', IntfcCrc: ',hexstr(uintfcrc,8),', IndCrc: ',hexstr(indcrc,8),')']);
  742. un.Crc:=ucrc;
  743. un.IntfCrc:=uintfcrc;
  744. end;
  745. end;
  746. Procedure ReadDerefmap;
  747. var
  748. i,mapsize : longint;
  749. s: string;
  750. begin
  751. mapsize:=ppufile.getlongint;
  752. writeln(['DerefMapsize: ',mapsize]);
  753. SetLength(CurUnit.RefUnits, mapsize);
  754. for i:=0 to mapsize-1 do
  755. begin
  756. s:=ppufile.getstring;
  757. writeln(['DerefMap[',i,'] = ',s]);
  758. CurUnit.RefUnits[i]:=LowerCase(s);
  759. end;
  760. end;
  761. Procedure ReadImportSymbols;
  762. var
  763. extlibname : string;
  764. j,
  765. extsymcnt : longint;
  766. extsymname : string;
  767. extsymmangledname : string;
  768. extsymordnr : longint;
  769. extsymisvar : boolean;
  770. begin
  771. while not ppufile.endofentry do
  772. begin
  773. extlibname:=ppufile.getstring;
  774. extsymcnt:=ppufile.getlongint;
  775. writeln(['External Library: ',extlibname,' (',extsymcnt,' imports)']);
  776. for j:=0 to extsymcnt-1 do
  777. begin
  778. extsymname:=ppufile.getstring;
  779. if ppuversion>130 then
  780. extsymmangledname:=ppufile.getstring
  781. else
  782. extsymmangledname:=extsymname;
  783. extsymordnr:=ppufile.getlongint;
  784. extsymisvar:=ppufile.getbyte<>0;
  785. writeln([' ',extsymname,' as ',extsymmangledname,
  786. '(OrdNr: ',extsymordnr,' IsVar: ',extsymisvar,')']);
  787. end;
  788. end;
  789. end;
  790. Procedure ReadDerefdata;
  791. begin
  792. derefdatalen:=ppufile.entrysize;
  793. if derefdatalen=0 then
  794. begin
  795. Writeln(['No Derefdata length=0']);
  796. derefdata:=nil;
  797. exit;
  798. end;
  799. Writeln(['Derefdata length: ',derefdatalen]);
  800. derefdata:=allocmem(derefdatalen);
  801. ppufile.getdata(derefdata^,derefdatalen);
  802. end;
  803. Procedure FreeDerefdata;
  804. begin
  805. if assigned(derefdata) then
  806. begin
  807. FreeMem(derefdata);
  808. derefdata:=nil;
  809. derefdatalen:=0;
  810. end;
  811. end;
  812. Procedure ReadWpoFileInfo;
  813. begin
  814. Writeln(['Compiled with input whole-program optimisation from ',ppufile.getstring,' ',filetimestring(ppufile.getlongint)]);
  815. end;
  816. Procedure ReadAsmSymbols;
  817. type
  818. { Copied from aasmbase.pas }
  819. TAsmsymbind=(
  820. AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL,AB_WEAK_EXTERNAL,
  821. { global in the current program/library, but not visible outside it }
  822. AB_PRIVATE_EXTERN,AB_LAZY,AB_IMPORT);
  823. TAsmsymtype=(
  824. AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION,AT_LABEL,
  825. {
  826. the address of this code label is taken somewhere in the code
  827. so it must be taken care of it when creating pic
  828. }
  829. AT_ADDR
  830. );
  831. var
  832. s,
  833. bindstr,
  834. typestr : string;
  835. i : longint;
  836. begin
  837. writeln([space,'Number of AsmSymbols: ',ppufile.getlongint]);
  838. i:=0;
  839. while (not ppufile.endofentry) and (not ppufile.error) do
  840. begin
  841. s:=ppufile.getstring;
  842. case tasmsymbind(ppufile.getbyte) of
  843. AB_EXTERNAL :
  844. bindstr:='External';
  845. AB_COMMON :
  846. bindstr:='Common';
  847. AB_LOCAL :
  848. bindstr:='Local';
  849. AB_GLOBAL :
  850. bindstr:='Global';
  851. AB_WEAK_EXTERNAL :
  852. bindstr:='Weak external';
  853. AB_PRIVATE_EXTERN :
  854. bindstr:='Private extern';
  855. AB_LAZY :
  856. bindstr:='Lazy';
  857. AB_IMPORT :
  858. bindstr:='Import';
  859. else
  860. begin
  861. bindstr:='<Error !!>';
  862. SetHasErrors;
  863. end;
  864. end;
  865. case tasmsymtype(ppufile.getbyte) of
  866. AT_FUNCTION :
  867. typestr:='Function';
  868. AT_DATA :
  869. typestr:='Data';
  870. AT_SECTION :
  871. typestr:='Section';
  872. AT_LABEL :
  873. typestr:='Label';
  874. AT_ADDR :
  875. typestr:='Label (with address taken)';
  876. else
  877. begin
  878. typestr:='<Error !!>';
  879. SetHasErrors;
  880. end;
  881. end;
  882. Writeln([space,' ',i,' : ',s,' [',bindstr,',',typestr,']']);
  883. inc(i);
  884. end;
  885. end;
  886. function getexprint:Tconstexprint;
  887. begin
  888. getexprint.overflow:=false;
  889. getexprint.signed:=boolean(ppufile.getbyte);
  890. getexprint.svalue:=ppufile.getint64;
  891. end;
  892. Procedure ReadPosInfo(Def: TPpuDef = nil);
  893. var
  894. info : byte;
  895. fileindex,line,column : longint;
  896. begin
  897. with ppufile do
  898. begin
  899. {
  900. info byte layout in bits:
  901. 0-1 - amount of bytes for fileindex
  902. 2-3 - amount of bytes for line
  903. 4-5 - amount of bytes for column
  904. }
  905. info:=getbyte;
  906. case (info and $03) of
  907. 0 : fileindex:=getbyte;
  908. 1 : fileindex:=getword;
  909. 2 : fileindex:=(getbyte shl 16) or getword;
  910. 3 : fileindex:=getlongint;
  911. end;
  912. case ((info shr 2) and $03) of
  913. 0 : line:=getbyte;
  914. 1 : line:=getword;
  915. 2 : line:=(getbyte shl 16) or getword;
  916. 3 : line:=getlongint;
  917. end;
  918. case ((info shr 4) and $03) of
  919. 0 : column:=getbyte;
  920. 1 : column:=getword;
  921. 2 : column:=(getbyte shl 16) or getword;
  922. 3 : column:=getlongint;
  923. end;
  924. Writeln([fileindex,' (',line,',',column,')']);
  925. if Def <> nil then
  926. begin
  927. Def.FilePos.FileIndex:=fileindex - 1;
  928. Def.FilePos.Line:=line;
  929. Def.FilePos.Col:=column;
  930. end;
  931. end;
  932. end;
  933. procedure readderef(const derefspace: string; Ref: TPpuRef = nil);
  934. var
  935. b : tdereftype;
  936. first : boolean;
  937. idx : longint;
  938. i,n : byte;
  939. pdata : pbyte;
  940. begin
  941. if not assigned(derefdata) then
  942. exit;
  943. first:=true;
  944. idx:=ppufile.getlongint;
  945. if idx = -1 then
  946. begin
  947. writeln('Nil');
  948. exit;
  949. end;
  950. if (idx>derefdatalen) then
  951. begin
  952. WriteError('!! Error: Deref idx '+IntToStr(idx)+' > '+IntToStr(derefdatalen));
  953. exit;
  954. end;
  955. write([derefspace,'(',idx,') ']);
  956. pdata:=@derefdata[idx];
  957. i:=0;
  958. n:=pdata[i];
  959. inc(i);
  960. if n<1 then
  961. begin
  962. WriteError('!! Error: Deref len < 1');
  963. exit;
  964. end;
  965. while (i<=n) do
  966. begin
  967. if not first then
  968. write(', ')
  969. else
  970. first:=false;
  971. b:=tdereftype(pdata[i]);
  972. inc(i);
  973. case b of
  974. deref_nil :
  975. write('Nil');
  976. deref_symid :
  977. begin
  978. idx:=pdata[i] shl 24 or pdata[i+1] shl 16 or pdata[i+2] shl 8 or pdata[i+3];
  979. inc(i,4);
  980. write(['SymId ',idx]);
  981. if Ref <> nil then
  982. Ref.Id:=idx;
  983. end;
  984. deref_defid :
  985. begin
  986. idx:=pdata[i] shl 24 or pdata[i+1] shl 16 or pdata[i+2] shl 8 or pdata[i+3];
  987. inc(i,4);
  988. write(['DefId ',idx]);
  989. if Ref <> nil then
  990. Ref.Id:=idx;
  991. end;
  992. deref_unit :
  993. begin
  994. idx:=pdata[i] shl 8 or pdata[i+1];
  995. inc(i,2);
  996. write(['Unit ',idx]);
  997. if Ref <> nil then
  998. Ref.UnitIndex:=idx;
  999. end;
  1000. else
  1001. begin
  1002. WriteError('!! unsupported dereftyp: '+IntToStr(ord(b)));
  1003. break;
  1004. end;
  1005. end;
  1006. end;
  1007. writeln;
  1008. end;
  1009. Procedure ReadUnitImportSyms;
  1010. var
  1011. c,i : longint;
  1012. begin
  1013. writeln([space,'Imported Symbols']);
  1014. writeln([space,'----------------']);
  1015. c:=ppufile.getlongint;
  1016. for i:=0 to c-1 do
  1017. readderef(space);
  1018. writeln([space]);
  1019. end;
  1020. procedure readpropaccesslist(const s:string; Ref: TPpuRef = nil);
  1021. { type tsltype is in symconst unit }
  1022. const
  1023. slstr : array[tsltype] of string[12] = (
  1024. '',
  1025. 'load',
  1026. 'call',
  1027. 'subscript',
  1028. 'vec',
  1029. 'typeconv',
  1030. 'absolutetype'
  1031. );
  1032. var
  1033. sl : tsltype;
  1034. begin
  1035. readderef('',Ref);
  1036. repeat
  1037. sl:=tsltype(ppufile.getbyte);
  1038. if sl=sl_none then
  1039. break;
  1040. write([s,'(',slstr[sl],') ']);
  1041. case sl of
  1042. sl_call,
  1043. sl_load,
  1044. sl_subscript :
  1045. if (Ref <> nil) and (Ref.IsNull) then
  1046. begin
  1047. readderef('',Ref);
  1048. Ref.IsSymId:=True;
  1049. end
  1050. else
  1051. readderef('');
  1052. sl_absolutetype,
  1053. sl_typeconv :
  1054. readderef('');
  1055. sl_vec :
  1056. begin
  1057. writeln([ppufile.getlongint]);
  1058. readderef('');
  1059. end;
  1060. end;
  1061. until false;
  1062. end;
  1063. (*
  1064. talignmentinfo = packed record
  1065. procalign,
  1066. loopalign,
  1067. jumpalign,
  1068. constalignmin,
  1069. constalignmax,
  1070. varalignmin,
  1071. varalignmax,
  1072. localalignmin,
  1073. localalignmax,
  1074. recordalignmin,
  1075. recordalignmax,
  1076. maxCrecordalign : longint;
  1077. end;
  1078. tsettings = packed record
  1079. alignment : talignmentinfo;
  1080. globalswitches : tglobalswitches;
  1081. moduleswitches : tmoduleswitches;
  1082. localswitches : tlocalswitches;
  1083. modeswitches : tmodeswitches;
  1084. optimizerswitches : toptimizerswitches;
  1085. { generate information necessary to perform these wpo's during a subsequent compilation }
  1086. genwpoptimizerswitches: twpoptimizerswitches;
  1087. { perform these wpo's using information generated during a previous compilation }
  1088. dowpoptimizerswitches: twpoptimizerswitches;
  1089. debugswitches : tdebugswitches;
  1090. { 0: old behaviour for sets <=256 elements
  1091. >0: round to this size }
  1092. setalloc,
  1093. packenum : shortint;
  1094. packrecords : shortint;
  1095. maxfpuregisters : shortint;
  1096. cputype,
  1097. optimizecputype : tcputype;
  1098. fputype : tfputype;
  1099. asmmode : tasmmode;
  1100. interfacetype : tinterfacetypes;
  1101. defproccall : tproccalloption;
  1102. sourcecodepage : tcodepagestring;
  1103. minfpconstprec : tfloattype;
  1104. disabledircache : boolean;
  1105. { CPU targets with microcontroller support can add a controller specific unit }
  1106. controllertype : tcontrollertype;
  1107. { WARNING: this pointer cannot be written as such in record token }
  1108. pmessage : pmessagestaterecord;
  1109. end;
  1110. *)
  1111. procedure readprocinfooptions(space : string);
  1112. (*
  1113. tprocinfoflag=(
  1114. { procedure has at least one assembler block }
  1115. pi_has_assembler_block,
  1116. { procedure does a call }
  1117. pi_do_call,
  1118. { procedure has a try statement = no register optimization }
  1119. pi_uses_exceptions,
  1120. { procedure is declared as @var(assembler), don't optimize}
  1121. pi_is_assembler,
  1122. { procedure contains data which needs to be finalized }
  1123. pi_needs_implicit_finally,
  1124. { procedure has the implicit try..finally generated }
  1125. pi_has_implicit_finally,
  1126. { procedure uses fpu}
  1127. pi_uses_fpu,
  1128. { procedure uses GOT for PIC code }
  1129. pi_needs_got,
  1130. { references var/proc/type/const in static symtable,
  1131. i.e. not allowed for inlining from other units }
  1132. pi_uses_static_symtable,
  1133. { set if the procedure has to push parameters onto the stack }
  1134. pi_has_stackparameter,
  1135. { set if the procedure has at least one label }
  1136. pi_has_label,
  1137. { calls itself recursive }
  1138. pi_is_recursive,
  1139. { stack frame optimization not possible (only on x86 probably) }
  1140. pi_needs_stackframe,
  1141. { set if the procedure has at least one register saved on the stack }
  1142. pi_has_saved_regs,
  1143. { dfa was generated for this proc }
  1144. pi_dfaavailable,
  1145. { subroutine contains interprocedural used labels }
  1146. pi_has_interproclabel,
  1147. { subroutine contains interprocedural gotos }
  1148. pi_has_global_goto
  1149. ); *)
  1150. type
  1151. tprocinfoopt=record
  1152. mask : tprocinfoflag;
  1153. str : string[81];
  1154. end;
  1155. const
  1156. procinfoopts=ord(high(tprocinfoflag)) - ord(low(tprocinfoflag));
  1157. procinfoopt : array[0..procinfoopts] of tprocinfoopt=(
  1158. (mask:pi_has_assembler_block;
  1159. str:' has at least one assembler block'),
  1160. (mask:pi_do_call;
  1161. str:' does a call'),
  1162. (mask:pi_uses_exceptions;
  1163. str:' has a try statement = no register optimization '),
  1164. (mask:pi_is_assembler;
  1165. str:' is declared as @var(assembler), don''t optimize'),
  1166. (mask:pi_needs_implicit_finally;
  1167. str:' contains data which needs to be finalized '),
  1168. (mask:pi_has_implicit_finally;
  1169. str:' has the implicit try..finally generated '),
  1170. (mask:pi_uses_fpu;
  1171. str:' uses fpu'),
  1172. (mask:pi_needs_got;
  1173. str:' uses GOT for PIC code '),
  1174. (mask:pi_uses_static_symtable;
  1175. str:' references var/proc/type/const in static symtable'),
  1176. (mask:pi_has_stackparameter;
  1177. str:' set if the procedure has to push parameters onto the stack '),
  1178. (mask:pi_has_label;
  1179. str:' set if the procedure has at least one label '),
  1180. (mask:pi_is_recursive;
  1181. str:' calls itself recursive '),
  1182. (mask:pi_needs_stackframe;
  1183. str:' stack frame optimization not possible (only on x86 probably) '),
  1184. (mask:pi_has_saved_regs;
  1185. str:' set if the procedure has at least one register saved on the stack '),
  1186. (mask:pi_dfaavailable;
  1187. str:' dfa was generated for this proc '),
  1188. (mask:pi_has_interproclabel;
  1189. str:' subroutine contains interprocedural used labels '),
  1190. (mask:pi_has_unwind_info;
  1191. str:' unwinding info was generated for this proc '),
  1192. (mask:pi_has_global_goto;
  1193. str:' subroutine contains interprocedural goto '),
  1194. (mask:pi_has_inherited;
  1195. str:' subroutine contains inherited call '),
  1196. (mask:pi_has_nested_exit;
  1197. str:' subroutine contains a nested subroutine which calls the exit of the current one '),
  1198. (mask:pi_has_stack_allocs;
  1199. str:' allocates memory on stack, so stack may be unbalanced on exit '),
  1200. (mask:pi_estimatestacksize;
  1201. str:' stack size is estimated before subroutine is compiled '),
  1202. (mask:pi_calls_c_varargs;
  1203. str:' calls function with C-style varargs '),
  1204. (mask:pi_has_open_array_parameter;
  1205. str:' has open array parameter ')
  1206. );
  1207. var
  1208. procinfooptions : tprocinfoflags;
  1209. i : longint;
  1210. first : boolean;
  1211. begin
  1212. ppufile.getsmallset(procinfooptions);
  1213. if procinfooptions<>[] then
  1214. begin
  1215. first:=true;
  1216. for i:=0 to procinfoopts do
  1217. if (procinfoopt[i].mask in procinfooptions) then
  1218. begin
  1219. if first then
  1220. first:=false
  1221. else
  1222. write(', ');
  1223. write(procinfoopt[i].str);
  1224. end;
  1225. end;
  1226. writeln;
  1227. end;
  1228. procedure readsymoptions(space : string; Def: TPpuDef = nil);
  1229. type
  1230. tsymopt=record
  1231. mask : tsymoption;
  1232. str : string[30];
  1233. end;
  1234. const
  1235. symopts=ord(high(tsymoption)) - ord(low(tsymoption));
  1236. { sp_none = 0 corresponds to nothing }
  1237. symopt : array[1..symopts] of tsymopt=(
  1238. (mask:sp_static; str:'Static'),
  1239. (mask:sp_hint_deprecated; str:'Hint Deprecated'),
  1240. (mask:sp_hint_platform; str:'Hint Platform'),
  1241. (mask:sp_hint_library; str:'Hint Library'),
  1242. (mask:sp_hint_unimplemented; str:'Hint Unimplemented'),
  1243. (mask:sp_hint_experimental; str:'Hint Experimental'),
  1244. (mask:sp_has_overloaded; str:'Has overloaded'),
  1245. (mask:sp_internal; str:'Internal'),
  1246. (mask:sp_implicitrename; str:'Implicit Rename'),
  1247. (mask:sp_generic_para; str:'Generic Parameter'),
  1248. (mask:sp_has_deprecated_msg; str:'Has Deprecated Message'),
  1249. (mask:sp_generic_dummy; str:'Generic Dummy'),
  1250. (mask:sp_explicitrename; str:'Explicit Rename')
  1251. );
  1252. var
  1253. symoptions : tsymoptions;
  1254. i : longint;
  1255. first : boolean;
  1256. begin
  1257. ppufile.getsmallset(symoptions);
  1258. if symoptions<>[] then
  1259. begin
  1260. if Def <> nil then
  1261. if sp_internal in symoptions then
  1262. Def.Visibility:=dvHidden;
  1263. first:=true;
  1264. for i:=1to symopts do
  1265. if (symopt[i].mask in symoptions) then
  1266. begin
  1267. if first then
  1268. first:=false
  1269. else
  1270. write(', ');
  1271. write(symopt[i].str);
  1272. end;
  1273. end;
  1274. writeln;
  1275. if sp_has_deprecated_msg in symoptions then
  1276. writeln([space,'Deprecated : ', ppufile.getstring]);
  1277. end;
  1278. procedure readvisibility(Def: TPpuDef = nil);
  1279. var
  1280. i: byte;
  1281. begin
  1282. i:=ppufile.getbyte;
  1283. if Def <> nil then
  1284. case tvisibility(i) of
  1285. vis_public: Def.Visibility:=dvPublic;
  1286. vis_published: Def.Visibility:=dvPublished;
  1287. vis_protected, vis_strictprotected: Def.Visibility:=dvProtected;
  1288. else Def.Visibility:=dvPrivate;
  1289. end;
  1290. writeln(Visibility2Str(i));
  1291. end;
  1292. procedure readcommonsym(const s:string; Def: TPpuDef = nil);
  1293. var
  1294. i: integer;
  1295. n: string;
  1296. begin
  1297. n:=ppufile.getstring;
  1298. if Def <> nil then
  1299. Def.Name:=n;
  1300. i:=ppufile.getlongint;
  1301. if Def <> nil then
  1302. Def.SetSymId(i);
  1303. writeln([space,'** Symbol Id ',i,' **']);
  1304. writeln([space,s,n]);
  1305. write ([space,' File Pos : ']);
  1306. readposinfo(Def);
  1307. write ([space,' Visibility : ']);
  1308. readvisibility(Def);
  1309. write ([space,' SymOptions : ']);
  1310. readsymoptions(space+' ',Def);
  1311. end;
  1312. var
  1313. { needed during tobjectdef parsing... }
  1314. current_defoptions : tdefoptions;
  1315. current_objectoptions : tobjectoptions;
  1316. procedure readcommondef(const s:string; out defoptions: tdefoptions; Def: TPpuDef = nil);
  1317. type
  1318. tdefopt=record
  1319. mask : tdefoption;
  1320. str : string[30];
  1321. end;
  1322. tdefstateinfo=record
  1323. mask : tdefstate;
  1324. str : string[30];
  1325. end;
  1326. tgenconstrflag=record
  1327. mask : tgenericconstraintflag;
  1328. str : string[30];
  1329. end;
  1330. ptoken=^ttoken;
  1331. pmsgstate =^tmsgstate;
  1332. const
  1333. defopt : array[1..ord(high(tdefoption))] of tdefopt=(
  1334. (mask:df_unique; str:'Unique Type'),
  1335. (mask:df_generic; str:'Generic'),
  1336. (mask:df_specialization; str:'Specialization'),
  1337. (mask:df_copied_def; str:'Copied Typedef'),
  1338. (mask:df_genconstraint; str:'Generic Constraint'),
  1339. { this should never happen for defs stored to a ppu file }
  1340. (mask:df_not_registered_no_free; str:'Unregistered/No free (invalid)'),
  1341. (mask:df_llvm_no_struct_packing; str:'LLVM unpacked struct')
  1342. );
  1343. defstate : array[1..ord(high(tdefstate))] of tdefstateinfo=(
  1344. (mask:ds_vmt_written; str:'VMT Written'),
  1345. (mask:ds_rtti_table_used; str:'RTTITable Used'),
  1346. (mask:ds_init_table_used; str:'InitTable Used'),
  1347. (mask:ds_rtti_table_written; str:'RTTITable Written'),
  1348. (mask:ds_init_table_written; str:'InitTable Written'),
  1349. (mask:ds_dwarf_dbg_info_used; str:'Dwarf DbgInfo Used'),
  1350. (mask:ds_dwarf_dbg_info_written;str:'Dwarf DbgInfo Written')
  1351. );
  1352. genconstrflag : array[1..ord(high(tgenericconstraintflag))] of tgenconstrflag=(
  1353. (mask:gcf_constructor; str:'Constructor'),
  1354. (mask:gcf_class; str:'Class'),
  1355. (mask:gcf_record; str:'Record')
  1356. );
  1357. var
  1358. defstates : tdefstates;
  1359. i, nb{, msgvalue}, mesgnb : longint;
  1360. first : boolean;
  1361. copy_size, min_size, tokenbufsize : longint;
  1362. tokenbuf : pbyte;
  1363. // idtoken,
  1364. token : ttoken;
  1365. // state : tmsgstate;
  1366. new_settings : Tsettings;
  1367. len : sizeint;
  1368. wstring : widestring;
  1369. astring : ansistring;
  1370. genconstr : tgenericconstraintflags;
  1371. function readtoken: ttoken;
  1372. var
  1373. b,b2 : byte;
  1374. begin
  1375. b:=tokenbuf[i];
  1376. inc(i);
  1377. if (b and $80)<>0 then
  1378. begin
  1379. b2:=tokenbuf[i];
  1380. inc(i);
  1381. result:=ttoken(((b and $7f) shl 8) or b2);
  1382. end
  1383. else
  1384. result:=ttoken(b);
  1385. end;
  1386. function gettokenbufdword : dword;
  1387. var
  1388. var32 : dword;
  1389. begin
  1390. var32:=pdword(@tokenbuf[i])^;
  1391. inc(i,sizeof(dword));
  1392. if ppufile.change_endian then
  1393. var32:=swapendian(var32);
  1394. result:=var32;
  1395. end;
  1396. function gettokenbufword : word;
  1397. var
  1398. var16 : word;
  1399. begin
  1400. var16:=pword(@tokenbuf[i])^;
  1401. inc(i,sizeof(word));
  1402. if ppufile.change_endian then
  1403. var16:=swapendian(var16);
  1404. result:=var16;
  1405. end;
  1406. function gettokenbufsizeint : int64;
  1407. var
  1408. var64 : int64;
  1409. var32 : longint;
  1410. var16 : smallint;
  1411. begin
  1412. if CpuAddrBitSize[cpu]=64 then
  1413. begin
  1414. var64:=pint64(@tokenbuf[i])^;
  1415. inc(i,sizeof(int64));
  1416. if ppufile.change_endian then
  1417. var64:=swapendian(var64);
  1418. result:=var64;
  1419. end
  1420. else if CpuAddrBitSize[cpu]=32 then
  1421. begin
  1422. var32:=plongint(@tokenbuf[i])^;
  1423. inc(i,sizeof(longint));
  1424. if ppufile.change_endian then
  1425. var32:=swapendian(var32);
  1426. result:=var32;
  1427. end
  1428. else if CpuAddrBitSize[cpu]=16 then
  1429. begin
  1430. var16:=psmallint(@tokenbuf[i])^;
  1431. inc(i,sizeof(smallint));
  1432. if ppufile.change_endian then
  1433. var16:=swapendian(var16);
  1434. result:=var16;
  1435. end
  1436. else
  1437. begin
  1438. WriteError('Wrong CpuAddrBitSize');
  1439. result:=0;
  1440. end;
  1441. end;
  1442. begin
  1443. i:=ppufile.getlongint;
  1444. if Def <> nil then
  1445. Def.Id:=i;
  1446. writeln([space,'** Definition Id ',i,' **']);
  1447. writeln([space,s]);
  1448. write ([space,' Type symbol : ']);
  1449. if Def <> nil then
  1450. readderef('', Def.Ref)
  1451. else
  1452. readderef('');
  1453. write ([space,' DefOptions : ']);
  1454. ppufile.getsmallset(defoptions);
  1455. if defoptions<>[] then
  1456. begin
  1457. first:=true;
  1458. for i:=1to high(defopt) do
  1459. if (defopt[i].mask in defoptions) then
  1460. begin
  1461. if first then
  1462. first:=false
  1463. else
  1464. write(', ');
  1465. write(defopt[i].str);
  1466. end;
  1467. end;
  1468. writeln;
  1469. write ([space,' DefStates : ']);
  1470. ppufile.getsmallset(defstates);
  1471. if defstates<>[] then
  1472. begin
  1473. first:=true;
  1474. for i:=1 to high(defstate) do
  1475. if (defstate[i].mask in defstates) then
  1476. begin
  1477. if first then
  1478. first:=false
  1479. else
  1480. write(', ');
  1481. write(defstate[i].str);
  1482. end;
  1483. end;
  1484. writeln;
  1485. if df_genconstraint in defoptions then
  1486. begin
  1487. ppufile.getsmallset(genconstr);
  1488. write ([space,' GenConstraints : ']);
  1489. if genconstr<>[] then
  1490. begin
  1491. first:=true;
  1492. for i:=1 to high(genconstrflag) do
  1493. if (genconstrflag[i].mask in genconstr) then
  1494. begin
  1495. if first then
  1496. first:=false
  1497. else
  1498. write(', ');
  1499. write(genconstrflag[i].str);
  1500. end;
  1501. end;
  1502. writeln;
  1503. len:=ppufile.getasizeint;
  1504. if len>0 then
  1505. begin
  1506. space:=' '+space;
  1507. writeln([space,'------ constraint defs begin ------']);
  1508. for i:=0 to len-1 do
  1509. begin
  1510. writeln([space,'------ constraint def ',i,' ------']);
  1511. readderef(space);
  1512. end;
  1513. writeln([space,'------ constraint defs end ------']);
  1514. delete(space,1,4);
  1515. end;
  1516. end;
  1517. if [df_generic,df_specialization]*defoptions<>[] then
  1518. begin
  1519. nb:=ppufile.getlongint;
  1520. writeln([space,'has ',nb,' parameters']);
  1521. if nb>0 then
  1522. begin
  1523. for i:=0 to nb-1 do
  1524. begin
  1525. writeln([space,'parameter ',i,': ',ppufile.getstring]);
  1526. readderef(space);
  1527. end;
  1528. end;
  1529. end;
  1530. if df_generic in defoptions then
  1531. begin
  1532. tokenbufsize:=ppufile.getlongint;
  1533. writeln([space,' Tokenbuffer size : ',tokenbufsize]);
  1534. tokenbuf:=allocmem(tokenbufsize);
  1535. ppufile.getdata(tokenbuf^,tokenbufsize);
  1536. i:=0;
  1537. write([space,' Tokens: ']);
  1538. while i<tokenbufsize do
  1539. begin
  1540. token:=readtoken;
  1541. if token<>_GENERICSPECIALTOKEN then
  1542. begin
  1543. if token <= high(ttoken) then
  1544. write(arraytokeninfo[token].str)
  1545. else
  1546. begin
  1547. HasMoreInfos;
  1548. write('Error in Token List');
  1549. break;
  1550. end;
  1551. {idtoken:=}readtoken;
  1552. end;
  1553. case token of
  1554. _CWCHAR,
  1555. _CWSTRING :
  1556. begin
  1557. len:=gettokenbufsizeint;
  1558. setlength(wstring,len);
  1559. move(tokenbuf[i],wstring[1],len*2);
  1560. write([' ',wstring]);
  1561. inc(i,len*2);
  1562. end;
  1563. _CSTRING:
  1564. begin
  1565. len:=gettokenbufsizeint;
  1566. setlength(astring,len);
  1567. move(tokenbuf[i],astring[1],len);
  1568. write([' ',astring]);
  1569. inc(i,len);
  1570. end;
  1571. _CCHAR,
  1572. _INTCONST,
  1573. _REALNUMBER :
  1574. begin
  1575. write([' ',pshortstring(@tokenbuf[i])^]);
  1576. inc(i,tokenbuf[i]+1);
  1577. end;
  1578. _ID :
  1579. begin
  1580. write([' ',pshortstring(@tokenbuf[i])^]);
  1581. inc(i,tokenbuf[i]+1);
  1582. end;
  1583. _GENERICSPECIALTOKEN:
  1584. begin
  1585. { Short version of column change,
  1586. byte or $80 used }
  1587. if (tokenbuf[i] and $80)<>0 then
  1588. begin
  1589. write(['Col: ',tokenbuf[i] and $7f]);
  1590. inc(i);
  1591. end
  1592. else
  1593. case tspecialgenerictoken(tokenbuf[i]) of
  1594. ST_LOADSETTINGS:
  1595. begin
  1596. inc(i);
  1597. write('Settings');
  1598. { This does not load pmessage pointer }
  1599. new_settings.pmessage:=nil;
  1600. { TSettings size depends in target...
  1601. We first read the size of the copied part }
  1602. { Still not cross endian ready :( }
  1603. copy_size:=gettokenbufsizeint;
  1604. if copy_size < sizeof(tsettings)-sizeof(pointer) then
  1605. min_size:=copy_size
  1606. else
  1607. min_size:= sizeof(tsettings)-sizeof(pointer);
  1608. move(tokenbuf[i],new_settings, min_size);
  1609. inc(i,copy_size);
  1610. end;
  1611. ST_LOADMESSAGES:
  1612. begin
  1613. inc(i);
  1614. write('Messages:');
  1615. mesgnb:=tokenbuf[i];
  1616. inc(i);
  1617. for nb:=1 to mesgnb do
  1618. begin
  1619. {msgvalue:=}gettokenbufsizeint;
  1620. inc(i,sizeof(sizeint));
  1621. //state:=tmsgstate(gettokenbufsizeint);
  1622. end;
  1623. end;
  1624. ST_LINE:
  1625. begin
  1626. inc(i);
  1627. write(['Line: ',gettokenbufdword]);
  1628. end;
  1629. ST_COLUMN:
  1630. begin
  1631. inc(i);
  1632. write(['Col: ',gettokenbufword]);
  1633. end;
  1634. ST_FILEINDEX:
  1635. begin
  1636. inc(i);
  1637. write(['File: ',gettokenbufword]);
  1638. end;
  1639. end;
  1640. end;
  1641. end;
  1642. if i<tokenbufsize then
  1643. write(',');
  1644. end;
  1645. writeln;
  1646. freemem(tokenbuf);
  1647. end;
  1648. if df_specialization in defoptions then
  1649. begin
  1650. write ([space,' Orig. GenericDef : ']);
  1651. readderef('');
  1652. end;
  1653. current_defoptions:=defoptions;
  1654. end;
  1655. { Read abstract procdef and return if inline procdef }
  1656. { type tproccalloption is in globtype unit }
  1657. { type tproctypeoption is in globtype unit }
  1658. { type tprocoption is in globtype unit }
  1659. procedure read_abstract_proc_def(var proccalloption:tproccalloption;var procoptions:tprocoptions; ProcDef: TPpuProcDef);
  1660. type
  1661. tproccallopt=record
  1662. mask : tproccalloption;
  1663. str : string[30];
  1664. end;
  1665. tproctypeopt=record
  1666. mask : tproctypeoption;
  1667. str : string[30];
  1668. end;
  1669. tprocopt=record
  1670. mask : tprocoption;
  1671. str : string[31];
  1672. end;
  1673. const
  1674. {proccalloptionStr is also in globtype unit }
  1675. proctypeopt : array[1..ord(high(tproctypeoption))] of tproctypeopt=(
  1676. (mask:potype_proginit; str:'ProgInit'),
  1677. (mask:potype_unitinit; str:'UnitInit'),
  1678. (mask:potype_unitfinalize; str:'UnitFinalize'),
  1679. (mask:potype_constructor; str:'Constructor'),
  1680. (mask:potype_destructor; str:'Destructor'),
  1681. (mask:potype_operator; str:'Operator'),
  1682. (mask:potype_procedure; str:'Procedure'),
  1683. (mask:potype_function; str:'Function'),
  1684. (mask:potype_class_constructor; str:'Class Constructor'),
  1685. (mask:potype_class_destructor; str:'Class Destructor'),
  1686. { Dispinterface property accessors }
  1687. (mask:potype_propgetter; str:'Property Getter'),
  1688. (mask:potype_propsetter; str:'Property Setter'),
  1689. (mask:potype_exceptfilter; str:'SEH filter'),
  1690. (mask:potype_mainstub; str:'main stub')
  1691. );
  1692. procopt : array[1..ord(high(tprocoption))] of tprocopt=(
  1693. (mask:po_classmethod; str:'ClassMethod'),
  1694. (mask:po_virtualmethod; str:'VirtualMethod'),
  1695. (mask:po_abstractmethod; str:'AbstractMethod'),
  1696. (mask:po_finalmethod; str:'FinalMethod'),
  1697. (mask:po_staticmethod; str:'StaticMethod'),
  1698. (mask:po_overridingmethod;str:'OverridingMethod'),
  1699. (mask:po_methodpointer; str:'MethodPointer'),
  1700. (mask:po_interrupt; str:'Interrupt'),
  1701. (mask:po_iocheck; str:'IOCheck'),
  1702. (mask:po_assembler; str:'Assembler'),
  1703. (mask:po_msgstr; str:'MsgStr'),
  1704. (mask:po_msgint; str:'MsgInt'),
  1705. (mask:po_exports; str:'Exports'),
  1706. (mask:po_external; str:'External'),
  1707. (mask:po_overload; str:'Overload'),
  1708. (mask:po_varargs; str:'VarArgs'),
  1709. (mask:po_internconst; str:'InternConst'),
  1710. (mask:po_addressonly; str:'AddressOnly'),
  1711. (mask:po_public; str:'Public'),
  1712. (mask:po_hascallingconvention;str:'HasCallingConvention'),
  1713. (mask:po_reintroduce; str:'ReIntroduce'),
  1714. (mask:po_explicitparaloc; str:'ExplicitParaloc'),
  1715. (mask:po_nostackframe; str:'NoStackFrame'),
  1716. (mask:po_has_mangledname; str:'HasMangledName'),
  1717. (mask:po_has_public_name; str:'HasPublicName'),
  1718. (mask:po_forward; str:'Forward'),
  1719. (mask:po_global; str:'Global'),
  1720. (mask:po_syscall_legacy; str:'SyscallLegacy'),
  1721. (mask:po_syscall_sysv; str:'SyscallSysV'),
  1722. (mask:po_syscall_basesysv;str:'SyscallBaseSysV'),
  1723. (mask:po_syscall_sysvbase;str:'SyscallSysVBase'),
  1724. (mask:po_syscall_r12base; str:'SyscallR12Base'),
  1725. (mask:po_syscall_has_libsym; str:'Has LibSym'),
  1726. (mask:po_inline; str:'Inline'),
  1727. (mask:po_compilerproc; str:'CompilerProc'),
  1728. (mask:po_has_importdll; str:'HasImportDLL'),
  1729. (mask:po_has_importname; str:'HasImportName'),
  1730. (mask:po_kylixlocal; str:'KylixLocal'),
  1731. (mask:po_dispid; str:'DispId'),
  1732. (mask:po_weakexternal; str:'WeakExternal'),
  1733. (mask:po_objc; str:'ObjC'),
  1734. (mask:po_enumerator_movenext; str:'EnumeratorMoveNext'),
  1735. (mask:po_optional; str: 'Optional'),
  1736. (mask:po_delphi_nested_cc;str: 'Delphi-style nested frameptr'),
  1737. (mask:po_java_nonvirtual; str: 'Java non-virtual method'),
  1738. (mask:po_ignore_for_overload_resolution;str: 'Ignored for overload resolution'),
  1739. (mask:po_rtlproc; str: 'RTL procedure'),
  1740. (mask:po_auto_raised_visibility; str: 'Visibility raised by compiler'),
  1741. (mask:po_far; str: 'Far'),
  1742. (mask:po_noreturn; str: 'No return'),
  1743. (mask:po_is_function_ref; str: 'Function reference'),
  1744. (mask:po_is_block; str: 'C "Block"'),
  1745. (mask:po_is_auto_getter; str: 'Automatically generated getter'),
  1746. (mask:po_is_auto_setter; str: 'Automatically generated setter')
  1747. );
  1748. var
  1749. proctypeoption : tproctypeoption;
  1750. i : longint;
  1751. first : boolean;
  1752. tempbuf : array[0..255] of byte;
  1753. begin
  1754. write([space,' Return type : ']);
  1755. readderef('', ProcDef.ReturnType);
  1756. proctypeoption:=tproctypeoption(ppufile.getbyte);
  1757. case proctypeoption of
  1758. potype_function: Include(ProcDef.Options, poFunction);
  1759. potype_procedure: Include(ProcDef.Options, poProcedure);
  1760. potype_constructor: Include(ProcDef.Options, poConstructor);
  1761. potype_destructor: Include(ProcDef.Options, poDestructor);
  1762. potype_operator: Include(ProcDef.Options, poOperator);
  1763. end;
  1764. write([space,' TypeOption : ']);
  1765. first:=true;
  1766. for i:=1 to high(proctypeopt) do
  1767. if (proctypeopt[i].mask=proctypeoption) then
  1768. begin
  1769. if first then
  1770. first:=false
  1771. else
  1772. write(', ');
  1773. write(proctypeopt[i].str);
  1774. end;
  1775. writeln;
  1776. proccalloption:=tproccalloption(ppufile.getbyte);
  1777. writeln([space,' CallOption : ',proccalloptionStr[proccalloption]]);
  1778. ppufile.getnormalset(procoptions);
  1779. if procoptions<>[] then
  1780. begin
  1781. if po_classmethod in procoptions then Include(ProcDef.Options, poClassMethod);
  1782. if po_virtualmethod in procoptions then Include(ProcDef.Options, poVirtual);
  1783. if po_abstractmethod in procoptions then Include(ProcDef.Options, poAbstract);
  1784. if po_overridingmethod in procoptions then Include(ProcDef.Options, poOverriding);
  1785. if po_overload in procoptions then Include(ProcDef.Options, poOverload);
  1786. if po_inline in procoptions then Include(ProcDef.Options, poInline);
  1787. if (po_methodpointer in procoptions) and (ProcDef.DefType = dtProcType) then
  1788. TPpuProcTypeDef(ProcDef).MethodPtr:=True;
  1789. write([space,' Options : ']);
  1790. first:=true;
  1791. for i:=1 to high(procopt) do
  1792. if (procopt[i].mask in procoptions) then
  1793. begin
  1794. if first then
  1795. first:=false
  1796. else
  1797. write(', ');
  1798. write(procopt[i].str);
  1799. end;
  1800. writeln;
  1801. end;
  1802. if (po_explicitparaloc in procoptions) then
  1803. begin
  1804. i:=ppufile.getbyte;
  1805. ppufile.getdata(tempbuf,i);
  1806. end;
  1807. if po_syscall_has_libsym in procoptions then
  1808. readderef(space);
  1809. end;
  1810. { type tvaroption is in unit symconst }
  1811. { register variable }
  1812. { type tvarregable is in unit symconst }
  1813. procedure readabstractvarsym(const s:string;var varoptions:tvaroptions; VarDef: TPpuVarDef = nil);
  1814. type
  1815. tvaropt=record
  1816. mask : tvaroption;
  1817. str : string[30];
  1818. end;
  1819. const
  1820. varopt : array[1..ord(high(tvaroption))] of tvaropt=(
  1821. (mask:vo_is_external; str:'External'),
  1822. (mask:vo_is_dll_var; str:'DLLVar'),
  1823. (mask:vo_is_thread_var; str:'ThreadVar'),
  1824. (mask:vo_has_local_copy; str:'HasLocalCopy'),
  1825. (mask:vo_is_const; str:'Constant'),
  1826. (mask:vo_is_public; str:'Public'),
  1827. (mask:vo_is_high_para; str:'HighValue'),
  1828. (mask:vo_is_funcret; str:'Funcret'),
  1829. (mask:vo_is_self; str:'Self'),
  1830. (mask:vo_is_vmt; str:'VMT'),
  1831. (mask:vo_is_result; str:'Result'),
  1832. (mask:vo_is_parentfp; str:'ParentFP'),
  1833. (mask:vo_is_loop_counter; str:'LoopCounter'),
  1834. (mask:vo_is_hidden_para; str:'Hidden'),
  1835. (mask:vo_has_explicit_paraloc;str:'ExplicitParaloc'),
  1836. (mask:vo_is_syscall_lib; str:'SysCallLib'),
  1837. (mask:vo_has_mangledname; str:'HasMangledName'),
  1838. (mask:vo_is_typed_const; str:'TypedConst'),
  1839. (mask:vo_is_range_check; str:'RangeCheckSwitch'),
  1840. (mask:vo_is_overflow_check; str:'OverflowCheckSwitch'),
  1841. (mask:vo_is_typinfo_para; str:'TypeInfo'),
  1842. (mask:vo_is_msgsel;str:'MsgSel'),
  1843. (mask:vo_is_weak_external;str:'WeakExternal'),
  1844. (mask:vo_is_first_field;str:'IsFirstField'),
  1845. (mask:vo_volatile; str:'Volatile'),
  1846. (mask:vo_has_section; str:'HasSection'),
  1847. (mask:vo_force_finalize; str:'ForceFinalize'),
  1848. (mask:vo_is_default_var; str:'DefaultIntrinsicVar')
  1849. );
  1850. var
  1851. i : longint;
  1852. first : boolean;
  1853. begin
  1854. readcommonsym(s, VarDef);
  1855. i:=ppufile.getbyte;
  1856. if (VarDef <> nil) and (VarDef.DefType = dtParam) then
  1857. with TPpuParamDef(VarDef) do
  1858. case tvarspez(i) of
  1859. vs_value: Spez:=psValue;
  1860. vs_var: Spez:=psVar;
  1861. vs_out: Spez:=psOut;
  1862. vs_const: Spez:=psConst;
  1863. vs_constref: Spez:=psConstRef;
  1864. end;
  1865. writeln([space,' Spez : ',Varspez2Str(i)]);
  1866. writeln([space,' Regable : ',Varregable2Str(ppufile.getbyte)]);
  1867. writeln([space,' Addr Taken : ',(ppufile.getbyte<>0)]);
  1868. write ([space,' Var Type : ']);
  1869. if VarDef <> nil then
  1870. readderef('',VarDef.VarType)
  1871. else
  1872. readderef('');
  1873. ppufile.getsmallset(varoptions);
  1874. if varoptions<>[] then
  1875. begin
  1876. if (VarDef <> nil) and (VarDef.DefType = dtParam) and (vo_is_hidden_para in varoptions) then
  1877. TPpuParamDef(VarDef).Spez:=psHidden;
  1878. write([space,' Options : ']);
  1879. first:=true;
  1880. for i:=1 to high(varopt) do
  1881. if (varopt[i].mask in varoptions) then
  1882. begin
  1883. if first then
  1884. first:=false
  1885. else
  1886. write(', ');
  1887. write(varopt[i].str);
  1888. end;
  1889. writeln;
  1890. end;
  1891. end;
  1892. procedure readobjectdefoptions(ObjDef: TPpuObjectDef = nil);
  1893. type
  1894. tsymopt=record
  1895. mask : tobjectoption;
  1896. str : string[30];
  1897. end;
  1898. const
  1899. symopt : array[1..ord(high(tobjectoption))] of tsymopt=(
  1900. (mask:oo_is_forward; str:'IsForward'),
  1901. (mask:oo_is_abstract; str:'IsAbstract'),
  1902. (mask:oo_is_sealed; str:'IsSealed'),
  1903. (mask:oo_has_virtual; str:'HasVirtual'),
  1904. (mask:oo_has_private; str:'HasPrivate'),
  1905. (mask:oo_has_protected; str:'HasProtected'),
  1906. (mask:oo_has_strictprivate; str:'HasStrictPrivate'),
  1907. (mask:oo_has_strictprotected;str:'HasStrictProtected'),
  1908. (mask:oo_has_constructor; str:'HasConstructor'),
  1909. (mask:oo_has_destructor; str:'HasDestructor'),
  1910. (mask:oo_has_vmt; str:'HasVMT'),
  1911. (mask:oo_has_msgstr; str:'HasMsgStr'),
  1912. (mask:oo_has_msgint; str:'HasMsgInt'),
  1913. (mask:oo_can_have_published; str:'CanHavePublished'),
  1914. (mask:oo_has_default_property;str:'HasDefaultProperty'),
  1915. (mask:oo_has_valid_guid; str:'HasValidGUID'),
  1916. (mask:oo_has_enumerator_movenext; str:'HasEnumeratorMoveNext'),
  1917. (mask:oo_has_enumerator_current; str:'HasEnumeratorCurrent'),
  1918. (mask:oo_is_external; str:'External'),
  1919. (mask:oo_is_formal; str:'Formal'),
  1920. (mask:oo_is_classhelper; str:'Class Helper/Category'),
  1921. (mask:oo_has_class_constructor; str:'HasClassConstructor'),
  1922. (mask:oo_has_class_destructor; str:'HasClassDestructor'),
  1923. (mask:oo_is_enum_class; str:'JvmEnumClass'),
  1924. (mask:oo_has_new_destructor; str:'HasNewDestructor')
  1925. );
  1926. var
  1927. i : longint;
  1928. first : boolean;
  1929. begin
  1930. ppufile.getsmallset(current_objectoptions);
  1931. if current_objectoptions<>[] then
  1932. begin
  1933. if ObjDef <> nil then
  1934. begin
  1935. if oo_is_abstract in current_objectoptions then
  1936. Include(ObjDef.Options, ooIsAbstract);
  1937. end;
  1938. first:=true;
  1939. for i:=1 to high(symopt) do
  1940. if (symopt[i].mask in current_objectoptions) then
  1941. begin
  1942. if first then
  1943. first:=false
  1944. else
  1945. write(', ');
  1946. write(symopt[i].str);
  1947. end;
  1948. end;
  1949. writeln;
  1950. end;
  1951. procedure readprocimploptions(const space: string; out implprocoptions: timplprocoptions);
  1952. type
  1953. tpiopt=record
  1954. mask : timplprocoption;
  1955. str : string[30];
  1956. end;
  1957. const
  1958. piopt : array[low(timplprocoption)..high(timplprocoption)] of tpiopt=(
  1959. (mask:pio_empty; str:'IsEmpty'),
  1960. (mask:pio_has_inlininginfo; str:'HasInliningInfo')
  1961. );
  1962. var
  1963. i: timplprocoption;
  1964. first: boolean;
  1965. begin
  1966. ppufile.getsmallset(implprocoptions);
  1967. if implprocoptions<>[] then
  1968. begin
  1969. first:=true;
  1970. write([space,' Options : ']);
  1971. for i:=low(piopt) to high(piopt) do
  1972. begin
  1973. if i in implprocoptions then
  1974. begin
  1975. if first then
  1976. first:=false
  1977. else
  1978. write(', ');
  1979. write(piopt[i].str);
  1980. end;
  1981. end;
  1982. writeln;
  1983. end;
  1984. end;
  1985. procedure readarraydefoptions(ArrayDef: TPpuArrayDef);
  1986. { type tarraydefoption is in unit symconst }
  1987. const
  1988. symopt : array[tarraydefoption] of string = (
  1989. { ado_IsConvertedPointer } 'ConvertedPointer',
  1990. { ado_IsDynamicArray } 'IsDynamicArray',
  1991. { ado_IsVariant } 'IsVariant',
  1992. { ado_IsConstructor } 'IsConstructor',
  1993. { ado_IsArrayOfConst } 'ArrayOfConst',
  1994. { ado_IsConstString } 'ConstString',
  1995. { ado_IsBitPacked } 'BitPacked'
  1996. );
  1997. var
  1998. symoptions: tarraydefoptions;
  1999. i: tarraydefoption;
  2000. first: boolean;
  2001. begin
  2002. ppufile.getsmallset(symoptions);
  2003. if symoptions<>[] then
  2004. begin
  2005. if ado_IsDynamicArray in symoptions then Include(ArrayDef.Options, aoDynamic);
  2006. first:=true;
  2007. for i:=Low(symopt) to high(symopt) do
  2008. if (i in symoptions) then
  2009. begin
  2010. if first then
  2011. first:=false
  2012. else
  2013. write(', ');
  2014. write(symopt[i]);
  2015. end;
  2016. end;
  2017. writeln;
  2018. end;
  2019. (* options for properties
  2020. tpropertyoption=(ppo_none,
  2021. ppo_indexed,
  2022. ppo_defaultproperty,
  2023. ppo_stored,
  2024. ppo_hasparameters,
  2025. ppo_implements,
  2026. ppo_enumerator_current,
  2027. ppo_overrides,
  2028. ppo_dispid_write { no longer used }
  2029. );
  2030. tpropertyoptions=set of tpropertyoption;
  2031. *)
  2032. function readpropertyoptions:tpropertyoptions;
  2033. { type tarraydefoption is in unit symconst }
  2034. type
  2035. tpropopt=record
  2036. mask : tpropertyoption;
  2037. str : string[30];
  2038. end;
  2039. const
  2040. symopt : array[1..ord(high(tpropertyoption))] of tpropopt=(
  2041. (mask:ppo_indexed;str:'indexed'),
  2042. (mask:ppo_defaultproperty;str:'default'),
  2043. (mask:ppo_stored;str:'stored'),
  2044. (mask:ppo_hasparameters;str:'has parameters'),
  2045. (mask:ppo_implements;str:'implements'),
  2046. (mask:ppo_enumerator_current;str:'enumerator current'),
  2047. (mask:ppo_overrides;str:'overrides'),
  2048. (mask:ppo_dispid_write;str:'dispid write') { no longer used }
  2049. );
  2050. var
  2051. i : longint;
  2052. first : boolean;
  2053. begin
  2054. ppufile.getsmallset(result);
  2055. if result<>[] then
  2056. begin
  2057. first:=true;
  2058. for i:=1 to high(symopt) do
  2059. if (symopt[i].mask in result) then
  2060. begin
  2061. if first then
  2062. first:=false
  2063. else
  2064. write(', ');
  2065. write(symopt[i].str);
  2066. end;
  2067. end;
  2068. writeln;
  2069. end;
  2070. procedure readnodetree;
  2071. var
  2072. l : longint;
  2073. p : pointer;
  2074. begin
  2075. with ppufile do
  2076. begin
  2077. if space<>'' then
  2078. Writeln([space,'------ nodetree ------']);
  2079. if readentry=ibnodetree then
  2080. begin
  2081. l:=entrysize;
  2082. Writeln([space,'Tree size : ',l]);
  2083. { Read data to prevent error that entry is not completly read }
  2084. getmem(p,l);
  2085. getdata(p^,l);
  2086. freemem(p);
  2087. end
  2088. else
  2089. begin
  2090. WriteError('!! ibnodetree not found');
  2091. end;
  2092. end;
  2093. end;
  2094. procedure ReadCreatedObjTypes;
  2095. var
  2096. i,j,
  2097. len,
  2098. bssize: longint;
  2099. bs: pbyte;
  2100. begin
  2101. if ppufile.readentry<>ibcreatedobjtypes then
  2102. begin
  2103. WriteError('!! ibcreatedobjtypes entry not found');
  2104. ppufile.skipdata(ppufile.entrysize);
  2105. exit
  2106. end;
  2107. writeln;
  2108. writeln([space,'WPO info']);
  2109. writeln([space,'--------']);
  2110. len:=ppufile.getlongint;
  2111. writeln([space,'** Instantiated Object/Class types: ',len,' **']);
  2112. space:=space+' ';
  2113. for i:=0 to len-1 do
  2114. readderef(space);
  2115. setlength(space,length(space)-2);
  2116. len:=ppufile.getlongint;
  2117. writeln([space,'** Instantiated ClassRef types: ',len,' **']);
  2118. space:=space+' ';
  2119. for i:=0 to len-1 do
  2120. readderef(space);
  2121. setlength(space,length(space)-2);
  2122. len:=ppufile.getlongint;
  2123. writeln([space,'** Possibly instantiated ClassRef types : ',len,' **']);
  2124. space:=space+' ';
  2125. for i:=0 to len-1 do
  2126. readderef(space);
  2127. setlength(space,length(space)-2);
  2128. len:=ppufile.getlongint;
  2129. writeln([space,'** Class types with called virtual methods info : ',len,' **']);
  2130. space:=space+' ';
  2131. for i:=0 to len-1 do
  2132. begin
  2133. write([space,'Class def : ']);
  2134. readderef('');
  2135. write([space+' ','Called vmtentries : ']);
  2136. bssize:=ppufile.getlongint;
  2137. getmem(bs,bssize);
  2138. ppufile.readdata(bs^,bssize);
  2139. for j:=0 to bssize*8-1 do
  2140. if (((bs+j shr 3)^ shr (j and 7)) and 1) <> 0 then
  2141. write([j,', ']);
  2142. writeln;
  2143. freemem(bs);
  2144. end;
  2145. setlength(space,length(space)-2);
  2146. end;
  2147. {****************************************************************************
  2148. Read Symbols Part
  2149. ****************************************************************************}
  2150. procedure readsymbols(const s:string; ParentDef: TPpuContainerDef = nil);
  2151. function _finddef(symdef: TPpuDef): TPpuDef;
  2152. begin
  2153. Result:=nil;
  2154. if symdef.Ref.IsCurUnit then
  2155. begin;
  2156. Result:=CurUnit.FindById(symdef.Ref.Id);
  2157. if (Result <> nil) and (Result.Ref.Id = symdef.Id) then
  2158. begin
  2159. Result.Name:=symdef.Name;
  2160. Result.FilePos:=symdef.FilePos;
  2161. end
  2162. else
  2163. Result:=nil;
  2164. end;
  2165. end;
  2166. type
  2167. pguid = ^tguid;
  2168. tguid = packed record
  2169. D1: LongWord;
  2170. D2: Word;
  2171. D3: Word;
  2172. D4: array[0..7] of Byte;
  2173. end;
  2174. var
  2175. b : byte;
  2176. pc : pchar;
  2177. ch : dword;
  2178. startnewline : boolean;
  2179. i,j,len : longint;
  2180. prettyname, ss : ansistring;
  2181. ws: widestring;
  2182. guid : tguid;
  2183. realvalue : ppureal;
  2184. doublevalue : double;
  2185. singlevalue : single;
  2186. extended : TSplit80bitReal;
  2187. tempbuf : array[0..127] of char;
  2188. pw : pcompilerwidestring;
  2189. varoptions : tvaroptions;
  2190. propoptions : tpropertyoptions;
  2191. iexp: Tconstexprint;
  2192. def: TPpuDef;
  2193. constdef: TPpuConstDef absolute def;
  2194. begin
  2195. with ppufile do
  2196. begin
  2197. if space<>'' then
  2198. Writeln([space,'------ ',s,' ------']);
  2199. if readentry=ibstartsyms then
  2200. begin
  2201. Writeln([space,'Symtable count: ',getlongint]);
  2202. end
  2203. else
  2204. Writeln('!! ibstartsym not found');
  2205. repeat
  2206. def:=nil;
  2207. b:=readentry;
  2208. case b of
  2209. ibunitsym :
  2210. readcommonsym('Unit symbol ');
  2211. ibnamespacesym :
  2212. begin
  2213. readcommonsym('NameSpace symbol ');
  2214. write([space,' Hidden Unit : ']);
  2215. readderef('');
  2216. end;
  2217. iblabelsym :
  2218. readcommonsym('Label symbol ');
  2219. ibtypesym :
  2220. begin
  2221. def:=TPpuTypeRef.Create(nil);
  2222. readcommonsym('Type symbol ',def);
  2223. write([space,' Result Type : ']);
  2224. readderef('', def.Ref);
  2225. if _finddef(def) = nil then
  2226. def.Parent:=ParentDef;
  2227. prettyname:=getansistring;
  2228. if prettyname<>'' then
  2229. begin
  2230. write([space,' Pretty Name : ']);
  2231. Writeln(prettyname);
  2232. end;
  2233. end;
  2234. ibprocsym :
  2235. begin
  2236. def:=TPpuDef.Create(nil);
  2237. readcommonsym('Procedure symbol ', def);
  2238. len:=ppufile.getword;
  2239. for i:=1 to len do
  2240. begin
  2241. write([space,' Definition : ']);
  2242. readderef('', def.Ref);
  2243. _finddef(def);
  2244. end;
  2245. end;
  2246. ibconstsym :
  2247. begin
  2248. constdef:=TPpuConstDef.Create(ParentDef);
  2249. readcommonsym('Constant symbol ',constdef);
  2250. b:=getbyte;
  2251. case tconsttyp(b) of
  2252. constord :
  2253. begin
  2254. write ([space,' OrdinalType : ']);
  2255. readderef('',constdef.TypeRef);
  2256. iexp:=getexprint;
  2257. constdef.ConstType:=ctInt;
  2258. constdef.VInt:=iexp.svalue;
  2259. writeln([space,' Value : ',constexp.tostr(iexp)]);
  2260. end;
  2261. constpointer :
  2262. begin
  2263. write ([space,' PointerType : ']);
  2264. readderef('',constdef.TypeRef);
  2265. constdef.ConstType:=ctInt;
  2266. constdef.VInt:=getaint;
  2267. writeln([space,' Value : ',constdef.VInt])
  2268. end;
  2269. conststring,
  2270. constresourcestring :
  2271. begin
  2272. write ([space,' StringType : ']);
  2273. readderef('',constdef.TypeRef);
  2274. len:=getlongint;
  2275. getmem(pc,len+1);
  2276. getdata(pc^,len);
  2277. (pc+len)^:= #0;
  2278. writeln([space,' Length : ',len]);
  2279. writeln([space,' Value : "',pc,'"']);
  2280. constdef.ConstType:=ctStr;
  2281. SetString(constdef.VStr, pc, len);
  2282. constdef.VStr:=UTF8Encode(constdef.VStr);
  2283. freemem(pc,len+1);
  2284. end;
  2285. constreal :
  2286. begin
  2287. constdef.ConstType:=ctFloat;
  2288. write ([space,' RealType : ']);
  2289. readderef('',constdef.TypeRef);
  2290. write([space,' Value : ']);
  2291. if entryleft=sizeof(ppureal) then
  2292. begin
  2293. realvalue:=getrealsize(sizeof(ppureal));
  2294. constdef.VFloat:=realvalue;
  2295. writeln([realvalue]);
  2296. end
  2297. else if entryleft=sizeof(double) then
  2298. begin
  2299. doublevalue:=getrealsize(sizeof(double));
  2300. constdef.VFloat:=doublevalue;
  2301. writeln([doublevalue]);
  2302. end
  2303. else if entryleft=sizeof(single) then
  2304. begin
  2305. singlevalue:=getrealsize(sizeof(single));
  2306. constdef.VFloat:=singlevalue;
  2307. writeln([singlevalue]);
  2308. end
  2309. else if entryleft=10 then
  2310. begin
  2311. getdata(extended,entryleft);
  2312. ss:=Real80bitToStr(extended);
  2313. constdef.VFloat:=StrToFloat(ss);
  2314. writeln(ss);
  2315. end
  2316. else
  2317. begin
  2318. realvalue:=0.0;
  2319. WriteError('Error reading real value');
  2320. end;
  2321. end;
  2322. constset :
  2323. begin
  2324. constdef.ConstType:=ctSet;
  2325. write ([space,' Set Type : ']);
  2326. readderef('',constdef.TypeRef);
  2327. for i:=1to 4 do
  2328. begin
  2329. write ([space,' Value : ']);
  2330. for j:=1to 8 do
  2331. begin
  2332. if j>1 then
  2333. write(',');
  2334. b:=getbyte;
  2335. write(hexstr(b,2));
  2336. constdef.VSet[i*j-1]:=b;
  2337. end;
  2338. writeln;
  2339. end;
  2340. end;
  2341. constnil:
  2342. begin
  2343. write([space,' NIL pointer :']);
  2344. readderef('',constdef.TypeRef);
  2345. constdef.ConstType:=ctPtr;
  2346. constdef.VInt:=0;
  2347. end;
  2348. constwstring :
  2349. begin
  2350. initwidestring(pw);
  2351. setlengthwidestring(pw,getlongint);
  2352. if widecharsize=2 then
  2353. { don't use getdata, because the compilerwidechars may have to
  2354. be byteswapped
  2355. }
  2356. begin
  2357. for i:=0 to pw^.len-1 do
  2358. pw^.data[i]:=ppufile.getword;
  2359. SetString(ws, PWideChar(pw^.data), pw^.len);
  2360. constdef.VStr:=UTF8Encode(ws);
  2361. constdef.ConstType:=ctStr;
  2362. end
  2363. else if widecharsize=4 then
  2364. begin
  2365. for i:=0 to pw^.len-1 do
  2366. pw^.data[i]:=cardinal(ppufile.getlongint);
  2367. end
  2368. else
  2369. begin
  2370. WriteError('Unsupported tcompilerwidechar size');
  2371. end;
  2372. Write([space,'Wide string type']);
  2373. startnewline:=true;
  2374. for i:=0 to pw^.len-1 do
  2375. begin
  2376. if startnewline then
  2377. begin
  2378. writeln;
  2379. write(space);
  2380. startnewline:=false;
  2381. end;
  2382. ch:=pw^.data[i];
  2383. if widecharsize=2 then
  2384. write(hexstr(ch,4))
  2385. else
  2386. write(hexstr(ch,8));
  2387. if ((i + 1) mod 8)= 0 then
  2388. startnewline:=true
  2389. else
  2390. if i <> pw^.len-1 then
  2391. write(', ');
  2392. end;
  2393. donewidestring(pw);
  2394. Writeln;
  2395. end;
  2396. constguid:
  2397. begin
  2398. write ([space,' IntfType : ']);
  2399. readderef('',constdef.TypeRef);
  2400. getdata(guid,sizeof(guid));
  2401. write ([space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-']);
  2402. for i:=0 to 7 do
  2403. begin
  2404. write(hexstr(guid.d4[i],2));
  2405. if i=1 then write('-');
  2406. end;
  2407. writeln('}');
  2408. end
  2409. else
  2410. Writeln (['!! Invalid unit format : Invalid const type encountered: ',b]);
  2411. end;
  2412. end;
  2413. ibabsolutevarsym :
  2414. begin
  2415. def:=TPpuVarDef.Create(ParentDef);
  2416. readabstractvarsym('Absolute variable symbol ',varoptions,TPpuVarDef(def));
  2417. Write ([space,' Relocated to ']);
  2418. b:=getbyte;
  2419. case absolutetyp(b) of
  2420. tovar :
  2421. readpropaccesslist(space+' Sym : ');
  2422. toasm :
  2423. Writeln(['Assembler name : ',getstring]);
  2424. toaddr :
  2425. begin
  2426. Write(['Address : ',getaword]);
  2427. if tsystemcpu(ppufile.header.common.cpu)=cpu_i386 then
  2428. Write([' (Far: ',getbyte<>0,')']);
  2429. if tsystemcpu(ppufile.header.common.cpu)=cpu_i8086 then
  2430. if getbyte<>0 then
  2431. Write([' (Far: TRUE, Segment=',getaword,')'])
  2432. else
  2433. Write([' (Far: FALSE)']);
  2434. Writeln;
  2435. end;
  2436. else
  2437. Writeln (['!! Invalid unit format : Invalid absolute type encountered: ',b]);
  2438. end;
  2439. end;
  2440. ibfieldvarsym :
  2441. begin
  2442. def:=TPpuFieldDef.Create(ParentDef);
  2443. readabstractvarsym('Field Variable symbol ',varoptions,TPpuVarDef(def));
  2444. writeln([space,' Address : ',getaint]);
  2445. if vo_has_mangledname in varoptions then
  2446. writeln([space,' Mangled name : ',getstring]);
  2447. end;
  2448. ibstaticvarsym :
  2449. begin
  2450. def:=TPpuVarDef.Create(ParentDef);
  2451. readabstractvarsym('Global Variable symbol ',varoptions,TPpuVarDef(def));
  2452. write ([space,' DefaultConst : ']);
  2453. readderef('');
  2454. if (vo_has_mangledname in varoptions) then
  2455. if tsystemcpu(ppufile.header.common.cpu)=cpu_jvm then
  2456. writeln([space,'AMangledname : ',getansistring])
  2457. else
  2458. writeln([space,'SMangledname : ',getstring]);
  2459. if vo_has_section in varoptions then
  2460. writeln(['Section name:',ppufile.getansistring]);
  2461. write ([space,' FieldVarSymDeref: ']);
  2462. readderef('');
  2463. end;
  2464. iblocalvarsym :
  2465. begin
  2466. readabstractvarsym('Local Variable symbol ',varoptions);
  2467. write ([space,' DefaultConst : ']);
  2468. readderef('');
  2469. end;
  2470. ibparavarsym :
  2471. begin
  2472. def:=TPpuParamDef.Create(ParentDef);
  2473. readabstractvarsym('Parameter Variable symbol ',varoptions,TPpuVarDef(def));
  2474. write ([space,' DefaultConst : ']);
  2475. readderef('',TPpuParamDef(def).DefaultValue);
  2476. writeln([space,' ParaNr : ',getword]);
  2477. writeln([space,' Univ : ',boolean(getbyte)]);
  2478. writeln([space,' VarState : ',getbyte]);
  2479. writeln([space,' Refs : ',getbyte]);
  2480. if (vo_has_explicit_paraloc in varoptions) then
  2481. begin
  2482. i:=getbyte;
  2483. getdata(tempbuf,i);
  2484. end;
  2485. end;
  2486. ibenumsym :
  2487. begin
  2488. def:=TPpuConstDef.Create(nil);
  2489. readcommonsym('Enumeration symbol ',def);
  2490. write ([space,' Definition : ']);
  2491. readderef('');
  2492. TPpuConstDef(def).ConstType:=ctInt;
  2493. TPpuConstDef(def).VInt:=getlongint;
  2494. writeln([space,' Value : ',TPpuConstDef(def).VInt]);
  2495. if (ParentDef <> nil) and (ParentDef.DefType = dtEnum) then
  2496. def.Parent:=ParentDef;
  2497. end;
  2498. ibsyssym :
  2499. begin
  2500. readcommonsym('Internal system symbol ');
  2501. writeln([space,' Internal Nr : ',getlongint]);
  2502. end;
  2503. ibmacrosym :
  2504. begin
  2505. readcommonsym('Macro symbol ');
  2506. writeln([space,' Defined: ',boolean(getbyte)]);
  2507. writeln([space,' Compiler var: ',boolean(getbyte)]);
  2508. len:=getlongint;
  2509. writeln([space,' Value length: ',len]);
  2510. if len > 0 then
  2511. begin
  2512. getmem(pc,len+1);
  2513. getdata(pc^,len);
  2514. (pc+len)^:= #0;
  2515. writeln([space,' Value: "',pc,'"']);
  2516. freemem(pc,len+1);
  2517. end;
  2518. end;
  2519. ibpropertysym :
  2520. begin
  2521. def:=TPpuPropDef.Create(ParentDef);
  2522. readcommonsym('Property ',def);
  2523. propoptions:=readpropertyoptions;
  2524. if ppo_overrides in propoptions then
  2525. begin
  2526. write ([space,' OverrideProp : ']);
  2527. readderef('');
  2528. end;
  2529. if ppo_defaultproperty in propoptions then
  2530. Include(TPpuPropDef(def).Options, poDefault);
  2531. write ([space,' Prop Type : ']);
  2532. readderef('',TPpuPropDef(def).PropType);
  2533. writeln([space,' Index : ',getlongint]);
  2534. writeln([space,' Default : ',getlongint]);
  2535. write ([space,' Index Type : ']);
  2536. readderef('');
  2537. { palt_none }
  2538. readpropaccesslist('');
  2539. write ([space,' Readaccess : ']);
  2540. readpropaccesslist(space+' Sym: ',TPpuPropDef(def).Getter);
  2541. write ([space,' Writeaccess : ']);
  2542. readpropaccesslist(space+' Sym: ',TPpuPropDef(def).Setter);
  2543. write ([space,' Storedaccess : ']);
  2544. readpropaccesslist(space+' Sym: ');
  2545. if [ppo_hasparameters,ppo_overrides]*propoptions=[ppo_hasparameters] then
  2546. begin
  2547. space:=' '+space;
  2548. readsymtable('parast',TPpuPropDef(def));
  2549. delete(space,1,4);
  2550. end;
  2551. end;
  2552. iberror :
  2553. begin
  2554. WriteError('!! Error in PPU');
  2555. exit;
  2556. end;
  2557. ibendsyms :
  2558. break;
  2559. else
  2560. begin
  2561. WriteError('!! Skipping unsupported PPU Entry in Symbols: '+IntToStr(b));
  2562. end;
  2563. end;
  2564. if (def <> nil) and (def.Parent = nil) then
  2565. def.Free;
  2566. if not EndOfEntry then
  2567. HasMoreInfos;
  2568. until false;
  2569. end;
  2570. end;
  2571. {****************************************************************************
  2572. Read defintions Part
  2573. ****************************************************************************}
  2574. procedure readdefinitions(const s:string; ParentDef: TPpuContainerDef);
  2575. { type tordtype is in symconst unit }
  2576. {
  2577. uvoid,
  2578. u8bit,u16bit,u32bit,u64bit,u128bit,
  2579. s8bit,s16bit,s32bit,s64bit,s128bit,
  2580. bool8bit,bool16bit,bool32bit,bool64bit,
  2581. uchar,uwidechar,scurrency
  2582. ); }
  2583. { type tobjecttyp is in symconst unit }
  2584. { type tvarianttype is in symconst unit }
  2585. var
  2586. b : byte;
  2587. l,j,tokenbufsize : longint;
  2588. tokenbuf : pbyte;
  2589. calloption : tproccalloption;
  2590. procoptions : tprocoptions;
  2591. implprocoptions: timplprocoptions;
  2592. defoptions: tdefoptions;
  2593. iexpr: Tconstexprint;
  2594. def: TPpuDef;
  2595. objdef: TPpuObjectDef absolute def;
  2596. arrdef: TPpuArrayDef absolute def;
  2597. enumdef: TPpuEnumDef absolute def;
  2598. setdef: TPpuSetDef absolute def;
  2599. orddef: TPpuOrdDef absolute def;
  2600. floatdef: TPpuFloatDef absolute def;
  2601. strdef: TPpuStringDef absolute def;
  2602. filedef: TPpuFileDef absolute def;
  2603. begin
  2604. with ppufile do
  2605. begin
  2606. if space<>'' then
  2607. Writeln([space,'------ ',s,' ------']);
  2608. if readentry<>ibstartdefs then
  2609. Writeln('!! ibstartdefs not found');
  2610. repeat
  2611. def:=nil;
  2612. b:=readentry;
  2613. case b of
  2614. ibpointerdef :
  2615. begin
  2616. def:=TPpuPointerDef.Create(ParentDef);
  2617. readcommondef('Pointer definition',defoptions,def);
  2618. write ([space,' Pointed Type : ']);
  2619. readderef('',TPpuPointerDef(def).Ptr);
  2620. writeln([space,' Has Pointer Math : ',(getbyte<>0)]);
  2621. if tsystemcpu(ppufile.header.common.cpu) in [cpu_i8086,cpu_i386,cpu_x86_64] then
  2622. begin
  2623. write([space,' X86 Pointer Type : ']);
  2624. b:=getbyte;
  2625. case tx86pointertyp(b) of
  2626. x86pt_near: writeln('Near');
  2627. x86pt_near_cs: writeln('Near ''CS''');
  2628. x86pt_near_ds: writeln('Near ''DS''');
  2629. x86pt_near_ss: writeln('Near ''SS''');
  2630. x86pt_near_es: writeln('Near ''ES''');
  2631. x86pt_near_fs: writeln('Near ''FS''');
  2632. x86pt_near_gs: writeln('Near ''GS''');
  2633. x86pt_far: writeln('Far');
  2634. x86pt_huge: writeln('Huge');
  2635. else
  2636. WriteWarning('Invalid x86 pointer type: ' + IntToStr(b));
  2637. end;
  2638. end;
  2639. end;
  2640. iborddef :
  2641. begin
  2642. orddef:=TPpuOrdDef.Create(ParentDef);
  2643. readcommondef('Ordinal definition',defoptions,orddef);
  2644. write ([space,' Base type : ']);
  2645. b:=getbyte;
  2646. case tordtype(b) of
  2647. uvoid:
  2648. begin
  2649. writeln('uvoid');
  2650. orddef.OrdType:=otVoid;
  2651. end;
  2652. u8bit:
  2653. begin
  2654. writeln('u8bit');
  2655. orddef.OrdType:=otUInt;
  2656. orddef.Size:=1;
  2657. end;
  2658. u16bit:
  2659. begin
  2660. writeln('u16bit');
  2661. orddef.OrdType:=otUInt;
  2662. orddef.Size:=2;
  2663. end;
  2664. u32bit:
  2665. begin
  2666. writeln('u32bit');
  2667. orddef.OrdType:=otUInt;
  2668. orddef.Size:=4;
  2669. end;
  2670. u64bit:
  2671. begin
  2672. writeln('u64bit');
  2673. orddef.OrdType:=otUInt;
  2674. orddef.Size:=8;
  2675. end;
  2676. u128bit:
  2677. begin
  2678. writeln('u128bit');
  2679. orddef.OrdType:=otUInt;
  2680. orddef.Size:=16;
  2681. end;
  2682. s8bit:
  2683. begin
  2684. writeln('s8bit');
  2685. orddef.OrdType:=otSInt;
  2686. orddef.Size:=1;
  2687. end;
  2688. s16bit:
  2689. begin
  2690. writeln('s16bit');
  2691. orddef.OrdType:=otSInt;
  2692. orddef.Size:=2;
  2693. end;
  2694. s32bit:
  2695. begin
  2696. writeln('s32bit');
  2697. orddef.OrdType:=otSInt;
  2698. orddef.Size:=4;
  2699. end;
  2700. s64bit:
  2701. begin
  2702. writeln('s64bit');
  2703. orddef.OrdType:=otSInt;
  2704. orddef.Size:=8;
  2705. end;
  2706. s128bit:
  2707. begin
  2708. writeln('s128bit');
  2709. orddef.OrdType:=otSInt;
  2710. orddef.Size:=16;
  2711. end;
  2712. pasbool8:
  2713. begin
  2714. writeln('pasbool8');
  2715. orddef.OrdType:=otPasBool;
  2716. orddef.Size:=1;
  2717. end;
  2718. pasbool16:
  2719. begin
  2720. writeln('pasbool16');
  2721. orddef.OrdType:=otPasBool;
  2722. orddef.Size:=2;
  2723. end;
  2724. pasbool32:
  2725. begin
  2726. writeln('pasbool32');
  2727. orddef.OrdType:=otPasBool;
  2728. orddef.Size:=4;
  2729. end;
  2730. pasbool64:
  2731. begin
  2732. writeln('pasbool64');
  2733. orddef.OrdType:=otPasBool;
  2734. orddef.Size:=8;
  2735. end;
  2736. bool8bit:
  2737. begin
  2738. writeln('bool8bit');
  2739. orddef.OrdType:=otBool;
  2740. orddef.Size:=1;
  2741. end;
  2742. bool16bit:
  2743. begin
  2744. writeln('bool16bit');
  2745. orddef.OrdType:=otBool;
  2746. orddef.Size:=2;
  2747. end;
  2748. bool32bit:
  2749. begin
  2750. writeln('bool32bit');
  2751. orddef.OrdType:=otBool;
  2752. orddef.Size:=4;
  2753. end;
  2754. bool64bit:
  2755. begin
  2756. writeln('bool64bit');
  2757. orddef.OrdType:=otBool;
  2758. orddef.Size:=8;
  2759. end;
  2760. uchar:
  2761. begin
  2762. writeln('uchar');
  2763. orddef.OrdType:=otChar;
  2764. orddef.Size:=1;
  2765. end;
  2766. uwidechar:
  2767. begin
  2768. writeln('uwidechar');
  2769. orddef.OrdType:=otChar;
  2770. orddef.Size:=2;
  2771. end;
  2772. scurrency:
  2773. begin
  2774. writeln('scurrency');
  2775. orddef.OrdType:=otCurrency;
  2776. orddef.Size:=8;
  2777. end;
  2778. else
  2779. WriteWarning('Invalid base type: ' + IntToStr(b));
  2780. end;
  2781. iexpr:=getexprint;
  2782. orddef.RangeLow:=iexpr.svalue;
  2783. write([space,' Range : ',constexp.tostr(iexpr)]);
  2784. iexpr:=getexprint;
  2785. orddef.RangeHigh:=iexpr.svalue;
  2786. writeln([' to ',constexp.tostr(iexpr)]);
  2787. end;
  2788. ibfloatdef :
  2789. begin
  2790. floatdef:=TPpuFloatDef.Create(ParentDef);
  2791. readcommondef('Float definition',defoptions,floatdef);
  2792. write ([space,' Float type : ']);
  2793. b:=getbyte;
  2794. case b of
  2795. ftSingle:
  2796. begin
  2797. writeln('Single');
  2798. floatdef.FloatType:=pftSingle;
  2799. end;
  2800. ftDouble:
  2801. begin
  2802. writeln('Double');
  2803. floatdef.FloatType:=pftDouble;
  2804. end;
  2805. ftExtended:
  2806. begin
  2807. writeln('Extended');
  2808. floatdef.FloatType:=pftExtended;
  2809. end;
  2810. ftComp:
  2811. begin
  2812. writeln('Comp');
  2813. floatdef.FloatType:=pftComp;
  2814. end;
  2815. ftCurr:
  2816. begin
  2817. writeln('Currency');
  2818. floatdef.FloatType:=pftCurrency;
  2819. end;
  2820. ftFloat128:
  2821. begin
  2822. writeln('Float128');
  2823. floatdef.FloatType:=pftFloat128;
  2824. end;
  2825. else
  2826. WriteWarning('Invalid float type: ' + IntToStr(b));
  2827. end;
  2828. end;
  2829. ibarraydef :
  2830. begin
  2831. arrdef:=TPpuArrayDef.Create(ParentDef);
  2832. readcommondef('Array definition',defoptions,arrdef);
  2833. write ([space,' Element type : ']);
  2834. readderef('',arrdef.ElType);
  2835. write ([space,' Range Type : ']);
  2836. readderef('',arrdef.RangeType);
  2837. arrdef.RangeLow:=getasizeint;
  2838. arrdef.RangeHigh:=getasizeint;
  2839. writeln([space,' Range : ',arrdef.RangeLow,' to ',arrdef.RangeHigh]);
  2840. write ([space,' Options : ']);
  2841. readarraydefoptions(arrdef);
  2842. if tsystemcpu(ppufile.header.common.cpu)=cpu_i8086 then
  2843. writeln([space,' Huge : ',(getbyte<>0)]);
  2844. readsymtable('symbols', arrdef);
  2845. end;
  2846. ibprocdef :
  2847. begin
  2848. def:=TPpuProcDef.Create(ParentDef);
  2849. readcommondef('Procedure definition',defoptions,def);
  2850. read_abstract_proc_def(calloption,procoptions,TPpuProcDef(def));
  2851. if (po_has_mangledname in procoptions) then
  2852. if tsystemcpu(ppufile.header.common.cpu)=cpu_jvm then
  2853. writeln([space,' Mangled name : ',getansistring])
  2854. else
  2855. writeln([space,' Mangled name : ',getstring]);
  2856. writeln([space,' Number : ',getword]);
  2857. writeln([space,' Level : ',getbyte]);
  2858. write ([space,' Class : ']);
  2859. readderef('');
  2860. write ([space,' Procsym : ']);
  2861. readderef('', def.Ref);
  2862. write ([space,' File Pos : ']);
  2863. readposinfo(def);
  2864. write ([space,' Visibility : ']);
  2865. readvisibility(def);
  2866. write ([space,' SymOptions : ']);
  2867. readsymoptions(space+' ');
  2868. writeln ([space,' Synthetic kind : ',Synthetic2Str(ppufile.getbyte)]);
  2869. if (po_has_importdll in procoptions) then
  2870. writeln([space,' Import DLL : ',getstring]);
  2871. if (po_has_importname in procoptions) then
  2872. writeln([space,' Import Name : ',getstring]);
  2873. writeln([space,' Import Nr : ',getword]);
  2874. if (po_msgint in procoptions) then
  2875. writeln([space,' MsgInt : ',getlongint]);
  2876. if (po_msgstr in procoptions) then
  2877. writeln([space,' MsgStr : ',getstring]);
  2878. if (po_dispid in procoptions) then
  2879. writeln([space,' DispID: ',ppufile.getlongint]);
  2880. readprocimploptions(space,implprocoptions);
  2881. if (pio_has_inlininginfo in implprocoptions) then
  2882. begin
  2883. write ([space,' FuncretSym : ']);
  2884. readderef('');
  2885. readprocinfooptions(space);
  2886. end;
  2887. b:=ppufile.getbyte;
  2888. if b<>0 then
  2889. begin
  2890. write ([space,' Alias names : ']);
  2891. for j:=1 to b do
  2892. begin
  2893. write(ppufile.getstring);
  2894. if j<b then
  2895. write(', ');
  2896. end;
  2897. writeln;
  2898. end;
  2899. tokenbufsize:=ppufile.getlongint;
  2900. if tokenbufsize<>0 then
  2901. begin
  2902. write ([space,' Declaration token buffer : TODO']);
  2903. tokenbuf:=allocmem(tokenbufsize);
  2904. ppufile.getdata(tokenbuf^,tokenbufsize);
  2905. freemem(tokenbuf);
  2906. end;
  2907. if tsystemcpu(ppufile.header.common.cpu)=cpu_powerpc then
  2908. begin
  2909. if po_syscall_has_libsym in procoptions then
  2910. begin
  2911. { library symbol for AmigaOS/MorphOS }
  2912. write ([space,' Library symbol : ']);
  2913. readderef('');
  2914. end;
  2915. end;
  2916. if not EndOfEntry then
  2917. HasMoreInfos;
  2918. space:=' '+space;
  2919. { parast }
  2920. readsymtable('parast', TPpuProcDef(def));
  2921. { localst }
  2922. if (pio_has_inlininginfo in implprocoptions) then
  2923. readsymtable('localst');
  2924. if (pio_has_inlininginfo in implprocoptions) then
  2925. readnodetree;
  2926. delete(space,1,4);
  2927. end;
  2928. ibprocvardef :
  2929. begin
  2930. def:=TPpuProcTypeDef.Create(ParentDef);
  2931. readcommondef('Procedural type (ProcVar) definition',defoptions,def);
  2932. read_abstract_proc_def(calloption,procoptions, TPpuProcDef(def));
  2933. writeln([space,' Symtable level :',ppufile.getbyte]);
  2934. if not EndOfEntry then
  2935. HasMoreInfos;
  2936. space:=' '+space;
  2937. { parast }
  2938. readsymtable('parast',TPpuProcDef(def));
  2939. delete(space,1,4);
  2940. if tsystemcpu(ppufile.header.common.cpu)=cpu_jvm then
  2941. readderef('');
  2942. end;
  2943. ibshortstringdef :
  2944. begin
  2945. strdef:=TPpuStringDef.Create(ParentDef);
  2946. strdef.StrType:=stShort;
  2947. readcommondef('ShortString definition',defoptions,strdef);
  2948. strdef.Len:=getbyte;
  2949. writeln([space,' Length : ',strdef.Len]);
  2950. end;
  2951. ibwidestringdef :
  2952. begin
  2953. strdef:=TPpuStringDef.Create(ParentDef);
  2954. strdef.StrType:=stWide;
  2955. readcommondef('WideString definition',defoptions,strdef);
  2956. strdef.Len:=getaint;
  2957. writeln([space,' Length : ',strdef.Len]);
  2958. end;
  2959. ibunicodestringdef :
  2960. begin
  2961. strdef:=TPpuStringDef.Create(ParentDef);
  2962. strdef.StrType:=stUnicode;
  2963. readcommondef('UnicodeString definition',defoptions,strdef);
  2964. strdef.Len:=getaint;
  2965. writeln([space,' Length : ',strdef.Len]);
  2966. writeln([space,' Encoding : ',getword]);
  2967. end;
  2968. ibansistringdef :
  2969. begin
  2970. strdef:=TPpuStringDef.Create(ParentDef);
  2971. strdef.StrType:=stAnsi;
  2972. readcommondef('AnsiString definition',defoptions,strdef);
  2973. strdef.Len:=getaint;
  2974. writeln([space,' Length : ',strdef.Len]);
  2975. writeln([space,' Encoding : ',getword]);
  2976. end;
  2977. iblongstringdef :
  2978. begin
  2979. strdef:=TPpuStringDef.Create(ParentDef);
  2980. strdef.StrType:=stLong;
  2981. readcommondef('Longstring definition',defoptions,strdef);
  2982. strdef.Len:=getaint;
  2983. writeln([space,' Length : ',strdef.Len]);
  2984. end;
  2985. ibrecorddef :
  2986. begin
  2987. objdef:=TPpuRecordDef.Create(ParentDef);
  2988. readcommondef('Record definition',defoptions, objdef);
  2989. def.Name:=getstring;
  2990. writeln([space,' Name of Record : ',objdef.Name]);
  2991. writeln([space,' Import lib/pkg : ',getstring]);
  2992. write ([space,' Options : ']);
  2993. readobjectdefoptions(objdef);
  2994. if (df_copied_def in defoptions) then
  2995. begin
  2996. Include(TPpuRecordDef(def).Options, ooCopied);
  2997. write([space,' Copied from : ']);
  2998. readderef('',objdef.Ancestor);
  2999. end
  3000. else
  3001. begin
  3002. writeln([space,' FieldAlign : ',shortint(getbyte)]);
  3003. writeln([space,' RecordAlign : ',shortint(getbyte)]);
  3004. writeln([space,' PadAlign : ',shortint(getbyte)]);
  3005. writeln([space,'UseFieldAlignment : ',shortint(getbyte)]);
  3006. writeln([space,' RecordAlignMin : ',shortint(getbyte)]);
  3007. objdef.Size:=getasizeint;
  3008. writeln([space,' DataSize : ',objdef.Size]);
  3009. writeln([space,' PaddingSize : ',getword]);
  3010. end;
  3011. if not EndOfEntry then
  3012. HasMoreInfos;
  3013. {read the record definitions and symbols}
  3014. if not(df_copied_def in current_defoptions) then
  3015. begin
  3016. space:=' '+space;
  3017. readrecsymtableoptions;
  3018. readsymtable('fields',TPpuRecordDef(def));
  3019. Delete(space,1,4);
  3020. end;
  3021. end;
  3022. ibobjectdef :
  3023. begin
  3024. objdef:=TPpuObjectDef.Create(ParentDef);
  3025. readcommondef('Object/Class definition',defoptions,objdef);
  3026. objdef.Name:=getstring;
  3027. writeln([space,' Name of Class : ',objdef.Name]);
  3028. writeln([space,' Import lib/pkg : ',getstring]);
  3029. write ([space,' Options : ']);
  3030. readobjectdefoptions(objdef);
  3031. b:=getbyte;
  3032. write ([space,' Type : ']);
  3033. case tobjecttyp(b) of
  3034. odt_class : writeln('class');
  3035. odt_object : writeln('object');
  3036. odt_interfacecom : writeln('interfacecom');
  3037. odt_interfacecorba : writeln('interfacecorba');
  3038. odt_cppclass : writeln('cppclass');
  3039. odt_dispinterface : writeln('dispinterface');
  3040. odt_objcclass : writeln('objcclass');
  3041. odt_objcprotocol : writeln('objcprotocol');
  3042. odt_helper : writeln('helper');
  3043. odt_objccategory : writeln('objccategory');
  3044. odt_javaclass : writeln('Java class');
  3045. odt_interfacejava : writeln('Java interface');
  3046. else WriteWarning('Invalid object type: ' + IntToStr(b));
  3047. end;
  3048. case tobjecttyp(b) of
  3049. odt_class, odt_cppclass, odt_objcclass, odt_javaclass:
  3050. objdef.ObjType:=otClass;
  3051. odt_object:
  3052. objdef.ObjType:=otObject;
  3053. odt_interfacecom, odt_interfacecorba, odt_interfacejava, odt_dispinterface:
  3054. objdef.ObjType:=otInterface;
  3055. odt_helper:
  3056. objdef.ObjType:=otHelper;
  3057. end;
  3058. writeln([space,' External name : ',getstring]);
  3059. objdef.Size:=getasizeint;
  3060. writeln([space,' DataSize : ',objdef.Size]);
  3061. writeln([space,' PaddingSize : ',getword]);
  3062. writeln([space,' FieldAlign : ',shortint(getbyte)]);
  3063. writeln([space,' RecordAlign : ',shortint(getbyte)]);
  3064. writeln([space,' RecordAlignMin : ',shortint(getbyte)]);
  3065. write ([space, ' VmtField : ']);
  3066. readderef('',nil);
  3067. write ([space, ' Ancestor Class : ']);
  3068. readderef('',objdef.Ancestor);
  3069. if tobjecttyp(b) in [odt_interfacecom,odt_interfacecorba,odt_dispinterface] then
  3070. begin
  3071. { IIDGUID }
  3072. for j:=1to 16 do
  3073. getbyte;
  3074. objdef.IID:=getstring;
  3075. writeln([space,' IID String : ',objdef.IID]);
  3076. end;
  3077. writeln([space,' Abstract methods : ',getlongint]);
  3078. if tobjecttyp(b)=odt_helper then
  3079. begin
  3080. write([space,' Helper parent : ']);
  3081. readderef('',objdef.HelperParent);
  3082. end;
  3083. l:=getlongint;
  3084. writeln([space,' VMT entries: ',l]);
  3085. for j:=1 to l do
  3086. begin
  3087. write([space,' ']);
  3088. readderef('');
  3089. write([space,' Visibility: ']);
  3090. readvisibility;
  3091. end;
  3092. if tobjecttyp(b) in [odt_class,odt_objcclass,odt_objcprotocol,odt_javaclass,odt_interfacejava] then
  3093. begin
  3094. l:=getlongint;
  3095. writeln([space,' Impl Intf Count : ',l]);
  3096. for j:=1 to l do
  3097. begin
  3098. write ([space,' - Definition : ']);
  3099. readderef('');
  3100. write ([space,' - Getter Def : ']);
  3101. readderef('');
  3102. writeln([space,' IOffset : ',getlongint]);
  3103. writeln([space,' Entry type : ',IntfEntryType2Str(getbyte)]);
  3104. end;
  3105. end;
  3106. if df_copied_def in current_defoptions then
  3107. begin
  3108. Include(objdef.Options, ooCopied);
  3109. writeln(' Copy of def: ');
  3110. readderef('',objdef.Ancestor);
  3111. end;
  3112. if not EndOfEntry then
  3113. HasMoreInfos;
  3114. if not(df_copied_def in current_defoptions) then
  3115. begin
  3116. {read the record definitions and symbols}
  3117. space:=' '+space;
  3118. readrecsymtableoptions;
  3119. readsymtable('fields',objdef);
  3120. Delete(space,1,4);
  3121. end;
  3122. end;
  3123. ibfiledef :
  3124. begin
  3125. filedef:=TPpuFileDef.Create(ParentDef);
  3126. ReadCommonDef('File definition',defoptions,filedef);
  3127. write ([space,' Type : ']);
  3128. case getbyte of
  3129. 0 : begin
  3130. writeln('Text');
  3131. filedef.FileType:=ftText;
  3132. end;
  3133. 1 : begin
  3134. writeln('Typed');
  3135. filedef.FileType:=ftTyped;
  3136. write ([space,' File of Type : ']);
  3137. readderef('',filedef.TypeRef);
  3138. end;
  3139. 2 : begin
  3140. writeln('Untyped');
  3141. filedef.FileType:=ftUntyped;
  3142. end;
  3143. end;
  3144. end;
  3145. ibformaldef :
  3146. begin
  3147. def:=TPpuFormalDef.Create(ParentDef);
  3148. readcommondef('Generic definition (void-typ)',defoptions,def);
  3149. TPpuFormalDef(def).IsTyped:=(getbyte<>0);
  3150. writeln([space,' Is Typed : ',TPpuFormalDef(def).IsTyped]);
  3151. end;
  3152. ibundefineddef :
  3153. begin
  3154. def:=TPpuUndefinedDef.Create(ParentDef);
  3155. readcommondef('Undefined definition (generic parameter)',defoptions,def);
  3156. end;
  3157. ibenumdef :
  3158. begin
  3159. enumdef:=TPpuEnumDef.Create(ParentDef);
  3160. readcommondef('Enumeration type definition',defoptions,enumdef);
  3161. enumdef.ElLow:=getaint;
  3162. writeln([space,' Smallest element : ',enumdef.ElLow]);
  3163. enumdef.ElHigh:=getaint;
  3164. writeln([space,' Largest element : ',enumdef.ElHigh]);
  3165. enumdef.Size:=byte(getaint);
  3166. writeln([space,' Size : ',enumdef.Size]);
  3167. if df_copied_def in defoptions then
  3168. begin
  3169. write([space,'Base enumeration type : ']);
  3170. readderef('',enumdef.CopyFrom);
  3171. end
  3172. else
  3173. begin
  3174. space:=' '+space;
  3175. readsymtable('elements',enumdef);
  3176. delete(space,1,4);
  3177. end;
  3178. if tsystemcpu(ppufile.header.common.cpu)=cpu_jvm then
  3179. begin
  3180. write([space,' Class def : ']);
  3181. readderef('');
  3182. end;
  3183. end;
  3184. ibclassrefdef :
  3185. begin
  3186. def:=TPpuClassRefDef.Create(ParentDef);
  3187. readcommondef('Class reference definition',defoptions,def);
  3188. write ([space,' Pointed Type : ']);
  3189. readderef('',TPpuClassRefDef(def).ClassRef);
  3190. end;
  3191. ibsetdef :
  3192. begin
  3193. setdef:=TPpuSetDef.Create(ParentDef);
  3194. readcommondef('Set definition',defoptions,setdef);
  3195. write ([space,' Element type : ']);
  3196. readderef('',setdef.ElType);
  3197. setdef.Size:=getasizeint;
  3198. writeln([space,' Size : ',setdef.Size]);
  3199. setdef.SetBase:=getasizeint;
  3200. writeln([space,' Set Base : ',setdef.SetBase]);
  3201. setdef.SetMax:=getasizeint;
  3202. writeln([space,' Set Max : ',setdef.SetMax]);
  3203. end;
  3204. ibvariantdef :
  3205. begin
  3206. def:=TPpuVariantDef.Create(ParentDef);
  3207. readcommondef('Variant definition',defoptions,def);
  3208. write ([space,' Varianttype : ']);
  3209. b:=getbyte;
  3210. case tvarianttype(b) of
  3211. vt_normalvariant :
  3212. writeln('Normal');
  3213. vt_olevariant :
  3214. begin
  3215. TPpuVariantDef(def).IsOLE:=True;
  3216. writeln('OLE');
  3217. end
  3218. else
  3219. WriteWarning('Invalid varianttype: ' + IntToStr(b));
  3220. end;
  3221. end;
  3222. iberror :
  3223. begin
  3224. WriteError('!! Error in PPU');
  3225. exit;
  3226. end;
  3227. ibenddefs :
  3228. break;
  3229. else
  3230. begin
  3231. WriteError('!! Skipping unsupported PPU Entry in definitions: '+IntToStr(b));
  3232. end;
  3233. end;
  3234. if (def <> nil) and (def.Parent = nil) then
  3235. def.Free;
  3236. if not EndOfEntry then
  3237. HasMoreInfos;
  3238. until false;
  3239. end;
  3240. end;
  3241. procedure readmoduleoptions(space : string);
  3242. type
  3243. { tmoduleoption type is in unit fmodule }
  3244. tmoduleoption = (mo_none,
  3245. mo_hint_deprecated,
  3246. mo_hint_platform,
  3247. mo_hint_library,
  3248. mo_hint_unimplemented,
  3249. mo_hint_experimental,
  3250. mo_has_deprecated_msg
  3251. );
  3252. tmoduleoptions = set of tmoduleoption;
  3253. tmoduleopt=record
  3254. mask : tmoduleoption;
  3255. str : string[30];
  3256. end;
  3257. const
  3258. moduleopts=ord(high(tmoduleoption));
  3259. moduleopt : array[1..moduleopts] of tmoduleopt=(
  3260. (mask:mo_hint_deprecated; str:'Hint Deprecated'),
  3261. (mask:mo_hint_platform; str:'Hint Platform'),
  3262. (mask:mo_hint_library; str:'Hint Library'),
  3263. (mask:mo_hint_unimplemented; str:'Hint Unimplemented'),
  3264. (mask:mo_hint_experimental; str:'Hint Experimental'),
  3265. (mask:mo_has_deprecated_msg; str:'Has Deprecated Message')
  3266. );
  3267. var
  3268. moduleoptions : tmoduleoptions;
  3269. i : longint;
  3270. first : boolean;
  3271. begin
  3272. ppufile.getsmallset(moduleoptions);
  3273. if moduleoptions<>[] then
  3274. begin
  3275. first:=true;
  3276. for i:=1to moduleopts do
  3277. if (moduleopt[i].mask in moduleoptions) then
  3278. begin
  3279. if first then
  3280. first:=false
  3281. else
  3282. write(', ');
  3283. write(moduleopt[i].str);
  3284. end;
  3285. end;
  3286. writeln;
  3287. if mo_has_deprecated_msg in moduleoptions then
  3288. writeln([space,'Deprecated : ', ppufile.getstring]);
  3289. end;
  3290. {****************************************************************************
  3291. Read General Part
  3292. ****************************************************************************}
  3293. procedure readinterface(silent : boolean);
  3294. var
  3295. b : byte;
  3296. sourcenumber, i : longint;
  3297. begin
  3298. with ppufile do
  3299. begin
  3300. repeat
  3301. b:=readentry;
  3302. case b of
  3303. ibmodulename :
  3304. begin
  3305. CurUnit.Name:=getstring;
  3306. if not silent then
  3307. Writeln(['Module Name: ',CurUnit.Name]);
  3308. end;
  3309. ibmoduleoptions:
  3310. if not silent then
  3311. readmoduleoptions(' ');
  3312. ibsourcefiles :
  3313. begin
  3314. sourcenumber:=1;
  3315. if not silent then
  3316. while not EndOfEntry do
  3317. begin
  3318. with TPpuSrcFile.Create(CurUnit.SourceFiles) do begin
  3319. Name:=getstring;
  3320. i:=getlongint;
  3321. if i >= 0 then
  3322. FileTime:=FileDateToDateTime(i);
  3323. Writeln(['Source file ',sourcenumber,' : ',Name,' ',filetimestring(i)]);
  3324. end;
  3325. inc(sourcenumber);
  3326. end;
  3327. end;
  3328. {$IFDEF MACRO_DIFF_HINT}
  3329. ibusedmacros :
  3330. begin
  3331. if not silent then
  3332. while not EndOfEntry do
  3333. begin
  3334. Write('Conditional ',getstring);
  3335. b:=getbyte;
  3336. if boolean(b)=true then
  3337. write(' defined at startup')
  3338. else
  3339. write(' not defined at startup');
  3340. b:=getbyte;
  3341. if boolean(b)=true then
  3342. writeln(' was used')
  3343. else
  3344. writeln;
  3345. end;
  3346. end;
  3347. {$ENDIF}
  3348. ibloadunit :
  3349. if not silent then
  3350. ReadLoadUnit;
  3351. iblinkunitofiles :
  3352. if not silent then
  3353. ReadLinkContainer('Link unit object file: ');
  3354. iblinkunitstaticlibs :
  3355. if not silent then
  3356. ReadLinkContainer('Link unit static lib: ');
  3357. iblinkunitsharedlibs :
  3358. if not silent then
  3359. ReadLinkContainer('Link unit shared lib: ');
  3360. iblinkotherofiles :
  3361. if not silent then
  3362. ReadLinkContainer('Link other object file: ');
  3363. iblinkotherstaticlibs :
  3364. if not silent then
  3365. ReadLinkContainer('Link other static lib: ');
  3366. iblinkothersharedlibs :
  3367. if not silent then
  3368. ReadLinkContainer('Link other shared lib: ');
  3369. iblinkotherframeworks:
  3370. if not silent then
  3371. ReadLinkContainer('Link framework: ');
  3372. ibmainname:
  3373. if not silent then
  3374. Writeln(['Specified main program symbol name: ',getstring]);
  3375. ibImportSymbols :
  3376. if not silent then
  3377. ReadImportSymbols;
  3378. ibderefdata :
  3379. ReadDerefData;
  3380. ibderefmap :
  3381. ReadDerefMap;
  3382. ibwpofile :
  3383. if not silent then
  3384. ReadWpoFileInfo;
  3385. ibresources :
  3386. if not silent then
  3387. ReadLinkContainer('Resource file: ');
  3388. iberror :
  3389. begin
  3390. WriteError('Error in PPU');
  3391. exit;
  3392. end;
  3393. ibendinterface :
  3394. break;
  3395. else
  3396. begin
  3397. WriteError('!! Skipping unsupported PPU Entry in General Part: '+IntToStr(b));
  3398. end;
  3399. end;
  3400. until false;
  3401. end;
  3402. end;
  3403. {****************************************************************************
  3404. Read Implementation Part
  3405. ****************************************************************************}
  3406. procedure readimplementation;
  3407. var
  3408. b : byte;
  3409. begin
  3410. with ppufile do
  3411. begin
  3412. repeat
  3413. b:=readentry;
  3414. case b of
  3415. ibasmsymbols :
  3416. ReadAsmSymbols;
  3417. ibloadunit :
  3418. ReadLoadUnit;
  3419. ibunitimportsyms :
  3420. ReadUnitImportSyms;
  3421. iberror :
  3422. begin
  3423. WriteError('Error in PPU');
  3424. exit;
  3425. end;
  3426. ibendimplementation :
  3427. break;
  3428. else
  3429. begin
  3430. WriteError('!! Skipping unsupported PPU Entry in Implementation: '+IntToStr(b));
  3431. end;
  3432. end;
  3433. until false;
  3434. end;
  3435. end;
  3436. procedure dofile (filename : string);
  3437. begin
  3438. { reset }
  3439. space:='';
  3440. { fix filename }
  3441. if pos('.',filename)=0 then
  3442. filename:=filename+'.ppu';
  3443. ppufile:=tppufile.create(filename);
  3444. if not ppufile.openfile then
  3445. begin
  3446. WriteError('IO-Error when opening : '+filename+', Skipping');
  3447. exit;
  3448. end;
  3449. { PPU File is open, check for PPU Id }
  3450. if not ppufile.CheckPPUID then
  3451. begin
  3452. WriteError(Filename+' : Not a valid PPU file, Skipping');
  3453. exit;
  3454. end;
  3455. { Check PPU Version }
  3456. ppuversion:=ppufile.getversion;
  3457. Writeln(['Analyzing ',filename,' (v',PPUVersion,')']);
  3458. if PPUVersion<16 then
  3459. begin
  3460. WriteError(Filename+' : Old PPU Formats (<v16) are not supported, Skipping');
  3461. exit;
  3462. end;
  3463. if not SkipVersionCheck and (PPUVersion <> CurrentPPUVersion) then
  3464. begin
  3465. WriteError(Format('Unsupported PPU version %d. Expecting PPU version %d.', [PPUVersion, CurrentPPUVersion]));
  3466. exit;
  3467. end;
  3468. CurUnit:=TPpuUnitDef.Create(UnitList);
  3469. CurUnit.Version:=ppuversion;
  3470. { Write PPU Header Information }
  3471. if (verbose and v_header)<>0 then
  3472. begin
  3473. Writeln;
  3474. Writeln('Header');
  3475. Writeln('-------');
  3476. with ppufile.header do
  3477. begin
  3478. Writeln(['Compiler version : ',ppufile.header.common.compiler shr 14,'.',
  3479. (ppufile.header.common.compiler shr 7) and $7f,'.',
  3480. ppufile.header.common.compiler and $7f]);
  3481. WriteLn(['Target processor : ',Cpu2Str(common.cpu)]);
  3482. WriteLn(['Target operating system : ',Target2Str(common.target)]);
  3483. Writeln(['Unit flags : ',PPUFlags2Str(common.flags)]);
  3484. Writeln(['FileSize (w/o header) : ',common.size]);
  3485. Writeln(['Checksum : ',hexstr(checksum,8)]);
  3486. Writeln(['Interface Checksum : ',hexstr(interface_checksum,8)]);
  3487. Writeln(['Indirect Checksum : ',hexstr(indirect_checksum,8)]);
  3488. Writeln(['Definitions stored : ',tostr(deflistsize)]);
  3489. Writeln(['Symbols stored : ',tostr(symlistsize)]);
  3490. end;
  3491. end;
  3492. with ppufile.header do
  3493. begin
  3494. CurUnit.Crc:=checksum;
  3495. CurUnit.IntfCrc:=interface_checksum;
  3496. CurUnit.TargetCPU:=Cpu2Str(common.cpu);
  3497. CurUnit.TargetOS:=Target2Str(common.target);
  3498. end;
  3499. {read the general stuff}
  3500. if (verbose and v_interface)<>0 then
  3501. begin
  3502. Writeln;
  3503. Writeln('Interface section');
  3504. Writeln('------------------');
  3505. readinterface(false);
  3506. end
  3507. { We need derefdata from Interface }
  3508. else if verbose and (v_defs or v_syms or v_implementation)<>0 then
  3509. readinterface(true)
  3510. else
  3511. ppufile.skipuntilentry(ibendinterface);
  3512. Writeln;
  3513. Writeln('Interface symtable');
  3514. Writeln('----------------------');
  3515. readsymtableoptions('interface');
  3516. {read the definitions}
  3517. if (verbose and v_defs)<>0 then
  3518. begin
  3519. Writeln;
  3520. Writeln('Interface definitions');
  3521. Writeln('----------------------');
  3522. readdefinitions('interface', CurUnit);
  3523. end
  3524. else
  3525. ppufile.skipuntilentry(ibenddefs);
  3526. {read the symbols}
  3527. if (verbose and v_syms)<>0 then
  3528. begin
  3529. Writeln;
  3530. Writeln('Interface Symbols');
  3531. Writeln('------------------');
  3532. readsymbols('interface',CurUnit);
  3533. end
  3534. else
  3535. ppufile.skipuntilentry(ibendsyms);
  3536. {read the macro symbols}
  3537. if (verbose and v_syms)<>0 then
  3538. begin
  3539. Writeln;
  3540. Writeln('Interface Macro Symbols');
  3541. Writeln('-----------------------');
  3542. end;
  3543. if ppufile.readentry<>ibexportedmacros then
  3544. begin
  3545. WriteError('!! Error in PPU');
  3546. exit;
  3547. end;
  3548. if boolean(ppufile.getbyte) then
  3549. begin
  3550. readsymtableoptions('interface macro');
  3551. {skip the definition section for macros (since they are never used) }
  3552. ppufile.skipuntilentry(ibenddefs);
  3553. {read the macro symbols}
  3554. if (verbose and v_syms)<>0 then
  3555. readsymbols('interface macro')
  3556. else
  3557. ppufile.skipuntilentry(ibendsyms);
  3558. end
  3559. else
  3560. Writeln('(no exported macros)');
  3561. {read the implementation stuff}
  3562. if (verbose and v_implementation)<>0 then
  3563. begin
  3564. Writeln;
  3565. Writeln('Implementation section');
  3566. Writeln('-----------------------');
  3567. readimplementation;
  3568. end
  3569. else
  3570. ppufile.skipuntilentry(ibendimplementation);
  3571. {read the static symtable}
  3572. Writeln;
  3573. Writeln('Implementation symtable');
  3574. Writeln('----------------------');
  3575. readsymtableoptions('implementation');
  3576. if (ppufile.header.common.flags and uf_local_symtable)<>0 then
  3577. begin
  3578. if (verbose and v_defs)<>0 then
  3579. begin
  3580. Writeln;
  3581. Writeln('Static definitions');
  3582. Writeln('----------------------');
  3583. readdefinitions('implementation', nil);
  3584. end
  3585. else
  3586. ppufile.skipuntilentry(ibenddefs);
  3587. {read the symbols}
  3588. if (verbose and v_syms)<>0 then
  3589. begin
  3590. Writeln;
  3591. Writeln('Static Symbols');
  3592. Writeln('------------------');
  3593. readsymbols('implementation');
  3594. end
  3595. else
  3596. ppufile.skipuntilentry(ibendsyms);
  3597. end;
  3598. ReadCreatedObjTypes;
  3599. FreeDerefdata;
  3600. {shutdown ppufile}
  3601. ppufile.closefile;
  3602. ppufile.free;
  3603. Writeln;
  3604. end;
  3605. procedure WriteLogo;
  3606. begin
  3607. writeln(Title+' Version '+version_string);
  3608. writeln(Copyright);
  3609. writeln;
  3610. end;
  3611. procedure help;
  3612. begin
  3613. WriteLogo;
  3614. writeln('usage: ppudump [options] <filename1> <filename2>...');
  3615. writeln;
  3616. writeln('[options] can be:');
  3617. writeln(' -F<format> Set output format to <format>');
  3618. writeln(' t - text format (default)');
  3619. writeln(' j - JSON format');
  3620. writeln(' x - XML format');
  3621. writeln(' -M Exit with ExitCode=2 if more information is available');
  3622. writeln(' -S Skip PPU version check. May lead to reading errors');
  3623. writeln(' -V<verbose> Set verbosity to <verbose>');
  3624. writeln(' H - Show header info');
  3625. writeln(' I - Show interface');
  3626. writeln(' M - Show implementation');
  3627. writeln(' S - Show interface symbols');
  3628. writeln(' D - Show interface definitions');
  3629. writeln(' A - Show all');
  3630. writeln(' -h, -? This helpscreen');
  3631. halt;
  3632. end;
  3633. var
  3634. startpara,
  3635. nrfile,i : longint;
  3636. para : string;
  3637. const
  3638. error_on_more : boolean = false;
  3639. begin
  3640. if paramcount<1 then
  3641. help;
  3642. { turn verbose on by default }
  3643. verbose:=v_all;
  3644. { read options }
  3645. startpara:=1;
  3646. while copy(paramstr(startpara),1,1)='-' do
  3647. begin
  3648. para:=paramstr(startpara);
  3649. case upcase(para[2]) of
  3650. 'F' : begin
  3651. FreeAndNil(pout);
  3652. if Length(para) > 2 then
  3653. case upcase(para[3]) of
  3654. 'T':
  3655. nostdout:=False;
  3656. 'J':
  3657. begin
  3658. nostdout:=True;
  3659. pout:=TPpuJsonOutput.Create(Output);
  3660. end;
  3661. 'X':
  3662. begin
  3663. nostdout:=True;
  3664. pout:=TPpuXmlOutput.Create(Output);
  3665. end;
  3666. else
  3667. begin
  3668. WriteError('Invalid output format: ' + para[3]);
  3669. Halt(1);
  3670. end;
  3671. end;
  3672. end;
  3673. 'M' : error_on_more:=true;
  3674. 'S' : SkipVersionCheck:=True;
  3675. 'V' : begin
  3676. verbose:=0;
  3677. for i:=3 to length(para) do
  3678. case upcase(para[i]) of
  3679. 'H' : verbose:=verbose or v_header;
  3680. 'I' : verbose:=verbose or v_interface;
  3681. 'M' : verbose:=verbose or v_implementation;
  3682. 'D' : verbose:=verbose or v_defs;
  3683. 'S' : verbose:=verbose or v_syms;
  3684. 'A' : verbose:=verbose or v_all;
  3685. end;
  3686. end;
  3687. 'H' : help;
  3688. '?' : help;
  3689. else
  3690. begin
  3691. WriteError('Invalid option: ' + para);
  3692. Halt(1);
  3693. end;
  3694. end;
  3695. inc(startpara);
  3696. end;
  3697. if not nostdout then
  3698. WriteLogo;
  3699. UnitList:=TPpuContainerDef.Create(nil);
  3700. try
  3701. UnitList.ItemsName:='';
  3702. { process files }
  3703. for nrfile:=startpara to paramcount do
  3704. dofile (paramstr(nrfile));
  3705. if not has_errors and (pout <> nil) then
  3706. begin
  3707. pout.Init;
  3708. UnitList.Write(pout);
  3709. pout.Done;
  3710. end;
  3711. finally
  3712. UnitList.Free;
  3713. pout.Free;
  3714. end;
  3715. if has_errors then
  3716. Halt(1);
  3717. if error_on_more and
  3718. (has_more_infos or has_warnings) then
  3719. Halt(2);
  3720. end.