ppudump.pp 165 KB

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