ppudump.pp 165 KB

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