ppudump.pp 165 KB

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