ppudump.pp 173 KB

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