ppudump.pp 165 KB

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