ppudump.pp 172 KB

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