ppudump.pp 173 KB

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