ppudump.pp 166 KB

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