ppudump.pp 171 KB

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