ppudump.pp 165 KB

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