ppudump.pp 172 KB

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