ppudump.pp 116 KB

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