ppudump.pp 169 KB

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