ppudump.pp 165 KB

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