ppudump.pp 165 KB

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