ppudump.pp 166 KB

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