ppudump.pp 173 KB

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