ppudump.pp 166 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250
  1. {
  2. Copyright (c) 1998-2020 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. {$packenum 1}
  20. {$define IN_PPUDUMP}
  21. uses
  22. { do NOT add symconst or globtype to make merging easier }
  23. { do include symconst and globtype now before splitting 2.5 PM 2011-06-15 }
  24. cutils,
  25. SysUtils,
  26. constexp,
  27. symconst,
  28. ppu,
  29. entfile,
  30. systems,
  31. cpuinfo,
  32. globals,
  33. globtype,
  34. widestr,
  35. tokens,
  36. version,
  37. ppuout,
  38. ppujson,
  39. ppuxml;
  40. const
  41. Title = 'PPU-Analyser';
  42. Copyright = 'Copyright (c) 1998-2020 by the Free Pascal Development Team';
  43. { verbosity }
  44. v_none = $0;
  45. v_header = $1;
  46. v_defs = $2;
  47. v_syms = $4;
  48. v_interface = $8;
  49. v_implementation = $10;
  50. // v_browser = $20;
  51. v_all = $ff;
  52. { not needed anymore $i systems.inc }
  53. { List of all supported cpus }
  54. const
  55. CpuTxt : array[tsystemcpu] of string[16]=
  56. (
  57. { 0 } 'none',
  58. { 1 } 'i386',
  59. { 2 } 'm68k',
  60. { 3 } 'alpha (obsolete)',
  61. { 4 } 'powerpc',
  62. { 5 } 'sparc',
  63. { 6 } 'vis (obsolete)',
  64. { 7 } 'ia64 (obsolete)',
  65. { 8 } 'x86_64',
  66. { 9 } 'mipseb',
  67. { 10 } 'arm',
  68. { 11 } 'powerpc64',
  69. { 12 } 'avr',
  70. { 13 } 'mipsel',
  71. { 14 } 'jvm',
  72. { 15 } 'i8086',
  73. { 16 } 'aarch64',
  74. { 17 } 'wasm',
  75. { 18 } 'sparc64',
  76. { 19 } 'riscv32',
  77. { 20 } 'riscv64',
  78. { 21 } 'xtensa',
  79. { 22 } 'z80'
  80. );
  81. CpuHasController : array[tsystemcpu] of boolean =
  82. (
  83. { 0 } false {'none'},
  84. { 1 } false {'i386'},
  85. { 2 } false {'m68k'},
  86. { 3 } false {'alpha (obsolete)'},
  87. { 4 } false {'powerpc'},
  88. { 5 } false {'sparc'},
  89. { 6 } false {'vis (obsolete)'},
  90. { 7 } false {'ia64 (obsolete)'},
  91. { 8 } false {'x86_64'},
  92. { 9 } false {'mipseb'},
  93. { 10 } true {'arm'},
  94. { 11 } false {'powerpc64'},
  95. { 12 } true {'avr'},
  96. { 13 } true {'mipsel'},
  97. { 14 } false {'jvm'},
  98. { 15 } false {'i8086'},
  99. { 16 } false {'aarch64'},
  100. { 17 } false {'wasm'},
  101. { 18 } false {'sparc64'},
  102. { 19 } false {'riscv32'},
  103. { 20 } false {'riscv64'},
  104. { 21 } true {'xtensa'},
  105. { 22 } true {'z80'}
  106. );
  107. { List of all supported system-cpu couples }
  108. const
  109. Targets : array[tsystem] of string[26]=(
  110. { 0 } 'none',
  111. { 1 } 'GO32V1 (obsolete)',
  112. { 2 } 'GO32V2',
  113. { 3 } 'Linux-i386',
  114. { 4 } 'OS/2',
  115. { 5 } 'Win32',
  116. { 6 } 'FreeBSD-i386',
  117. { 7 } 'Amiga',
  118. { 8 } 'Atari',
  119. { 9 } 'MacOSClassic-m68k',
  120. { 10 } 'Linux-m68k',
  121. { 11 } 'PalmOS-m68k',
  122. { 12 } 'Linux-alpha (obsolete)',
  123. { 13 } 'Linux-ppc',
  124. { 14 } 'MacOSClassic-ppc',
  125. { 15 } 'Solaris-i386',
  126. { 16 } 'BeOS-i386',
  127. { 17 } 'NetBSD-i386',
  128. { 18 } 'NetBSD-m68k',
  129. { 19 } 'Netware-i386-clib',
  130. { 20 } 'Qnx-i386',
  131. { 21 } 'WDOSX-i386',
  132. { 22 } 'Solaris-sparc',
  133. { 23 } 'Linux-sparc',
  134. { 24 } 'OpenBSD-i386',
  135. { 25 } 'OpenBSD-m68k (obsolete)',
  136. { 26 } 'Linux-x86-64',
  137. { 27 } 'Darwin-ppc',
  138. { 28 } 'OS/2 via EMX',
  139. { 29 } 'NetBSD-powerpc',
  140. { 30 } 'OpenBSD-powerpc',
  141. { 31 } 'Linux-arm',
  142. { 32 } 'Watcom-i386',
  143. { 33 } 'MorphOS-powerpc',
  144. { 34 } 'FreeBSD-x86-64',
  145. { 35 } 'Netware-i386-libc',
  146. { 36 } 'Amiga-PowerPC',
  147. { 37 } 'Win64-x64',
  148. { 38 } 'WinCE-ARM',
  149. { 39 } 'Win64-iA64 (obsolete)',
  150. { 40 } 'WinCE-i386',
  151. { 41 } 'Linux-x64',
  152. { 42 } 'GBA-arm',
  153. { 43 } 'Linux-powerpc64',
  154. { 44 } 'Darwin-i386',
  155. { 45 } 'PalmOS-arm',
  156. { 46 } 'Darwin-powerpc64',
  157. { 47 } 'NDS-arm',
  158. { 48 } 'Embedded-i386',
  159. { 49 } 'Embedded-m68k',
  160. { 50 } 'Embedded-alpha (obsolete)',
  161. { 51 } 'Embedded-powerpc',
  162. { 52 } 'Embedded-sparc',
  163. { 53 } 'Embedded-vm (obsolete)',
  164. { 54 } 'Embedded-iA64 (obsolete)',
  165. { 55 } 'Embedded-x64',
  166. { 56 } 'Embedded-mips',
  167. { 57 } 'Embedded-arm',
  168. { 58 } 'Embedded-powerpc64',
  169. { 59 } 'Symbian-i386',
  170. { 60 } 'Symbian-arm',
  171. { 61 } 'Darwin-x64',
  172. { 62 } 'Embedded-avr',
  173. { 63 } 'Haiku-i386',
  174. { 64 } 'iOS-ARM',
  175. { 65 } 'Solaris-x86-64',
  176. { 66 } 'Linux-MIPS',
  177. { 67 } 'Linux-MIPSel',
  178. { 68 } 'NativeNT-i386',
  179. { 69 } 'iPhoneSim-i386',
  180. { 70 } 'Wii-powerpc',
  181. { 71 } 'OpenBSD-x86-64',
  182. { 72 } 'NetBSD-x86-64',
  183. { 73 } 'AIX-powerpc',
  184. { 74 } 'AIX-powerpc64',
  185. { 75 } 'Java-JVM',
  186. { 76 } 'Android-JVM',
  187. { 77 } 'Android-arm',
  188. { 78 } 'Android-i386',
  189. { 79 } 'MSDOS-i8086',
  190. { 80 } 'Android-MIPSel',
  191. { 81 } 'Embedded-mipseb',
  192. { 82 } 'Embedded-mipsel',
  193. { 83 } 'AROS-i386',
  194. { 84 } 'AROS-x86-64',
  195. { 85 } 'DragonFly-x86-64',
  196. { 86 } 'iOS-AArch64',
  197. { 87 } 'iPhoneSim-x86-64',
  198. { 88 } 'Linux-AArch64',
  199. { 89 } 'Win16',
  200. { 90 } 'Embedded-i8086',
  201. { 91 } 'AROS-arm',
  202. { 92 } 'WebAssembly-wasm',
  203. { 93 } 'Linux-sparc64',
  204. { 94 } 'Solaris-sparc64',
  205. { 95 } 'NetBSD-arm',
  206. { 96 } 'Linux-RiscV32',
  207. { 97 } 'Linux-RiscV64',
  208. { 98 } 'Embedded-RiscV32',
  209. { 99 } 'Embedded-RiscV64',
  210. { 100 } 'Android-AArch64',
  211. { 101 } 'Android-x86-64',
  212. { 102 } 'Haiku-x86-64',
  213. { 103 } 'Embedded-Xtensa',
  214. { 104 } 'FreeRTos-Xtensa',
  215. { 105 } 'Linux-Xtensa',
  216. { 106 } 'FreeRTos-arm',
  217. { 107 } 'Win64-AArch64',
  218. { 108 } 'Embedded-Z80',
  219. { 109 } 'ZXSpectrum-Z80',
  220. { 110 } 'MSX-DOS-Z80',
  221. { 111 } 'Darwin-AArch64',
  222. { 112 } 'AmstradCPC-Z80',
  223. { 113 } 'SinclairQL-m68k'
  224. );
  225. const
  226. { in widestr, we have the following definition
  227. type
  228. tcompilerwidechar = word;
  229. thus widecharsize seems to always be 2 bytes }
  230. widecharsize : longint = 2;
  231. cpu : tsystemcpu = cpu_no;
  232. { This type is defined in scanner.pas unit }
  233. type
  234. tspecialgenerictoken = (
  235. ST_LOADSETTINGS,
  236. ST_LINE,
  237. ST_COLUMN,
  238. ST_FILEINDEX,
  239. ST_LOADMESSAGES,
  240. ST_INVALID);
  241. type
  242. tcpu_i386 = (
  243. cpu_variant_i386_none,
  244. cpu_variant_386,
  245. cpu_variant_486,
  246. cpu_variant_Pentium,
  247. cpu_variant_Pentium2,
  248. cpu_variant_Pentium3,
  249. cpu_variant_Pentium4,
  250. cpu_variant_PentiumM,
  251. cpu_variant_core_i,
  252. cpu_variant_core_avx,
  253. cpu_variant_core_avx2);
  254. tcpu_m68k = (
  255. cpu_variant_m68k_none,
  256. cpu_variant_MC68000,
  257. cpu_variant_MC68020,
  258. cpu_variant_MC68040,
  259. cpu_variant_MC68060,
  260. cpu_variant_isa_a,
  261. cpu_variant_isa_a_p,
  262. cpu_variant_isa_b,
  263. cpu_variant_isa_c,
  264. cpu_variant_cfv4e
  265. );
  266. tcpu_powerpc = (
  267. cpu_variant_powerpc_none,
  268. cpu_variant_ppc604,
  269. cpu_variant_ppc750,
  270. cpu_variant_ppc7400,
  271. cpu_variant_ppc970
  272. );
  273. tcpu_sparc = (
  274. cpu_variant_sparc_none,
  275. cpu_variant_SPARC_V7,
  276. cpu_variant_SPARC_V8,
  277. cpu_variant_SPARC_V9
  278. );
  279. tcpu_x86_64 = (
  280. cpu_variant_x86_64_none,
  281. cpu_variant_athlon64,
  282. cpu_variant_x86_64_core_i,
  283. cpu_variant_x86_64_core_avx,
  284. cpu_variant_x86_64_core_avx2
  285. );
  286. tcpu_mipseb = (
  287. cpu_variant_mipseb_none,
  288. cpu_variant_mips1,
  289. cpu_variant_mips2,
  290. cpu_variant_mips3,
  291. cpu_variant_mips4,
  292. cpu_variant_mips5,
  293. cpu_variant_mips32,
  294. cpu_variant_mips32r2,
  295. cpu_variant_pic32mx
  296. );
  297. tcpu_arm = (
  298. cpu_variant_arm_none,
  299. cpu_variant_armv3,
  300. cpu_variant_armv4,
  301. cpu_variant_armv4t,
  302. cpu_variant_armv5,
  303. cpu_variant_armv5t,
  304. cpu_variant_armv5te,
  305. cpu_variant_armv5tej,
  306. cpu_variant_armv6,
  307. cpu_variant_armv6k,
  308. cpu_variant_armv6t2,
  309. cpu_variant_armv6z,
  310. cpu_variant_armv6m,
  311. cpu_variant_armv7,
  312. cpu_variant_armv7a,
  313. cpu_variant_armv7r,
  314. cpu_variant_armv7m,
  315. cpu_variant_armv7em
  316. );
  317. tcpu_powerpc64 = (
  318. cpu_variant_powerpc64_none,
  319. cpu_variant_powerpc64_ppc970
  320. );
  321. tcpu_avr = (
  322. cpu_variant_avr_none,
  323. cpu_variant_avr1,
  324. cpu_variant_avr2,
  325. cpu_variant_avr25,
  326. cpu_variant_avr3,
  327. cpu_variant_avr31,
  328. cpu_variant_avr35,
  329. cpu_variant_avr4,
  330. cpu_variant_avr5,
  331. cpu_variant_avr51,
  332. cpu_variant_avr6
  333. );
  334. tcpu_mipsel = tcpu_mipseb;
  335. tcpu_jvm = (
  336. cpu_variant_jvm_none,
  337. { jvm, same as cpu_none }
  338. cpu_variant_jvm,
  339. { jvm byte code to be translated into Dalvik bytecode: more type-
  340. sensitive }
  341. cpu_variant_dalvik
  342. );
  343. tcpu_i8086 = (
  344. cpu_variant_i8086_none,
  345. cpu_variant_8086,
  346. cpu_variant_186,
  347. cpu_variant_286,
  348. cpu_variant_i8086_386,
  349. cpu_variant_i8086_486,
  350. cpu_variant_i8086_Pentium,
  351. cpu_variant_i8086_Pentium2,
  352. cpu_variant_i8086_Pentium3,
  353. cpu_variant_i8086_Pentium4,
  354. cpu_variant_i8086_PentiumM
  355. );
  356. tcpu_aarch64 = (
  357. cpu_variant_aarch64_none,
  358. cpu_variant_armv8
  359. );
  360. tcpu_wasm = (
  361. cpu_variant_wasm_none);
  362. tcpu_sparc64 = (
  363. cpu_variant_sparc64_none,
  364. cpu_variant_SPARC64_V9
  365. );
  366. tcpu_riscv32 = (
  367. cpu_variant_riscv32_none,
  368. cpu_variant_rv32imafd,
  369. cpu_variant_rv32ima,
  370. cpu_variant_rv32im,
  371. cpu_variant_rv32i
  372. );
  373. tcpu_riscv64 = (
  374. cpu_variant_riscv64_none,
  375. cpu_variant_rv64imafdc,
  376. cpu_variant_rv64imafd,
  377. cpu_variant_rv64ima,
  378. cpu_variant_rv64im,
  379. cpu_variant_rv64i
  380. );
  381. tcpu_type = record
  382. case tsystemcpu of
  383. cpu_no: { 0 }
  384. ();
  385. cpu_i386: { 1 }
  386. (cpu_i386 : tcpu_i386;);
  387. cpu_m68k: { 2 }
  388. (cpu_m68k : tcpu_m68k;);
  389. obsolete_cpu_alpha: { 3 }
  390. ();
  391. cpu_powerpc: { 4 }
  392. (cpu_powerpc : tcpu_powerpc;);
  393. cpu_sparc: { 5 }
  394. (cpu_sparc : tcpu_sparc;);
  395. obsolete_cpu_vm: { 6 }
  396. ();
  397. obsolete_cpu_ia64: { 7 }
  398. ();
  399. cpu_x86_64: { 8 }
  400. (cpu_x86_64 : tcpu_x86_64;);
  401. cpu_mipseb: { 9 }
  402. (cpu_mipseb : tcpu_mipseb;);
  403. cpu_arm: { 10 }
  404. (cpu_arm : tcpu_arm;);
  405. cpu_powerpc64: { 11 }
  406. (cpu_powerpc64 : tcpu_powerpc64;);
  407. cpu_avr: { 12 }
  408. (cpu_avr : tcpu_avr;);
  409. cpu_mipsel: { 13 }
  410. (cpu_mipsel : tcpu_mipsel;);
  411. cpu_jvm: { 14 }
  412. (cpu_jvm : tcpu_jvm;);
  413. cpu_i8086: { 15 }
  414. (cpu_i8086 : tcpu_i8086;);
  415. cpu_aarch64: { 16 }
  416. (cpu_aarch64 : tcpu_aarch64;);
  417. cpu_wasm: { 17 }
  418. (cpu_wasm : tcpu_wasm;);
  419. cpu_sparc64: { 18 }
  420. (cpu_sparc64 : tcpu_sparc64;);
  421. cpu_riscv32: { 19 }
  422. (cpu_riscv32 : tcpu_riscv32;);
  423. cpu_riscv64: { 20 }
  424. (cpu_riscv64 : tcpu_riscv64;);
  425. end;
  426. TPpuModuleDef = class(TPpuUnitDef)
  427. ModuleFlags: tmoduleflags;
  428. end;
  429. type
  430. tppudumpfile = class(tppufile)
  431. protected
  432. procedure RaiseAssertion(Code: Longint); override;
  433. end;
  434. var
  435. ppufile : tppudumpfile;
  436. ppuversion : dword;
  437. space : string;
  438. verbose : longint;
  439. derefdata : pbyte;
  440. derefdatalen : longint;
  441. pout: TPpuOutput;
  442. nostdout: boolean;
  443. UnitList: TPpuContainerDef;
  444. CurUnit: TPpuModuleDef;
  445. SkipVersionCheck: boolean;
  446. SymAnsiStr: boolean;
  447. var
  448. { needed during tobjectdef parsing... }
  449. current_defoptions : tdefoptions;
  450. current_objectoptions : tobjectoptions;
  451. current_symtable_options : tsymtableoptions;
  452. {****************************************************************************
  453. Helper Routines
  454. ****************************************************************************}
  455. {****************************************************************************
  456. Routine to read 80-bit reals
  457. ****************************************************************************
  458. }
  459. {$PUSH}
  460. {$WARN 6018 OFF} { Turn off unreachable code warning }
  461. { On platforms with sizeof(ext) <> 10 the code below will cause an unreachable
  462. code warning, which will cause compilation failures with -Sew (KB) }
  463. type
  464. TSplit80bitReal = packed record
  465. case byte of
  466. 0: (bytes: Array[0..9] of byte);
  467. 1: (words: Array[0..4] of word);
  468. {$ifdef FPC_LITTLE_ENDIAN}
  469. 2: (cards: Array[0..1] of cardinal; w: word);
  470. {$else not FPC_LITTLE_ENDIAN}
  471. 2: (w:word; cards: Array[0..1] of cardinal);
  472. {$endif not FPC_LITTLE_ENDIAN}
  473. end;
  474. const
  475. maxDigits = 17;
  476. function Real80bitToStr(var e : TSplit80bitReal;var ext : extended) : string;
  477. var
  478. Temp : string;
  479. new : TSplit80bitReal;
  480. fraczero, expmaximal, sign, outside_double : boolean;
  481. exp : smallint;
  482. d : double;
  483. i : longint;
  484. mantval : qword;
  485. begin
  486. if ppufile.change_endian then
  487. begin
  488. for i:=0 to 9 do
  489. new.bytes[i]:=e.bytes[9-i];
  490. e:=new;
  491. end;
  492. if sizeof(ext)=10 then
  493. begin
  494. ext:=pextended(@e)^;
  495. str(ext,result);
  496. exit;
  497. end;
  498. { extended, format (MSB): 1 Sign bit, 15 bit exponent, 64 bit mantissa }
  499. sign := (e.w and $8000) <> 0;
  500. expMaximal := (e.w and $7fff) = 32767;
  501. exp:=(e.w and $7fff) - 16383 - 63;
  502. fraczero := (e.cards[0] = 0) and
  503. ((e.cards[1] and $7fffffff) = 0);
  504. {$ifdef FPC_LITTLE_ENDIAN}
  505. mantval := qword(e.cards[0]) or (qword(e.cards[1]) shl 32);
  506. {$else not FPC_LITTLE_ENDIAN}
  507. mantval := (qword(e.cards[0]) shl 32) or qword(e.cards[1]);
  508. {$endif not FPC_LITTLE_ENDIAN}
  509. if expMaximal then
  510. if fraczero then
  511. if sign then
  512. temp := '-Inf'
  513. else temp := '+Inf'
  514. else temp := 'Nan'
  515. else
  516. begin
  517. d:=double(mantval);
  518. if sign then
  519. d:=-d;
  520. outside_double:=false;
  521. Try
  522. if exp > 0 then
  523. begin
  524. for i:=1 to exp do
  525. d:=d *2.0;
  526. end
  527. else if exp < 0 then
  528. begin
  529. for i:=1 to -exp do
  530. d:=d /2.0;
  531. end;
  532. Except
  533. outside_double:=true;
  534. end;
  535. if (mantval<>0) and (d=0.0) then
  536. outside_double:=true;
  537. if outside_double then
  538. begin
  539. Temp:='Extended value outside double bound';
  540. ext:=0.0;
  541. end
  542. else
  543. begin
  544. ext:=d;
  545. system.str(d,temp);
  546. end;
  547. end;
  548. result:=temp;
  549. end;
  550. {$POP}
  551. const has_errors : boolean = false;
  552. has_warnings : boolean = false;
  553. has_more_infos : boolean = false;
  554. procedure SetHasErrors;
  555. begin
  556. has_errors:=true;
  557. end;
  558. Procedure WriteError(const S : string);
  559. Begin
  560. system.Writeln(StdErr, S);
  561. SetHasErrors;
  562. End;
  563. procedure StrAppend(var st : string; const st2 : string);
  564. begin
  565. st:=st+st2;
  566. end;
  567. procedure tppudumpfile.RaiseAssertion(Code: Longint);
  568. begin
  569. WriteError('Internal Error ' + ToStr(Code));
  570. inherited RaiseAssertion(Code);
  571. end;
  572. Procedure WriteWarning(const S : string);
  573. var
  574. ss: string;
  575. Begin
  576. ss:='!! Warning: ' + S;
  577. if nostdout then
  578. system.Writeln(StdErr, ss)
  579. else
  580. system.Writeln(ss);
  581. has_warnings:=true;
  582. End;
  583. procedure Write(const s: string);
  584. begin
  585. if nostdout then exit;
  586. system.write(s);
  587. end;
  588. procedure Write(const params: array of const);
  589. var
  590. i: integer;
  591. { Last vtType define in rtl/inc/objpash.inc }
  592. const
  593. max_vttype = vtUnicodeString;
  594. begin
  595. if nostdout then exit;
  596. for i:=Low(params) to High(params) do
  597. { All vtType in
  598. vtInteger = 0;
  599. vtBoolean = 1;
  600. vtChar = 2;
  601. vtExtended = 3;
  602. vtString = 4;
  603. vtPointer = 5;
  604. vtPChar = 6;
  605. vtObject = 7;
  606. vtClass = 8;
  607. vtWideChar = 9;
  608. vtPWideChar = 10;
  609. vtAnsiString32 = 11; called vtAnsiString in objpas unit
  610. vtCurrency = 12;
  611. vtVariant = 13;
  612. vtInterface = 14;
  613. vtWideString = 15;
  614. vtInt64 = 16;
  615. vtQWord = 17;
  616. vtUnicodeString = 18;
  617. // vtAnsiString16 = 19; not yet used
  618. // vtAnsiString64 = 20; not yet used
  619. }
  620. with TVarRec(params[i]) do
  621. case VType of
  622. vtInteger: system.write(VInteger);
  623. vtBoolean: system.write(VBoolean);
  624. vtChar: system.write(VChar);
  625. vtExtended: system.write(VExtended^);
  626. vtString: system.write(VString^);
  627. vtPointer:
  628. begin
  629. { Not sure the display will be correct
  630. if sizeof pointer is not native }
  631. WriteWarning('Pointer constant');
  632. end;
  633. vtPChar: system.write(VPChar);
  634. vtObject:
  635. begin
  636. { Not sure the display will be correct
  637. if sizeof pointer is not native }
  638. WriteWarning('Object constant');
  639. end;
  640. vtClass:
  641. begin
  642. { Not sure the display will be correct
  643. if sizeof pointer is not native }
  644. WriteWarning('Class constant');
  645. end;
  646. vtWideChar: system.write(VWideChar);
  647. vtPWideChar:
  648. begin
  649. WriteWarning('PWideChar constant');
  650. end;
  651. vtAnsiString: system.write(ansistring(VAnsiString));
  652. vtCurrency : system.write(VCurrency^);
  653. vtVariant :
  654. begin
  655. { Not sure the display will be correct
  656. if sizeof pointer is not native }
  657. WriteWarning('Variant constant');
  658. end;
  659. vtInterface :
  660. begin
  661. { Not sure the display will be correct
  662. if sizeof pointer is not native }
  663. WriteWarning('Interface constant');
  664. end;
  665. vtWideString : system.write(widestring(VWideString));
  666. vtInt64: system.write(VInt64^);
  667. vtQWord: system.write(VQWord^);
  668. vtUnicodeString : system.write(unicodestring(VUnicodeString));
  669. else
  670. begin
  671. system.writeln;
  672. system.writeln('Unsupported var type: ', VType);
  673. Halt(10);
  674. end;
  675. end;
  676. end;
  677. procedure Writeln(const s: string = '');
  678. begin
  679. if nostdout then exit;
  680. system.writeln(s);
  681. end;
  682. procedure Writeln(const params: array of const);
  683. begin
  684. if nostdout then exit;
  685. Write(params);
  686. system.writeln;
  687. end;
  688. Procedure HasMoreInfos;
  689. begin
  690. Writeln('!! Entry has more information stored');
  691. has_more_infos:=true;
  692. end;
  693. function Unknown(const st : string; val :longint) : string;
  694. Begin
  695. Unknown:='<!! Unknown'+st+' value '+tostr(val)+'>';
  696. SetHasErrors;
  697. end;
  698. function ToStr(w:longint):String;
  699. begin
  700. Str(w,ToStr);
  701. end;
  702. Function Target2Str(w:longint):string;
  703. begin
  704. if w<=ord(high(tsystem)) then
  705. Target2Str:=Targets[tsystem(w)]
  706. else
  707. Target2Str:=Unknown('target',w);
  708. end;
  709. Function Cpu2Str(w:longint):string;
  710. begin
  711. if w<=ord(high(tsystemcpu)) then
  712. begin
  713. cpu:=tsystemcpu(w);
  714. Cpu2Str:=CpuTxt[cpu];
  715. end
  716. else
  717. Cpu2Str:=Unknown('cpu',w);
  718. end;
  719. Function Varspez2Str(w:longint):string;
  720. const
  721. { in symconst unit
  722. tvarspez = (vs_value,vs_const,vs_var,vs_out,vs_constref); }
  723. varspezstr : array[tvarspez] of string[8]=('Value','Const','Var','Out','ConstRef','Final');
  724. begin
  725. if w<=ord(high(varspezstr)) then
  726. Varspez2Str:=varspezstr[tvarspez(w)]
  727. else
  728. Varspez2Str:=Unknown('varspez',w);
  729. end;
  730. Function VarRegable2Str(w:longint):string;
  731. { tvarregable type is defined in symconst unit }
  732. const
  733. varregableStr : array[tvarregable] of string[6]=('None','IntReg','FPUReg','MMReg','Addr');
  734. begin
  735. if w<=ord(high(varregablestr)) then
  736. Varregable2Str:=varregablestr[tvarregable(w)]
  737. else
  738. Varregable2Str:=Unknown('regable',w);
  739. end;
  740. Function Visibility2Str(w:longint):string;
  741. const
  742. { tvisibility type is defined in symconst unit }
  743. visibilityName : array[tvisibility] of string[16] = (
  744. 'hidden','strict private','private','strict protected','protected',
  745. 'public','published','<none>'
  746. );
  747. begin
  748. if w<=ord(high(visibilityName)) then
  749. result:=visibilityName[tvisibility(w)]
  750. else
  751. result:=Unknown('visibility',w);
  752. end;
  753. Function IntfEntryType2Str(w:longint):string;
  754. const
  755. { tinterfaceentrytype type is defined in symconst unit }
  756. Name : array[tinterfaceentrytype] of string = (
  757. 'standard','virtual method result','static method result','field value','virtual method class',
  758. 'static method class','field value class'
  759. );
  760. begin
  761. if w<=ord(high(Name)) then
  762. result:=Name[tinterfaceentrytype(w)]
  763. else
  764. result:=Unknown('entry type',w);
  765. end;
  766. function PPUFlags2Str(flags:dword):string;
  767. type
  768. tflagopt=record
  769. mask : dword;
  770. str : string[30];
  771. end;
  772. const
  773. flagopts=8;
  774. flagopt : array[1..flagopts] of tflagopt=(
  775. (mask: $4 ;str:'big_endian'),
  776. // (mask: $10 ;str:'browser'),
  777. (mask: $20 ;str:'in_library'),
  778. (mask: $40 ;str:'smart_linked'),
  779. (mask: $80 ;str:'static_linked'),
  780. (mask: $100 ;str:'shared_linked'),
  781. (mask: $400 ;str:'no_link'),
  782. (mask: $1000 ;str:'little_endian'),
  783. (mask: $8000 ;str:'fpu_emulation_on')
  784. );
  785. var
  786. i : longint;
  787. ntflags : dword;
  788. first : boolean;
  789. s : string;
  790. begin
  791. s:='';
  792. ntflags:=flags;
  793. if flags<>0 then
  794. begin
  795. first:=true;
  796. for i:=1to flagopts do
  797. if (flags and flagopt[i].mask)<>0 then
  798. begin
  799. if first then
  800. first:=false
  801. else
  802. s:=s+', ';
  803. s:=s+flagopt[i].str;
  804. ntflags:=ntflags and (not flagopt[i].mask);
  805. end;
  806. end
  807. else
  808. s:='none';
  809. if ntflags<>0 then
  810. begin
  811. s:=s+' unknown '+hexstr(ntflags,8);
  812. SetHasErrors;
  813. end;
  814. PPUFlags2Str:=s;
  815. end;
  816. Function L0(l:longint):string;
  817. {
  818. return the string of value l, if l<10 then insert a zero, so
  819. the string is always at least 2 chars '01','02',etc
  820. }
  821. var
  822. s : string;
  823. begin
  824. Str(l,s);
  825. if l<10 then
  826. s:='0'+s;
  827. L0:=s;
  828. end;
  829. function filetimestring( t : longint) : string;
  830. {
  831. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  832. }
  833. var
  834. DT : TDateTime;
  835. hsec : word;
  836. Year,Month,Day: Word;
  837. hour,min,sec : word;
  838. begin
  839. if t=-1 then
  840. begin
  841. Result := 'Not Found';
  842. SetHasErrors;
  843. exit;
  844. end;
  845. DT := FileDateToDateTime(t);
  846. DecodeTime(DT,hour,min,sec,hsec);
  847. DecodeDate(DT,year,month,day);
  848. Result := L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  849. end;
  850. {****************************************************************************
  851. Read Routines
  852. ****************************************************************************}
  853. function readsymstr(ppufile: tppufile): ansistring;
  854. begin
  855. if not(mf_symansistr in CurUnit.ModuleFlags) then
  856. result:=ppufile.getstring
  857. else
  858. result:=ppufile.getansistring;
  859. end;
  860. function readmanagementoperatoroptions(const space : string;const name : string):tmanagementoperators;forward;
  861. procedure readrecsymtableoptions;
  862. var
  863. usefieldalignment : shortint;
  864. begin
  865. if ppufile.readentry<>ibrecsymtableoptions then
  866. begin
  867. SetHasErrors;
  868. exit;
  869. end;
  870. writeln([space,' recordalignment: ',shortint(ppufile.getbyte)]);
  871. usefieldalignment:=shortint(ppufile.getbyte);
  872. writeln([space,' usefieldalignment: ',usefieldalignment]);
  873. writeln([space,' recordalignmin: ',shortint(ppufile.getbyte)]);
  874. if (usefieldalignment=C_alignment) then
  875. writeln([space,' fieldalignment: ',shortint(ppufile.getbyte)]);
  876. readmanagementoperatoroptions(space,'Fields have MOPs');
  877. end;
  878. function readsymtableoptions(const s: string) : tsymtableoptions;
  879. type
  880. tsymtblopt=record
  881. mask : tsymtableoption;
  882. str : string[30];
  883. end;
  884. const
  885. symtblopts=ord(high(tsymtableoption)) + 1;
  886. symtblopt : array[1..symtblopts] of tsymtblopt=(
  887. (mask:sto_has_helper; str:'Has helper'),
  888. (mask:sto_has_generic; str:'Has generic'),
  889. (mask:sto_has_operator; str:'Has operator'),
  890. (mask:sto_needs_init_final;str:'Needs init final table'),
  891. (mask:sto_has_non_trivial_init;str:'Has non trivial init')
  892. );
  893. var
  894. options : tsymtableoptions;
  895. first : boolean;
  896. i : integer;
  897. begin
  898. if ppufile.readentry<>ibsymtableoptions then
  899. begin
  900. SetHasErrors;
  901. exit;
  902. end;
  903. ppufile.getset(tppuset1(options));
  904. if space<>'' then
  905. writeln([space,'------ ',s,' ------']);
  906. write([space,'Symtable options: ']);
  907. if options<>[] then
  908. begin
  909. first:=true;
  910. for i:=1 to symtblopts do
  911. if (symtblopt[i].mask in options) then
  912. begin
  913. if first then
  914. first:=false
  915. else
  916. write(', ');
  917. write(symtblopt[i].str);
  918. end;
  919. end
  920. else
  921. write('none');
  922. writeln;
  923. readsymtableoptions:=options;
  924. end;
  925. procedure readdefinitions(const s:string; ParentDef: TPpuContainerDef); forward;
  926. procedure readsymbols(const s:string; ParentDef: TPpuContainerDef = nil); forward;
  927. procedure readsymtable(const s: string; ParentDef: TPpuContainerDef = nil);
  928. var
  929. stored_symtable_options : tsymtableoptions;
  930. begin
  931. stored_symtable_options:=current_symtable_options;
  932. current_symtable_options:=readsymtableoptions(s);
  933. readdefinitions(s, ParentDef);
  934. readsymbols(s, ParentDef);
  935. current_symtable_options:=stored_symtable_options;
  936. end;
  937. procedure readrecordsymtable(const s: string; ParentDef: TPpuContainerDef = nil);
  938. begin
  939. readrecsymtableoptions;
  940. readsymtable(s, ParentDef);
  941. end;
  942. Procedure ReadLinkContainer(const prefix:string);
  943. {
  944. Read a serie of strings and write to the screen starting every line
  945. with prefix
  946. }
  947. function maskstr(m:longint):string;
  948. { link options are in globtype unit
  949. const
  950. link_none = $0;
  951. link_always = $1;
  952. link_static = $2;
  953. link_smart = $4;
  954. link_shared = $8; }
  955. var
  956. s : string;
  957. begin
  958. s:='';
  959. if (m and link_always)<>0 then
  960. s:=s+'always ';
  961. if (m and link_static)<>0 then
  962. s:=s+'static ';
  963. if (m and link_smart)<>0 then
  964. s:=s+'smart ';
  965. if (m and link_shared)<>0 then
  966. s:=s+'shared ';
  967. maskstr:=s;
  968. end;
  969. var
  970. s : string;
  971. m : longint;
  972. begin
  973. while not ppufile.endofentry do
  974. begin
  975. s:=ppufile.getstring;
  976. m:=ppufile.getlongint;
  977. WriteLn([prefix,s,' (',maskstr(m),')']);
  978. end;
  979. end;
  980. Procedure ReadContainer(const prefix:string);
  981. {
  982. Read a series of strings and write to the screen starting every line
  983. with prefix
  984. }
  985. begin
  986. while not ppufile.endofentry do
  987. WriteLn([prefix,ppufile.getstring]);
  988. end;
  989. procedure ReadLoadUnit;
  990. var
  991. ucrc,uintfcrc, indcrc : cardinal;
  992. un: TPpuUnitDef;
  993. begin
  994. while not ppufile.EndOfEntry do
  995. begin
  996. un:=TPpuUnitDef.Create(CurUnit.UsedUnits);
  997. un.Name:=ppufile.getstring;
  998. write(['Uses unit: ',un.Name]);
  999. ucrc:=cardinal(ppufile.getlongint);
  1000. uintfcrc:=cardinal(ppufile.getlongint);
  1001. indcrc:=cardinal(ppufile.getlongint);
  1002. writeln([' (Crc: ',hexstr(ucrc,8),', IntfcCrc: ',hexstr(uintfcrc,8),', IndCrc: ',hexstr(indcrc,8),')']);
  1003. un.Crc:=ucrc;
  1004. un.IntfCrc:=uintfcrc;
  1005. end;
  1006. end;
  1007. Procedure ReadDerefmap;
  1008. var
  1009. i,mapsize : longint;
  1010. s: string;
  1011. begin
  1012. mapsize:=ppufile.getlongint;
  1013. writeln(['DerefMapsize: ',mapsize]);
  1014. SetLength(CurUnit.RefUnits, mapsize);
  1015. for i:=0 to mapsize-1 do
  1016. begin
  1017. s:=ppufile.getstring;
  1018. writeln(['DerefMap[',i,'] = ',s]);
  1019. CurUnit.RefUnits[i]:=LowerCase(s);
  1020. end;
  1021. end;
  1022. Procedure ReadImportSymbols;
  1023. var
  1024. extlibname : string;
  1025. j,
  1026. extsymcnt : longint;
  1027. extsymname : string;
  1028. extsymmangledname : string;
  1029. extsymordnr : longint;
  1030. extsymisvar : boolean;
  1031. begin
  1032. while not ppufile.endofentry do
  1033. begin
  1034. extlibname:=ppufile.getstring;
  1035. extsymcnt:=ppufile.getlongint;
  1036. writeln(['External Library: ',extlibname,' (',extsymcnt,' imports)']);
  1037. for j:=0 to extsymcnt-1 do
  1038. begin
  1039. extsymname:=ppufile.getstring;
  1040. extsymmangledname:=ppufile.getstring;
  1041. extsymordnr:=ppufile.getlongint;
  1042. extsymisvar:=ppufile.getbyte<>0;
  1043. writeln([' ',extsymname,' as ',extsymmangledname,
  1044. '(OrdNr: ',extsymordnr,' IsVar: ',extsymisvar,')']);
  1045. end;
  1046. end;
  1047. end;
  1048. Procedure ReadDerefdata;
  1049. begin
  1050. derefdatalen:=ppufile.entrysize;
  1051. if derefdatalen=0 then
  1052. begin
  1053. Writeln(['No Derefdata length=0']);
  1054. derefdata:=nil;
  1055. exit;
  1056. end;
  1057. Writeln(['Derefdata length: ',derefdatalen]);
  1058. derefdata:=allocmem(derefdatalen);
  1059. ppufile.getdata(derefdata^,derefdatalen);
  1060. end;
  1061. Procedure FreeDerefdata;
  1062. begin
  1063. if assigned(derefdata) then
  1064. begin
  1065. FreeMem(derefdata);
  1066. derefdata:=nil;
  1067. derefdatalen:=0;
  1068. end;
  1069. end;
  1070. Procedure ReadWpoFileInfo;
  1071. begin
  1072. Writeln(['Compiled with input whole-program optimisation from ',ppufile.getstring,' ',filetimestring(ppufile.getlongint)]);
  1073. end;
  1074. Procedure ReadAsmSymbols;
  1075. const
  1076. unitasmlisttype: array[tunitasmlisttype] of string[6]=(
  1077. 'PUBLIC',
  1078. 'EXTERN'
  1079. );
  1080. type
  1081. { Copied from aasmbase.pas }
  1082. TAsmsymbind=(
  1083. AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL,AB_WEAK_EXTERNAL,
  1084. { global in the current program/library, but not visible outside it }
  1085. AB_PRIVATE_EXTERN,AB_LAZY,AB_IMPORT,
  1086. { a symbol that's internal to the compiler and used as a temp }
  1087. AB_TEMP,
  1088. { a global symbol that points to another global symbol and is only used
  1089. to allow indirect loading in case of packages and indirect imports }
  1090. AB_INDIRECT,AB_EXTERNAL_INDIRECT);
  1091. TAsmsymtype=(
  1092. AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION,AT_LABEL,
  1093. {
  1094. the address of this code label is taken somewhere in the code
  1095. so it must be taken care of it when creating pic
  1096. }
  1097. AT_ADDR,
  1098. { Label for debug or other non-program information }
  1099. AT_METADATA,
  1100. { label for data that must always be accessed indirectly, because it
  1101. is handled explcitely in the system unit or (e.g. RTTI and threadvar
  1102. tables) -- never seen in an assembler/assembler writer, always
  1103. changed to AT_DATA }
  1104. AT_DATA_FORCEINDIRECT,
  1105. { don't generate an implicit indirect symbol as that might be provided
  1106. by other means (e.g. the typed const builder) to ensure a correct
  1107. section name }
  1108. AT_DATA_NOINDIRECT,
  1109. { Thread-local symbol (ELF targets) }
  1110. AT_TLS,
  1111. { GNU indirect function (ELF targets) }
  1112. AT_GNU_IFUNC
  1113. );
  1114. var
  1115. s,
  1116. bindstr,
  1117. typestr : string;
  1118. i : longint;
  1119. t: tunitasmlisttype;
  1120. begin
  1121. writeln([space,'Assembler Symbols']);
  1122. writeln([space,'-----------------']);
  1123. t:=tunitasmlisttype(ppufile.getbyte);
  1124. if (t>=Low(tunitasmlisttype)) and (t<=High(tunitasmlisttype)) then
  1125. typestr:=unitasmlisttype[t]
  1126. else
  1127. typestr:='UNKNOWN';
  1128. writeln([space,'Type: ',typestr]);
  1129. writeln([space,'Count: ',ppufile.getlongint]);
  1130. i:=0;
  1131. while (not ppufile.endofentry) and (not ppufile.error) do
  1132. begin
  1133. s:=ppufile.getstring;
  1134. case tasmsymbind(ppufile.getbyte) of
  1135. AB_EXTERNAL :
  1136. bindstr:='External';
  1137. AB_COMMON :
  1138. bindstr:='Common';
  1139. AB_LOCAL :
  1140. bindstr:='Local';
  1141. AB_GLOBAL :
  1142. bindstr:='Global';
  1143. AB_WEAK_EXTERNAL :
  1144. bindstr:='Weak external';
  1145. AB_PRIVATE_EXTERN :
  1146. bindstr:='Private extern';
  1147. AB_LAZY :
  1148. bindstr:='Lazy';
  1149. AB_IMPORT :
  1150. bindstr:='Import';
  1151. AB_TEMP :
  1152. bindstr:='Temp';
  1153. AB_INDIRECT :
  1154. bindstr:='Indirect';
  1155. AB_EXTERNAL_INDIRECT :
  1156. bindstr:='Indirect external';
  1157. else
  1158. begin
  1159. bindstr:='<Error !!>';
  1160. SetHasErrors;
  1161. end;
  1162. end;
  1163. case tasmsymtype(ppufile.getbyte) of
  1164. AT_FUNCTION :
  1165. typestr:='Function';
  1166. AT_DATA :
  1167. typestr:='Data';
  1168. AT_SECTION :
  1169. typestr:='Section';
  1170. AT_LABEL :
  1171. typestr:='Label';
  1172. AT_ADDR :
  1173. typestr:='Label (with address taken)';
  1174. AT_METADATA :
  1175. typestr:='Metadata';
  1176. { this shouldn't appear in a PPU }
  1177. AT_DATA_FORCEINDIRECT :
  1178. typestr:='Data (ForceIndirect)';
  1179. { this shouldn't appear in a PPU }
  1180. AT_DATA_NOINDIRECT:
  1181. typestr:='Data (NoIndirect)';
  1182. AT_TLS :
  1183. typestr:='TLS';
  1184. AT_GNU_IFUNC :
  1185. typestr:='GNU IFUNC';
  1186. else
  1187. begin
  1188. typestr:='<Error !!>';
  1189. SetHasErrors;
  1190. end;
  1191. end;
  1192. Writeln([space,' ',i,' : ',s,' [',bindstr,',',typestr,']']);
  1193. inc(i);
  1194. end;
  1195. writeln([space]);
  1196. end;
  1197. function getexprint:Tconstexprint;
  1198. begin
  1199. getexprint.overflow:=false;
  1200. getexprint.signed:=ppufile.getboolean;
  1201. getexprint.svalue:=ppufile.getint64;
  1202. end;
  1203. Procedure ReadPosInfo(Def: TPpuDef = nil);
  1204. var
  1205. info : byte;
  1206. fileindex,line,column : longint;
  1207. begin
  1208. with ppufile do
  1209. begin
  1210. fileindex:=0;
  1211. line:=0;
  1212. column:=0;
  1213. {
  1214. info byte layout in bits:
  1215. 0-1 - amount of bytes for fileindex
  1216. 2-3 - amount of bytes for line
  1217. 4-5 - amount of bytes for column
  1218. }
  1219. info:=getbyte;
  1220. case (info and $03) of
  1221. 0 : fileindex:=getbyte;
  1222. 1 : fileindex:=getword;
  1223. 2 : fileindex:=(getbyte shl 16) or getword;
  1224. 3 : fileindex:=getlongint;
  1225. end;
  1226. case ((info shr 2) and $03) of
  1227. 0 : line:=getbyte;
  1228. 1 : line:=getword;
  1229. 2 : line:=(getbyte shl 16) or getword;
  1230. 3 : line:=getlongint;
  1231. end;
  1232. case ((info shr 4) and $03) of
  1233. 0 : column:=getbyte;
  1234. 1 : column:=getword;
  1235. 2 : column:=(getbyte shl 16) or getword;
  1236. 3 : column:=getlongint;
  1237. end;
  1238. Writeln([fileindex,' (',line,',',column,')']);
  1239. if Def <> nil then
  1240. begin
  1241. Def.FilePos.FileIndex:=fileindex;
  1242. Def.FilePos.Line:=line;
  1243. Def.FilePos.Col:=column;
  1244. end;
  1245. end;
  1246. end;
  1247. procedure readderef(const derefspace: string; Ref: TPpuRef = nil);
  1248. var
  1249. b : tdereftype;
  1250. first : boolean;
  1251. idx : longint;
  1252. i,n : byte;
  1253. pdata : pbyte;
  1254. begin
  1255. if not assigned(derefdata) then
  1256. exit;
  1257. first:=true;
  1258. idx:=ppufile.getlongint;
  1259. if idx = -1 then
  1260. begin
  1261. writeln('Nil');
  1262. exit;
  1263. end;
  1264. if (idx>derefdatalen) then
  1265. begin
  1266. WriteError('!! Error: Deref idx '+IntToStr(idx)+' > '+IntToStr(derefdatalen));
  1267. exit;
  1268. end;
  1269. write([derefspace,'(',idx,') ']);
  1270. pdata:=@derefdata[idx];
  1271. i:=0;
  1272. n:=pdata[i];
  1273. inc(i);
  1274. if n<1 then
  1275. begin
  1276. WriteError('!! Error: Deref len < 1');
  1277. exit;
  1278. end;
  1279. while (i<=n) do
  1280. begin
  1281. if not first then
  1282. write(', ')
  1283. else
  1284. first:=false;
  1285. b:=tdereftype(pdata[i]);
  1286. inc(i);
  1287. case b of
  1288. deref_nil :
  1289. write('Nil');
  1290. deref_symid :
  1291. begin
  1292. idx:=pdata[i] shl 24 or pdata[i+1] shl 16 or pdata[i+2] shl 8 or pdata[i+3];
  1293. inc(i,4);
  1294. write(['SymId ',idx]);
  1295. if Ref <> nil then
  1296. Ref.Id:=idx;
  1297. end;
  1298. deref_defid :
  1299. begin
  1300. idx:=pdata[i] shl 24 or pdata[i+1] shl 16 or pdata[i+2] shl 8 or pdata[i+3];
  1301. inc(i,4);
  1302. write(['DefId ',idx]);
  1303. if Ref <> nil then
  1304. Ref.Id:=idx;
  1305. end;
  1306. deref_unit :
  1307. begin
  1308. idx:=pdata[i] shl 8 or pdata[i+1];
  1309. inc(i,2);
  1310. write(['Unit ',idx]);
  1311. if Ref <> nil then
  1312. Ref.UnitIndex:=idx;
  1313. end;
  1314. else
  1315. begin
  1316. WriteError('!! unsupported dereftyp: '+IntToStr(ord(b)));
  1317. break;
  1318. end;
  1319. end;
  1320. end;
  1321. writeln;
  1322. end;
  1323. Procedure ReadUnitImportSyms;
  1324. var
  1325. c,i : longint;
  1326. begin
  1327. writeln([space,'Imported Symbols']);
  1328. writeln([space,'----------------']);
  1329. c:=ppufile.getlongint;
  1330. for i:=0 to c-1 do
  1331. readderef(space);
  1332. writeln([space]);
  1333. end;
  1334. procedure readpropaccesslist(const s:string; Ref: TPpuRef = nil);
  1335. { type tsltype is in symconst unit }
  1336. const
  1337. slstr : array[tsltype] of string[12] = (
  1338. '',
  1339. 'load',
  1340. 'call',
  1341. 'subscript',
  1342. 'vec',
  1343. 'typeconv',
  1344. 'absolutetype'
  1345. );
  1346. var
  1347. sl : tsltype;
  1348. begin
  1349. readderef('',Ref);
  1350. repeat
  1351. sl:=tsltype(ppufile.getbyte);
  1352. if sl=sl_none then
  1353. break;
  1354. write([s,'(',slstr[sl],') ']);
  1355. case sl of
  1356. sl_none : ;
  1357. sl_call,
  1358. sl_load,
  1359. sl_subscript :
  1360. if (Ref <> nil) and (Ref.IsNull) then
  1361. begin
  1362. readderef('',Ref);
  1363. Ref.IsSymId:=True;
  1364. end
  1365. else
  1366. readderef('');
  1367. sl_absolutetype,
  1368. sl_typeconv :
  1369. readderef('');
  1370. sl_vec :
  1371. begin
  1372. writeln([ppufile.getlongint]);
  1373. readderef('');
  1374. end;
  1375. end;
  1376. until false;
  1377. end;
  1378. (*
  1379. talignmentinfo = packed record
  1380. procalign,
  1381. loopalign,
  1382. jumpalign,
  1383. constalignmin,
  1384. constalignmax,
  1385. varalignmin,
  1386. varalignmax,
  1387. localalignmin,
  1388. localalignmax,
  1389. recordalignmin,
  1390. recordalignmax,
  1391. maxCrecordalign : longint;
  1392. end;
  1393. tsettings = packed record
  1394. alignment : talignmentinfo;
  1395. globalswitches : tglobalswitches;
  1396. moduleswitches : tmoduleswitches;
  1397. localswitches : tlocalswitches;
  1398. modeswitches : tmodeswitches;
  1399. optimizerswitches : toptimizerswitches;
  1400. { generate information necessary to perform these wpo's during a subsequent compilation }
  1401. genwpoptimizerswitches: twpoptimizerswitches;
  1402. { perform these wpo's using information generated during a previous compilation }
  1403. dowpoptimizerswitches: twpoptimizerswitches;
  1404. debugswitches : tdebugswitches;
  1405. { 0: old behaviour for sets <=256 elements
  1406. >0: round to this size }
  1407. setalloc,
  1408. packenum : shortint;
  1409. packrecords : shortint;
  1410. maxfpuregisters : shortint;
  1411. cputype,
  1412. optimizecputype : tcputype;
  1413. fputype : tfputype;
  1414. asmmode : tasmmode;
  1415. interfacetype : tinterfacetypes;
  1416. defproccall : tproccalloption;
  1417. sourcecodepage : tcodepagestring;
  1418. minfpconstprec : tfloattype;
  1419. disabledircache : boolean;
  1420. { CPU targets with microcontroller support can add a controller specific unit }
  1421. controllertype : tcontrollertype;
  1422. { WARNING: this pointer cannot be written as such in record token }
  1423. pmessage : pmessagestaterecord;
  1424. end;
  1425. *)
  1426. procedure readprocinfooptions(space : string);
  1427. (*
  1428. tprocinfoflag=(
  1429. { procedure has at least one assembler block }
  1430. pi_has_assembler_block,
  1431. { procedure does a call }
  1432. pi_do_call,
  1433. { procedure has a try statement = no register optimization }
  1434. pi_uses_exceptions,
  1435. { procedure is declared as @var(assembler), don't optimize}
  1436. pi_is_assembler,
  1437. { procedure contains data which needs to be finalized }
  1438. pi_needs_implicit_finally,
  1439. { procedure has the implicit try..finally generated }
  1440. pi_has_implicit_finally,
  1441. { procedure uses fpu}
  1442. pi_uses_fpu,
  1443. { procedure uses GOT for PIC code }
  1444. pi_needs_got,
  1445. { references var/proc/type/const in static symtable,
  1446. i.e. not allowed for inlining from other units }
  1447. pi_uses_static_symtable,
  1448. { set if the procedure has to push parameters onto the stack }
  1449. pi_has_stackparameter,
  1450. { set if the procedure has at least one label }
  1451. pi_has_label,
  1452. { calls itself recursive }
  1453. pi_is_recursive,
  1454. { stack frame optimization not possible (only on x86 probably) }
  1455. pi_needs_stackframe,
  1456. { set if the procedure has at least one register saved on the stack }
  1457. pi_has_saved_regs,
  1458. { dfa was generated for this proc }
  1459. pi_dfaavailable,
  1460. { subroutine contains interprocedural used labels }
  1461. pi_has_interproclabel,
  1462. { subroutine contains interprocedural gotos }
  1463. pi_has_global_goto
  1464. ); *)
  1465. type
  1466. tprocinfoopt=record
  1467. mask : tprocinfoflag;
  1468. str : string[81];
  1469. end;
  1470. const
  1471. procinfoopts=ord(high(tprocinfoflag)) - ord(low(tprocinfoflag));
  1472. procinfoopt : array[0..procinfoopts] of tprocinfoopt=(
  1473. (mask:pi_has_assembler_block;
  1474. str:' has at least one assembler block'),
  1475. (mask:pi_do_call;
  1476. str:' does a call'),
  1477. (mask:pi_uses_exceptions;
  1478. str:' has a try statement = no register optimization '),
  1479. (mask:pi_is_assembler;
  1480. str:' is declared as @var(assembler), don''t optimize'),
  1481. (mask:pi_needs_implicit_finally;
  1482. str:' contains data which needs to be finalized '),
  1483. (mask:pi_has_implicit_finally;
  1484. str:' has the implicit try..finally generated '),
  1485. (mask:pi_uses_fpu;
  1486. str:' uses fpu'),
  1487. (mask:pi_needs_got;
  1488. str:' uses GOT for PIC code '),
  1489. (mask:pi_uses_static_symtable;
  1490. str:' references var/proc/type/const in static symtable'),
  1491. (mask:pi_has_stackparameter;
  1492. str:' set if the procedure has to push parameters onto the stack '),
  1493. (mask:pi_has_label;
  1494. str:' set if the procedure has at least one label '),
  1495. (mask:pi_is_recursive;
  1496. str:' calls itself recursive '),
  1497. (mask:pi_needs_stackframe;
  1498. str:' stack frame optimization not possible (only on x86 probably) '),
  1499. (mask:pi_has_saved_regs;
  1500. str:' set if the procedure has at least one register saved on the stack '),
  1501. (mask:pi_dfaavailable;
  1502. str:' dfa was generated for this proc '),
  1503. (mask:pi_has_interproclabel;
  1504. str:' subroutine contains interprocedural used labels '),
  1505. (mask:pi_has_unwind_info;
  1506. str:' unwinding info was generated for this proc '),
  1507. (mask:pi_has_global_goto;
  1508. str:' subroutine contains interprocedural goto '),
  1509. (mask:pi_has_inherited;
  1510. str:' subroutine contains inherited call '),
  1511. (mask:pi_has_nested_exit;
  1512. str:' subroutine contains a nested subroutine which calls the exit of the current one '),
  1513. (mask:pi_has_stack_allocs;
  1514. str:' allocates memory on stack, so stack may be unbalanced on exit '),
  1515. (mask:pi_estimatestacksize;
  1516. str:' stack size is estimated before subroutine is compiled '),
  1517. (mask:pi_calls_c_varargs;
  1518. str:' calls function with C-style varargs '),
  1519. (mask:pi_has_open_array_parameter;
  1520. str:' has open array parameter '),
  1521. (mask:pi_uses_threadvar;
  1522. str:' uses threadvars '),
  1523. (mask:pi_has_except_table_data;
  1524. str:' has except table data '),
  1525. (mask:pi_needs_tls;
  1526. str:' uses TLS data pointer '),
  1527. (mask:pi_uses_get_frame;
  1528. str:' uses get_frame'),
  1529. (mask:pi_uses_ymm;
  1530. str:' uses ymm register (x86 only)')
  1531. );
  1532. var
  1533. procinfooptions : tprocinfoflags;
  1534. i : longint;
  1535. first : boolean;
  1536. begin
  1537. ppufile.getset(tppuset4(procinfooptions));
  1538. if procinfooptions<>[] then
  1539. begin
  1540. first:=true;
  1541. for i:=0 to procinfoopts do
  1542. if (procinfoopt[i].mask in procinfooptions) then
  1543. begin
  1544. if first then
  1545. first:=false
  1546. else
  1547. write(', ');
  1548. write(procinfoopt[i].str);
  1549. end;
  1550. end;
  1551. writeln;
  1552. end;
  1553. procedure readsymoptions(space : string; Def: TPpuDef = nil);
  1554. type
  1555. tsymopt=record
  1556. mask : tsymoption;
  1557. str : string[30];
  1558. end;
  1559. const
  1560. symopts=ord(high(tsymoption)) - ord(low(tsymoption));
  1561. { sp_none = 0 corresponds to nothing }
  1562. symopt : array[1..symopts] of tsymopt=(
  1563. (mask:sp_static; str:'Static'),
  1564. (mask:sp_hint_deprecated; str:'Hint Deprecated'),
  1565. (mask:sp_hint_platform; str:'Hint Platform'),
  1566. (mask:sp_hint_library; str:'Hint Library'),
  1567. (mask:sp_hint_unimplemented; str:'Hint Unimplemented'),
  1568. (mask:sp_hint_experimental; str:'Hint Experimental'),
  1569. (mask:sp_has_overloaded; str:'Has overloaded'),
  1570. (mask:sp_internal; str:'Internal'),
  1571. (mask:sp_implicitrename; str:'Implicit Rename'),
  1572. (mask:sp_generic_para; str:'Generic Parameter'),
  1573. (mask:sp_has_deprecated_msg; str:'Has Deprecated Message'),
  1574. (mask:sp_generic_dummy; str:'Generic Dummy'),
  1575. (mask:sp_explicitrename; str:'Explicit Rename'),
  1576. (mask:sp_generic_const; str:'Generic Constant Parameter')
  1577. );
  1578. var
  1579. symoptions : tsymoptions;
  1580. i : longint;
  1581. first : boolean;
  1582. begin
  1583. ppufile.getset(tppuset2(symoptions));
  1584. if symoptions<>[] then
  1585. begin
  1586. if Def <> nil then
  1587. begin
  1588. if sp_internal in symoptions then
  1589. Def.Visibility:=dvHidden;
  1590. if sp_generic_dummy in symoptions then
  1591. Def.GenericDummy:=true;
  1592. end;
  1593. first:=true;
  1594. for i:=1to symopts do
  1595. if (symopt[i].mask in symoptions) then
  1596. begin
  1597. if first then
  1598. first:=false
  1599. else
  1600. write(', ');
  1601. write(symopt[i].str);
  1602. end;
  1603. end;
  1604. writeln;
  1605. if sp_has_deprecated_msg in symoptions then
  1606. writeln([space,'Deprecated : ', ppufile.getstring]);
  1607. end;
  1608. procedure readvisibility(Def: TPpuDef = nil);
  1609. var
  1610. i: byte;
  1611. begin
  1612. i:=ppufile.getbyte;
  1613. if Def <> nil then
  1614. case tvisibility(i) of
  1615. vis_public: Def.Visibility:=dvPublic;
  1616. vis_published: Def.Visibility:=dvPublished;
  1617. vis_protected, vis_strictprotected: Def.Visibility:=dvProtected;
  1618. else Def.Visibility:=dvPrivate;
  1619. end;
  1620. writeln(Visibility2Str(i));
  1621. end;
  1622. procedure readattrs(def: TPpuDef);
  1623. var
  1624. i,cnt,paras: longint;
  1625. begin
  1626. cnt:=ppufile.getlongint;
  1627. if cnt>0 then
  1628. begin
  1629. writeln([space,' Attributes : ']);
  1630. space:=' '+space;
  1631. if assigned(def) then
  1632. SetLength(def.Attrs,cnt);
  1633. for i:=0 to cnt-1 do
  1634. begin
  1635. writeln([space,'** Custom Attribute ',i,' **']);
  1636. write ([space,' Type symbol : ']);
  1637. if assigned(def) then
  1638. begin
  1639. def.Attrs[i].TypeSym:=TPpuRef.Create;
  1640. readderef('',def.Attrs[i].TypeSym);
  1641. end
  1642. else
  1643. readderef('');
  1644. write ([space,' Type constructor : ']);
  1645. if assigned(def) then
  1646. begin
  1647. def.Attrs[i].TypeConstr:=TPpuRef.Create;
  1648. readderef('',def.Attrs[i].TypeConstr);
  1649. end
  1650. else
  1651. readderef('');
  1652. paras:=ppufile.getlongint;
  1653. writeln([space,' Parameters : ',paras]);
  1654. if assigned(def) then
  1655. def.Attrs[i].ParaCount:=paras;
  1656. end;
  1657. delete(space,1,4);
  1658. end;
  1659. end;
  1660. procedure readnodetree; forward;
  1661. procedure readattrparas(def: TPpuDef);
  1662. var
  1663. attr,para: LongInt;
  1664. begin
  1665. if Length(def.Attrs) > 0 then
  1666. writeln([space,' Attr Paras : ']);
  1667. space:=' '+space;
  1668. for attr:=0 to High(def.Attrs) do
  1669. begin
  1670. writeln([space,'** Custom Attribute ',attr,' Arguments **']);
  1671. space:=' '+space;
  1672. for para:=0 to def.Attrs[attr].ParaCount-1 do
  1673. begin
  1674. readnodetree;
  1675. end;
  1676. delete(space,1,4);
  1677. end;
  1678. delete(space,1,4);
  1679. end;
  1680. procedure readdefsubentries(def: TPpuDef);
  1681. begin
  1682. space:=' '+space;
  1683. readattrparas(def);
  1684. delete(space,1,4);
  1685. end;
  1686. procedure readsymsubentries(def: TPpuDef);
  1687. begin
  1688. readattrparas(def);
  1689. end;
  1690. procedure readcommonsym(const s:string; Def: TPpuDef = nil);
  1691. var
  1692. i: integer;
  1693. n: ansistring;
  1694. begin
  1695. n:=readsymstr(ppufile);
  1696. if Def <> nil then
  1697. Def.Name:=n;
  1698. i:=ppufile.getlongint;
  1699. if Def <> nil then
  1700. Def.SetSymId(i);
  1701. writeln([space,'** Symbol Id ',i,' **']);
  1702. writeln([space,s,n]);
  1703. write ([space,' File Pos : ']);
  1704. readposinfo(Def);
  1705. write ([space,' Visibility : ']);
  1706. readvisibility(Def);
  1707. write ([space,' SymOptions : ']);
  1708. readsymoptions(space+' ',Def);
  1709. readattrs(Def);
  1710. end;
  1711. procedure readcgpara(const space:string);
  1712. { this is originally in cgbase.pas }
  1713. type
  1714. TCGLoc=(LOC_INVALID, LOC_VOID, LOC_CONSTANT, LOC_JUMP, LOC_FLAGS,
  1715. LOC_REGISTER, LOC_CREGISTER, LOC_FPUREGISTER, LOC_CFPUREGISTER,
  1716. LOC_MMXREGISTER, LOC_CMMXREGISTER, LOC_MMREGISTER, LOC_CMMREGISTER,
  1717. LOC_SUBSETREG, LOC_CSUBSETREG, LOC_SUBSETREF, LOC_CSUBSETREF,
  1718. LOC_CREFERENCE, LOC_REFERENCE);
  1719. const
  1720. tcgloc2str : array[TCGLoc] of string[12] = (
  1721. 'LOC_INVALID', 'LOC_VOID', 'LOC_CONST', 'LOC_JUMP', 'LOC_FLAGS',
  1722. 'LOC_REG', 'LOC_CREG', 'LOC_FPUREG', 'LOC_CFPUREG',
  1723. 'LOC_MMXREG', 'LOC_CMMXREG', 'LOC_MMREG', 'LOC_CMMREG',
  1724. 'LOC_SSETREG', 'LOC_CSSETREG', 'LOC_SSETREF', 'LOC_CSSETREF',
  1725. 'LOC_CREF', 'LOC_REF');
  1726. var
  1727. i: byte;
  1728. ii: longint;
  1729. np: byte;
  1730. loc: tcgloc;
  1731. begin
  1732. i:=ppufile.getbyte;
  1733. writeln([space,' Alignment : ',i]);
  1734. i:=ppufile.getbyte;
  1735. writeln([space,' Size : ',i]);
  1736. ii:=ppufile.getaint;
  1737. writeln([space,' IntSize : ',ii]);
  1738. readderef(space+' ');
  1739. np:=ppufile.getbyte;
  1740. writeln([space,' NumParaloc : ',np]);
  1741. while np > 0 do
  1742. begin
  1743. i:=ppufile.getbyte;
  1744. writeln([space,' Paraloc Size : ',i]);
  1745. loc:=tcgloc(ppufile.getbyte);
  1746. if loc > high(tcgloc) then
  1747. begin
  1748. WriteError('!! Location is out of range! '+IntToStr(ord(loc)));
  1749. loc:=LOC_INVALID;
  1750. end;
  1751. writeln([space,' Paraloc Loc : (',ord(loc),') ',tcgloc2str[loc]]);
  1752. case loc of
  1753. LOC_REFERENCE:
  1754. begin
  1755. writeln([space,' RegIndex : $',hexstr(ppufile.getdword,8)]);
  1756. writeln([space,' Offset : ',ppufile.getaint]);
  1757. end;
  1758. LOC_FPUREGISTER,
  1759. LOC_CFPUREGISTER,
  1760. LOC_MMREGISTER,
  1761. LOC_CMMREGISTER,
  1762. LOC_REGISTER,
  1763. LOC_CREGISTER :
  1764. begin
  1765. writeln([space,' ShiftVal : ',ppufile.getbyte]);
  1766. writeln([space,' Register : $',hexstr(ppufile.getdword,8)]);
  1767. end;
  1768. LOC_VOID:
  1769. begin end
  1770. else
  1771. WriteError('!! Invalid location error')
  1772. end;
  1773. dec(np);
  1774. end;
  1775. end;
  1776. procedure displaytokenbuffer(tokenbuf : pbyte;tokenbufsize : longint);
  1777. type
  1778. ptoken=^ttoken;
  1779. pmsgstate =^tmsgstate;
  1780. var
  1781. tbi : longint;
  1782. state : tmsgstate;
  1783. prev_settings, new_settings : Tsettings;
  1784. nb, msgvalue, mesgnb : longint;
  1785. function readtoken: ttoken;
  1786. var
  1787. b,b2 : byte;
  1788. begin
  1789. b:=tokenbuf[tbi];
  1790. inc(tbi);
  1791. if (b and $80)<>0 then
  1792. begin
  1793. b2:=tokenbuf[tbi];
  1794. inc(tbi);
  1795. result:=ttoken(((b and $7f) shl 8) or b2);
  1796. end
  1797. else
  1798. result:=ttoken(b);
  1799. end;
  1800. function gettokenbufdword : dword;
  1801. var
  1802. var32 : dword;
  1803. begin
  1804. var32:=unaligned(pdword(@tokenbuf[tbi])^);
  1805. inc(tbi,sizeof(dword));
  1806. if ppufile.change_endian then
  1807. var32:=swapendian(var32);
  1808. result:=var32;
  1809. end;
  1810. function gettokenbufword : word;
  1811. var
  1812. var16 : word;
  1813. begin
  1814. var16:=unaligned(pword(@tokenbuf[tbi])^);
  1815. inc(tbi,sizeof(word));
  1816. if ppufile.change_endian then
  1817. var16:=swapendian(var16);
  1818. result:=var16;
  1819. end;
  1820. function gettokenbuflongint : longint;
  1821. var
  1822. var32 : longint;
  1823. begin
  1824. var32:=unaligned(plongint(@tokenbuf[tbi])^);
  1825. inc(tbi,sizeof(longint));
  1826. if ppufile.change_endian then
  1827. var32:=swapendian(var32);
  1828. result:=var32;
  1829. end;
  1830. function gettokenbufshortint : shortint;
  1831. var
  1832. var8 : shortint;
  1833. begin
  1834. var8:=pshortint(@tokenbuf[tbi])^;
  1835. inc(tbi,sizeof(shortint));
  1836. result:=var8;
  1837. end;
  1838. procedure tokenreadset(var b;size : longint);
  1839. var
  1840. i : longint;
  1841. begin
  1842. move(tokenbuf[tbi],b,size);
  1843. inc(tbi,size);
  1844. if ppufile.change_endian then
  1845. for i:=0 to size-1 do
  1846. Pbyte(@b)[i]:=reverse_byte(Pbyte(@b)[i]);
  1847. end;
  1848. function gettokenbufbyte : byte;
  1849. begin
  1850. result:=pbyte(@tokenbuf[tbi])^;
  1851. inc(tbi);
  1852. end;
  1853. function tokenreadenum(size : longint) : longword;
  1854. begin
  1855. if size=1 then
  1856. result:=gettokenbufbyte
  1857. else if size=2 then
  1858. result:=gettokenbufword
  1859. else if size=4 then
  1860. result:=gettokenbufdword;
  1861. end;
  1862. function gettokenbufsizeint : int64;
  1863. var
  1864. var64 : int64;
  1865. var32 : longint;
  1866. var16 : smallint;
  1867. begin
  1868. if CpuAddrBitSize[cpu]=64 then
  1869. begin
  1870. var64:=unaligned(pint64(@tokenbuf[tbi])^);
  1871. inc(tbi,sizeof(int64));
  1872. if ppufile.change_endian then
  1873. var64:=swapendian(var64);
  1874. result:=var64;
  1875. end
  1876. else if CpuAddrBitSize[cpu]=32 then
  1877. begin
  1878. var32:=unaligned(plongint(@tokenbuf[tbi])^);
  1879. inc(tbi,sizeof(longint));
  1880. if ppufile.change_endian then
  1881. var32:=swapendian(var32);
  1882. result:=var32;
  1883. end
  1884. else if CpuAddrBitSize[cpu]=16 then
  1885. begin
  1886. { ASizeInt is still a longint, see globtype.pas unit }
  1887. var32:=unaligned(plongint(@tokenbuf[tbi])^);
  1888. inc(tbi,sizeof(longint));
  1889. if ppufile.change_endian then
  1890. var32:=swapendian(var32);
  1891. result:=var32;
  1892. end
  1893. else
  1894. begin
  1895. WriteError('Wrong CpuAddrBitSize');
  1896. result:=0;
  1897. end;
  1898. end;
  1899. procedure tokenreadsettings(var asettings : tsettings; expected_size : asizeint);
  1900. { This procedure
  1901. needs to be changed whenever
  1902. globals.tsettings type is changed,
  1903. the problem is that no error will appear
  1904. before tests with generics are tested. PM }
  1905. var
  1906. startpos, endpos : longword;
  1907. begin
  1908. { WARNING all those fields need to be in the correct
  1909. order otherwise cross_endian PPU reading will fail }
  1910. startpos:=tbi;
  1911. with asettings do
  1912. begin
  1913. alignment.procalign:=gettokenbuflongint;
  1914. alignment.loopalign:=gettokenbuflongint;
  1915. alignment.jumpalign:=gettokenbuflongint;
  1916. alignment.jumpalignskipmax:=gettokenbuflongint;
  1917. alignment.coalescealign:=gettokenbuflongint;
  1918. alignment.coalescealignskipmax:=gettokenbuflongint;
  1919. alignment.constalignmin:=gettokenbuflongint;
  1920. alignment.constalignmax:=gettokenbuflongint;
  1921. alignment.varalignmin:=gettokenbuflongint;
  1922. alignment.varalignmax:=gettokenbuflongint;
  1923. alignment.localalignmin:=gettokenbuflongint;
  1924. alignment.localalignmax:=gettokenbuflongint;
  1925. alignment.recordalignmin:=gettokenbuflongint;
  1926. alignment.recordalignmax:=gettokenbuflongint;
  1927. alignment.maxCrecordalign:=gettokenbuflongint;
  1928. tokenreadset(globalswitches,sizeof(globalswitches));
  1929. tokenreadset(targetswitches,sizeof(targetswitches));
  1930. tokenreadset(moduleswitches,sizeof(moduleswitches));
  1931. tokenreadset(localswitches,sizeof(localswitches));
  1932. tokenreadset(modeswitches,sizeof(modeswitches));
  1933. tokenreadset(optimizerswitches,sizeof(optimizerswitches));
  1934. tokenreadset(genwpoptimizerswitches,sizeof(genwpoptimizerswitches));
  1935. tokenreadset(dowpoptimizerswitches,sizeof(dowpoptimizerswitches));
  1936. tokenreadset(debugswitches,sizeof(debugswitches));
  1937. { 0: old behaviour for sets <=256 elements
  1938. >0: round to this size }
  1939. setalloc:=gettokenbufshortint;
  1940. packenum:=gettokenbufshortint;
  1941. packrecords:=gettokenbufshortint;
  1942. maxfpuregisters:=gettokenbufshortint;
  1943. cputype:=tcputype(tokenreadenum(sizeof(tcputype)));
  1944. optimizecputype:=tcputype(tokenreadenum(sizeof(tcputype)));
  1945. fputype:=tfputype(tokenreadenum(sizeof(tfputype)));
  1946. asmmode:=tasmmode(tokenreadenum(sizeof(tasmmode)));
  1947. interfacetype:=tinterfacetypes(tokenreadenum(sizeof(tinterfacetypes)));
  1948. defproccall:=tproccalloption(tokenreadenum(sizeof(tproccalloption)));
  1949. { tstringencoding is word type,
  1950. thus this should be OK here }
  1951. sourcecodepage:=tstringEncoding(gettokenbufword);
  1952. minfpconstprec:=tfloattype(tokenreadenum(sizeof(tfloattype)));
  1953. disabledircache:=boolean(gettokenbufbyte);
  1954. tlsmodel:=ttlsmodel(tokenreadenum(sizeof(ttlsmodel)));
  1955. { TH: Since the field was conditional originally, it was not stored in PPUs. }
  1956. { While adding ControllerSupport constant, I decided not to store ct_none }
  1957. { on targets not supporting controllers, but this might be changed here and }
  1958. { in tokenwritesettings in the future to unify the PPU structure and handling }
  1959. { of this field in the compiler. }
  1960. {$PUSH}
  1961. {$WARN 6018 OFF} (* Unreachable code due to compile time evaluation *)
  1962. if CpuHasController[cpu] then
  1963. controllertype:=tcontrollertype(tokenreadenum(sizeof(tcontrollertype)))
  1964. else
  1965. ControllerType:=ct_none;
  1966. {$POP}
  1967. endpos:=tbi;
  1968. if endpos-startpos<>expected_size then
  1969. Writeln(['Wrong size of Settings read-in: ',expected_size,' expected, but got ',endpos-startpos]);
  1970. end;
  1971. end;
  1972. procedure dump_new_settings;
  1973. (* tsettings = record
  1974. alignment : talignmentinfo;
  1975. globalswitches : tglobalswitches;
  1976. targetswitches : ttargetswitches;
  1977. moduleswitches : tmoduleswitches;
  1978. localswitches : tlocalswitches;
  1979. modeswitches : tmodeswitches;
  1980. optimizerswitches : toptimizerswitches;
  1981. { generate information necessary to perform these wpo's during a subsequent compilation }
  1982. genwpoptimizerswitches: twpoptimizerswitches;
  1983. { perform these wpo's using information generated during a previous compilation }
  1984. dowpoptimizerswitches: twpoptimizerswitches;
  1985. debugswitches : tdebugswitches;
  1986. { 0: old behaviour for sets <=256 elements
  1987. >0: round to this size }
  1988. setalloc,
  1989. packenum : shortint;
  1990. packrecords : shortint;
  1991. maxfpuregisters : shortint;
  1992. cputype,
  1993. optimizecputype,
  1994. asmcputype : tcputype;
  1995. fputype : tfputype;
  1996. asmmode : tasmmode;
  1997. interfacetype : tinterfacetypes;
  1998. defproccall : tproccalloption;
  1999. sourcecodepage : tstringencoding;
  2000. minfpconstprec : tfloattype;
  2001. disabledircache : boolean;
  2002. tlsmodel : ttlsmodel;
  2003. {$if defined(i8086)}
  2004. x86memorymodel : tx86memorymodel;
  2005. {$endif defined(i8086)}
  2006. {$if defined(ARM)}
  2007. instructionset : tinstructionset;
  2008. {$endif defined(ARM)}
  2009. {$if defined(LLVM) and not defined(GENERIC_CPU)}
  2010. llvmversion: tllvmversion;
  2011. {$endif defined(LLVM) and not defined(GENERIC_CPU)}
  2012. { CPU targets with microcontroller support can add a controller specific unit }
  2013. controllertype : tcontrollertype;
  2014. { WARNING: this pointer cannot be written as such in record token }
  2015. pmessage : pmessagestaterecord;
  2016. end; *)
  2017. const
  2018. targetswitchname : array[ttargetswitch] of string[30] =
  2019. { global target-specific switches }
  2020. ('Target None', {ts_none}
  2021. { generate code that results in smaller TOCs than normal (AIX) }
  2022. 'Small TOC', {ts_small_toc}
  2023. { for the JVM target: generate integer array initializations via string
  2024. constants in order to reduce the generated code size (Java routines
  2025. are limited to 64kb of bytecode) }
  2026. 'JVM compact int array init', {ts_compact_int_array_init}
  2027. { for the JVM target: intialize enum fields in constructors with the
  2028. enum class instance corresponding to ordinal value 0 (not done by
  2029. default because this initialization can only be performed after the
  2030. inherited constructors have run, and if they call a virtual method
  2031. of the current class, then this virtual method may already have
  2032. initialized that field with another value and the constructor
  2033. initialization will result in data loss }
  2034. 'JVM enum field init', {ts_jvm_enum_field_init}
  2035. { when automatically generating getters/setters for properties, use
  2036. these strings as prefixes for the generated getters/setter names }
  2037. 'Auto getter prefix', {ts_auto_getter_prefix}
  2038. 'Auto setter prefix', {ts_auto_setter_predix}
  2039. 'Thumb interworking', {ts_thumb_interworking,}
  2040. { lowercase the first character of routine names, used to generate
  2041. names that are compliant with Java coding standards from code
  2042. written according to Delphi coding standards }
  2043. 'LowerCase proc start', {ts_lowercase_proc_start,}
  2044. { initialise local variables on the JVM target so you won't get
  2045. accidental uses of uninitialised values }
  2046. 'Init locals', {ts_init_locals}
  2047. { emit a CLD instruction before using the x86 string instructions }
  2048. 'Emit CLD instruction', {ts_cld}
  2049. { increment BP before pushing it in the function prologue and decrement
  2050. it after popping it in the function epilogue, iff the function is
  2051. going to terminate with a far ret. Thus, the BP value pushed on the
  2052. stack becomes odd if the function is far and even if the function is
  2053. near. This allows walking the BP chain on the stack and e.g.
  2054. obtaining a stack trace even if the program uses a mixture of near
  2055. and far calls. This is also required for Win16 real mode, because it
  2056. allows Windows to move code segments around (in order to defragment
  2057. memory) and then walk through the stacks of all running programs and
  2058. update the segment values of the segment that has moved. }
  2059. 'Use odd BP for far procs' {ts_x86_far_procs_push_odd_bp}
  2060. );
  2061. moduleswitchname : array[tmoduleswitch] of string[40] =
  2062. ('Module None', {cs_modulenone,}
  2063. { parser }
  2064. 'Floating Point Emulation',{ cs_fp_emulation}
  2065. 'Extended syntax', {cs_extsyntax}
  2066. 'Open string', {cs_openstring}
  2067. { support }
  2068. 'Goto allowed', {cs_support_goto}
  2069. 'Macro support', {cs_support_macro}
  2070. 'C operator support', {cs_support_c_operators}
  2071. { generation }
  2072. 'Profile', {cs_profile}
  2073. 'Debug information', {cs_debuginfo}
  2074. 'Compilation of System unit', {cs_compilesystem}
  2075. 'Line information', {cs_lineinfo}
  2076. 'Implicit exceptions', {cs_implicit_exceptions}
  2077. 'Explicit CodePage', {cs_explicit_codepage}
  2078. 'System CodePage', {cs_system_codepage}
  2079. { linking }
  2080. 'Create smart units', {cs_create_smart}
  2081. 'Create dynamic', {cs_create_dynamic}
  2082. 'Create PIC code', {cs_create_pic}
  2083. { browser switches are back }
  2084. 'Browser', {cs_browser}
  2085. 'Local Browser', {cs_local_browser}
  2086. { target specific }
  2087. 'Executable Stack', {cs_executable_stack}
  2088. { i8086 specific }
  2089. 'Huge code', {cs_huge_code}
  2090. 'Win16 smart callbacks', {cs_win16_smartcallbacks}
  2091. { Record usage of checkpointer experimental feature }
  2092. 'CheckPointer used', {cs_checkpointer_called}
  2093. 'Supports LLVM Link-Time Optimization' {cs_lto}
  2094. );
  2095. globalswitchname : array[tglobalswitch] of string[50] =
  2096. ('Global None',{cs_globalnone}
  2097. { parameter switches }
  2098. 'Check unit name', {cs_check_unit_name}
  2099. 'Constructor name', {cs_constructor_name}
  2100. 'Support exceptions',{cs_support_exceptions}
  2101. 'Support Objective-C pas',{ cs_support_c_objectivepas}
  2102. 'Transparent file names', {cs_transparent_file_names}
  2103. { units }
  2104. 'Load Objpas Unit', {cs_load_objpas_unit}
  2105. 'Load GPC unit', {cs_load_gpc_unit}
  2106. 'Load FPCKylix unit', {cs_load_fpcylix_unit}
  2107. 'Support Vectors', {cs_support_vectors}
  2108. { debuginfo }
  2109. 'Use HeapTRc unit', {cs_use_heaptrc}
  2110. 'Use line information', {cs_use_lineinfo}
  2111. 'Use GDB Valgrind', {cs_gdb_valgrind}
  2112. 'No regalloc', {cs_no_regalloc}
  2113. 'Stabs preserve cases', {cs_stabs_preservecase}
  2114. { assembling }
  2115. 'Leave assembler file', {cs_asm_leave}
  2116. 'Use external assembler', {cs_asm_extern}
  2117. 'Use pipes to call assembler', {cs_asm_pipe}
  2118. 'Add source infos into assembler files', {cs_asm_source}
  2119. 'Add register allocation into assembler files', {cs_asm_regalloc}
  2120. 'Add temporary allocation into assmebler files', {cs_asm_tempalloc}
  2121. 'Add node information into assembler files', {cs_asm_nodes}
  2122. 'Adapt assembler call to GNU version <= 2.25', {cs_asm_pre_binutils_2_25}
  2123. { linking }
  2124. 'Skip linking stage', {cs_link_nolink}
  2125. 'Link static', {cs_link_static}
  2126. 'Link smart', {cs_link_smart}
  2127. 'Link shared', {cs_link_shared}
  2128. 'Link deffile', {cs_link_deffile}
  2129. 'Strip after linking', {cs_link_strip}
  2130. 'Use linker static flag',{cs_link_staticflag}
  2131. 'Link on target OS',{cs_link_on_target}
  2132. 'Use external linker', {cs_link_extern}
  2133. 'Link opt vtable', {cs_link_opt_vtable}
  2134. 'Link opt used sections', {cs_link_opt_used_sections}
  2135. 'Link debug to separate file',{cs_link_separate_dbg_file}
  2136. 'Create linker map', {cs_link_map}
  2137. 'Link to pthread', {cs_link_pthread}
  2138. 'Link no default lib order', {cs_link_no_default_lib_order}
  2139. 'Link using native linker', {cs_link_native}
  2140. 'Link for GNU linker version <=2.19', {cs_link_pre_binutils_2_19}
  2141. 'Link using vlink', {cs_link_vlink}
  2142. 'Link-Time Optimization disabled for system unit', {cs_lto_nosystem}
  2143. 'Assemble on target OS', {cs_asemble_on_target}
  2144. 'Use a memory model to support >2GB static data on 64 Bit target' {cs_large}
  2145. );
  2146. localswitchname : array[tlocalswitch] of string[50] =
  2147. { Switches which can be changed locally }
  2148. ('Local None', {cs_localnone}
  2149. { codegen }
  2150. 'Check overflow', {cs_check_overflow}
  2151. 'Check range', {cs_check_range}
  2152. 'Check object error', {cs_check_object}
  2153. 'Check I/O error', {cs_check_io}
  2154. 'Check stack', {cs_check_stack}
  2155. 'Check pointer', {cs_checkpointer}
  2156. 'Check ordinal size', {cs_check_ordinal_size}
  2157. 'Generate stackframes', {cs_generate_stackframes}
  2158. 'Do assertions', {cs_do_assertion}
  2159. 'Generate RTTI', {cs_generate_rtti}
  2160. 'Full boolean evaluaion', {cs_full_boolean_eval}
  2161. 'Typed constant are writable', {cs_typed_const_writable}
  2162. 'Allow calcuation on enum types', {cs_allow_enum_calc}
  2163. 'Do inline', {cs_do_inline}
  2164. 'Add FWAIT instruction for FPU 8087', {cs_fpu_fwait}
  2165. 'IEEE errors', {cs_ieee_errors}
  2166. 'Check low address loading', {cs_check_low_addr_load}
  2167. 'Imported data', {cs_imported_data}
  2168. 'Excess precision', {cs_excessprecision}
  2169. 'Check fpu exceptions', {cs_check_fpu_exceptions}
  2170. 'Check all case coverage', {cs_check_all_case_coverage}
  2171. { mmx }
  2172. 'Allow MMX instructions', {cs_mmx}
  2173. 'Use MMX saturation', {cs_mmx_saturation}
  2174. { parser }
  2175. 'Use typed addresses', {cs_typed_addresses}
  2176. 'Use strict var strings', {cs_strict_var_strings}
  2177. 'Use reference counted strings', {cs_refcountedstrings}
  2178. 'Use bit-packing', {cs_bitpacking}
  2179. 'Use var property setter', {cs_varpropsetter}
  2180. 'Use scoped enums',{cs_scopedenums}
  2181. 'Use pointer math', {cs_pointermath}
  2182. { macpas specific}
  2183. 'MACPAS exteranl variable', {cs_external_var}
  2184. 'MACPAS externally visible', {cs_externally_visible}
  2185. { jvm specific }
  2186. 'JVM check var copyout', {cs_check_var_copyout}
  2187. 'Zero based strings', {cs_zerobasedstrings}
  2188. { i8086 specific }
  2189. 'i8086 force FAR calls', {cs_force_far_calls}
  2190. 'i8086 huge pointer arithmetic', {cs_hugeptr_arithmetic_normalization}
  2191. 'i8086 huge pointer comparison' {cs_hugeptr_comparison_normalization}
  2192. );
  2193. { Switches which can be changed by a mode (fpc,tp7,delphi) }
  2194. modeswitchname : array[tmodeswitch] of string[50] =
  2195. ('m_none',
  2196. { generic }
  2197. 'm_fpc','m_objfpc','m_delphi','m_tp7','m_mac','m_iso','m_extpas',
  2198. {$ifdef gpc_mode}'m_gpc',{$endif}
  2199. { more specific }
  2200. 'm_class', { delphi class model }
  2201. 'm_objpas', { load objpas unit }
  2202. 'm_result', { result in functions }
  2203. 'm_string_pchar', { pchar 2 string conversion }
  2204. 'm_cvar_support', { cvar variable directive }
  2205. 'm_nested_comment', { nested comments }
  2206. 'm_tp_procvar', { tp style procvars (no @ needed) }
  2207. 'm_mac_procvar', { macpas style procvars }
  2208. 'm_repeat_forward', { repeating forward declarations is needed }
  2209. 'm_pointer_2_procedure', { allows the assignement of pointers to
  2210. procedure variables }
  2211. 'm_autoderef', { does auto dereferencing of struct. vars }
  2212. 'm_initfinal', { initialization/finalization for units }
  2213. 'm_default_ansistring', { ansistring turned on by default }
  2214. 'm_out', { support the calling convention OUT }
  2215. 'm_default_para', { support default parameters }
  2216. 'm_hintdirective', { support hint directives }
  2217. 'm_duplicate_names', { allow locals/paras to have duplicate names of globals }
  2218. 'm_property', { allow properties }
  2219. 'm_default_inline', { allow inline proc directive }
  2220. 'm_except', { allow exception-related keywords }
  2221. 'm_objectivec1', { support interfacing with Objective-C (1.0) }
  2222. 'm_objectivec2', { support interfacing with Objective-C (2.0) }
  2223. 'm_nested_procvars', { support nested procedural variables }
  2224. 'm_non_local_goto', { support non local gotos (like iso pascal) }
  2225. 'm_advanced_records', { advanced record syntax with visibility sections, methods and properties }
  2226. 'm_isolike_unary_minus', { unary minus like in iso pascal: same precedence level as binary minus/plus }
  2227. 'm_systemcodepage', { use system codepage as compiler codepage by default, emit ansistrings with system codepage }
  2228. 'm_final_fields', { allows declaring fields as "final", which means they must be initialised
  2229. in the (class) constructor and are constant from then on (same as final
  2230. fields in Java) }
  2231. 'm_default_unicodestring', { makes the default string type in $h+ mode unicodestring rather than
  2232. ansistring; similarly, char becomes unicodechar rather than ansichar }
  2233. 'm_type_helpers', { allows the declaration of "type helper" for all supported types
  2234. (primitive types, records, classes, interfaces) }
  2235. 'm_blocks', { support for http://en.wikipedia.org/wiki/Blocks_(C_language_extension) }
  2236. 'm_isolike_io', { I/O as it required by an ISO compatible compiler }
  2237. 'm_isolike_program_para',{ program parameters as it required by an ISO compatible compiler }
  2238. 'm_isolike_mod', { mod operation as it is required by an iso compatible compiler }
  2239. 'm_array_operators', { use Delphi compatible array operators instead of custom ones ("+") }
  2240. 'm_multi_helpers', { helpers can appear in multiple scopes simultaneously }
  2241. 'm_array2dynarray', { regular arrays can be implicitly converted to dynamic arrays }
  2242. 'm_prefixed_attributes' { enable attributes that are defined before the type they belong to }
  2243. );
  2244. { optimizer }
  2245. optimizerswitchname : array[toptimizerswitch] of string[50] =
  2246. ('cs_opt_none',
  2247. 'cs_opt_level1',
  2248. 'cs_opt_level2',
  2249. 'cs_opt_level3',
  2250. 'cs_opt_level4',
  2251. 'cs_opt_regvar',
  2252. 'cs_opt_uncertain',
  2253. 'cs_opt_size',
  2254. 'cs_opt_stackframe',
  2255. 'cs_opt_peephole',
  2256. 'cs_opt_loopunroll',
  2257. 'cs_opt_tailrecursion',
  2258. 'cs_opt_nodecse',
  2259. 'cs_opt_nodedfa',
  2260. 'cs_opt_loopstrength',
  2261. 'cs_opt_scheduler',
  2262. 'cs_opt_autoinline',
  2263. 'cs_useebp',
  2264. 'cs_userbp',
  2265. 'cs_opt_reorder_fields',
  2266. 'cs_opt_fastmath',
  2267. { Allow removing expressions whose result is not used, even when this
  2268. can change program behaviour (range check errors disappear',
  2269. access violations due to invalid pointer derefences disappear, ...).
  2270. Note: it does not (and must not) remove expressions that have
  2271. explicit side-effects, only implicit side-effects (like the ones
  2272. mentioned before) can disappear.
  2273. }
  2274. 'cs_opt_dead_values',
  2275. { compiler checks for empty procedures/methods and removes calls to them if possible }
  2276. 'cs_opt_remove_empty_proc',
  2277. 'cs_opt_constant_propagate',
  2278. 'cs_opt_dead_store_eliminate',
  2279. 'cs_opt_forcenostackframe',
  2280. 'cs_opt_use_load_modify_store',
  2281. 'cs_opt_unused_para'
  2282. );
  2283. var
  2284. globalswitch : tglobalswitch;
  2285. targetswitch : ttargetswitch;
  2286. moduleswitch : tmoduleswitch;
  2287. localswitch : tlocalswitch;
  2288. modeswitch : tmodeswitch;
  2289. optimizerswitch : toptimizerswitch;
  2290. globalswitches : tglobalswitches;
  2291. targetswitches : ttargetswitches;
  2292. moduleswitches : tmoduleswitches;
  2293. localswitches : tlocalswitches;
  2294. modeswitches : tmodeswitches;
  2295. optimizerswitches : toptimizerswitches;
  2296. begin
  2297. {alignment : talignmentinfo;}
  2298. {talignmentinfo = packed record}
  2299. writeln('Procedure alignment: '+tostr(new_settings.alignment.procalign));
  2300. writeln('Loop alignment: '+tostr(new_settings.alignment.loopalign));
  2301. { alignment for labels after unconditional jumps, this must be a power of two }
  2302. writeln('Jump alignment: '+tostr(new_settings.alignment.jumpalign));
  2303. { max. alignment for labels after unconditional jumps:
  2304. the compiler tries to align jumpalign, however, to do so it inserts at maximum jumpalignskipmax bytes or uses
  2305. the next smaller power of two of jumpalign }
  2306. writeln('Jump skip max alignment: '+tostr(new_settings.alignment.jumpalignskipmax));
  2307. { alignment for labels where two flows of the program flow coalesce, this must be a power of two }
  2308. writeln('Coalescence alignment: '+tostr(new_settings.alignment.coalescealign));
  2309. { max. alignment for labels where two flows of the program flow coalesce
  2310. the compiler tries to align to coalescealign, however, to do so it inserts at maximum coalescealignskipmax bytes or uses
  2311. the next smaller power of two of coalescealign }
  2312. writeln('Coalescence skip max alignment: '+tostr(new_settings.alignment.coalescealignskipmax));
  2313. writeln('Const min alignment: '+tostr(new_settings.alignment.constalignmin));
  2314. writeln('Const max alignment: '+tostr(new_settings.alignment.constalignmax));
  2315. writeln('Var min alignment: '+tostr(new_settings.alignment.varalignmin));
  2316. writeln('Var max alignment: '+tostr(new_settings.alignment.varalignmax));
  2317. writeln('Local min alignment: '+tostr(new_settings.alignment.localalignmin));
  2318. writeln('Local max alignment: '+tostr(new_settings.alignment.localalignmax));
  2319. writeln('Min record alignment: '+tostr(new_settings.alignment.recordalignmin));
  2320. writeln('Max record alignment: '+tostr(new_settings.alignment.recordalignmax));
  2321. writeln('Max C record alignment: '+tostr(new_settings.alignment.maxCrecordalign));
  2322. globalswitches:=new_settings.globalswitches;
  2323. for globalswitch:=low(tglobalswitch) to high(tglobalswitch) do
  2324. if globalswitch in globalswitches then
  2325. begin
  2326. writeln('global switch: '+globalswitchname[globalswitch]);
  2327. exclude(globalswitches,globalswitch);
  2328. end;
  2329. if (globalswitches <> []) then
  2330. writeln('Unknown global switch');
  2331. targetswitches:=new_settings.targetswitches;
  2332. for targetswitch:=low(ttargetswitch) to high(ttargetswitch) do
  2333. if targetswitch in targetswitches then
  2334. begin
  2335. writeln('target switch: '+targetswitchname[targetswitch]);
  2336. exclude(targetswitches,targetswitch);
  2337. end;
  2338. if (targetswitches <> []) then
  2339. writeln('Unknown target switch');
  2340. moduleswitches:=new_settings.moduleswitches;
  2341. for moduleswitch:=low(tmoduleswitch) to high(tmoduleswitch) do
  2342. if moduleswitch in moduleswitches then
  2343. begin
  2344. writeln('module switch: '+moduleswitchname[moduleswitch]);
  2345. exclude(moduleswitches,moduleswitch);
  2346. end;
  2347. if (moduleswitches <> []) then
  2348. writeln('Unknown module switch');
  2349. localswitches:=new_settings.localswitches;
  2350. for localswitch:=low(tlocalswitch) to high(tlocalswitch) do
  2351. if localswitch in localswitches then
  2352. begin
  2353. writeln('local switch: '+localswitchname[localswitch]);
  2354. exclude(localswitches,localswitch);
  2355. end;
  2356. if (localswitches <> []) then
  2357. writeln('Unknown local switch');
  2358. modeswitches:=new_settings.modeswitches;
  2359. for modeswitch:=low(tmodeswitch) to high(tmodeswitch) do
  2360. if modeswitch in modeswitches then
  2361. begin
  2362. writeln(['mode switch: ',modeswitchname[modeswitch]]);
  2363. exclude(modeswitches,modeswitch);
  2364. end;
  2365. if (modeswitches <> []) then
  2366. writeln('Unknown mode switch');
  2367. optimizerswitches:=new_settings.optimizerswitches;
  2368. for optimizerswitch:=low(toptimizerswitch) to high(toptimizerswitch) do
  2369. if optimizerswitch in optimizerswitches then
  2370. begin
  2371. writeln(['optimizer switch: ',optimizerswitchname[optimizerswitch]]);
  2372. exclude(optimizerswitches,optimizerswitch);
  2373. end;
  2374. if (optimizerswitches <> []) then
  2375. writeln('Unknown optimizer switch');
  2376. writeln(['Set allocation size ',new_settings.setalloc]);
  2377. writeln(['Pack enums ',new_settings.packenum]);
  2378. writeln(['Pack records ',new_settings.packrecords]);
  2379. writeln(['Max FPU registers ',new_settings.maxfpuregisters]);
  2380. writeln(['CPU type ',new_settings.cputype]);
  2381. writeln(['CPU optimize type ',new_settings.optimizecputype]);
  2382. writeln(['FPU type ',new_settings.fputype]);
  2383. writeln(['ASM mode ',new_settings.asmmode]);
  2384. end;
  2385. var
  2386. linestr,genstr : string;
  2387. token : ttoken;
  2388. copy_size, stbi, last_col, new_col : longint;
  2389. last_line,new_line : dword;
  2390. len : sizeint;
  2391. wstring : widestring;
  2392. astring : ansistring;
  2393. begin
  2394. tbi:=0;
  2395. last_line:=0;
  2396. last_col:=0;
  2397. linestr:='';
  2398. genstr:='';
  2399. fillchar(new_settings,sizeof(new_settings),#0);
  2400. fillchar(prev_settings,sizeof(prev_settings),#0);
  2401. write([space,' Tokens: ']);
  2402. while tbi<tokenbufsize do
  2403. begin
  2404. token:=readtoken;
  2405. if token<>_GENERICSPECIALTOKEN then
  2406. begin
  2407. if token <= high(ttoken) then
  2408. begin
  2409. write(arraytokeninfo[token].str);
  2410. if not (token in [_CWCHAR, _CWSTRING, _CSTRING, _CCHAR,
  2411. _INTCONST,_REALNUMBER, _ID]) then
  2412. StrAppend(linestr,lowercase(arraytokeninfo[token].str));
  2413. end
  2414. else
  2415. begin
  2416. HasMoreInfos;
  2417. write('Error in Token List');
  2418. break;
  2419. end;
  2420. {idtoken:=}readtoken;
  2421. end;
  2422. case token of
  2423. _CWCHAR,
  2424. _CWSTRING :
  2425. begin
  2426. len:=gettokenbufsizeint;
  2427. setlength(wstring,len);
  2428. move(tokenbuf[tbi],wstring[1],len*2);
  2429. write([' ''',wstring,'''']);
  2430. StrAppend(linestr,' ''');
  2431. StrAppend(linestr,wstring);
  2432. StrAppend(linestr,'''');
  2433. inc(tbi,len*2);
  2434. end;
  2435. _CSTRING:
  2436. begin
  2437. len:=gettokenbufsizeint;
  2438. setlength(astring,len);
  2439. if len>0 then
  2440. move(tokenbuf[tbi],astring[1],len);
  2441. write([' ''',astring,'''']);
  2442. StrAppend(linestr,' ''');
  2443. StrAppend(linestr,astring);
  2444. StrAppend(linestr,'''');
  2445. inc(tbi,len);
  2446. end;
  2447. _CCHAR:
  2448. begin
  2449. write([' ''',unaligned(pshortstring(@tokenbuf[tbi])^),'''']);
  2450. StrAppend(linestr,' ''');
  2451. StrAppend(linestr,unaligned(pshortstring(@tokenbuf[tbi])^));
  2452. StrAppend(linestr,'''');
  2453. inc(tbi,tokenbuf[tbi]+1);
  2454. end;
  2455. _INTCONST,
  2456. _REALNUMBER :
  2457. begin
  2458. write([' ',unaligned(pshortstring(@tokenbuf[tbi])^)]);
  2459. StrAppend(linestr,unaligned(pshortstring(@tokenbuf[tbi])^));
  2460. inc(tbi,tokenbuf[tbi]+1);
  2461. end;
  2462. _ID :
  2463. begin
  2464. write([' ',unaligned(pshortstring(@tokenbuf[tbi])^)]);
  2465. StrAppend(linestr,unaligned(pshortstring(@tokenbuf[tbi])^));
  2466. inc(tbi,tokenbuf[tbi]+1);
  2467. end;
  2468. _GENERICSPECIALTOKEN:
  2469. begin
  2470. { Short version of column change,
  2471. byte or $80 used }
  2472. if (tokenbuf[tbi] and $80)<>0 then
  2473. begin
  2474. new_col:=tokenbuf[tbi] and $7f;
  2475. write(['Col: ',new_col]);
  2476. if length(linestr)<new_col-1 then
  2477. StrAppend(linestr,StringOfChar(' ',new_col - 1 - length(linestr)));
  2478. inc(tbi);
  2479. last_col:=new_col;
  2480. end
  2481. else
  2482. case tspecialgenerictoken(tokenbuf[tbi]) of
  2483. ST_LOADSETTINGS:
  2484. begin
  2485. inc(tbi);
  2486. write([space,'Settings: ']);
  2487. fillchar(new_settings,sizeof(new_settings),#0);
  2488. { This does not load pmessage pointer }
  2489. new_settings.pmessage:=nil;
  2490. { TSettings size depends in target...
  2491. We first read the size of the copied part }
  2492. { Still not cross endian ready :( }
  2493. copy_size:=gettokenbufsizeint;
  2494. stbi:=tbi;
  2495. tokenreadsettings(new_settings, copy_size);
  2496. tbi:=stbi+copy_size;
  2497. if CompareByte(new_settings,prev_settings,sizeof(new_settings))<>0 then
  2498. begin
  2499. dump_new_settings;
  2500. writeln;
  2501. end
  2502. else
  2503. begin
  2504. writeln('Unchanged');
  2505. end;
  2506. prev_settings:=new_settings;
  2507. end;
  2508. ST_LOADMESSAGES:
  2509. begin
  2510. inc(tbi);
  2511. mesgnb:=tokenbuf[tbi];
  2512. writeln([space,mesgnb,' messages: ']);
  2513. inc(tbi);
  2514. for nb:=1 to mesgnb do
  2515. begin
  2516. msgvalue:=gettokenbufsizeint;
  2517. //inc(tbi,sizeof(sizeint));
  2518. state:=tmsgstate(gettokenbufsizeint);
  2519. writeln(['#',msgvalue,' ',state]);
  2520. end;
  2521. end;
  2522. ST_LINE:
  2523. begin
  2524. inc(tbi);
  2525. new_line:=gettokenbufdword;
  2526. if (new_line<>last_line) then
  2527. begin
  2528. StrAppend(genstr,linestr+LineEnding);
  2529. linestr:='';
  2530. end;
  2531. writeln(['Line: ',new_line]);
  2532. last_line:=new_line;
  2533. end;
  2534. ST_COLUMN:
  2535. begin
  2536. inc(tbi);
  2537. new_col:=gettokenbufword;
  2538. write(['Col: ',new_col]);
  2539. if length(linestr)<new_col - 1 then
  2540. StrAppend(linestr,StringOfChar(' ',new_col - 1 - length(linestr)));
  2541. last_col:=new_col;
  2542. end;
  2543. ST_FILEINDEX:
  2544. begin
  2545. inc(tbi);
  2546. StrAppend(genstr,linestr+LineEnding);
  2547. linestr:='';
  2548. write(['File: ',gettokenbufword]);
  2549. end;
  2550. else
  2551. begin
  2552. HasMoreInfos;
  2553. write('Error in Token List');
  2554. break;
  2555. end;
  2556. end;
  2557. end;
  2558. else ; { empty else to avoid warning }
  2559. end;
  2560. if tbi<tokenbufsize then
  2561. write(',');
  2562. end;
  2563. writeln;
  2564. StrAppend(genstr,linestr);
  2565. writeln(['##',genstr,'##']);
  2566. end;
  2567. procedure readcommondef(const s:string; out defoptions: tdefoptions; Def: TPpuDef = nil);
  2568. type
  2569. tdefopt=record
  2570. mask : tdefoption;
  2571. str : string[30];
  2572. end;
  2573. tdefstateinfo=record
  2574. mask : tdefstate;
  2575. str : string[30];
  2576. end;
  2577. tgenconstrflag=record
  2578. mask : tgenericconstraintflag;
  2579. str : string[30];
  2580. end;
  2581. const
  2582. defopt : array[1..ord(high(tdefoption))] of tdefopt=(
  2583. (mask:df_unique; str:'Unique Type'),
  2584. (mask:df_generic; str:'Generic'),
  2585. (mask:df_specialization; str:'Specialization'),
  2586. (mask:df_copied_def; str:'Copied Typedef'),
  2587. (mask:df_genconstraint; str:'Generic Constraint'),
  2588. { this should never happen for defs stored to a ppu file }
  2589. (mask:df_not_registered_no_free; str:'Unregistered/No free (invalid)'),
  2590. (mask:df_llvm_no_struct_packing; str:'LLVM unpacked struct'),
  2591. (mask:df_internal; str:'Internal'),
  2592. (mask:df_has_global_ref; str:'Has Global Ref'),
  2593. (mask:df_has_generic_fields; str:'Has generic fields')
  2594. );
  2595. defstate : array[1..ord(high(tdefstate))] of tdefstateinfo=(
  2596. (mask:ds_vmt_written; str:'VMT Written'),
  2597. (mask:ds_rtti_table_used; str:'RTTITable Used'),
  2598. (mask:ds_init_table_used; str:'InitTable Used'),
  2599. (mask:ds_rtti_table_written; str:'RTTITable Written'),
  2600. (mask:ds_init_table_written; str:'InitTable Written'),
  2601. (mask:ds_dwarf_dbg_info_used; str:'Dwarf DbgInfo Used'),
  2602. (mask:ds_dwarf_dbg_info_written;str:'Dwarf DbgInfo Written')
  2603. );
  2604. genconstrflag : array[1..ord(high(tgenericconstraintflag))] of tgenconstrflag=(
  2605. (mask:gcf_constructor; str:'Constructor'),
  2606. (mask:gcf_class; str:'Class'),
  2607. (mask:gcf_record; str:'Record')
  2608. );
  2609. var
  2610. defstates : tdefstates;
  2611. i, nb, len : longint;
  2612. first : boolean;
  2613. min_size, tokenbufsize : longint;
  2614. tokenbuf : pbyte;
  2615. genconstr : tgenericconstraintflags;
  2616. begin
  2617. i:=ppufile.getlongint;
  2618. if Def <> nil then
  2619. Def.Id:=i;
  2620. writeln([space,'** Definition Id ',i,' **']);
  2621. writeln([space,s]);
  2622. write ([space,' Type symbol : ']);
  2623. if Def <> nil then
  2624. readderef('', Def.Ref)
  2625. else
  2626. readderef('');
  2627. write ([space,' DefOptions : ']);
  2628. ppufile.getset(tppuset2(defoptions));
  2629. if defoptions<>[] then
  2630. begin
  2631. first:=true;
  2632. for i:=1to high(defopt) do
  2633. if (defopt[i].mask in defoptions) then
  2634. begin
  2635. if first then
  2636. first:=false
  2637. else
  2638. write(', ');
  2639. write(defopt[i].str);
  2640. end;
  2641. end;
  2642. writeln;
  2643. write ([space,' DefStates : ']);
  2644. ppufile.getset(tppuset1(defstates));
  2645. if defstates<>[] then
  2646. begin
  2647. first:=true;
  2648. for i:=1 to high(defstate) do
  2649. if (defstate[i].mask in defstates) then
  2650. begin
  2651. if first then
  2652. first:=false
  2653. else
  2654. write(', ');
  2655. write(defstate[i].str);
  2656. end;
  2657. end;
  2658. writeln;
  2659. if df_genconstraint in defoptions then
  2660. begin
  2661. ppufile.getset(tppuset1(genconstr));
  2662. write ([space,' GenConstraints : ']);
  2663. if genconstr<>[] then
  2664. begin
  2665. first:=true;
  2666. for i:=1 to high(genconstrflag) do
  2667. if (genconstrflag[i].mask in genconstr) then
  2668. begin
  2669. if first then
  2670. first:=false
  2671. else
  2672. write(', ');
  2673. write(genconstrflag[i].str);
  2674. end;
  2675. end;
  2676. writeln;
  2677. len:=ppufile.getlongint;
  2678. if len>0 then
  2679. begin
  2680. space:=' '+space;
  2681. writeln([space,'------ constraint defs begin ------']);
  2682. for i:=0 to len-1 do
  2683. begin
  2684. writeln([space,'------ constraint def ',i,' ------']);
  2685. readderef(space);
  2686. end;
  2687. writeln([space,'------ constraint defs end ------']);
  2688. delete(space,1,4);
  2689. end;
  2690. end;
  2691. if [df_generic,df_specialization]*defoptions<>[] then
  2692. begin
  2693. nb:=ppufile.getlongint;
  2694. writeln([space,'has ',nb,' parameters']);
  2695. if nb>0 then
  2696. begin
  2697. for i:=0 to nb-1 do
  2698. begin
  2699. writeln([space,'parameter ',i,': ',ppufile.getstring]);
  2700. readderef(space);
  2701. end;
  2702. end;
  2703. end;
  2704. if df_generic in defoptions then
  2705. begin
  2706. tokenbufsize:=ppufile.getlongint;
  2707. writeln([space,' Tokenbuffer size : ',tokenbufsize]);
  2708. tokenbuf:=allocmem(tokenbufsize);
  2709. ppufile.getdata(tokenbuf^,tokenbufsize);
  2710. displaytokenbuffer(tokenbuf,tokenbufsize);
  2711. freemem(tokenbuf);
  2712. end;
  2713. if df_specialization in defoptions then
  2714. begin
  2715. write ([space,' Orig. GenericDef : ']);
  2716. readderef('');
  2717. end;
  2718. space:=space+' ';
  2719. readattrs(def);
  2720. delete(space,1,4);
  2721. current_defoptions:=defoptions;
  2722. end;
  2723. { Read abstract procdef and return if inline procdef }
  2724. { type tproccalloption is in globtype unit }
  2725. { type tproctypeoption is in globtype unit }
  2726. { type tprocoption is in globtype unit }
  2727. procedure read_abstract_proc_def(var proccalloption:tproccalloption;var procoptions:tprocoptions; ProcDef: TPpuProcDef);
  2728. type
  2729. tproccallopt=record
  2730. mask : tproccalloption;
  2731. str : string[30];
  2732. end;
  2733. tproctypeopt=record
  2734. mask : tproctypeoption;
  2735. str : string[30];
  2736. end;
  2737. tprocopt=record
  2738. mask : tprocoption;
  2739. str : string[34];
  2740. end;
  2741. const
  2742. {proccalloptionStr is also in globtype unit }
  2743. proctypeopt : array[1..ord(high(tproctypeoption))] of tproctypeopt=(
  2744. (mask:potype_proginit; str:'ProgInit'),
  2745. (mask:potype_unitinit; str:'UnitInit'),
  2746. (mask:potype_unitfinalize; str:'UnitFinalize'),
  2747. (mask:potype_constructor; str:'Constructor'),
  2748. (mask:potype_destructor; str:'Destructor'),
  2749. (mask:potype_operator; str:'Operator'),
  2750. (mask:potype_procedure; str:'Procedure'),
  2751. (mask:potype_function; str:'Function'),
  2752. (mask:potype_class_constructor; str:'Class Constructor'),
  2753. (mask:potype_class_destructor; str:'Class Destructor'),
  2754. { Dispinterface property accessors }
  2755. (mask:potype_propgetter; str:'Property Getter'),
  2756. (mask:potype_propsetter; str:'Property Setter'),
  2757. (mask:potype_exceptfilter; str:'SEH filter'),
  2758. (mask:potype_mainstub; str:'main stub'),
  2759. (mask:potype_pkgstub; str:'package stub'),
  2760. (mask:potype_libmainstub; str:'library main stub')
  2761. );
  2762. procopt : array[1..ord(high(tprocoption))] of tprocopt=(
  2763. (mask:po_classmethod; str:'ClassMethod'),
  2764. (mask:po_virtualmethod; str:'VirtualMethod'),
  2765. (mask:po_abstractmethod; str:'AbstractMethod'),
  2766. (mask:po_finalmethod; str:'FinalMethod'),
  2767. (mask:po_staticmethod; str:'StaticMethod'),
  2768. (mask:po_overridingmethod;str:'OverridingMethod'),
  2769. (mask:po_methodpointer; str:'MethodPointer'),
  2770. (mask:po_interrupt; str:'Interrupt'),
  2771. (mask:po_iocheck; str:'IOCheck'),
  2772. (mask:po_assembler; str:'Assembler'),
  2773. (mask:po_msgstr; str:'MsgStr'),
  2774. (mask:po_msgint; str:'MsgInt'),
  2775. (mask:po_exports; str:'Exports'),
  2776. (mask:po_external; str:'External'),
  2777. (mask:po_overload; str:'Overload'),
  2778. (mask:po_varargs; str:'VarArgs'),
  2779. (mask:po_internconst; str:'InternConst'),
  2780. (mask:po_addressonly; str:'AddressOnly'),
  2781. (mask:po_public; str:'Public'),
  2782. (mask:po_hascallingconvention;str:'HasCallingConvention'),
  2783. (mask:po_reintroduce; str:'ReIntroduce'),
  2784. (mask:po_explicitparaloc; str:'ExplicitParaloc'),
  2785. (mask:po_nostackframe; str:'NoStackFrame'),
  2786. (mask:po_has_mangledname; str:'HasMangledName'),
  2787. (mask:po_has_public_name; str:'HasPublicName'),
  2788. (mask:po_forward; str:'Forward'),
  2789. (mask:po_global; str:'Global'),
  2790. (mask:po_syscall; str:'Syscall'),
  2791. (mask:po_syscall_legacy; str:'SyscallLegacy'),
  2792. (mask:po_syscall_basenone;str:'SyscallBaseNone'),
  2793. (mask:po_syscall_basefirst;str:'SyscallBaseFirst'),
  2794. (mask:po_syscall_baselast;str:'SyscallBaseLast'),
  2795. (mask:po_syscall_basereg; str:'SyscallBaseReg'),
  2796. (mask:po_syscall_has_libsym; str:'Has LibSym'),
  2797. (mask:po_syscall_has_importnr; str:'Uses ImportNr'),
  2798. (mask:po_inline; str:'Inline'),
  2799. (mask:po_compilerproc; str:'CompilerProc'),
  2800. (mask:po_has_importdll; str:'HasImportDLL'),
  2801. (mask:po_has_importname; str:'HasImportName'),
  2802. (mask:po_kylixlocal; str:'KylixLocal'),
  2803. (mask:po_dispid; str:'DispId'),
  2804. (mask:po_weakexternal; str:'WeakExternal'),
  2805. (mask:po_objc; str:'ObjC'),
  2806. (mask:po_enumerator_movenext; str:'EnumeratorMoveNext'),
  2807. (mask:po_optional; str: 'Optional'),
  2808. (mask:po_delphi_nested_cc;str: 'Delphi-style nested frameptr'),
  2809. (mask:po_java_nonvirtual; str: 'Java non-virtual method'),
  2810. (mask:po_ignore_for_overload_resolution;str: 'Ignored for overload resolution'),
  2811. (mask:po_rtlproc; str: 'RTL procedure'),
  2812. (mask:po_auto_raised_visibility; str: 'Visibility raised by compiler'),
  2813. (mask:po_far; str: 'Far'),
  2814. (mask:po_hasnearfarcallmodel; str: 'Near/Far explicit'),
  2815. (mask:po_noreturn; str: 'No return'),
  2816. (mask:po_is_function_ref; str: 'Function reference'),
  2817. (mask:po_is_block; str: 'C "Block"'),
  2818. (mask:po_is_auto_getter; str: 'Automatically generated getter'),
  2819. (mask:po_is_auto_setter; str: 'Automatically generated setter'),
  2820. (mask:po_noinline; str: 'Never inline'),
  2821. (mask:po_variadic; str: 'C VarArgs with array-of-const para'),
  2822. (mask:po_objc_related_result_type; str: 'Objective-C related result type')
  2823. );
  2824. var
  2825. proctypeoption : tproctypeoption;
  2826. i : longint;
  2827. first : boolean;
  2828. begin
  2829. write([space,' Return type : ']);
  2830. readderef('', ProcDef.ReturnType);
  2831. proctypeoption:=tproctypeoption(ppufile.getbyte);
  2832. case proctypeoption of
  2833. potype_function: Include(ProcDef.Options, poFunction);
  2834. potype_procedure: Include(ProcDef.Options, poProcedure);
  2835. potype_constructor: Include(ProcDef.Options, poConstructor);
  2836. potype_destructor: Include(ProcDef.Options, poDestructor);
  2837. potype_operator: Include(ProcDef.Options, poOperator);
  2838. end;
  2839. write([space,' TypeOption : ']);
  2840. first:=true;
  2841. for i:=1 to high(proctypeopt) do
  2842. if (proctypeopt[i].mask=proctypeoption) then
  2843. begin
  2844. if first then
  2845. first:=false
  2846. else
  2847. write(', ');
  2848. write(proctypeopt[i].str);
  2849. end;
  2850. writeln;
  2851. proccalloption:=tproccalloption(ppufile.getbyte);
  2852. writeln([space,' CallOption : ',proccalloptionStr[proccalloption]]);
  2853. ppufile.getset(tppuset8(procoptions));
  2854. if procoptions<>[] then
  2855. begin
  2856. if po_classmethod in procoptions then Include(ProcDef.Options, poClassMethod);
  2857. if po_virtualmethod in procoptions then Include(ProcDef.Options, poVirtual);
  2858. if po_abstractmethod in procoptions then Include(ProcDef.Options, poAbstract);
  2859. if po_overridingmethod in procoptions then Include(ProcDef.Options, poOverriding);
  2860. if po_overload in procoptions then Include(ProcDef.Options, poOverload);
  2861. if po_inline in procoptions then Include(ProcDef.Options, poInline);
  2862. if (po_methodpointer in procoptions) and (ProcDef.DefType = dtProcType) then
  2863. TPpuProcTypeDef(ProcDef).MethodPtr:=True;
  2864. write([space,' Options : ']);
  2865. first:=true;
  2866. for i:=1 to high(procopt) do
  2867. if (procopt[i].mask in procoptions) then
  2868. begin
  2869. if first then
  2870. first:=false
  2871. else
  2872. write(', ');
  2873. write(procopt[i].str);
  2874. end;
  2875. writeln;
  2876. end;
  2877. if (po_explicitparaloc in procoptions) then
  2878. begin
  2879. readcgpara(space);
  2880. end;
  2881. end;
  2882. { type tvaroption is in unit symconst }
  2883. { register variable }
  2884. { type tvarregable is in unit symconst }
  2885. procedure readabstractvarsym(const s:string;var varoptions:tvaroptions; VarDef: TPpuVarDef = nil);
  2886. type
  2887. tvaropt=record
  2888. mask : tvaroption;
  2889. str : string[30];
  2890. end;
  2891. const
  2892. varopt : array[1..ord(high(tvaroption))] of tvaropt=(
  2893. (mask:vo_is_external; str:'External'),
  2894. (mask:vo_is_dll_var; str:'DLLVar'),
  2895. (mask:vo_is_thread_var; str:'ThreadVar'),
  2896. (mask:vo_has_local_copy; str:'HasLocalCopy'),
  2897. (mask:vo_is_const; str:'Constant'),
  2898. (mask:vo_is_public; str:'Public'),
  2899. (mask:vo_is_high_para; str:'HighValue'),
  2900. (mask:vo_is_funcret; str:'Funcret'),
  2901. (mask:vo_is_self; str:'Self'),
  2902. (mask:vo_is_vmt; str:'VMT'),
  2903. (mask:vo_is_result; str:'Result'),
  2904. (mask:vo_is_parentfp; str:'ParentFP'),
  2905. (mask:vo_is_loop_counter; str:'LoopCounter'),
  2906. (mask:vo_is_hidden_para; str:'Hidden'),
  2907. (mask:vo_has_explicit_paraloc;str:'ExplicitParaloc'),
  2908. (mask:vo_is_syscall_lib; str:'SysCallLib'),
  2909. (mask:vo_has_mangledname; str:'HasMangledName'),
  2910. (mask:vo_is_typed_const; str:'TypedConst'),
  2911. (mask:vo_is_range_check; str:'RangeCheckSwitch'),
  2912. (mask:vo_is_overflow_check; str:'OverflowCheckSwitch'),
  2913. (mask:vo_is_typinfo_para; str:'TypeInfo'),
  2914. (mask:vo_is_msgsel;str:'MsgSel'),
  2915. (mask:vo_is_weak_external;str:'WeakExternal'),
  2916. (mask:vo_is_first_field;str:'IsFirstField'),
  2917. (mask:vo_volatile; str:'Volatile'),
  2918. (mask:vo_has_section; str:'HasSection'),
  2919. (mask:vo_force_finalize; str:'ForceFinalize'),
  2920. (mask:vo_is_default_var; str:'DefaultIntrinsicVar'),
  2921. (mask:vo_is_far; str:'IsFar'),
  2922. (mask:vo_has_global_ref; str:'HasGlobalRef')
  2923. );
  2924. type
  2925. tvaraccessdesc=record
  2926. mask: tvarsymaccessflag;
  2927. str: string[30];
  2928. end;
  2929. const
  2930. varaccessstr : array[ord(low(tvarsymaccessflag))..ord(high(tvarsymaccessflag))] of tvaraccessdesc=(
  2931. (mask: vsa_addr_taken; str:'Address taken'),
  2932. (mask: vsa_different_scope; str:'Accessed from different scope')
  2933. );
  2934. var
  2935. i : longint;
  2936. accessflag: tvarsymaccessflag;
  2937. varsymaccessflags: tvarsymaccessflags;
  2938. first : boolean;
  2939. begin
  2940. readcommonsym(s, VarDef);
  2941. i:=ppufile.getbyte;
  2942. if (VarDef <> nil) and (VarDef.DefType = dtParam) then
  2943. with TPpuParamDef(VarDef) do
  2944. case tvarspez(i) of
  2945. vs_value: Spez:=psValue;
  2946. vs_var: Spez:=psVar;
  2947. vs_out: Spez:=psOut;
  2948. vs_const: Spez:=psConst;
  2949. vs_constref: Spez:=psConstRef;
  2950. end;
  2951. writeln([space,' Spez : ',Varspez2Str(i)]);
  2952. writeln([space,' Regable : ',Varregable2Str(ppufile.getbyte)]);
  2953. ppufile.getset(tppuset1(varsymaccessflags));
  2954. write([space, ' Access Flags : ']);
  2955. first:=true;
  2956. for i:=low(varaccessstr) to high(varaccessstr) do
  2957. begin
  2958. if varaccessstr[i].mask in varsymaccessflags then
  2959. begin
  2960. if first then
  2961. first:=false
  2962. else
  2963. write([', ']);
  2964. write([varaccessstr[i].str]);
  2965. end
  2966. end;
  2967. writeln;
  2968. write ([space,' Var Type : ']);
  2969. if VarDef <> nil then
  2970. readderef('',VarDef.VarType)
  2971. else
  2972. readderef('');
  2973. ppufile.getset(tppuset4(varoptions));
  2974. if varoptions<>[] then
  2975. begin
  2976. if (VarDef <> nil) and (VarDef.DefType = dtParam) and (vo_is_hidden_para in varoptions) then
  2977. TPpuParamDef(VarDef).Spez:=psHidden;
  2978. write([space,' Options : ']);
  2979. first:=true;
  2980. for i:=1 to high(varopt) do
  2981. if (varopt[i].mask in varoptions) then
  2982. begin
  2983. if first then
  2984. first:=false
  2985. else
  2986. write(', ');
  2987. write(varopt[i].str);
  2988. end;
  2989. writeln;
  2990. end;
  2991. end;
  2992. procedure readobjectdefoptions(ObjDef: TPpuObjectDef = nil);
  2993. type
  2994. tsymopt=record
  2995. mask : tobjectoption;
  2996. str : string[30];
  2997. end;
  2998. const
  2999. symopt : array[1..ord(high(tobjectoption))] of tsymopt=(
  3000. (mask:oo_is_forward; str:'IsForward'),
  3001. (mask:oo_is_abstract; str:'IsAbstract'),
  3002. (mask:oo_is_sealed; str:'IsSealed'),
  3003. (mask:oo_has_virtual; str:'HasVirtual'),
  3004. (mask:oo_has_private; str:'HasPrivate'),
  3005. (mask:oo_has_protected; str:'HasProtected'),
  3006. (mask:oo_has_strictprivate; str:'HasStrictPrivate'),
  3007. (mask:oo_has_strictprotected;str:'HasStrictProtected'),
  3008. (mask:oo_has_constructor; str:'HasConstructor'),
  3009. (mask:oo_has_destructor; str:'HasDestructor'),
  3010. (mask:oo_has_vmt; str:'HasVMT'),
  3011. (mask:oo_has_msgstr; str:'HasMsgStr'),
  3012. (mask:oo_has_msgint; str:'HasMsgInt'),
  3013. (mask:oo_can_have_published; str:'CanHavePublished'),
  3014. (mask:oo_has_default_property;str:'HasDefaultProperty'),
  3015. (mask:oo_has_valid_guid; str:'HasValidGUID'),
  3016. (mask:oo_has_enumerator_movenext; str:'HasEnumeratorMoveNext'),
  3017. (mask:oo_has_enumerator_current; str:'HasEnumeratorCurrent'),
  3018. (mask:oo_is_external; str:'External'),
  3019. (mask:oo_is_formal; str:'Formal'),
  3020. (mask:oo_is_classhelper; str:'Class Helper/Category'),
  3021. (mask:oo_has_class_constructor; str:'HasClassConstructor'),
  3022. (mask:oo_has_class_destructor; str:'HasClassDestructor'),
  3023. (mask:oo_is_enum_class; str:'JvmEnumClass'),
  3024. (mask:oo_has_new_destructor; str:'HasNewDestructor')
  3025. );
  3026. var
  3027. i : longint;
  3028. first : boolean;
  3029. begin
  3030. ppufile.getset(tppuset4(current_objectoptions));
  3031. if current_objectoptions<>[] then
  3032. begin
  3033. if ObjDef <> nil then
  3034. begin
  3035. if oo_is_abstract in current_objectoptions then
  3036. Include(ObjDef.Options, ooIsAbstract);
  3037. end;
  3038. first:=true;
  3039. for i:=1 to high(symopt) do
  3040. if (symopt[i].mask in current_objectoptions) then
  3041. begin
  3042. if first then
  3043. first:=false
  3044. else
  3045. write(', ');
  3046. write(symopt[i].str);
  3047. end;
  3048. end;
  3049. writeln;
  3050. end;
  3051. procedure readprocimploptions(const space: string; out implprocoptions: timplprocoptions);
  3052. type
  3053. tpiopt=record
  3054. mask : timplprocoption;
  3055. str : string[30];
  3056. end;
  3057. const
  3058. piopt : array[low(timplprocoption)..high(timplprocoption)] of tpiopt=(
  3059. (mask:pio_empty; str:'IsEmpty'),
  3060. (mask:pio_has_inlininginfo; str:'HasInliningInfo'),
  3061. (mask:pio_inline_not_possible; str:'InlineNotPossible'),
  3062. (mask:pio_nested_access; str:'NestedAccess'),
  3063. (mask:pio_thunk; str:'Thunk'),
  3064. (mask:pio_fastmath; str:'FastMath'),
  3065. (mask:pio_inline_forbidden; str:'InlineForbidden')
  3066. );
  3067. var
  3068. i: timplprocoption;
  3069. first: boolean;
  3070. begin
  3071. ppufile.getset(tppuset1(implprocoptions));
  3072. if implprocoptions<>[] then
  3073. begin
  3074. first:=true;
  3075. write([space,' Options : ']);
  3076. for i:=low(piopt) to high(piopt) do
  3077. begin
  3078. if i in implprocoptions then
  3079. begin
  3080. if first then
  3081. first:=false
  3082. else
  3083. write(', ');
  3084. write(piopt[i].str);
  3085. end;
  3086. end;
  3087. writeln;
  3088. end;
  3089. end;
  3090. procedure readarraydefoptions(ArrayDef: TPpuArrayDef);
  3091. { type tarraydefoption is in unit symconst }
  3092. const
  3093. symopt : array[tarraydefoption] of string = (
  3094. { ado_IsConvertedPointer } 'ConvertedPointer',
  3095. { ado_IsDynamicArray } 'IsDynamicArray',
  3096. { ado_IsVariant } 'IsVariant',
  3097. { ado_IsConstructor } 'IsConstructor',
  3098. { ado_IsArrayOfConst } 'ArrayOfConst',
  3099. { ado_IsConstString } 'ConstString',
  3100. { ado_IsBitPacked } 'BitPacked',
  3101. { ado_IsVector } 'Vector',
  3102. { ado_IsGeneric } 'Generic'
  3103. );
  3104. var
  3105. symoptions: tarraydefoptions;
  3106. i: tarraydefoption;
  3107. first: boolean;
  3108. begin
  3109. ppufile.getset(tppuset2(symoptions));
  3110. if symoptions<>[] then
  3111. begin
  3112. if ado_IsDynamicArray in symoptions then Include(ArrayDef.Options, aoDynamic);
  3113. first:=true;
  3114. for i:=Low(symopt) to high(symopt) do
  3115. if (i in symoptions) then
  3116. begin
  3117. if first then
  3118. first:=false
  3119. else
  3120. write(', ');
  3121. write(symopt[i]);
  3122. end;
  3123. end;
  3124. writeln;
  3125. end;
  3126. (* options for properties
  3127. tpropertyoption=(ppo_none,
  3128. ppo_indexed,
  3129. ppo_defaultproperty,
  3130. ppo_stored,
  3131. ppo_hasparameters,
  3132. ppo_implements,
  3133. ppo_enumerator_current,
  3134. ppo_overrides,
  3135. ppo_dispid_write { no longer used }
  3136. );
  3137. tpropertyoptions=set of tpropertyoption;
  3138. *)
  3139. function readpropertyoptions:tpropertyoptions;
  3140. { type tarraydefoption is in unit symconst }
  3141. type
  3142. tpropopt=record
  3143. mask : tpropertyoption;
  3144. str : string[30];
  3145. end;
  3146. const
  3147. symopt : array[1..ord(high(tpropertyoption))] of tpropopt=(
  3148. (mask:ppo_indexed;str:'indexed'),
  3149. (mask:ppo_defaultproperty;str:'default'),
  3150. (mask:ppo_stored;str:'stored'),
  3151. (mask:ppo_hasparameters;str:'has parameters'),
  3152. (mask:ppo_implements;str:'implements'),
  3153. (mask:ppo_enumerator_current;str:'enumerator current'),
  3154. (mask:ppo_overrides;str:'overrides'),
  3155. (mask:ppo_dispid_write;str:'dispid write') { no longer used }
  3156. );
  3157. var
  3158. i : longint;
  3159. first : boolean;
  3160. begin
  3161. ppufile.getset(tppuset2(result));
  3162. if result<>[] then
  3163. begin
  3164. first:=true;
  3165. for i:=1 to high(symopt) do
  3166. if (symopt[i].mask in result) then
  3167. begin
  3168. if first then
  3169. first:=false
  3170. else
  3171. write(', ');
  3172. write(symopt[i].str);
  3173. end;
  3174. end;
  3175. writeln;
  3176. end;
  3177. function readmanagementoperatoroptions(const space : string;const name : string):tmanagementoperators;
  3178. { type is in unit symconst }
  3179. { Management operator options
  3180. tmanagementoperator=(
  3181. mop_none,
  3182. mop_initialize,
  3183. mop_finalize,
  3184. mop_addref,
  3185. mop_copy);
  3186. }
  3187. type
  3188. tmopopt=record
  3189. mask : tmanagementoperator;
  3190. str : string[10];
  3191. end;
  3192. const
  3193. managementoperatoropt : array[1..ord(high(tmanagementoperator))] of tmopopt=(
  3194. (mask:mop_initialize;str:'initialize'),
  3195. (mask:mop_finalize;str:'finalize'),
  3196. (mask:mop_addref;str:'addref'),
  3197. (mask:mop_copy;str:'copy')
  3198. );
  3199. var
  3200. i : longint;
  3201. first : boolean;
  3202. begin
  3203. ppufile.getset(tppuset1(result));
  3204. if result<>[] then
  3205. begin
  3206. first:=true;
  3207. for i:=1 to high(managementoperatoropt) do
  3208. if (managementoperatoropt[i].mask in result) then
  3209. begin
  3210. if first then
  3211. begin
  3212. write(space);
  3213. write(name);
  3214. write(': ');
  3215. first:=false;
  3216. end
  3217. else
  3218. write(', ');
  3219. write(managementoperatoropt[i].str);
  3220. end;
  3221. if not first then
  3222. writeln;
  3223. end;
  3224. end;
  3225. procedure readnodetree;
  3226. var
  3227. l : longint;
  3228. p : pointer;
  3229. begin
  3230. with ppufile do
  3231. begin
  3232. if space<>'' then
  3233. Writeln([space,'------ nodetree ------']);
  3234. if readentry=ibnodetree then
  3235. begin
  3236. l:=entrysize;
  3237. Writeln([space,'Tree size : ',l]);
  3238. { Read data to prevent error that entry is not completly read }
  3239. getmem(p,l);
  3240. getdata(p^,l);
  3241. freemem(p);
  3242. end
  3243. else
  3244. begin
  3245. WriteError('!! ibnodetree not found');
  3246. end;
  3247. end;
  3248. end;
  3249. procedure ReadCreatedObjTypes;
  3250. var
  3251. i,j,
  3252. len,
  3253. bssize: longint;
  3254. bs: pbyte;
  3255. begin
  3256. if ppufile.readentry<>ibcreatedobjtypes then
  3257. begin
  3258. WriteError('!! ibcreatedobjtypes entry not found');
  3259. ppufile.skipdata(ppufile.entrysize);
  3260. exit
  3261. end;
  3262. writeln;
  3263. writeln([space,'WPO info']);
  3264. writeln([space,'--------']);
  3265. len:=ppufile.getlongint;
  3266. writeln([space,'** Instantiated Object/Class types: ',len,' **']);
  3267. space:=space+' ';
  3268. for i:=0 to len-1 do
  3269. readderef(space);
  3270. setlength(space,length(space)-2);
  3271. len:=ppufile.getlongint;
  3272. writeln([space,'** Instantiated ClassRef types: ',len,' **']);
  3273. space:=space+' ';
  3274. for i:=0 to len-1 do
  3275. readderef(space);
  3276. setlength(space,length(space)-2);
  3277. len:=ppufile.getlongint;
  3278. writeln([space,'** Possibly instantiated ClassRef types : ',len,' **']);
  3279. space:=space+' ';
  3280. for i:=0 to len-1 do
  3281. readderef(space);
  3282. setlength(space,length(space)-2);
  3283. len:=ppufile.getlongint;
  3284. writeln([space,'** Class types with called virtual methods info : ',len,' **']);
  3285. space:=space+' ';
  3286. for i:=0 to len-1 do
  3287. begin
  3288. write([space,'Class def : ']);
  3289. readderef('');
  3290. write([space+' ','Called vmtentries : ']);
  3291. bssize:=ppufile.getlongint;
  3292. getmem(bs,bssize);
  3293. ppufile.readdata(bs^,bssize);
  3294. for j:=0 to bssize*8-1 do
  3295. if (((bs+j shr 3)^ shr (j and 7)) and 1) <> 0 then
  3296. write([j,', ']);
  3297. writeln;
  3298. freemem(bs);
  3299. end;
  3300. setlength(space,length(space)-2);
  3301. end;
  3302. {****************************************************************************
  3303. Read Symbols Part
  3304. ****************************************************************************}
  3305. procedure readsymbols(const s:string; ParentDef: TPpuContainerDef = nil);
  3306. function _finddef(symdef: TPpuDef): TPpuDef;
  3307. begin
  3308. Result:=nil;
  3309. if symdef.Ref.IsCurUnit then
  3310. begin;
  3311. Result:=CurUnit.FindById(symdef.Ref.Id);
  3312. if (Result <> nil) and (Result.Ref.Id = symdef.Id) then
  3313. begin
  3314. Result.Name:=symdef.Name;
  3315. Result.FilePos:=symdef.FilePos;
  3316. end
  3317. else
  3318. Result:=nil;
  3319. end;
  3320. end;
  3321. type
  3322. pguid = ^tguid;
  3323. tguid = packed record
  3324. D1: LongWord;
  3325. D2: Word;
  3326. D3: Word;
  3327. D4: array[0..7] of Byte;
  3328. end;
  3329. var
  3330. b : byte;
  3331. pc : pchar;
  3332. ch : dword;
  3333. startnewline : boolean;
  3334. i,j,len : longint;
  3335. prettyname, ss : ansistring;
  3336. ws: widestring;
  3337. guid : tguid;
  3338. realvalue : ppureal;
  3339. doublevalue : double;
  3340. singlevalue : single;
  3341. realstr : shortstring;
  3342. extended : TSplit80bitReal;
  3343. pw : pcompilerwidestring;
  3344. varoptions : tvaroptions;
  3345. propoptions : tpropertyoptions;
  3346. iexp: Tconstexprint;
  3347. def: TPpuDef;
  3348. constdef: TPpuConstDef absolute def;
  3349. begin
  3350. with ppufile do
  3351. begin
  3352. if space<>'' then
  3353. Writeln([space,'------ ',s,' ------']);
  3354. if readentry=ibstartsyms then
  3355. begin
  3356. Writeln([space,'Symtable count: ',getlongint]);
  3357. end
  3358. else
  3359. Writeln('!! ibstartsym not found');
  3360. repeat
  3361. def:=nil;
  3362. b:=readentry;
  3363. case b of
  3364. ibunitsym :
  3365. readcommonsym('Unit symbol ');
  3366. ibnamespacesym :
  3367. begin
  3368. readcommonsym('NameSpace symbol ');
  3369. write([space,' Hidden Unit : ']);
  3370. readderef('');
  3371. end;
  3372. iblabelsym :
  3373. readcommonsym('Label symbol ');
  3374. ibtypesym :
  3375. begin
  3376. def:=TPpuTypeRef.Create(nil);
  3377. readcommonsym('Type symbol ',def);
  3378. write([space,' Result Type : ']);
  3379. readderef('', def.Ref);
  3380. if _finddef(def) = nil then
  3381. def.Parent:=ParentDef;
  3382. prettyname:=getansistring;
  3383. if prettyname<>'' then
  3384. begin
  3385. write([space,' Pretty Name : ']);
  3386. Writeln(prettyname);
  3387. end;
  3388. end;
  3389. ibprocsym :
  3390. begin
  3391. def:=TPpuDef.Create(nil);
  3392. readcommonsym('Procedure symbol ', def);
  3393. len:=ppufile.getword;
  3394. for i:=1 to len do
  3395. begin
  3396. write([space,' Definition : ']);
  3397. readderef('', def.Ref);
  3398. _finddef(def);
  3399. end;
  3400. if def.GenericDummy then
  3401. begin
  3402. len:=ppufile.getword;
  3403. for i:=1 to len do
  3404. begin
  3405. write([space,' Gen Ovld : ']);
  3406. readderef('',def.Ref);
  3407. _finddef(def);
  3408. end;
  3409. end;
  3410. end;
  3411. ibconstsym :
  3412. begin
  3413. constdef:=TPpuConstDef.Create(ParentDef);
  3414. readcommonsym('Constant symbol ',constdef);
  3415. b:=getbyte;
  3416. case tconsttyp(b) of
  3417. constord :
  3418. begin
  3419. write ([space,' OrdinalType : ']);
  3420. readderef('',constdef.TypeRef);
  3421. iexp:=getexprint;
  3422. constdef.ConstType:=ctInt;
  3423. constdef.VInt:=iexp.svalue;
  3424. writeln([space,' Value : ',constexp.tostr(iexp)]);
  3425. end;
  3426. constpointer :
  3427. begin
  3428. write ([space,' PointerType : ']);
  3429. readderef('',constdef.TypeRef);
  3430. constdef.ConstType:=ctInt;
  3431. constdef.VInt:=int64(getptruint);
  3432. writeln([space,' Value : ',constdef.VInt])
  3433. end;
  3434. conststring,
  3435. constresourcestring :
  3436. begin
  3437. write ([space,' StringType : ']);
  3438. readderef('',constdef.TypeRef);
  3439. len:=getlongint;
  3440. getmem(pc,len+1);
  3441. getdata(pc^,len);
  3442. (pc+len)^:= #0;
  3443. writeln([space,' Length : ',len]);
  3444. writeln([space,' Value : "',pc,'"']);
  3445. constdef.ConstType:=ctStr;
  3446. SetString(constdef.VStr, pc, len);
  3447. constdef.VStr:=UTF8Encode(constdef.VStr);
  3448. freemem(pc,len+1);
  3449. end;
  3450. constreal :
  3451. begin
  3452. constdef.ConstType:=ctFloat;
  3453. write ([space,' RealType : ']);
  3454. readderef('',constdef.TypeRef);
  3455. write([space,' Value : ']);
  3456. if entryleft=sizeof(ppureal) then
  3457. begin
  3458. realvalue:=getrealsize(sizeof(ppureal));
  3459. constdef.VFloat:=realvalue;
  3460. system.str(realvalue,realstr);
  3461. writeln([realstr]);
  3462. end
  3463. else if entryleft=sizeof(double) then
  3464. begin
  3465. doublevalue:=getrealsize(sizeof(double));
  3466. constdef.VFloat:=doublevalue;
  3467. system.str(doublevalue,realstr);
  3468. writeln([realstr]);
  3469. end
  3470. else if entryleft=sizeof(single) then
  3471. begin
  3472. singlevalue:=getrealsize(sizeof(single));
  3473. constdef.VFloat:=singlevalue;
  3474. system.str(singlevalue,realstr);
  3475. writeln([realstr]);
  3476. end
  3477. else if entryleft=10 then
  3478. begin
  3479. getdata(extended,entryleft);
  3480. ss:=Real80bitToStr(extended,constdef.VFloat);
  3481. writeln(ss);
  3482. end
  3483. else
  3484. begin
  3485. realvalue:=0.0;
  3486. WriteError('Error reading real value');
  3487. end;
  3488. end;
  3489. constset :
  3490. begin
  3491. constdef.ConstType:=ctSet;
  3492. write ([space,' Set Type : ']);
  3493. readderef('',constdef.TypeRef);
  3494. for i:=1to 4 do
  3495. begin
  3496. write ([space,' Value : ']);
  3497. for j:=1to 8 do
  3498. begin
  3499. if j>1 then
  3500. write(',');
  3501. b:=getbyte;
  3502. write(hexstr(b,2));
  3503. constdef.VSet[i*j-1]:=b;
  3504. end;
  3505. writeln;
  3506. end;
  3507. end;
  3508. constnil:
  3509. begin
  3510. write([space,' NIL pointer :']);
  3511. readderef('',constdef.TypeRef);
  3512. constdef.ConstType:=ctPtr;
  3513. constdef.VInt:=0;
  3514. end;
  3515. constwstring :
  3516. begin
  3517. initwidestring(pw);
  3518. setlengthwidestring(pw,getlongint);
  3519. if widecharsize=2 then
  3520. { don't use getdata, because the compilerwidechars may have to
  3521. be byteswapped
  3522. }
  3523. begin
  3524. for i:=0 to pw^.len-1 do
  3525. pw^.data[i]:=ppufile.getword;
  3526. SetString(ws, PWideChar(pw^.data), pw^.len);
  3527. constdef.VStr:=UTF8Encode(ws);
  3528. constdef.ConstType:=ctStr;
  3529. end
  3530. else if widecharsize=4 then
  3531. begin
  3532. for i:=0 to pw^.len-1 do
  3533. pw^.data[i]:=cardinal(ppufile.getlongint);
  3534. end
  3535. else
  3536. begin
  3537. WriteError('Unsupported tcompilerwidechar size');
  3538. end;
  3539. Write([space,'Wide string type']);
  3540. startnewline:=true;
  3541. for i:=0 to pw^.len-1 do
  3542. begin
  3543. if startnewline then
  3544. begin
  3545. writeln;
  3546. write(space);
  3547. startnewline:=false;
  3548. end;
  3549. ch:=pw^.data[i];
  3550. if widecharsize=2 then
  3551. write(hexstr(ch,4))
  3552. else
  3553. write(hexstr(ch,8));
  3554. if ((i + 1) mod 8)= 0 then
  3555. startnewline:=true
  3556. else
  3557. if i <> pw^.len-1 then
  3558. write(', ');
  3559. end;
  3560. donewidestring(pw);
  3561. Writeln;
  3562. end;
  3563. constguid:
  3564. begin
  3565. write ([space,' IntfType : ']);
  3566. readderef('',constdef.TypeRef);
  3567. getdata(guid,sizeof(guid));
  3568. write ([space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-']);
  3569. for i:=0 to 7 do
  3570. begin
  3571. write(hexstr(guid.d4[i],2));
  3572. if i=1 then write('-');
  3573. end;
  3574. writeln('}');
  3575. end
  3576. else
  3577. Writeln (['!! Invalid unit format : Invalid const type encountered: ',b]);
  3578. end;
  3579. end;
  3580. ibabsolutevarsym :
  3581. begin
  3582. def:=TPpuVarDef.Create(ParentDef);
  3583. readabstractvarsym('Absolute variable symbol ',varoptions,TPpuVarDef(def));
  3584. Write ([space,' Relocated to ']);
  3585. b:=getbyte;
  3586. case absolutetyp(b) of
  3587. tovar :
  3588. readpropaccesslist(space+' Sym : ');
  3589. toasm :
  3590. Writeln(['Assembler name : ',getstring]);
  3591. toaddr :
  3592. begin
  3593. Write(['Address : ',getpuint]);
  3594. if tsystemcpu(ppufile.header.common.cpu)=cpu_i386 then
  3595. Write([' (Far: ',getbyte<>0,')']);
  3596. if tsystemcpu(ppufile.header.common.cpu)=cpu_i8086 then
  3597. if getbyte<>0 then
  3598. Write([' (Far: TRUE, Segment=',getaword,')'])
  3599. else
  3600. Write([' (Far: FALSE)']);
  3601. Writeln;
  3602. end;
  3603. else
  3604. Writeln (['!! Invalid unit format : Invalid absolute type encountered: ',b]);
  3605. end;
  3606. end;
  3607. ibfieldvarsym :
  3608. begin
  3609. def:=TPpuFieldDef.Create(ParentDef);
  3610. readabstractvarsym('Field Variable symbol ',varoptions,TPpuVarDef(def));
  3611. writeln([space,' Address : ',getasizeint]);
  3612. if vo_has_mangledname in varoptions then
  3613. writeln([space,' Mangled name : ',getstring]);
  3614. end;
  3615. ibstaticvarsym :
  3616. begin
  3617. def:=TPpuVarDef.Create(ParentDef);
  3618. readabstractvarsym('Global Variable symbol ',varoptions,TPpuVarDef(def));
  3619. write ([space,' DefaultConst : ']);
  3620. readderef('');
  3621. if (vo_has_mangledname in varoptions) then
  3622. writeln([space,'Mangledname : ',readsymstr(ppufile)]);
  3623. if vo_has_section in varoptions then
  3624. writeln(['Section name:',ppufile.getansistring]);
  3625. write ([space,' FieldVarSymDeref: ']);
  3626. readderef('');
  3627. end;
  3628. iblocalvarsym :
  3629. begin
  3630. readabstractvarsym('Local Variable symbol ',varoptions);
  3631. write ([space,' DefaultConst : ']);
  3632. readderef('');
  3633. end;
  3634. ibparavarsym :
  3635. begin
  3636. def:=TPpuParamDef.Create(ParentDef);
  3637. readabstractvarsym('Parameter Variable symbol ',varoptions,TPpuVarDef(def));
  3638. write ([space,' DefaultConst : ']);
  3639. readderef('',TPpuParamDef(def).DefaultValue);
  3640. writeln([space,' ParaNr : ',getword]);
  3641. writeln([space,' Univ : ',getboolean]);
  3642. writeln([space,' VarState : ',getbyte]);
  3643. writeln([space,' Refs : ',getbyte]);
  3644. if (vo_has_explicit_paraloc in varoptions) then
  3645. begin
  3646. readcgpara(space+' ');
  3647. end;
  3648. end;
  3649. ibenumsym :
  3650. begin
  3651. def:=TPpuConstDef.Create(nil);
  3652. readcommonsym('Enumeration symbol ',def);
  3653. write ([space,' Definition : ']);
  3654. readderef('');
  3655. TPpuConstDef(def).ConstType:=ctInt;
  3656. TPpuConstDef(def).VInt:=getlongint;
  3657. writeln([space,' Value : ',TPpuConstDef(def).VInt]);
  3658. if (ParentDef <> nil) and (ParentDef.DefType = dtEnum) then
  3659. def.Parent:=ParentDef;
  3660. end;
  3661. ibsyssym :
  3662. begin
  3663. readcommonsym('Internal system symbol ');
  3664. writeln([space,' Internal Nr : ',getlongint]);
  3665. end;
  3666. ibmacrosym :
  3667. begin
  3668. readcommonsym('Macro symbol ');
  3669. writeln([space,' Defined: ',getboolean]);
  3670. writeln([space,' Compiler var: ',getboolean]);
  3671. len:=getlongint;
  3672. writeln([space,' Value length: ',len]);
  3673. if len > 0 then
  3674. begin
  3675. getmem(pc,len+1);
  3676. getdata(pc^,len);
  3677. (pc+len)^:= #0;
  3678. writeln([space,' Value: "',pc,'"']);
  3679. freemem(pc,len+1);
  3680. end;
  3681. end;
  3682. ibpropertysym :
  3683. begin
  3684. def:=TPpuPropDef.Create(ParentDef);
  3685. readcommonsym('Property ',def);
  3686. write ([space,' Prop Options : ']);
  3687. propoptions:=readpropertyoptions;
  3688. if ppo_overrides in propoptions then
  3689. begin
  3690. write ([space,' OverrideProp : ']);
  3691. readderef('');
  3692. end;
  3693. if ppo_defaultproperty in propoptions then
  3694. Include(TPpuPropDef(def).Options, poDefault);
  3695. write ([space,' Prop Type : ']);
  3696. readderef('',TPpuPropDef(def).PropType);
  3697. writeln([space,' Index : ',getlongint]);
  3698. writeln([space,' Default : ',getlongint]);
  3699. write ([space,' Index Type : ']);
  3700. readderef('');
  3701. { palt_none }
  3702. write ([space,' Noneaccess : ']);
  3703. readpropaccesslist('');
  3704. write ([space,' Readaccess : ']);
  3705. readpropaccesslist(space+' Sym: ',TPpuPropDef(def).Getter);
  3706. write ([space,' Writeaccess : ']);
  3707. readpropaccesslist(space+' Sym: ',TPpuPropDef(def).Setter);
  3708. write ([space,' Storedaccess : ']);
  3709. readpropaccesslist(space+' Sym: ');
  3710. if [ppo_hasparameters,ppo_overrides]*propoptions=[ppo_hasparameters] then
  3711. begin
  3712. space:=' '+space;
  3713. readsymtable('parast',TPpuPropDef(def));
  3714. delete(space,1,4);
  3715. end;
  3716. end;
  3717. iberror :
  3718. begin
  3719. WriteError('!! Error in PPU');
  3720. exit;
  3721. end;
  3722. ibendsyms :
  3723. break;
  3724. else
  3725. begin
  3726. WriteError('!! Skipping unsupported PPU Entry in Symbols: '+IntToStr(b));
  3727. end;
  3728. end;
  3729. if assigned(def) then
  3730. readsymsubentries(def);
  3731. if (def <> nil) and (def.Parent = nil) then
  3732. def.Free;
  3733. if not EndOfEntry then
  3734. HasMoreInfos;
  3735. until false;
  3736. end;
  3737. end;
  3738. {****************************************************************************
  3739. Read defintions Part
  3740. ****************************************************************************}
  3741. procedure readdefinitions(const s:string; ParentDef: TPpuContainerDef);
  3742. { type tordtype is in symconst unit }
  3743. {
  3744. uvoid,
  3745. u8bit,u16bit,u32bit,u64bit,u128bit,
  3746. s8bit,s16bit,s32bit,s64bit,s128bit,
  3747. bool8bit,bool16bit,bool32bit,bool64bit,
  3748. uchar,uwidechar,scurrency,customint
  3749. ); }
  3750. { type tobjecttyp is in symconst unit }
  3751. { type tvarianttype is in symconst unit }
  3752. { type thelpertype is in symconst unit }
  3753. var
  3754. b : byte;
  3755. otb : byte; { Object Type byte, needed later again }
  3756. l,j,tokenbufsize : longint;
  3757. tokenbuf : pbyte;
  3758. calloption : tproccalloption;
  3759. procoptions : tprocoptions;
  3760. implprocoptions: timplprocoptions;
  3761. defoptions: tdefoptions;
  3762. iexpr: Tconstexprint;
  3763. def: TPpuDef;
  3764. objdef: TPpuObjectDef absolute def;
  3765. arrdef: TPpuArrayDef absolute def;
  3766. enumdef: TPpuEnumDef absolute def;
  3767. setdef: TPpuSetDef absolute def;
  3768. orddef: TPpuOrdDef absolute def;
  3769. floatdef: TPpuFloatDef absolute def;
  3770. strdef: TPpuStringDef absolute def;
  3771. filedef: TPpuFileDef absolute def;
  3772. begin
  3773. with ppufile do
  3774. begin
  3775. if space<>'' then
  3776. Writeln([space,'------ ',s,' ------']);
  3777. if readentry<>ibstartdefs then
  3778. Writeln('!! ibstartdefs not found');
  3779. repeat
  3780. def:=nil;
  3781. b:=readentry;
  3782. case b of
  3783. ibpointerdef :
  3784. begin
  3785. def:=TPpuPointerDef.Create(ParentDef);
  3786. readcommondef('Pointer definition',defoptions,def);
  3787. write ([space,' Pointed Type : ']);
  3788. readderef('',TPpuPointerDef(def).Ptr);
  3789. writeln([space,' Has Pointer Math : ',(getbyte<>0)]);
  3790. if tsystemcpu(ppufile.header.common.cpu) in [cpu_i8086,cpu_i386,cpu_x86_64] then
  3791. begin
  3792. write([space,' X86 Pointer Type : ']);
  3793. b:=getbyte;
  3794. case tx86pointertyp(b) of
  3795. x86pt_near: writeln('Near');
  3796. x86pt_near_cs: writeln('Near ''CS''');
  3797. x86pt_near_ds: writeln('Near ''DS''');
  3798. x86pt_near_ss: writeln('Near ''SS''');
  3799. x86pt_near_es: writeln('Near ''ES''');
  3800. x86pt_near_fs: writeln('Near ''FS''');
  3801. x86pt_near_gs: writeln('Near ''GS''');
  3802. x86pt_far: writeln('Far');
  3803. x86pt_huge: writeln('Huge');
  3804. else
  3805. WriteWarning('Invalid x86 pointer type: ' + IntToStr(b));
  3806. end;
  3807. end;
  3808. end;
  3809. iborddef :
  3810. begin
  3811. orddef:=TPpuOrdDef.Create(ParentDef);
  3812. readcommondef('Ordinal definition',defoptions,orddef);
  3813. write ([space,' Base type : ']);
  3814. b:=getbyte;
  3815. case tordtype(b) of
  3816. uvoid:
  3817. begin
  3818. writeln('uvoid');
  3819. orddef.OrdType:=otVoid;
  3820. end;
  3821. u8bit:
  3822. begin
  3823. writeln('u8bit');
  3824. orddef.OrdType:=otUInt;
  3825. orddef.Size:=1;
  3826. end;
  3827. u16bit:
  3828. begin
  3829. writeln('u16bit');
  3830. orddef.OrdType:=otUInt;
  3831. orddef.Size:=2;
  3832. end;
  3833. u32bit:
  3834. begin
  3835. writeln('u32bit');
  3836. orddef.OrdType:=otUInt;
  3837. orddef.Size:=4;
  3838. end;
  3839. u64bit:
  3840. begin
  3841. writeln('u64bit');
  3842. orddef.OrdType:=otUInt;
  3843. orddef.Size:=8;
  3844. end;
  3845. u128bit:
  3846. begin
  3847. writeln('u128bit');
  3848. orddef.OrdType:=otUInt;
  3849. orddef.Size:=16;
  3850. end;
  3851. s8bit:
  3852. begin
  3853. writeln('s8bit');
  3854. orddef.OrdType:=otSInt;
  3855. orddef.Size:=1;
  3856. end;
  3857. s16bit:
  3858. begin
  3859. writeln('s16bit');
  3860. orddef.OrdType:=otSInt;
  3861. orddef.Size:=2;
  3862. end;
  3863. s32bit:
  3864. begin
  3865. writeln('s32bit');
  3866. orddef.OrdType:=otSInt;
  3867. orddef.Size:=4;
  3868. end;
  3869. s64bit:
  3870. begin
  3871. writeln('s64bit');
  3872. orddef.OrdType:=otSInt;
  3873. orddef.Size:=8;
  3874. end;
  3875. s128bit:
  3876. begin
  3877. writeln('s128bit');
  3878. orddef.OrdType:=otSInt;
  3879. orddef.Size:=16;
  3880. end;
  3881. pasbool1:
  3882. begin
  3883. writeln('pasbool1');
  3884. orddef.OrdType:=otPasBool;
  3885. orddef.Size:=1;
  3886. end;
  3887. pasbool8:
  3888. begin
  3889. writeln('pasbool8');
  3890. orddef.OrdType:=otPasBool;
  3891. orddef.Size:=1;
  3892. end;
  3893. pasbool16:
  3894. begin
  3895. writeln('pasbool16');
  3896. orddef.OrdType:=otPasBool;
  3897. orddef.Size:=2;
  3898. end;
  3899. pasbool32:
  3900. begin
  3901. writeln('pasbool32');
  3902. orddef.OrdType:=otPasBool;
  3903. orddef.Size:=4;
  3904. end;
  3905. pasbool64:
  3906. begin
  3907. writeln('pasbool64');
  3908. orddef.OrdType:=otPasBool;
  3909. orddef.Size:=8;
  3910. end;
  3911. bool8bit:
  3912. begin
  3913. writeln('bool8bit');
  3914. orddef.OrdType:=otBool;
  3915. orddef.Size:=1;
  3916. end;
  3917. bool16bit:
  3918. begin
  3919. writeln('bool16bit');
  3920. orddef.OrdType:=otBool;
  3921. orddef.Size:=2;
  3922. end;
  3923. bool32bit:
  3924. begin
  3925. writeln('bool32bit');
  3926. orddef.OrdType:=otBool;
  3927. orddef.Size:=4;
  3928. end;
  3929. bool64bit:
  3930. begin
  3931. writeln('bool64bit');
  3932. orddef.OrdType:=otBool;
  3933. orddef.Size:=8;
  3934. end;
  3935. uchar:
  3936. begin
  3937. writeln('uchar');
  3938. orddef.OrdType:=otChar;
  3939. orddef.Size:=1;
  3940. end;
  3941. uwidechar:
  3942. begin
  3943. writeln('uwidechar');
  3944. orddef.OrdType:=otChar;
  3945. orddef.Size:=2;
  3946. end;
  3947. scurrency:
  3948. begin
  3949. writeln('scurrency');
  3950. orddef.OrdType:=otCurrency;
  3951. orddef.Size:=8;
  3952. end;
  3953. customint:
  3954. begin
  3955. writeln('customint');
  3956. orddef.OrdType:=otSint;
  3957. orddef.Size:=sizeof(ASizeInt);
  3958. end
  3959. else
  3960. WriteWarning('Invalid base type: ' + IntToStr(b));
  3961. end;
  3962. iexpr:=getexprint;
  3963. orddef.RangeLow:=iexpr.svalue;
  3964. write([space,' Range : ',constexp.tostr(iexpr)]);
  3965. iexpr:=getexprint;
  3966. orddef.RangeHigh:=iexpr.svalue;
  3967. writeln([' to ',constexp.tostr(iexpr)]);
  3968. end;
  3969. ibfloatdef :
  3970. begin
  3971. floatdef:=TPpuFloatDef.Create(ParentDef);
  3972. readcommondef('Float definition',defoptions,floatdef);
  3973. write ([space,' Float type : ']);
  3974. b:=getbyte;
  3975. case b of
  3976. ftSingle:
  3977. begin
  3978. writeln('Single');
  3979. floatdef.FloatType:=pftSingle;
  3980. end;
  3981. ftDouble:
  3982. begin
  3983. writeln('Double');
  3984. floatdef.FloatType:=pftDouble;
  3985. end;
  3986. ftExtended:
  3987. begin
  3988. writeln('Extended');
  3989. floatdef.FloatType:=pftExtended;
  3990. end;
  3991. ftComp:
  3992. begin
  3993. writeln('Comp');
  3994. floatdef.FloatType:=pftComp;
  3995. end;
  3996. ftCurr:
  3997. begin
  3998. writeln('Currency');
  3999. floatdef.FloatType:=pftCurrency;
  4000. end;
  4001. ftFloat128:
  4002. begin
  4003. writeln('Float128');
  4004. floatdef.FloatType:=pftFloat128;
  4005. end;
  4006. else
  4007. WriteWarning('Invalid float type: ' + IntToStr(b));
  4008. end;
  4009. end;
  4010. ibarraydef :
  4011. begin
  4012. arrdef:=TPpuArrayDef.Create(ParentDef);
  4013. readcommondef('Array definition',defoptions,arrdef);
  4014. write ([space,' Element type : ']);
  4015. readderef('',arrdef.ElType);
  4016. write ([space,' Range Type : ']);
  4017. readderef('',arrdef.RangeType);
  4018. arrdef.RangeLow:=getasizeint;
  4019. arrdef.RangeHigh:=getasizeint;
  4020. writeln([space,' Range : ',arrdef.RangeLow,' to ',arrdef.RangeHigh]);
  4021. write ([space,' Options : ']);
  4022. readarraydefoptions(arrdef);
  4023. if tsystemcpu(ppufile.header.common.cpu)=cpu_i8086 then
  4024. writeln([space,' Huge : ',(getbyte<>0)]);
  4025. readsymtable('symbols', arrdef);
  4026. end;
  4027. ibprocdef :
  4028. begin
  4029. def:=TPpuProcDef.Create(ParentDef);
  4030. readcommondef('Procedure definition',defoptions,def);
  4031. read_abstract_proc_def(calloption,procoptions,TPpuProcDef(def));
  4032. if (po_has_mangledname in procoptions) then
  4033. writeln([space,' Mangled name : ',readsymstr(ppufile)]);
  4034. writeln([space,' Number : ',getword]);
  4035. writeln([space,' Level : ',getbyte]);
  4036. write ([space,' Class : ']);
  4037. readderef('');
  4038. write ([space,' Procsym : ']);
  4039. readderef('', def.Ref);
  4040. write ([space,' File Pos : ']);
  4041. readposinfo(def);
  4042. write ([space,' Visibility : ']);
  4043. readvisibility(def);
  4044. write ([space,' SymOptions : ']);
  4045. readsymoptions(space+' ');
  4046. if (po_has_importdll in procoptions) then
  4047. writeln([space,' Import DLL : ',getstring]);
  4048. if (po_has_importname in procoptions) then
  4049. writeln([space,' Import Name : ',getstring]);
  4050. writeln([space,' Import Nr : ',getword]);
  4051. if (po_msgint in procoptions) then
  4052. writeln([space,' MsgInt : ',getlongint]);
  4053. if (po_msgstr in procoptions) then
  4054. writeln([space,' MsgStr : ',getstring]);
  4055. if (po_dispid in procoptions) then
  4056. writeln([space,' DispID: ',ppufile.getlongint]);
  4057. readprocimploptions(space,implprocoptions);
  4058. if (pio_has_inlininginfo in implprocoptions) then
  4059. begin
  4060. write ([space,' FuncretSym : ']);
  4061. readderef('');
  4062. readprocinfooptions(space);
  4063. end;
  4064. b:=ppufile.getbyte;
  4065. if b<>0 then
  4066. begin
  4067. write ([space,' Alias names : ']);
  4068. for j:=1 to b do
  4069. begin
  4070. write(ppufile.getstring);
  4071. if j<b then
  4072. write(', ');
  4073. end;
  4074. writeln;
  4075. end;
  4076. tokenbufsize:=ppufile.getlongint;
  4077. if tokenbufsize<>0 then
  4078. begin
  4079. space:=space + ' ';
  4080. write ([space,'Declaration token buffer : size = ',tokenbufsize]);
  4081. tokenbuf:=allocmem(tokenbufsize);
  4082. ppufile.getdata(tokenbuf^,tokenbufsize);
  4083. displaytokenbuffer(tokenbuf,tokenbufsize);
  4084. freemem(tokenbuf);
  4085. delete(space,1,4);
  4086. end;
  4087. if po_syscall_has_libsym in procoptions then
  4088. begin
  4089. { library symbol for AmigaOS/MorphOS/AROS }
  4090. write ([space,' Library symbol : ']);
  4091. readderef('');
  4092. end;
  4093. if not EndOfEntry then
  4094. HasMoreInfos;
  4095. space:=' '+space;
  4096. { parast }
  4097. readsymtable('parast', TPpuProcDef(def));
  4098. { localst }
  4099. if (pio_has_inlininginfo in implprocoptions) then
  4100. readsymtable('inline localst')
  4101. else if (df_generic in defoptions) then
  4102. readsymtable('generic localst');
  4103. if (pio_has_inlininginfo in implprocoptions) then
  4104. readnodetree;
  4105. delete(space,1,4);
  4106. end;
  4107. ibprocvardef :
  4108. begin
  4109. def:=TPpuProcTypeDef.Create(ParentDef);
  4110. readcommondef('Procedural type (ProcVar) definition',defoptions,def);
  4111. read_abstract_proc_def(calloption,procoptions, TPpuProcDef(def));
  4112. writeln([space,' Symtable level :',ppufile.getbyte]);
  4113. if tsystemcpu(ppufile.header.common.cpu)=cpu_jvm then
  4114. readderef('');
  4115. if not EndOfEntry then
  4116. HasMoreInfos;
  4117. space:=' '+space;
  4118. { parast }
  4119. readsymtable('parast',TPpuProcDef(def));
  4120. delete(space,1,4);
  4121. end;
  4122. ibshortstringdef :
  4123. begin
  4124. strdef:=TPpuStringDef.Create(ParentDef);
  4125. strdef.StrType:=stShort;
  4126. readcommondef('ShortString definition',defoptions,strdef);
  4127. strdef.Len:=getbyte;
  4128. writeln([space,' Length : ',strdef.Len]);
  4129. end;
  4130. ibwidestringdef :
  4131. begin
  4132. strdef:=TPpuStringDef.Create(ParentDef);
  4133. strdef.StrType:=stWide;
  4134. readcommondef('WideString definition',defoptions,strdef);
  4135. strdef.Len:=getasizeint;
  4136. writeln([space,' Length : ',strdef.Len]);
  4137. end;
  4138. ibunicodestringdef :
  4139. begin
  4140. strdef:=TPpuStringDef.Create(ParentDef);
  4141. strdef.StrType:=stUnicode;
  4142. readcommondef('UnicodeString definition',defoptions,strdef);
  4143. strdef.Len:=getasizeint;
  4144. writeln([space,' Length : ',strdef.Len]);
  4145. writeln([space,' Encoding : ',getword]);
  4146. end;
  4147. ibansistringdef :
  4148. begin
  4149. strdef:=TPpuStringDef.Create(ParentDef);
  4150. strdef.StrType:=stAnsi;
  4151. readcommondef('AnsiString definition',defoptions,strdef);
  4152. strdef.Len:=getasizeint;
  4153. writeln([space,' Length : ',strdef.Len]);
  4154. writeln([space,' Encoding : ',getword]);
  4155. end;
  4156. iblongstringdef :
  4157. begin
  4158. strdef:=TPpuStringDef.Create(ParentDef);
  4159. strdef.StrType:=stLong;
  4160. readcommondef('Longstring definition',defoptions,strdef);
  4161. strdef.Len:=getasizeint;
  4162. writeln([space,' Length : ',strdef.Len]);
  4163. end;
  4164. ibrecorddef :
  4165. begin
  4166. objdef:=TPpuRecordDef.Create(ParentDef);
  4167. readcommondef('Record definition',defoptions, objdef);
  4168. def.Name:=getstring;
  4169. writeln([space,' Name of Record : ',objdef.Name]);
  4170. writeln([space,' Import lib/pkg : ',getstring]);
  4171. write ([space,' Options : ']);
  4172. readobjectdefoptions(objdef);
  4173. if (df_copied_def in defoptions) then
  4174. begin
  4175. Include(TPpuRecordDef(def).Options, ooCopied);
  4176. write([space,' Copied from : ']);
  4177. readderef('',objdef.Ancestor);
  4178. end
  4179. else
  4180. begin
  4181. writeln([space,' FieldAlign : ',shortint(getbyte)]);
  4182. writeln([space,' RecordAlign : ',shortint(getbyte)]);
  4183. writeln([space,' PadAlign : ',shortint(getbyte)]);
  4184. writeln([space,'UseFieldAlignment : ',shortint(getbyte)]);
  4185. writeln([space,' RecordAlignMin : ',shortint(getbyte)]);
  4186. objdef.Size:=getasizeint;
  4187. writeln([space,' DataSize : ',objdef.Size]);
  4188. writeln([space,' PaddingSize : ',getword]);
  4189. readmanagementoperatoroptions(space,'Management operators');
  4190. end;
  4191. {read the record definitions and symbols}
  4192. if not(df_copied_def in current_defoptions) then
  4193. begin
  4194. space:=' '+space;
  4195. readrecordsymtable('fields',TPpuRecordDef(def));
  4196. Delete(space,1,4);
  4197. end;
  4198. if not EndOfEntry then
  4199. HasMoreInfos;
  4200. end;
  4201. ibobjectdef :
  4202. begin
  4203. objdef:=TPpuObjectDef.Create(ParentDef);
  4204. readcommondef('Object/Class definition',defoptions,objdef);
  4205. objdef.Name:=getstring;
  4206. writeln([space,' Name of Class : ',objdef.Name]);
  4207. writeln([space,' Import lib/pkg : ',getstring]);
  4208. write ([space,' Options : ']);
  4209. readobjectdefoptions(objdef);
  4210. otb:=getbyte;
  4211. write ([space,' Type : ']);
  4212. case tobjecttyp(otb) of
  4213. odt_class : writeln('class');
  4214. odt_object : writeln('object');
  4215. odt_interfacecom : writeln('interfacecom');
  4216. odt_interfacecorba : writeln('interfacecorba');
  4217. odt_cppclass : writeln('cppclass');
  4218. odt_dispinterface : writeln('dispinterface');
  4219. odt_objcclass : writeln('objcclass');
  4220. odt_objcprotocol : writeln('objcprotocol');
  4221. odt_helper : writeln('helper');
  4222. odt_objccategory : writeln('objccategory');
  4223. odt_javaclass : writeln('Java class');
  4224. odt_interfacejava : writeln('Java interface');
  4225. else WriteWarning('Invalid object type: ' + IntToStr(b));
  4226. end;
  4227. case tobjecttyp(otb) of
  4228. odt_class, odt_cppclass, odt_objcclass, odt_javaclass:
  4229. objdef.ObjType:=otClass;
  4230. odt_object:
  4231. objdef.ObjType:=otObject;
  4232. odt_interfacecom, odt_interfacecorba, odt_interfacejava, odt_dispinterface:
  4233. objdef.ObjType:=otInterface;
  4234. odt_helper:
  4235. objdef.ObjType:=otHelper;
  4236. end;
  4237. b:=getbyte;
  4238. write ([space,' Helper Type : ']);
  4239. case thelpertype(b) of
  4240. ht_none : writeln('none');
  4241. ht_class : writeln('class helper');
  4242. ht_record : writeln('record helper');
  4243. ht_type : writeln('type helper');
  4244. else WriteWarning('Invalid helper type: ' + IntToStr(b));
  4245. end;
  4246. writeln([space,' External name : ',getstring]);
  4247. objdef.Size:=getasizeint;
  4248. writeln([space,' DataSize : ',objdef.Size]);
  4249. writeln([space,' PaddingSize : ',getword]);
  4250. writeln([space,' FieldAlign : ',shortint(getbyte)]);
  4251. writeln([space,' RecordAlign : ',shortint(getbyte)]);
  4252. writeln([space,' RecordAlignMin : ',shortint(getbyte)]);
  4253. write ([space, ' VmtField : ']);
  4254. readderef('',nil);
  4255. write ([space, ' Ancestor Class : ']);
  4256. readderef('',objdef.Ancestor);
  4257. if tobjecttyp(otb) in [odt_interfacecom,odt_interfacecorba,odt_dispinterface] then
  4258. begin
  4259. { IIDGUID }
  4260. for j:=1to 16 do
  4261. getbyte;
  4262. objdef.IID:=getstring;
  4263. writeln([space,' IID String : ',objdef.IID]);
  4264. end;
  4265. l:=getlongint;
  4266. if l > 0 then
  4267. objdef.Options:=objdef.Options + [ooAbstractMethods];
  4268. writeln([space,' Abstract methods : ',l]);
  4269. if tobjecttyp(otb)=odt_helper then
  4270. begin
  4271. write([space,' Helper parent : ']);
  4272. readderef('',objdef.HelperParent);
  4273. end;
  4274. l:=getlongint;
  4275. writeln([space,' VMT entries: ',l]);
  4276. for j:=1 to l do
  4277. begin
  4278. write([space,' ']);
  4279. readderef('');
  4280. write([space,' Visibility: ']);
  4281. readvisibility;
  4282. end;
  4283. if tobjecttyp(otb) in [odt_class,odt_objcclass,odt_objcprotocol,odt_javaclass,odt_interfacejava] then
  4284. begin
  4285. l:=getlongint;
  4286. writeln([space,' Impl Intf Count : ',l]);
  4287. for j:=1 to l do
  4288. begin
  4289. write ([space,' - Definition : ']);
  4290. readderef('');
  4291. write ([space,' - Getter Def : ']);
  4292. readderef('');
  4293. writeln([space,' IOffset : ',getlongint]);
  4294. writeln([space,' Entry type : ',IntfEntryType2Str(getbyte)]);
  4295. end;
  4296. end;
  4297. if df_copied_def in current_defoptions then
  4298. begin
  4299. Include(objdef.Options, ooCopied);
  4300. writeln(' Copy of def: ');
  4301. readderef('',objdef.Ancestor);
  4302. end
  4303. else
  4304. begin
  4305. {read the record definitions and symbols}
  4306. space:=' '+space;
  4307. readrecordsymtable('fields',objdef);
  4308. Delete(space,1,4);
  4309. end;
  4310. if not EndOfEntry then
  4311. HasMoreInfos;
  4312. end;
  4313. ibfiledef :
  4314. begin
  4315. filedef:=TPpuFileDef.Create(ParentDef);
  4316. ReadCommonDef('File definition',defoptions,filedef);
  4317. write ([space,' Type : ']);
  4318. case getbyte of
  4319. 0 : begin
  4320. writeln('Text');
  4321. filedef.FileType:=ftText;
  4322. end;
  4323. 1 : begin
  4324. writeln('Typed');
  4325. filedef.FileType:=ftTyped;
  4326. write ([space,' File of Type : ']);
  4327. readderef('',filedef.TypeRef);
  4328. end;
  4329. 2 : begin
  4330. writeln('Untyped');
  4331. filedef.FileType:=ftUntyped;
  4332. end;
  4333. end;
  4334. end;
  4335. ibformaldef :
  4336. begin
  4337. def:=TPpuFormalDef.Create(ParentDef);
  4338. readcommondef('Generic definition (void-typ)',defoptions,def);
  4339. TPpuFormalDef(def).IsTyped:=(getbyte<>0);
  4340. writeln([space,' Is Typed : ',TPpuFormalDef(def).IsTyped]);
  4341. end;
  4342. ibundefineddef :
  4343. begin
  4344. def:=TPpuUndefinedDef.Create(ParentDef);
  4345. readcommondef('Undefined definition (generic parameter)',defoptions,def);
  4346. end;
  4347. ibenumdef :
  4348. begin
  4349. enumdef:=TPpuEnumDef.Create(ParentDef);
  4350. readcommondef('Enumeration type definition',defoptions,enumdef);
  4351. enumdef.ElLow:=getaint;
  4352. writeln([space,' Smallest element : ',enumdef.ElLow]);
  4353. enumdef.ElHigh:=getaint;
  4354. writeln([space,' Largest element : ',enumdef.ElHigh]);
  4355. enumdef.Size:=byte(getaint);
  4356. writeln([space,' Size : ',enumdef.Size]);
  4357. if df_copied_def in defoptions then
  4358. begin
  4359. write([space,'Base enumeration type : ']);
  4360. readderef('',enumdef.CopyFrom);
  4361. end
  4362. else
  4363. begin
  4364. space:=' '+space;
  4365. readsymtable('elements',enumdef);
  4366. delete(space,1,4);
  4367. end;
  4368. if tsystemcpu(ppufile.header.common.cpu)=cpu_jvm then
  4369. begin
  4370. write([space,' Class def : ']);
  4371. readderef('');
  4372. end;
  4373. end;
  4374. ibclassrefdef :
  4375. begin
  4376. def:=TPpuClassRefDef.Create(ParentDef);
  4377. readcommondef('Class reference definition',defoptions,def);
  4378. write ([space,' Pointed Type : ']);
  4379. readderef('',TPpuClassRefDef(def).ClassRef);
  4380. end;
  4381. ibsetdef :
  4382. begin
  4383. setdef:=TPpuSetDef.Create(ParentDef);
  4384. readcommondef('Set definition',defoptions,setdef);
  4385. write ([space,' Element type : ']);
  4386. readderef('',setdef.ElType);
  4387. setdef.Size:=getasizeint;
  4388. writeln([space,' Size : ',setdef.Size]);
  4389. setdef.SetBase:=getasizeint;
  4390. writeln([space,' Set Base : ',setdef.SetBase]);
  4391. setdef.SetMax:=getasizeint;
  4392. writeln([space,' Set Max : ',setdef.SetMax]);
  4393. end;
  4394. ibvariantdef :
  4395. begin
  4396. def:=TPpuVariantDef.Create(ParentDef);
  4397. readcommondef('Variant definition',defoptions,def);
  4398. write ([space,' Varianttype : ']);
  4399. b:=getbyte;
  4400. case tvarianttype(b) of
  4401. vt_normalvariant :
  4402. writeln('Normal');
  4403. vt_olevariant :
  4404. begin
  4405. TPpuVariantDef(def).IsOLE:=True;
  4406. writeln('OLE');
  4407. end
  4408. else
  4409. WriteWarning('Invalid varianttype: ' + IntToStr(b));
  4410. end;
  4411. end;
  4412. iberror :
  4413. begin
  4414. WriteError('!! Error in PPU');
  4415. exit;
  4416. end;
  4417. ibenddefs :
  4418. break;
  4419. else
  4420. begin
  4421. WriteError('!! Skipping unsupported PPU Entry in definitions: '+IntToStr(b));
  4422. end;
  4423. end;
  4424. if assigned(def) then
  4425. readdefsubentries(def);
  4426. if (def <> nil) and (def.Parent = nil) then
  4427. def.Free;
  4428. if not EndOfEntry then
  4429. HasMoreInfos;
  4430. until false;
  4431. end;
  4432. end;
  4433. procedure readmoduleoptions(space : string);
  4434. type
  4435. { tmoduleoption type is in unit fmodule }
  4436. tmoduleoption = (mo_none,
  4437. mo_hint_deprecated,
  4438. mo_hint_platform,
  4439. mo_hint_library,
  4440. mo_hint_unimplemented,
  4441. mo_hint_experimental,
  4442. mo_has_deprecated_msg
  4443. );
  4444. tmoduleoptions = set of tmoduleoption;
  4445. tmoduleopt=record
  4446. mask : tmoduleoption;
  4447. str : string[30];
  4448. end;
  4449. const
  4450. moduleopts=ord(high(tmoduleoption));
  4451. moduleopt : array[1..moduleopts] of tmoduleopt=(
  4452. (mask:mo_hint_deprecated; str:'Hint Deprecated'),
  4453. (mask:mo_hint_platform; str:'Hint Platform'),
  4454. (mask:mo_hint_library; str:'Hint Library'),
  4455. (mask:mo_hint_unimplemented; str:'Hint Unimplemented'),
  4456. (mask:mo_hint_experimental; str:'Hint Experimental'),
  4457. (mask:mo_has_deprecated_msg; str:'Has Deprecated Message')
  4458. );
  4459. var
  4460. moduleoptions : tmoduleoptions;
  4461. i : longint;
  4462. first : boolean;
  4463. begin
  4464. ppufile.getset(tppuset1(moduleoptions));
  4465. if moduleoptions<>[] then
  4466. begin
  4467. first:=true;
  4468. for i:=1to moduleopts do
  4469. if (moduleopt[i].mask in moduleoptions) then
  4470. begin
  4471. if first then
  4472. first:=false
  4473. else
  4474. write(', ');
  4475. write(moduleopt[i].str);
  4476. end;
  4477. end;
  4478. writeln;
  4479. if mo_has_deprecated_msg in moduleoptions then
  4480. writeln([space,'Deprecated : ', ppufile.getstring]);
  4481. end;
  4482. {****************************************************************************
  4483. Read General Part
  4484. ****************************************************************************}
  4485. procedure readinterface(silent : boolean);
  4486. var
  4487. b : byte;
  4488. sourcenumber, i : longint;
  4489. feature : tfeature;
  4490. features : tfeatures;
  4491. s : string;
  4492. begin
  4493. with ppufile do
  4494. begin
  4495. repeat
  4496. b:=readentry;
  4497. case b of
  4498. ibmodulename :
  4499. begin
  4500. CurUnit.Name:=getstring;
  4501. if not silent then
  4502. Writeln(['Module Name: ',CurUnit.Name]);
  4503. end;
  4504. ibfeatures :
  4505. begin
  4506. getset(tppuset4(features));
  4507. Writeln('Features: ');
  4508. for feature:=low(tfeatures) to high(tfeature) do
  4509. if feature in features then
  4510. begin
  4511. str(feature,s);
  4512. s:=copy(s,3,255);
  4513. writeln([s]);
  4514. end;
  4515. end;
  4516. ibmoduleoptions:
  4517. if not silent then
  4518. readmoduleoptions(' ');
  4519. ibsourcefiles :
  4520. begin
  4521. sourcenumber:=1;
  4522. if not silent then
  4523. while not EndOfEntry do
  4524. begin
  4525. with TPpuSrcFile.Create(CurUnit.SourceFiles) do begin
  4526. Name:=getstring;
  4527. i:=getlongint;
  4528. try
  4529. if i >= 0 then
  4530. FileTime:=FileDateToDateTime(i);
  4531. Writeln(['Source file ',sourcenumber,' : ',Name,' ',filetimestring(i)]);
  4532. except
  4533. end;
  4534. end;
  4535. inc(sourcenumber);
  4536. end;
  4537. end;
  4538. {$IFDEF MACRO_DIFF_HINT}
  4539. ibusedmacros :
  4540. begin
  4541. if not silent then
  4542. while not EndOfEntry do
  4543. begin
  4544. Write('Conditional ',getstring);
  4545. if getboolean then
  4546. write(' defined at startup')
  4547. else
  4548. write(' not defined at startup');
  4549. if getboolean then
  4550. writeln(' was used')
  4551. else
  4552. writeln;
  4553. end;
  4554. end;
  4555. {$ENDIF}
  4556. ibloadunit :
  4557. if not silent then
  4558. ReadLoadUnit;
  4559. iblinkunitofiles :
  4560. if not silent then
  4561. ReadLinkContainer('Link unit object file: ');
  4562. iblinkunitstaticlibs :
  4563. if not silent then
  4564. ReadLinkContainer('Link unit static lib: ');
  4565. iblinkunitsharedlibs :
  4566. if not silent then
  4567. ReadLinkContainer('Link unit shared lib: ');
  4568. iblinkotherofiles :
  4569. if not silent then
  4570. ReadLinkContainer('Link other object file: ');
  4571. iblinkotherstaticlibs :
  4572. if not silent then
  4573. ReadLinkContainer('Link other static lib: ');
  4574. iblinkothersharedlibs :
  4575. if not silent then
  4576. ReadLinkContainer('Link other shared lib: ');
  4577. iblinkotherframeworks:
  4578. if not silent then
  4579. ReadLinkContainer('Link framework: ');
  4580. ibjvmnamespace:
  4581. Writeln('JVM name space: '+getString);
  4582. ibmainname:
  4583. if not silent then
  4584. Writeln(['Specified main program symbol name: ',getstring]);
  4585. ibImportSymbols :
  4586. if not silent then
  4587. ReadImportSymbols;
  4588. ibderefdata :
  4589. ReadDerefData;
  4590. ibderefmap :
  4591. ReadDerefMap;
  4592. ibwpofile :
  4593. if not silent then
  4594. ReadWpoFileInfo;
  4595. ibresources :
  4596. if not silent then
  4597. ReadContainer('Resource file: ');
  4598. iborderedsymbols:
  4599. if not silent then
  4600. ReadContainer('Ordered symbol: ');
  4601. iberror :
  4602. begin
  4603. WriteError('Error in PPU');
  4604. exit;
  4605. end;
  4606. ibendinterface :
  4607. break;
  4608. else
  4609. begin
  4610. WriteError('!! Skipping unsupported PPU Entry in General Part: '+IntToStr(b));
  4611. end;
  4612. end;
  4613. until false;
  4614. end;
  4615. end;
  4616. {****************************************************************************
  4617. Read Implementation Part
  4618. ****************************************************************************}
  4619. procedure readimplementation;
  4620. var
  4621. b : byte;
  4622. begin
  4623. with ppufile do
  4624. begin
  4625. repeat
  4626. b:=readentry;
  4627. case b of
  4628. ibasmsymbols :
  4629. ReadAsmSymbols;
  4630. ibloadunit :
  4631. ReadLoadUnit;
  4632. ibunitimportsyms :
  4633. ReadUnitImportSyms;
  4634. iberror :
  4635. begin
  4636. WriteError('Error in PPU');
  4637. exit;
  4638. end;
  4639. ibendimplementation :
  4640. break;
  4641. else
  4642. begin
  4643. WriteError('!! Skipping unsupported PPU Entry in Implementation: '+IntToStr(b));
  4644. end;
  4645. end;
  4646. until false;
  4647. end;
  4648. end;
  4649. function parseextraheader(module: TPpuModuleDef; ppufile: tppufile): boolean;
  4650. var
  4651. b: byte;
  4652. begin
  4653. result:=false;
  4654. b:=ppufile.readentry;
  4655. if b<>ibextraheader then
  4656. exit;
  4657. CurUnit.LongVersion:=cardinal(ppufile.getlongint);
  4658. Writeln(['LongVersion: ',CurUnit.LongVersion]);
  4659. ppufile.getset(tppuset4(CurUnit.ModuleFlags));
  4660. result:=ppufile.EndOfEntry and (CurUnit.LongVersion=CurrentPPULongVersion);
  4661. if mf_symansistr in CurUnit.ModuleFlags then
  4662. SymAnsiStr:=true;
  4663. end;
  4664. procedure dofile (filename : string);
  4665. begin
  4666. { reset }
  4667. space:='';
  4668. { fix filename }
  4669. if pos('.',filename)=0 then
  4670. filename:=filename+'.ppu';
  4671. ppufile:=tppudumpfile.create(filename);
  4672. if not ppufile.openfile then
  4673. begin
  4674. WriteError('IO-Error when opening : '+filename+', Skipping');
  4675. exit;
  4676. end;
  4677. { PPU File is open, check for PPU Id }
  4678. if not ppufile.CheckPPUID then
  4679. begin
  4680. WriteError(Filename+' : Not a valid PPU file, Skipping');
  4681. exit;
  4682. end;
  4683. { Check PPU Version }
  4684. ppuversion:=ppufile.getversion;
  4685. Writeln(['Analyzing ',filename,' (v',PPUVersion,')']);
  4686. if not SkipVersionCheck and (PPUVersion <> CurrentPPUVersion) then
  4687. begin
  4688. WriteError(Format('Unsupported PPU version %d. Expecting PPU version %d.', [PPUVersion, CurrentPPUVersion]));
  4689. exit;
  4690. end;
  4691. CurUnit:=TPpuModuleDef.Create(UnitList);
  4692. CurUnit.Version:=ppuversion;
  4693. if not parseextraheader(CurUnit, ppufile) then
  4694. begin
  4695. WriteError(Format('Unsupported PPU sub-version %d. Expecting PPU sub-version %d.', [CurUnit.LongVersion, CurrentPPULongVersion]));
  4696. end;
  4697. { Write PPU Header Information }
  4698. if (verbose and v_header)<>0 then
  4699. begin
  4700. Writeln;
  4701. Writeln('Header');
  4702. Writeln('-------');
  4703. with ppufile.header do
  4704. begin
  4705. Writeln(['Compiler version : ',ppufile.header.common.compiler shr 14,'.',
  4706. (ppufile.header.common.compiler shr 7) and $7f,'.',
  4707. ppufile.header.common.compiler and $7f]);
  4708. WriteLn(['Target processor : ',Cpu2Str(common.cpu)]);
  4709. WriteLn(['Target operating system : ',Target2Str(common.target)]);
  4710. Writeln(['Unit flags : ',PPUFlags2Str(common.flags)]);
  4711. Writeln(['FileSize (w/o header) : ',common.size]);
  4712. Writeln(['Checksum : ',hexstr(checksum,8)]);
  4713. Writeln(['Interface Checksum : ',hexstr(interface_checksum,8)]);
  4714. Writeln(['Indirect Checksum : ',hexstr(indirect_checksum,8)]);
  4715. Writeln(['Definitions stored : ',tostr(deflistsize)]);
  4716. Writeln(['Symbols stored : ',tostr(symlistsize)]);
  4717. end;
  4718. end;
  4719. with ppufile.header do
  4720. begin
  4721. CurUnit.Crc:=checksum;
  4722. CurUnit.IntfCrc:=interface_checksum;
  4723. CurUnit.TargetCPU:=Cpu2Str(common.cpu);
  4724. CurUnit.TargetOS:=Target2Str(common.target);
  4725. end;
  4726. {read the general stuff}
  4727. if (verbose and v_interface)<>0 then
  4728. begin
  4729. Writeln;
  4730. Writeln('Interface section');
  4731. Writeln('------------------');
  4732. readinterface(false);
  4733. end
  4734. { We need derefdata from Interface }
  4735. else if verbose and (v_defs or v_syms or v_implementation)<>0 then
  4736. readinterface(true)
  4737. else
  4738. ppufile.skipuntilentry(ibendinterface);
  4739. Writeln;
  4740. Writeln('Interface symtable');
  4741. Writeln('----------------------');
  4742. readsymtableoptions('interface');
  4743. {read the definitions}
  4744. if (verbose and v_defs)<>0 then
  4745. begin
  4746. Writeln;
  4747. Writeln('Interface definitions');
  4748. Writeln('----------------------');
  4749. readdefinitions('interface', CurUnit);
  4750. end
  4751. else
  4752. ppufile.skipuntilentry(ibenddefs);
  4753. {read the symbols}
  4754. if (verbose and v_syms)<>0 then
  4755. begin
  4756. Writeln;
  4757. Writeln('Interface Symbols');
  4758. Writeln('------------------');
  4759. readsymbols('interface',CurUnit);
  4760. end
  4761. else
  4762. ppufile.skipuntilentry(ibendsyms);
  4763. {read the macro symbols}
  4764. if (verbose and v_syms)<>0 then
  4765. begin
  4766. Writeln;
  4767. Writeln('Interface Macro Symbols');
  4768. Writeln('-----------------------');
  4769. end;
  4770. if ppufile.readentry<>ibexportedmacros then
  4771. begin
  4772. WriteError('!! Error in PPU');
  4773. exit;
  4774. end;
  4775. if ppufile.getboolean then
  4776. begin
  4777. readsymtableoptions('interface macro');
  4778. {skip the definition section for macros (since they are never used) }
  4779. ppufile.skipuntilentry(ibenddefs);
  4780. {read the macro symbols}
  4781. if (verbose and v_syms)<>0 then
  4782. readsymbols('interface macro')
  4783. else
  4784. ppufile.skipuntilentry(ibendsyms);
  4785. end
  4786. else
  4787. Writeln('(no exported macros)');
  4788. {read the implementation stuff}
  4789. if (verbose and v_implementation)<>0 then
  4790. begin
  4791. Writeln;
  4792. Writeln('Implementation section');
  4793. Writeln('-----------------------');
  4794. readimplementation;
  4795. end
  4796. else
  4797. ppufile.skipuntilentry(ibendimplementation);
  4798. {read the static symtable}
  4799. Writeln;
  4800. Writeln('Implementation symtable');
  4801. Writeln('----------------------');
  4802. readsymtableoptions('implementation');
  4803. if (mf_local_symtable in CurUnit.ModuleFlags) then
  4804. begin
  4805. if (verbose and v_defs)<>0 then
  4806. begin
  4807. Writeln;
  4808. Writeln('Static definitions');
  4809. Writeln('----------------------');
  4810. readdefinitions('implementation', nil);
  4811. end
  4812. else
  4813. ppufile.skipuntilentry(ibenddefs);
  4814. {read the symbols}
  4815. if (verbose and v_syms)<>0 then
  4816. begin
  4817. Writeln;
  4818. Writeln('Static Symbols');
  4819. Writeln('------------------');
  4820. readsymbols('implementation');
  4821. end
  4822. else
  4823. ppufile.skipuntilentry(ibendsyms);
  4824. end;
  4825. ReadCreatedObjTypes;
  4826. FreeDerefdata;
  4827. {shutdown ppufile}
  4828. ppufile.closefile;
  4829. ppufile.free;
  4830. Writeln;
  4831. end;
  4832. procedure WriteLogo;
  4833. begin
  4834. writeln(Title+' Version '+version_string);
  4835. writeln(Copyright);
  4836. writeln;
  4837. end;
  4838. procedure help;
  4839. begin
  4840. WriteLogo;
  4841. writeln('usage: ppudump [options] <filename1> <filename2>...');
  4842. writeln;
  4843. writeln('[options] can be:');
  4844. writeln(' -F<format> Set output format to <format>');
  4845. writeln(' t - text format (default)');
  4846. writeln(' j - JSON format');
  4847. writeln(' x - XML format');
  4848. writeln(' -M Exit with ExitCode=2 if more information is available');
  4849. writeln(' -S Skip PPU version check. May lead to reading errors');
  4850. writeln(' -V<verbose> Set verbosity to <verbose>');
  4851. writeln(' H - Show header info');
  4852. writeln(' I - Show interface');
  4853. writeln(' M - Show implementation');
  4854. writeln(' S - Show interface symbols');
  4855. writeln(' D - Show interface definitions');
  4856. writeln(' A - Show all');
  4857. writeln(' -h, -? This helpscreen');
  4858. halt;
  4859. end;
  4860. var
  4861. startpara,
  4862. nrfile,i : longint;
  4863. para : string;
  4864. const
  4865. error_on_more : boolean = false;
  4866. begin
  4867. if paramcount<1 then
  4868. help;
  4869. { turn verbose on by default }
  4870. verbose:=v_all;
  4871. { read options }
  4872. startpara:=1;
  4873. while copy(paramstr(startpara),1,1)='-' do
  4874. begin
  4875. para:=paramstr(startpara);
  4876. case upcase(para[2]) of
  4877. 'F' : begin
  4878. FreeAndNil(pout);
  4879. if Length(para) > 2 then
  4880. case upcase(para[3]) of
  4881. 'T':
  4882. nostdout:=False;
  4883. 'J':
  4884. begin
  4885. nostdout:=True;
  4886. pout:=TPpuJsonOutput.Create(StdOutputHandle);
  4887. end;
  4888. 'X':
  4889. begin
  4890. nostdout:=True;
  4891. pout:=TPpuXmlOutput.Create(StdOutputHandle);
  4892. end;
  4893. else
  4894. begin
  4895. WriteError('Invalid output format: ' + para[3]);
  4896. Halt(1);
  4897. end;
  4898. end;
  4899. end;
  4900. 'M' : error_on_more:=true;
  4901. 'S' : SkipVersionCheck:=True;
  4902. 'V' : begin
  4903. verbose:=0;
  4904. for i:=3 to length(para) do
  4905. case upcase(para[i]) of
  4906. 'H' : verbose:=verbose or v_header;
  4907. 'I' : verbose:=verbose or v_interface;
  4908. 'M' : verbose:=verbose or v_implementation;
  4909. 'D' : verbose:=verbose or v_defs;
  4910. 'S' : verbose:=verbose or v_syms;
  4911. 'A' : verbose:=verbose or v_all;
  4912. end;
  4913. end;
  4914. 'H' : help;
  4915. '?' : help;
  4916. else
  4917. begin
  4918. WriteError('Invalid option: ' + para);
  4919. Halt(1);
  4920. end;
  4921. end;
  4922. inc(startpara);
  4923. end;
  4924. if not nostdout then
  4925. WriteLogo;
  4926. UnitList:=TPpuContainerDef.Create(nil);
  4927. try
  4928. UnitList.ItemsName:='';
  4929. { process files }
  4930. for nrfile:=startpara to paramcount do
  4931. dofile (paramstr(nrfile));
  4932. if not has_errors and (pout <> nil) then
  4933. begin
  4934. pout.Init;
  4935. UnitList.Write(pout);
  4936. pout.Done;
  4937. end;
  4938. finally
  4939. UnitList.Free;
  4940. pout.Free;
  4941. end;
  4942. if has_errors then
  4943. Halt(1);
  4944. if error_on_more and
  4945. (has_more_infos or has_warnings) then
  4946. Halt(2);
  4947. end.