ppudump.pp 165 KB

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