symdef.pas 203 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
  4. Symbol table implementation for the definitions
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit symdef;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. { common }
  23. cutils,cclasses,
  24. { global }
  25. globtype,globals,tokens,
  26. { symtable }
  27. symconst,symbase,symtype,
  28. { ppu }
  29. symppu,ppu,
  30. { node }
  31. node,
  32. { aasm }
  33. aasmbase,aasmtai,
  34. cpubase,cpuinfo,
  35. cgbase
  36. {$ifdef Delphi}
  37. ,dmisc
  38. {$endif}
  39. ;
  40. type
  41. {************************************************
  42. TDef
  43. ************************************************}
  44. tstoreddef = class(tdef)
  45. typesymderef : tderef;
  46. { persistent (available across units) rtti and init tables }
  47. rttitablesym,
  48. inittablesym : tsym; {trttisym}
  49. rttitablesymderef,
  50. inittablesymderef : tderef;
  51. { local (per module) rtti and init tables }
  52. localrttilab : array[trttitype] of tasmlabel;
  53. { linked list of global definitions }
  54. nextglobal,
  55. previousglobal : tstoreddef;
  56. {$ifdef EXTDEBUG}
  57. fileinfo : tfileposinfo;
  58. {$endif}
  59. {$ifdef GDB}
  60. globalnb : word;
  61. is_def_stab_written : tdefstabstatus;
  62. {$endif GDB}
  63. constructor create;
  64. constructor ppuloaddef(ppufile:tcompilerppufile);
  65. destructor destroy;override;
  66. function getcopy : tstoreddef;virtual;
  67. procedure ppuwritedef(ppufile:tcompilerppufile);
  68. procedure ppuwrite(ppufile:tcompilerppufile);virtual;abstract;
  69. procedure buildderef;override;
  70. procedure buildderefimpl;override;
  71. procedure deref;override;
  72. procedure derefimpl;override;
  73. function size:longint;override;
  74. function alignment:longint;override;
  75. function is_publishable : boolean;override;
  76. function needs_inittable : boolean;override;
  77. { debug }
  78. {$ifdef GDB}
  79. function stabstring : pchar;virtual;
  80. procedure concatstabto(asmlist : taasmoutput);virtual;
  81. function NumberString:string;
  82. procedure set_globalnb;virtual;
  83. function allstabstring : pchar;virtual;
  84. {$endif GDB}
  85. { rtti generation }
  86. procedure write_rtti_name;
  87. procedure write_rtti_data(rt:trttitype);virtual;
  88. procedure write_child_rtti_data(rt:trttitype);virtual;
  89. function get_rtti_label(rt:trttitype):tasmsymbol;
  90. { regvars }
  91. function is_intregable : boolean;
  92. function is_fpuregable : boolean;
  93. private
  94. savesize : longint;
  95. end;
  96. tparaitem = class(TLinkedListItem)
  97. paratype : ttype; { required for procvar }
  98. parasym : tsym;
  99. parasymderef : tderef;
  100. defaultvalue : tsym; { tconstsym }
  101. defaultvaluederef : tderef;
  102. paratyp : tvarspez; { required for procvar }
  103. paraloc : array[tcallercallee] of tparalocation;
  104. is_hidden : boolean; { is this a hidden (implicit) parameter }
  105. {$ifdef EXTDEBUG}
  106. eqval : tequaltype;
  107. {$endif EXTDEBUG}
  108. end;
  109. tfiletyp = (ft_text,ft_typed,ft_untyped);
  110. tfiledef = class(tstoreddef)
  111. filetyp : tfiletyp;
  112. typedfiletype : ttype;
  113. constructor createtext;
  114. constructor createuntyped;
  115. constructor createtyped(const tt : ttype);
  116. constructor ppuload(ppufile:tcompilerppufile);
  117. procedure ppuwrite(ppufile:tcompilerppufile);override;
  118. procedure buildderef;override;
  119. procedure deref;override;
  120. function gettypename:string;override;
  121. function getmangledparaname:string;override;
  122. procedure setsize;
  123. { debug }
  124. {$ifdef GDB}
  125. function stabstring : pchar;override;
  126. procedure concatstabto(asmlist : taasmoutput);override;
  127. {$endif GDB}
  128. end;
  129. tvariantdef = class(tstoreddef)
  130. varianttype : tvarianttype;
  131. constructor create(v : tvarianttype);
  132. constructor ppuload(ppufile:tcompilerppufile);
  133. function gettypename:string;override;
  134. procedure ppuwrite(ppufile:tcompilerppufile);override;
  135. procedure setsize;
  136. function needs_inittable : boolean;override;
  137. procedure write_rtti_data(rt:trttitype);override;
  138. {$ifdef GDB}
  139. procedure concatstabto(asmlist : taasmoutput);override;
  140. {$endif GDB}
  141. end;
  142. tformaldef = class(tstoreddef)
  143. constructor create;
  144. constructor ppuload(ppufile:tcompilerppufile);
  145. procedure ppuwrite(ppufile:tcompilerppufile);override;
  146. function gettypename:string;override;
  147. {$ifdef GDB}
  148. function stabstring : pchar;override;
  149. procedure concatstabto(asmlist : taasmoutput);override;
  150. {$endif GDB}
  151. end;
  152. tforwarddef = class(tstoreddef)
  153. tosymname : pstring;
  154. forwardpos : tfileposinfo;
  155. constructor create(const s:string;const pos : tfileposinfo);
  156. destructor destroy;override;
  157. function gettypename:string;override;
  158. end;
  159. terrordef = class(tstoreddef)
  160. constructor create;
  161. function gettypename:string;override;
  162. function getmangledparaname : string;override;
  163. { debug }
  164. {$ifdef GDB}
  165. function stabstring : pchar;override;
  166. procedure concatstabto(asmlist : taasmoutput);override;
  167. {$endif GDB}
  168. end;
  169. { tpointerdef and tclassrefdef should get a common
  170. base class, but I derived tclassrefdef from tpointerdef
  171. to avoid problems with bugs (FK)
  172. }
  173. tpointerdef = class(tstoreddef)
  174. pointertype : ttype;
  175. is_far : boolean;
  176. constructor create(const tt : ttype);
  177. constructor createfar(const tt : ttype);
  178. constructor ppuload(ppufile:tcompilerppufile);
  179. procedure ppuwrite(ppufile:tcompilerppufile);override;
  180. procedure buildderef;override;
  181. procedure deref;override;
  182. function gettypename:string;override;
  183. { debug }
  184. {$ifdef GDB}
  185. function stabstring : pchar;override;
  186. procedure concatstabto(asmlist : taasmoutput);override;
  187. {$endif GDB}
  188. end;
  189. tabstractrecorddef = class(tstoreddef)
  190. private
  191. Count : integer;
  192. FRTTIType : trttitype;
  193. {$ifdef GDB}
  194. StabRecString : pchar;
  195. StabRecSize : Integer;
  196. RecOffset : Integer;
  197. procedure addname(p : tnamedindexitem;arg:pointer);
  198. {$endif}
  199. procedure count_field_rtti(sym : tnamedindexitem;arg:pointer);
  200. procedure write_field_rtti(sym : tnamedindexitem;arg:pointer);
  201. procedure generate_field_rtti(sym : tnamedindexitem;arg:pointer);
  202. public
  203. symtable : tsymtable;
  204. function getsymtable(t:tgetsymtable):tsymtable;override;
  205. end;
  206. trecorddef = class(tabstractrecorddef)
  207. public
  208. isunion : boolean;
  209. constructor create(p : tsymtable);
  210. constructor ppuload(ppufile:tcompilerppufile);
  211. destructor destroy;override;
  212. procedure ppuwrite(ppufile:tcompilerppufile);override;
  213. procedure buildderef;override;
  214. procedure deref;override;
  215. function size:longint;override;
  216. function alignment : longint;override;
  217. function gettypename:string;override;
  218. { debug }
  219. {$ifdef GDB}
  220. function stabstring : pchar;override;
  221. procedure concatstabto(asmlist : taasmoutput);override;
  222. {$endif GDB}
  223. function needs_inittable : boolean;override;
  224. { rtti }
  225. procedure write_child_rtti_data(rt:trttitype);override;
  226. procedure write_rtti_data(rt:trttitype);override;
  227. end;
  228. tprocdef = class;
  229. timplementedinterfaces = class;
  230. tobjectdef = class(tabstractrecorddef)
  231. private
  232. {$ifdef GDB}
  233. procedure addprocname(p :tnamedindexitem;arg:pointer);
  234. {$endif GDB}
  235. procedure count_published_properties(sym:tnamedindexitem;arg:pointer);
  236. procedure write_property_info(sym : tnamedindexitem;arg:pointer);
  237. procedure generate_published_child_rtti(sym : tnamedindexitem;arg:pointer);
  238. procedure count_published_fields(sym:tnamedindexitem;arg:pointer);
  239. procedure writefields(sym:tnamedindexitem;arg:pointer);
  240. public
  241. childof : tobjectdef;
  242. childofderef : tderef;
  243. objname,
  244. objrealname : pstring;
  245. objectoptions : tobjectoptions;
  246. { to be able to have a variable vmt position }
  247. { and no vmt field for objects without virtuals }
  248. vmt_offset : longint;
  249. {$ifdef GDB}
  250. writing_class_record_stab : boolean;
  251. {$endif GDB}
  252. objecttype : tobjectdeftype;
  253. iidguid: pguid;
  254. iidstr: pstring;
  255. lastvtableindex: longint;
  256. { store implemented interfaces defs and name mappings }
  257. implementedinterfaces: timplementedinterfaces;
  258. constructor create(ot : tobjectdeftype;const n : string;c : tobjectdef);
  259. constructor ppuload(ppufile:tcompilerppufile);
  260. destructor destroy;override;
  261. procedure ppuwrite(ppufile:tcompilerppufile);override;
  262. function gettypename:string;override;
  263. procedure buildderef;override;
  264. procedure deref;override;
  265. function getparentdef:tdef;override;
  266. function size : longint;override;
  267. function alignment:longint;override;
  268. function vmtmethodoffset(index:longint):longint;
  269. function members_need_inittable : boolean;
  270. { this should be called when this class implements an interface }
  271. procedure prepareguid;
  272. function is_publishable : boolean;override;
  273. function needs_inittable : boolean;override;
  274. function vmt_mangledname : string;
  275. function rtti_name : string;
  276. procedure check_forwards;
  277. function is_related(d : tobjectdef) : boolean;
  278. function next_free_name_index : longint;
  279. procedure insertvmt;
  280. procedure set_parent(c : tobjectdef);
  281. function searchdestructor : tprocdef;
  282. { debug }
  283. {$ifdef GDB}
  284. function stabstring : pchar;override;
  285. procedure set_globalnb;override;
  286. function classnumberstring : string;
  287. procedure concatstabto(asmlist : taasmoutput);override;
  288. function allstabstring : pchar;override;
  289. {$endif GDB}
  290. { rtti }
  291. procedure write_child_rtti_data(rt:trttitype);override;
  292. procedure write_rtti_data(rt:trttitype);override;
  293. function generate_field_table : tasmlabel;
  294. end;
  295. timplementedinterfaces = class
  296. constructor create;
  297. destructor destroy; override;
  298. function count: longint;
  299. function interfaces(intfindex: longint): tobjectdef;
  300. function interfacesderef(intfindex: longint): tderef;
  301. function ioffsets(intfindex: longint): plongint;
  302. function searchintf(def: tdef): longint;
  303. procedure addintf(def: tdef);
  304. procedure buildderef;
  305. procedure deref;
  306. { add interface reference loaded from ppu }
  307. procedure addintf_deref(const d:tderef);
  308. procedure clearmappings;
  309. procedure addmappings(intfindex: longint; const name, newname: string);
  310. function getmappings(intfindex: longint; const name: string; var nextexist: pointer): string;
  311. procedure clearimplprocs;
  312. procedure addimplproc(intfindex: longint; procdef: tprocdef);
  313. function implproccount(intfindex: longint): longint;
  314. function implprocs(intfindex: longint; procindex: longint): tprocdef;
  315. function isimplmergepossible(intfindex, remainindex: longint; var weight: longint): boolean;
  316. private
  317. finterfaces: tindexarray;
  318. procedure checkindex(intfindex: longint);
  319. end;
  320. tclassrefdef = class(tpointerdef)
  321. constructor create(const t:ttype);
  322. constructor ppuload(ppufile:tcompilerppufile);
  323. procedure ppuwrite(ppufile:tcompilerppufile);override;
  324. function gettypename:string;override;
  325. { debug }
  326. {$ifdef GDB}
  327. function stabstring : pchar;override;
  328. procedure concatstabto(asmlist : taasmoutput);override;
  329. {$endif GDB}
  330. end;
  331. tarraydef = class(tstoreddef)
  332. lowrange,
  333. highrange : longint;
  334. rangetype : ttype;
  335. IsDynamicArray,
  336. IsVariant,
  337. IsConstructor,
  338. IsArrayOfConst : boolean;
  339. protected
  340. _elementtype : ttype;
  341. public
  342. function elesize : longint;
  343. constructor create(l,h : longint;const t : ttype);
  344. constructor ppuload(ppufile:tcompilerppufile);
  345. procedure ppuwrite(ppufile:tcompilerppufile);override;
  346. function gettypename:string;override;
  347. function getmangledparaname : string;override;
  348. procedure setelementtype(t: ttype);
  349. {$ifdef GDB}
  350. function stabstring : pchar;override;
  351. procedure concatstabto(asmlist : taasmoutput);override;
  352. {$endif GDB}
  353. procedure buildderef;override;
  354. procedure deref;override;
  355. function size : longint;override;
  356. function alignment : longint;override;
  357. { returns the label of the range check string }
  358. function needs_inittable : boolean;override;
  359. procedure write_child_rtti_data(rt:trttitype);override;
  360. procedure write_rtti_data(rt:trttitype);override;
  361. property elementtype : ttype Read _ElementType;
  362. end;
  363. torddef = class(tstoreddef)
  364. low,high : TConstExprInt;
  365. typ : tbasetype;
  366. constructor create(t : tbasetype;v,b : TConstExprInt);
  367. constructor ppuload(ppufile:tcompilerppufile);
  368. function getcopy : tstoreddef;override;
  369. procedure ppuwrite(ppufile:tcompilerppufile);override;
  370. function is_publishable : boolean;override;
  371. function gettypename:string;override;
  372. procedure setsize;
  373. { debug }
  374. {$ifdef GDB}
  375. function stabstring : pchar;override;
  376. {$endif GDB}
  377. { rtti }
  378. procedure write_rtti_data(rt:trttitype);override;
  379. end;
  380. tfloatdef = class(tstoreddef)
  381. typ : tfloattype;
  382. constructor create(t : tfloattype);
  383. constructor ppuload(ppufile:tcompilerppufile);
  384. function getcopy : tstoreddef;override;
  385. procedure ppuwrite(ppufile:tcompilerppufile);override;
  386. function gettypename:string;override;
  387. function is_publishable : boolean;override;
  388. procedure setsize;
  389. { debug }
  390. {$ifdef GDB}
  391. function stabstring : pchar;override;
  392. {$endif GDB}
  393. { rtti }
  394. procedure write_rtti_data(rt:trttitype);override;
  395. end;
  396. tabstractprocdef = class(tstoreddef)
  397. { saves a definition to the return type }
  398. rettype : ttype;
  399. parast : tsymtable;
  400. para : tlinkedlist;
  401. proctypeoption : tproctypeoption;
  402. proccalloption : tproccalloption;
  403. procoptions : tprocoptions;
  404. maxparacount,
  405. minparacount : byte;
  406. {$ifdef i386}
  407. fpu_used : byte; { how many stack fpu must be empty }
  408. {$endif i386}
  409. funcret_paraloc : array[tcallercallee] of tparalocation;
  410. has_paraloc_info : boolean; { paraloc info is available }
  411. constructor create(level:byte);
  412. constructor ppuload(ppufile:tcompilerppufile);
  413. destructor destroy;override;
  414. procedure ppuwrite(ppufile:tcompilerppufile);override;
  415. procedure buildderef;override;
  416. procedure deref;override;
  417. procedure releasemem;
  418. function concatpara(afterpara:tparaitem;const tt:ttype;sym : tsym;defval:tsym;vhidden:boolean):tparaitem;
  419. function insertpara(const tt:ttype;sym : tsym;defval:tsym;vhidden:boolean):tparaitem;
  420. procedure removepara(currpara:tparaitem);
  421. function typename_paras(showhidden:boolean): string;
  422. procedure test_if_fpu_result;
  423. function is_methodpointer:boolean;virtual;
  424. function is_addressonly:boolean;virtual;
  425. { debug }
  426. {$ifdef GDB}
  427. function stabstring : pchar;override;
  428. procedure concatstabto(asmlist : taasmoutput);override;
  429. {$endif GDB}
  430. end;
  431. tprocvardef = class(tabstractprocdef)
  432. constructor create(level:byte);
  433. constructor ppuload(ppufile:tcompilerppufile);
  434. procedure ppuwrite(ppufile:tcompilerppufile);override;
  435. procedure buildderef;override;
  436. procedure deref;override;
  437. function getsymtable(t:tgetsymtable):tsymtable;override;
  438. function size : longint;override;
  439. function gettypename:string;override;
  440. function is_publishable : boolean;override;
  441. function is_methodpointer:boolean;override;
  442. function is_addressonly:boolean;override;
  443. { debug }
  444. {$ifdef GDB}
  445. function stabstring : pchar;override;
  446. procedure concatstabto(asmlist : taasmoutput); override;
  447. {$endif GDB}
  448. { rtti }
  449. procedure write_rtti_data(rt:trttitype);override;
  450. end;
  451. tmessageinf = record
  452. case integer of
  453. 0 : (str : pchar);
  454. 1 : (i : longint);
  455. end;
  456. tprocdef = class(tabstractprocdef)
  457. private
  458. _mangledname : pstring;
  459. {$ifdef GDB}
  460. isstabwritten : boolean;
  461. {$endif GDB}
  462. public
  463. extnumber : word;
  464. overloadnumber : word;
  465. messageinf : tmessageinf;
  466. {$ifndef EXTDEBUG}
  467. { where is this function defined and what were the symbol
  468. flags, needed here because there
  469. is only one symbol for all overloaded functions
  470. EXTDEBUG has fileinfo in tdef (PFV) }
  471. fileinfo : tfileposinfo;
  472. {$endif}
  473. symoptions : tsymoptions;
  474. { symbol owning this definition }
  475. procsym : tsym;
  476. procsymderef : tderef;
  477. { alias names }
  478. aliasnames : tstringlist;
  479. { symtables }
  480. localst : tsymtable;
  481. funcretsym : tsym;
  482. funcretsymderef : tderef;
  483. { browser info }
  484. lastref,
  485. defref,
  486. lastwritten : tref;
  487. refcount : longint;
  488. _class : tobjectdef;
  489. _classderef : tderef;
  490. { it's a tree, but this not easy to handle }
  491. { used for inlined procs }
  492. code : tnode;
  493. { name of the result variable to insert in the localsymtable }
  494. resultname : stringid;
  495. { true, if the procedure is only declared }
  496. { (forward procedure) }
  497. forwarddef,
  498. { true if the procedure is declared in the interface }
  499. interfacedef : boolean;
  500. { true if the procedure has a forward declaration }
  501. hasforward : boolean;
  502. { check the problems of manglednames }
  503. has_mangledname : boolean;
  504. constructor create(level:byte);
  505. constructor ppuload(ppufile:tcompilerppufile);
  506. destructor destroy;override;
  507. procedure ppuwrite(ppufile:tcompilerppufile);override;
  508. procedure buildderef;override;
  509. procedure buildderefimpl;override;
  510. procedure deref;override;
  511. procedure derefimpl;override;
  512. function getsymtable(t:tgetsymtable):tsymtable;override;
  513. function gettypename : string;override;
  514. function mangledname : string;
  515. procedure setmangledname(const s : string);
  516. procedure load_references(ppufile:tcompilerppufile;locals:boolean);
  517. function write_references(ppufile:tcompilerppufile;locals:boolean):boolean;
  518. { inserts the local symbol table, if this is not
  519. no local symbol table is built. Should be called only
  520. when we are sure that a local symbol table will be required.
  521. }
  522. procedure insert_localst;
  523. function fullprocname(showhidden:boolean):string;
  524. function cplusplusmangledname : string;
  525. function is_methodpointer:boolean;override;
  526. function is_addressonly:boolean;override;
  527. function is_visible_for_object(currobjdef:tobjectdef):boolean;
  528. { debug }
  529. {$ifdef GDB}
  530. function stabstring : pchar;override;
  531. procedure concatstabto(asmlist : taasmoutput);override;
  532. {$endif GDB}
  533. end;
  534. { single linked list of overloaded procs }
  535. pprocdeflist = ^tprocdeflist;
  536. tprocdeflist = record
  537. def : tprocdef;
  538. defderef : tderef;
  539. next : pprocdeflist;
  540. end;
  541. tstringdef = class(tstoreddef)
  542. string_typ : tstringtype;
  543. len : longint;
  544. constructor createshort(l : byte);
  545. constructor loadshort(ppufile:tcompilerppufile);
  546. constructor createlong(l : longint);
  547. constructor loadlong(ppufile:tcompilerppufile);
  548. constructor createansi(l : longint);
  549. constructor loadansi(ppufile:tcompilerppufile);
  550. constructor createwide(l : longint);
  551. constructor loadwide(ppufile:tcompilerppufile);
  552. function getcopy : tstoreddef;override;
  553. function stringtypname:string;
  554. function size : longint;override;
  555. procedure ppuwrite(ppufile:tcompilerppufile);override;
  556. function gettypename:string;override;
  557. function getmangledparaname:string;override;
  558. function is_publishable : boolean;override;
  559. { debug }
  560. {$ifdef GDB}
  561. function stabstring : pchar;override;
  562. procedure concatstabto(asmlist : taasmoutput);override;
  563. {$endif GDB}
  564. { init/final }
  565. function needs_inittable : boolean;override;
  566. { rtti }
  567. procedure write_rtti_data(rt:trttitype);override;
  568. end;
  569. tenumdef = class(tstoreddef)
  570. minval,
  571. maxval : longint;
  572. has_jumps : boolean;
  573. firstenum : tsym; {tenumsym}
  574. basedef : tenumdef;
  575. basedefderef : tderef;
  576. constructor create;
  577. constructor create_subrange(_basedef:tenumdef;_min,_max:longint);
  578. constructor ppuload(ppufile:tcompilerppufile);
  579. destructor destroy;override;
  580. procedure ppuwrite(ppufile:tcompilerppufile);override;
  581. procedure buildderef;override;
  582. procedure deref;override;
  583. function gettypename:string;override;
  584. function is_publishable : boolean;override;
  585. procedure calcsavesize;
  586. procedure setmax(_max:longint);
  587. procedure setmin(_min:longint);
  588. function min:longint;
  589. function max:longint;
  590. { debug }
  591. {$ifdef GDB}
  592. function stabstring : pchar;override;
  593. {$endif GDB}
  594. { rtti }
  595. procedure write_rtti_data(rt:trttitype);override;
  596. procedure write_child_rtti_data(rt:trttitype);override;
  597. private
  598. procedure correct_owner_symtable;
  599. end;
  600. tsetdef = class(tstoreddef)
  601. elementtype : ttype;
  602. settype : tsettype;
  603. constructor create(const t:ttype;high : longint);
  604. constructor ppuload(ppufile:tcompilerppufile);
  605. destructor destroy;override;
  606. procedure ppuwrite(ppufile:tcompilerppufile);override;
  607. procedure buildderef;override;
  608. procedure deref;override;
  609. function gettypename:string;override;
  610. function is_publishable : boolean;override;
  611. { debug }
  612. {$ifdef GDB}
  613. function stabstring : pchar;override;
  614. procedure concatstabto(asmlist : taasmoutput);override;
  615. {$endif GDB}
  616. { rtti }
  617. procedure write_rtti_data(rt:trttitype);override;
  618. procedure write_child_rtti_data(rt:trttitype);override;
  619. end;
  620. Tdefmatch=(dm_exact,dm_equal,dm_convertl1);
  621. var
  622. aktobjectdef : tobjectdef; { used for private functions check !! }
  623. firstglobaldef, { linked list of all globals defs }
  624. lastglobaldef : tstoreddef; { used to reset stabs/ranges }
  625. {$ifdef GDB}
  626. { for STAB debugging }
  627. globaltypecount : word;
  628. pglobaltypecount : pword;
  629. {$endif GDB}
  630. { default types }
  631. generrortype, { error in definition }
  632. voidpointertype, { pointer for Void-Pointerdef }
  633. charpointertype, { pointer for Char-Pointerdef }
  634. voidfarpointertype,
  635. cformaltype, { unique formal definition }
  636. voidtype, { Pointer to Void (procedure) }
  637. cchartype, { Pointer to Char }
  638. cwidechartype, { Pointer to WideChar }
  639. booltype, { pointer to boolean type }
  640. u8bittype, { Pointer to 8-Bit unsigned }
  641. u16bittype, { Pointer to 16-Bit unsigned }
  642. u32bittype, { Pointer to 32-Bit unsigned }
  643. s32bittype, { Pointer to 32-Bit signed }
  644. cu64bittype, { pointer to 64 bit unsigned def }
  645. cs64bittype, { pointer to 64 bit signed def, }
  646. s32floattype, { pointer for realconstn }
  647. s64floattype, { pointer for realconstn }
  648. s80floattype, { pointer to type of temp. floats }
  649. s64currencytype, { pointer to a currency type }
  650. s32fixedtype, { pointer to type of temp. fixed }
  651. cshortstringtype, { pointer to type of short string const }
  652. clongstringtype, { pointer to type of long string const }
  653. cansistringtype, { pointer to type of ansi string const }
  654. cwidestringtype, { pointer to type of wide string const }
  655. openshortstringtype, { pointer to type of an open shortstring,
  656. needed for readln() }
  657. openchararraytype, { pointer to type of an open array of char,
  658. needed for readln() }
  659. cfiletype, { get the same definition for all file }
  660. { used for stabs }
  661. methodpointertype, { typecasting of methodpointers to extract self }
  662. { we use only one variant def for every variant class }
  663. cvarianttype,
  664. colevarianttype,
  665. { unsigned ord type with the same size as a pointer }
  666. ordpointertype,
  667. defaultordconsttype, { pointer to type of ordinal constants }
  668. pvmttype : ttype; { type of classrefs, used for stabs }
  669. { pointer to the anchestor of all classes }
  670. class_tobject : tobjectdef;
  671. { pointer to the ancestor of all COM interfaces }
  672. interface_iunknown : tobjectdef;
  673. { pointer to the TGUID type
  674. of all interfaces }
  675. rec_tguid : trecorddef;
  676. { Pointer to a procdef with no parameters and no return value.
  677. This is used for procedures which are generated automatically
  678. by the compiler.
  679. }
  680. voidprocdef : tprocdef;
  681. const
  682. {$ifdef i386}
  683. pbestrealtype : ^ttype = @s80floattype;
  684. {$endif}
  685. {$ifdef x86_64}
  686. pbestrealtype : ^ttype = @s80floattype;
  687. {$endif}
  688. {$ifdef m68k}
  689. pbestrealtype : ^ttype = @s64floattype;
  690. {$endif}
  691. {$ifdef alpha}
  692. pbestrealtype : ^ttype = @s64floattype;
  693. {$endif}
  694. {$ifdef powerpc}
  695. pbestrealtype : ^ttype = @s64floattype;
  696. {$endif}
  697. {$ifdef ia64}
  698. pbestrealtype : ^ttype = @s64floattype;
  699. {$endif}
  700. {$ifdef SPARC}
  701. pbestrealtype : ^ttype = @s64floattype;
  702. {$endif SPARC}
  703. {$ifdef vis}
  704. pbestrealtype : ^ttype = @s64floattype;
  705. {$endif vis}
  706. {$ifdef ARM}
  707. pbestrealtype : ^ttype = @s64floattype;
  708. {$endif ARM}
  709. function reverseparaitems(p: tparaitem): tparaitem;
  710. function mangledname_prefix(typeprefix:string;st:tsymtable):string;
  711. {$ifdef GDB}
  712. { GDB Helpers }
  713. function typeglobalnumber(const s : string) : string;
  714. {$endif GDB}
  715. { should be in the types unit, but the types unit uses the node stuff :( }
  716. function is_interfacecom(def: tdef): boolean;
  717. function is_interfacecorba(def: tdef): boolean;
  718. function is_interface(def: tdef): boolean;
  719. function is_object(def: tdef): boolean;
  720. function is_class(def: tdef): boolean;
  721. function is_cppclass(def: tdef): boolean;
  722. function is_class_or_interface(def: tdef): boolean;
  723. procedure reset_global_defs;
  724. implementation
  725. uses
  726. {$ifdef Delphi}
  727. sysutils,
  728. {$else Delphi}
  729. strings,
  730. {$endif Delphi}
  731. { global }
  732. verbose,
  733. { target }
  734. systems,aasmcpu,paramgr,
  735. { symtable }
  736. symsym,symtable,symutil,defutil,
  737. { module }
  738. {$ifdef GDB}
  739. gdb,
  740. {$endif GDB}
  741. fmodule,
  742. { other }
  743. gendef
  744. ;
  745. {****************************************************************************
  746. Helpers
  747. ****************************************************************************}
  748. function reverseparaitems(p: tparaitem): tparaitem;
  749. var
  750. hp1, hp2: tparaitem;
  751. begin
  752. hp1:=nil;
  753. while assigned(p) do
  754. begin
  755. { pull out }
  756. hp2:=p;
  757. p:=tparaitem(p.next);
  758. { pull in }
  759. tparaitem(hp2.next):=hp1;
  760. hp1:=hp2;
  761. end;
  762. reverseparaitems:=hp1;
  763. end;
  764. function mangledname_prefix(typeprefix:string;st:tsymtable):string;
  765. var
  766. s,
  767. prefix : string;
  768. begin
  769. prefix:='';
  770. if not assigned(st) then
  771. internalerror(200204212);
  772. { sub procedures }
  773. while (st.symtabletype=localsymtable) do
  774. begin
  775. if st.defowner.deftype<>procdef then
  776. internalerror(200204173);
  777. s:=tprocdef(st.defowner).procsym.name;
  778. if tprocdef(st.defowner).overloadnumber>0 then
  779. s:=s+'$'+tostr(tprocdef(st.defowner).overloadnumber);
  780. prefix:=s+'$'+prefix;
  781. st:=st.defowner.owner;
  782. end;
  783. { object/classes symtable }
  784. if (st.symtabletype=objectsymtable) then
  785. begin
  786. if st.defowner.deftype<>objectdef then
  787. internalerror(200204174);
  788. prefix:=tobjectdef(st.defowner).objname^+'_$_'+prefix;
  789. st:=st.defowner.owner;
  790. end;
  791. { symtable must now be static or global }
  792. if not(st.symtabletype in [staticsymtable,globalsymtable]) then
  793. internalerror(200204175);
  794. mangledname_prefix:=typeprefix+'_'+st.name^+'_'+prefix;
  795. end;
  796. {$ifdef GDB}
  797. procedure forcestabto(asmlist : taasmoutput; pd : tdef);
  798. begin
  799. if tstoreddef(pd).is_def_stab_written = not_written then
  800. begin
  801. if assigned(pd.typesym) then
  802. ttypesym(pd.typesym).isusedinstab := true;
  803. tstoreddef(pd).concatstabto(asmlist);
  804. end;
  805. end;
  806. {$endif GDB}
  807. {****************************************************************************
  808. TDEF (base class for definitions)
  809. ****************************************************************************}
  810. constructor tstoreddef.create;
  811. begin
  812. inherited create;
  813. savesize := 0;
  814. {$ifdef EXTDEBUG}
  815. fileinfo := aktfilepos;
  816. {$endif}
  817. if registerdef then
  818. symtablestack.registerdef(self);
  819. {$ifdef GDB}
  820. is_def_stab_written := not_written;
  821. globalnb := 0;
  822. {$endif GDB}
  823. if assigned(lastglobaldef) then
  824. begin
  825. lastglobaldef.nextglobal := self;
  826. previousglobal:=lastglobaldef;
  827. end
  828. else
  829. begin
  830. firstglobaldef := self;
  831. previousglobal := nil;
  832. end;
  833. lastglobaldef := self;
  834. nextglobal := nil;
  835. fillchar(localrttilab,sizeof(localrttilab),0);
  836. end;
  837. constructor tstoreddef.ppuloaddef(ppufile:tcompilerppufile);
  838. begin
  839. inherited create;
  840. {$ifdef EXTDEBUG}
  841. fillchar(fileinfo,sizeof(fileinfo),0);
  842. {$endif}
  843. {$ifdef GDB}
  844. is_def_stab_written := not_written;
  845. globalnb := 0;
  846. {$endif GDB}
  847. if assigned(lastglobaldef) then
  848. begin
  849. lastglobaldef.nextglobal := self;
  850. previousglobal:=lastglobaldef;
  851. end
  852. else
  853. begin
  854. firstglobaldef := self;
  855. previousglobal:=nil;
  856. end;
  857. lastglobaldef := self;
  858. nextglobal := nil;
  859. fillchar(localrttilab,sizeof(localrttilab),0);
  860. { load }
  861. indexnr:=ppufile.getword;
  862. ppufile.getderef(typesymderef);
  863. ppufile.getsmallset(defoptions);
  864. if df_has_rttitable in defoptions then
  865. ppufile.getderef(rttitablesymderef);
  866. if df_has_inittable in defoptions then
  867. ppufile.getderef(inittablesymderef);
  868. end;
  869. destructor tstoreddef.destroy;
  870. begin
  871. { first element ? }
  872. if not(assigned(previousglobal)) then
  873. begin
  874. firstglobaldef := nextglobal;
  875. if assigned(firstglobaldef) then
  876. firstglobaldef.previousglobal:=nil;
  877. end
  878. else
  879. begin
  880. { remove reference in the element before }
  881. previousglobal.nextglobal:=nextglobal;
  882. end;
  883. { last element ? }
  884. if not(assigned(nextglobal)) then
  885. begin
  886. lastglobaldef := previousglobal;
  887. if assigned(lastglobaldef) then
  888. lastglobaldef.nextglobal:=nil;
  889. end
  890. else
  891. nextglobal.previousglobal:=previousglobal;
  892. previousglobal:=nil;
  893. nextglobal:=nil;
  894. end;
  895. function tstoreddef.getcopy : tstoreddef;
  896. begin
  897. Message(sym_e_cant_create_unique_type);
  898. getcopy:=nil;
  899. end;
  900. procedure tstoreddef.ppuwritedef(ppufile:tcompilerppufile);
  901. begin
  902. ppufile.putword(indexnr);
  903. ppufile.putderef(typesymderef);
  904. ppufile.putsmallset(defoptions);
  905. if df_has_rttitable in defoptions then
  906. ppufile.putderef(rttitablesymderef);
  907. if df_has_inittable in defoptions then
  908. ppufile.putderef(inittablesymderef);
  909. {$ifdef GDB}
  910. if globalnb = 0 then
  911. begin
  912. if assigned(owner) then
  913. globalnb := owner.getnewtypecount
  914. else
  915. begin
  916. globalnb := PGlobalTypeCount^;
  917. Inc(PGlobalTypeCount^);
  918. end;
  919. end;
  920. {$endif GDB}
  921. end;
  922. procedure tstoreddef.buildderef;
  923. begin
  924. typesymderef.build(typesym);
  925. rttitablesymderef.build(rttitablesym);
  926. inittablesymderef.build(inittablesym);
  927. end;
  928. procedure tstoreddef.buildderefimpl;
  929. begin
  930. end;
  931. procedure tstoreddef.deref;
  932. begin
  933. typesym:=ttypesym(typesymderef.resolve);
  934. if df_has_rttitable in defoptions then
  935. rttitablesym:=trttisym(rttitablesymderef.resolve);
  936. if df_has_inittable in defoptions then
  937. inittablesym:=trttisym(inittablesymderef.resolve);
  938. end;
  939. procedure tstoreddef.derefimpl;
  940. begin
  941. end;
  942. function tstoreddef.size : longint;
  943. begin
  944. size:=savesize;
  945. end;
  946. function tstoreddef.alignment : longint;
  947. begin
  948. { normal alignment by default }
  949. alignment:=0;
  950. end;
  951. {$ifdef GDB}
  952. procedure tstoreddef.set_globalnb;
  953. begin
  954. globalnb :=PGlobalTypeCount^;
  955. inc(PglobalTypeCount^);
  956. end;
  957. function tstoreddef.stabstring : pchar;
  958. begin
  959. stabstring := strpnew('t'+numberstring+';');
  960. end;
  961. function tstoreddef.numberstring : string;
  962. var table : tsymtable;
  963. begin
  964. {formal def have no type !}
  965. if deftype = formaldef then
  966. begin
  967. numberstring := tstoreddef(voidtype.def).numberstring;
  968. exit;
  969. end;
  970. if (not assigned(typesym)) or (not ttypesym(typesym).isusedinstab) then
  971. begin
  972. {set even if debuglist is not defined}
  973. if assigned(typesym) then
  974. ttypesym(typesym).isusedinstab := true;
  975. if assigned(debuglist) and (is_def_stab_written = not_written) then
  976. concatstabto(debuglist);
  977. end;
  978. if not (cs_gdb_dbx in aktglobalswitches) then
  979. begin
  980. if globalnb = 0 then
  981. set_globalnb;
  982. numberstring := tostr(globalnb);
  983. end
  984. else
  985. begin
  986. if globalnb = 0 then
  987. begin
  988. if assigned(owner) then
  989. globalnb := owner.getnewtypecount
  990. else
  991. begin
  992. globalnb := PGlobalTypeCount^;
  993. Inc(PGlobalTypeCount^);
  994. end;
  995. end;
  996. if assigned(typesym) then
  997. begin
  998. table := ttypesym(typesym).owner;
  999. if table.unitid > 0 then
  1000. numberstring := '('+tostr(table.unitid)+','+tostr(tstoreddef(ttypesym(typesym).restype.def).globalnb)+')'
  1001. else
  1002. numberstring := tostr(globalnb);
  1003. exit;
  1004. end;
  1005. numberstring := tostr(globalnb);
  1006. end;
  1007. end;
  1008. function tstoreddef.allstabstring : pchar;
  1009. var stabchar : string[2];
  1010. ss,st : pchar;
  1011. sname : string;
  1012. sym_line_no : longint;
  1013. begin
  1014. ss := stabstring;
  1015. getmem(st,strlen(ss)+512);
  1016. stabchar := 't';
  1017. if deftype in tagtypes then
  1018. stabchar := 'Tt';
  1019. if assigned(typesym) then
  1020. begin
  1021. sname := ttypesym(typesym).name;
  1022. sym_line_no:=ttypesym(typesym).fileinfo.line;
  1023. end
  1024. else
  1025. begin
  1026. sname := ' ';
  1027. sym_line_no:=0;
  1028. end;
  1029. strpcopy(st,'"'+sname+':'+stabchar+numberstring+'=');
  1030. strpcopy(strecopy(strend(st),ss),'",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0');
  1031. allstabstring := strnew(st);
  1032. freemem(st,strlen(ss)+512);
  1033. strdispose(ss);
  1034. end;
  1035. procedure tstoreddef.concatstabto(asmlist : taasmoutput);
  1036. var stab_str : pchar;
  1037. begin
  1038. if ((typesym = nil) or ttypesym(typesym).isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  1039. and (is_def_stab_written = not_written) then
  1040. begin
  1041. If cs_gdb_dbx in aktglobalswitches then
  1042. begin
  1043. { otherwise you get two of each def }
  1044. If assigned(typesym) then
  1045. begin
  1046. if ttypesym(typesym).typ=symconst.typesym then
  1047. ttypesym(typesym).isusedinstab:=true;
  1048. if (ttypesym(typesym).owner = nil) or
  1049. ((ttypesym(typesym).owner.symtabletype = globalsymtable) and
  1050. tglobalsymtable(ttypesym(typesym).owner).dbx_count_ok) then
  1051. begin
  1052. {with DBX we get the definition from the other objects }
  1053. is_def_stab_written := written;
  1054. exit;
  1055. end;
  1056. end;
  1057. end;
  1058. { to avoid infinite loops }
  1059. is_def_stab_written := being_written;
  1060. stab_str := allstabstring;
  1061. asmList.concat(Tai_stabs.Create(stab_str));
  1062. is_def_stab_written := written;
  1063. end;
  1064. end;
  1065. {$endif GDB}
  1066. procedure tstoreddef.write_rtti_name;
  1067. var
  1068. str : string;
  1069. begin
  1070. { name }
  1071. if assigned(typesym) then
  1072. begin
  1073. str:=ttypesym(typesym).realname;
  1074. rttiList.concat(Tai_string.Create(chr(length(str))+str));
  1075. end
  1076. else
  1077. rttiList.concat(Tai_string.Create(#0))
  1078. end;
  1079. procedure tstoreddef.write_rtti_data(rt:trttitype);
  1080. begin
  1081. rttilist.concat(tai_const.create_8bit(tkUnknown));
  1082. write_rtti_name;
  1083. end;
  1084. procedure tstoreddef.write_child_rtti_data(rt:trttitype);
  1085. begin
  1086. end;
  1087. function tstoreddef.get_rtti_label(rt:trttitype) : tasmsymbol;
  1088. begin
  1089. { try to reuse persistent rtti data }
  1090. if (rt=fullrtti) and (df_has_rttitable in defoptions) then
  1091. get_rtti_label:=trttisym(rttitablesym).get_label
  1092. else
  1093. if (rt=initrtti) and (df_has_inittable in defoptions) then
  1094. get_rtti_label:=trttisym(inittablesym).get_label
  1095. else
  1096. begin
  1097. if not assigned(localrttilab[rt]) then
  1098. begin
  1099. objectlibrary.getdatalabel(localrttilab[rt]);
  1100. write_child_rtti_data(rt);
  1101. if (cs_create_smart in aktmoduleswitches) then
  1102. rttiList.concat(Tai_cut.Create);
  1103. rttiList.concat(Tai_align.create(const_align(pointer_size)));
  1104. if (cs_create_smart in aktmoduleswitches) then
  1105. rttiList.concat(Tai_symbol.Create_global(localrttilab[rt],0))
  1106. else
  1107. rttiList.concat(Tai_symbol.Create(localrttilab[rt],0));
  1108. write_rtti_data(rt);
  1109. rttiList.concat(Tai_symbol_end.Create(localrttilab[rt]));
  1110. end;
  1111. get_rtti_label:=localrttilab[rt];
  1112. end;
  1113. end;
  1114. { returns true, if the definition can be published }
  1115. function tstoreddef.is_publishable : boolean;
  1116. begin
  1117. is_publishable:=false;
  1118. end;
  1119. { needs an init table }
  1120. function tstoreddef.needs_inittable : boolean;
  1121. begin
  1122. needs_inittable:=false;
  1123. end;
  1124. function tstoreddef.is_intregable : boolean;
  1125. begin
  1126. is_intregable:=false;
  1127. case deftype of
  1128. pointerdef,
  1129. enumdef:
  1130. is_intregable:=true;
  1131. procvardef :
  1132. is_intregable:=not(po_methodpointer in tprocvardef(self).procoptions);
  1133. orddef :
  1134. case torddef(self).typ of
  1135. bool8bit,bool16bit,bool32bit,
  1136. u8bit,u16bit,u32bit,
  1137. s8bit,s16bit,s32bit:
  1138. is_intregable:=true;
  1139. end;
  1140. objectdef:
  1141. is_intregable:=is_class(self) or is_interface(self);
  1142. setdef:
  1143. is_intregable:=(tsetdef(self).settype=smallset);
  1144. end;
  1145. end;
  1146. function tstoreddef.is_fpuregable : boolean;
  1147. begin
  1148. is_fpuregable:=(deftype=floatdef);
  1149. end;
  1150. {****************************************************************************
  1151. Tstringdef
  1152. ****************************************************************************}
  1153. constructor tstringdef.createshort(l : byte);
  1154. begin
  1155. inherited create;
  1156. string_typ:=st_shortstring;
  1157. deftype:=stringdef;
  1158. len:=l;
  1159. savesize:=len+1;
  1160. end;
  1161. constructor tstringdef.loadshort(ppufile:tcompilerppufile);
  1162. begin
  1163. inherited ppuloaddef(ppufile);
  1164. string_typ:=st_shortstring;
  1165. deftype:=stringdef;
  1166. len:=ppufile.getbyte;
  1167. savesize:=len+1;
  1168. end;
  1169. constructor tstringdef.createlong(l : longint);
  1170. begin
  1171. inherited create;
  1172. string_typ:=st_longstring;
  1173. deftype:=stringdef;
  1174. len:=l;
  1175. savesize:=POINTER_SIZE;
  1176. end;
  1177. constructor tstringdef.loadlong(ppufile:tcompilerppufile);
  1178. begin
  1179. inherited ppuloaddef(ppufile);
  1180. deftype:=stringdef;
  1181. string_typ:=st_longstring;
  1182. len:=ppufile.getlongint;
  1183. savesize:=POINTER_SIZE;
  1184. end;
  1185. constructor tstringdef.createansi(l : longint);
  1186. begin
  1187. inherited create;
  1188. string_typ:=st_ansistring;
  1189. deftype:=stringdef;
  1190. len:=l;
  1191. savesize:=POINTER_SIZE;
  1192. end;
  1193. constructor tstringdef.loadansi(ppufile:tcompilerppufile);
  1194. begin
  1195. inherited ppuloaddef(ppufile);
  1196. deftype:=stringdef;
  1197. string_typ:=st_ansistring;
  1198. len:=ppufile.getlongint;
  1199. savesize:=POINTER_SIZE;
  1200. end;
  1201. constructor tstringdef.createwide(l : longint);
  1202. begin
  1203. inherited create;
  1204. string_typ:=st_widestring;
  1205. deftype:=stringdef;
  1206. len:=l;
  1207. savesize:=POINTER_SIZE;
  1208. end;
  1209. constructor tstringdef.loadwide(ppufile:tcompilerppufile);
  1210. begin
  1211. inherited ppuloaddef(ppufile);
  1212. deftype:=stringdef;
  1213. string_typ:=st_widestring;
  1214. len:=ppufile.getlongint;
  1215. savesize:=POINTER_SIZE;
  1216. end;
  1217. function tstringdef.getcopy : tstoreddef;
  1218. begin
  1219. result:=tstringdef.create;
  1220. result.deftype:=stringdef;
  1221. tstringdef(result).string_typ:=string_typ;
  1222. tstringdef(result).len:=len;
  1223. tstringdef(result).savesize:=savesize;
  1224. end;
  1225. function tstringdef.stringtypname:string;
  1226. const
  1227. typname:array[tstringtype] of string[8]=('',
  1228. 'shortstr','longstr','ansistr','widestr'
  1229. );
  1230. begin
  1231. stringtypname:=typname[string_typ];
  1232. end;
  1233. function tstringdef.size : longint;
  1234. begin
  1235. size:=savesize;
  1236. end;
  1237. procedure tstringdef.ppuwrite(ppufile:tcompilerppufile);
  1238. begin
  1239. inherited ppuwritedef(ppufile);
  1240. if string_typ=st_shortstring then
  1241. begin
  1242. {$ifdef extdebug}
  1243. if len > 255 then internalerror(12122002);
  1244. {$endif}
  1245. ppufile.putbyte(byte(len))
  1246. end
  1247. else
  1248. ppufile.putlongint(len);
  1249. case string_typ of
  1250. st_shortstring : ppufile.writeentry(ibshortstringdef);
  1251. st_longstring : ppufile.writeentry(iblongstringdef);
  1252. st_ansistring : ppufile.writeentry(ibansistringdef);
  1253. st_widestring : ppufile.writeentry(ibwidestringdef);
  1254. end;
  1255. end;
  1256. {$ifdef GDB}
  1257. function tstringdef.stabstring : pchar;
  1258. var
  1259. bytest,charst,longst : string;
  1260. begin
  1261. case string_typ of
  1262. st_shortstring:
  1263. begin
  1264. charst := typeglobalnumber('char');
  1265. { this is what I found in stabs.texinfo but
  1266. gdb 4.12 for go32 doesn't understand that !! }
  1267. {$IfDef GDBknowsstrings}
  1268. stabstring := strpnew('n'+charst+';'+tostr(len));
  1269. {$else}
  1270. bytest := typeglobalnumber('byte');
  1271. stabstring := strpnew('s'+tostr(len+1)+'length:'+bytest
  1272. +',0,8;st:ar'+bytest
  1273. +';1;'+tostr(len)+';'+charst+',8,'+tostr(len*8)+';;');
  1274. {$EndIf}
  1275. end;
  1276. st_longstring:
  1277. begin
  1278. charst := typeglobalnumber('char');
  1279. { this is what I found in stabs.texinfo but
  1280. gdb 4.12 for go32 doesn't understand that !! }
  1281. {$IfDef GDBknowsstrings}
  1282. stabstring := strpnew('n'+charst+';'+tostr(len));
  1283. {$else}
  1284. bytest := typeglobalnumber('byte');
  1285. longst := typeglobalnumber('longint');
  1286. stabstring := strpnew('s'+tostr(len+5)+'length:'+longst
  1287. +',0,32;dummy:'+bytest+',32,8;st:ar'+bytest
  1288. +';1;'+tostr(len)+';'+charst+',40,'+tostr(len*8)+';;');
  1289. {$EndIf}
  1290. end;
  1291. st_ansistring:
  1292. begin
  1293. { an ansi string looks like a pchar easy !! }
  1294. stabstring:=strpnew('*'+typeglobalnumber('char'));
  1295. end;
  1296. st_widestring:
  1297. begin
  1298. { an ansi string looks like a pwidechar easy !! }
  1299. stabstring:=strpnew('*'+typeglobalnumber('widechar'));
  1300. end;
  1301. end;
  1302. end;
  1303. procedure tstringdef.concatstabto(asmlist : taasmoutput);
  1304. begin
  1305. inherited concatstabto(asmlist);
  1306. end;
  1307. {$endif GDB}
  1308. function tstringdef.needs_inittable : boolean;
  1309. begin
  1310. needs_inittable:=string_typ in [st_ansistring,st_widestring];
  1311. end;
  1312. function tstringdef.gettypename : string;
  1313. const
  1314. names : array[tstringtype] of string[20] = ('',
  1315. 'ShortString','LongString','AnsiString','WideString');
  1316. begin
  1317. gettypename:=names[string_typ];
  1318. end;
  1319. procedure tstringdef.write_rtti_data(rt:trttitype);
  1320. begin
  1321. case string_typ of
  1322. st_ansistring:
  1323. begin
  1324. rttiList.concat(Tai_const.Create_8bit(tkAString));
  1325. write_rtti_name;
  1326. end;
  1327. st_widestring:
  1328. begin
  1329. rttiList.concat(Tai_const.Create_8bit(tkWString));
  1330. write_rtti_name;
  1331. end;
  1332. st_longstring:
  1333. begin
  1334. rttiList.concat(Tai_const.Create_8bit(tkLString));
  1335. write_rtti_name;
  1336. end;
  1337. st_shortstring:
  1338. begin
  1339. rttiList.concat(Tai_const.Create_8bit(tkSString));
  1340. write_rtti_name;
  1341. rttiList.concat(Tai_const.Create_8bit(len));
  1342. end;
  1343. end;
  1344. end;
  1345. function tstringdef.getmangledparaname : string;
  1346. begin
  1347. getmangledparaname:='STRING';
  1348. end;
  1349. function tstringdef.is_publishable : boolean;
  1350. begin
  1351. is_publishable:=true;
  1352. end;
  1353. {****************************************************************************
  1354. TENUMDEF
  1355. ****************************************************************************}
  1356. constructor tenumdef.create;
  1357. begin
  1358. inherited create;
  1359. deftype:=enumdef;
  1360. minval:=0;
  1361. maxval:=0;
  1362. calcsavesize;
  1363. has_jumps:=false;
  1364. basedef:=nil;
  1365. firstenum:=nil;
  1366. correct_owner_symtable;
  1367. end;
  1368. constructor tenumdef.create_subrange(_basedef:tenumdef;_min,_max:longint);
  1369. begin
  1370. inherited create;
  1371. deftype:=enumdef;
  1372. minval:=_min;
  1373. maxval:=_max;
  1374. basedef:=_basedef;
  1375. calcsavesize;
  1376. has_jumps:=false;
  1377. firstenum:=basedef.firstenum;
  1378. while assigned(firstenum) and (tenumsym(firstenum).value<>minval) do
  1379. firstenum:=tenumsym(firstenum).nextenum;
  1380. correct_owner_symtable;
  1381. end;
  1382. constructor tenumdef.ppuload(ppufile:tcompilerppufile);
  1383. begin
  1384. inherited ppuloaddef(ppufile);
  1385. deftype:=enumdef;
  1386. ppufile.getderef(basedefderef);
  1387. minval:=ppufile.getlongint;
  1388. maxval:=ppufile.getlongint;
  1389. savesize:=ppufile.getlongint;
  1390. has_jumps:=false;
  1391. firstenum:=Nil;
  1392. end;
  1393. procedure tenumdef.calcsavesize;
  1394. begin
  1395. if (aktpackenum=4) or (min<0) or (max>65535) then
  1396. savesize:=4
  1397. else
  1398. if (aktpackenum=2) or (min<0) or (max>255) then
  1399. savesize:=2
  1400. else
  1401. savesize:=1;
  1402. end;
  1403. procedure tenumdef.setmax(_max:longint);
  1404. begin
  1405. maxval:=_max;
  1406. calcsavesize;
  1407. end;
  1408. procedure tenumdef.setmin(_min:longint);
  1409. begin
  1410. minval:=_min;
  1411. calcsavesize;
  1412. end;
  1413. function tenumdef.min:longint;
  1414. begin
  1415. min:=minval;
  1416. end;
  1417. function tenumdef.max:longint;
  1418. begin
  1419. max:=maxval;
  1420. end;
  1421. procedure tenumdef.buildderef;
  1422. begin
  1423. inherited buildderef;
  1424. basedefderef.build(basedef);
  1425. end;
  1426. procedure tenumdef.deref;
  1427. begin
  1428. inherited deref;
  1429. basedef:=tenumdef(basedefderef.resolve);
  1430. end;
  1431. destructor tenumdef.destroy;
  1432. begin
  1433. inherited destroy;
  1434. end;
  1435. procedure tenumdef.ppuwrite(ppufile:tcompilerppufile);
  1436. begin
  1437. inherited ppuwritedef(ppufile);
  1438. ppufile.putderef(basedefderef);
  1439. ppufile.putlongint(min);
  1440. ppufile.putlongint(max);
  1441. ppufile.putlongint(savesize);
  1442. ppufile.writeentry(ibenumdef);
  1443. end;
  1444. { used for enumdef because the symbols are
  1445. inserted in the owner symtable }
  1446. procedure tenumdef.correct_owner_symtable;
  1447. var
  1448. st : tsymtable;
  1449. begin
  1450. if assigned(owner) and
  1451. (owner.symtabletype in [recordsymtable,objectsymtable]) then
  1452. begin
  1453. owner.defindex.deleteindex(self);
  1454. st:=owner;
  1455. while (st.symtabletype in [recordsymtable,objectsymtable]) do
  1456. st:=st.next;
  1457. st.registerdef(self);
  1458. end;
  1459. end;
  1460. {$ifdef GDB}
  1461. function tenumdef.stabstring : pchar;
  1462. var st,st2 : pchar;
  1463. p : tenumsym;
  1464. s : string;
  1465. memsize : word;
  1466. begin
  1467. memsize := memsizeinc;
  1468. getmem(st,memsize);
  1469. { we can specify the size with @s<size>; prefix PM }
  1470. if savesize <> std_param_align then
  1471. strpcopy(st,'@s'+tostr(savesize*8)+';e')
  1472. else
  1473. strpcopy(st,'e');
  1474. p := tenumsym(firstenum);
  1475. while assigned(p) do
  1476. begin
  1477. s :=p.name+':'+tostr(p.value)+',';
  1478. { place for the ending ';' also }
  1479. if (strlen(st)+length(s)+1<memsize) then
  1480. strpcopy(strend(st),s)
  1481. else
  1482. begin
  1483. getmem(st2,memsize+memsizeinc);
  1484. strcopy(st2,st);
  1485. freemem(st,memsize);
  1486. st := st2;
  1487. memsize := memsize+memsizeinc;
  1488. strpcopy(strend(st),s);
  1489. end;
  1490. p := p.nextenum;
  1491. end;
  1492. strpcopy(strend(st),';');
  1493. stabstring := strnew(st);
  1494. freemem(st,memsize);
  1495. end;
  1496. {$endif GDB}
  1497. procedure tenumdef.write_child_rtti_data(rt:trttitype);
  1498. begin
  1499. if assigned(basedef) then
  1500. basedef.get_rtti_label(rt);
  1501. end;
  1502. procedure tenumdef.write_rtti_data(rt:trttitype);
  1503. var
  1504. hp : tenumsym;
  1505. begin
  1506. rttiList.concat(Tai_const.Create_8bit(tkEnumeration));
  1507. write_rtti_name;
  1508. case savesize of
  1509. 1:
  1510. rttiList.concat(Tai_const.Create_8bit(otUByte));
  1511. 2:
  1512. rttiList.concat(Tai_const.Create_8bit(otUWord));
  1513. 4:
  1514. rttiList.concat(Tai_const.Create_8bit(otULong));
  1515. end;
  1516. rttiList.concat(Tai_const.Create_32bit(min));
  1517. rttiList.concat(Tai_const.Create_32bit(max));
  1518. if assigned(basedef) then
  1519. rttiList.concat(Tai_const_symbol.Create(basedef.get_rtti_label(rt)))
  1520. else
  1521. rttiList.concat(Tai_const.Create_32bit(0));
  1522. hp:=tenumsym(firstenum);
  1523. while assigned(hp) do
  1524. begin
  1525. rttiList.concat(Tai_const.Create_8bit(length(hp.name)));
  1526. rttiList.concat(Tai_string.Create(lower(hp.name)));
  1527. hp:=hp.nextenum;
  1528. end;
  1529. rttiList.concat(Tai_const.Create_8bit(0));
  1530. end;
  1531. function tenumdef.is_publishable : boolean;
  1532. begin
  1533. is_publishable:=true;
  1534. end;
  1535. function tenumdef.gettypename : string;
  1536. begin
  1537. gettypename:='<enumeration type>';
  1538. end;
  1539. {****************************************************************************
  1540. TORDDEF
  1541. ****************************************************************************}
  1542. constructor torddef.create(t : tbasetype;v,b : TConstExprInt);
  1543. begin
  1544. inherited create;
  1545. deftype:=orddef;
  1546. low:=v;
  1547. high:=b;
  1548. typ:=t;
  1549. setsize;
  1550. end;
  1551. constructor torddef.ppuload(ppufile:tcompilerppufile);
  1552. var
  1553. l1,l2 : longint;
  1554. begin
  1555. inherited ppuloaddef(ppufile);
  1556. deftype:=orddef;
  1557. typ:=tbasetype(ppufile.getbyte);
  1558. if sizeof(TConstExprInt)=8 then
  1559. begin
  1560. l1:=ppufile.getlongint;
  1561. l2:=ppufile.getlongint;
  1562. {$ifopt R+}
  1563. {$define Range_check_on}
  1564. {$endif opt R+}
  1565. {$R- needed here }
  1566. low:=qword(l1)+(int64(l2) shl 32);
  1567. {$ifdef Range_check_on}
  1568. {$R+}
  1569. {$undef Range_check_on}
  1570. {$endif Range_check_on}
  1571. end
  1572. else
  1573. low:=ppufile.getlongint;
  1574. if sizeof(TConstExprInt)=8 then
  1575. begin
  1576. l1:=ppufile.getlongint;
  1577. l2:=ppufile.getlongint;
  1578. {$ifopt R+}
  1579. {$define Range_check_on}
  1580. {$endif opt R+}
  1581. {$R- needed here }
  1582. high:=qword(l1)+(int64(l2) shl 32);
  1583. {$ifdef Range_check_on}
  1584. {$R+}
  1585. {$undef Range_check_on}
  1586. {$endif Range_check_on}
  1587. end
  1588. else
  1589. high:=ppufile.getlongint;
  1590. setsize;
  1591. end;
  1592. function torddef.getcopy : tstoreddef;
  1593. begin
  1594. result:=torddef.create(typ,low,high);
  1595. result.deftype:=orddef;
  1596. torddef(result).low:=low;
  1597. torddef(result).high:=high;
  1598. torddef(result).typ:=typ;
  1599. torddef(result).savesize:=savesize;
  1600. end;
  1601. procedure torddef.setsize;
  1602. const
  1603. sizetbl : array[tbasetype] of longint = (
  1604. 0,
  1605. 1,2,4,8,
  1606. 1,2,4,8,
  1607. 1,2,4,
  1608. 1,2,8
  1609. );
  1610. begin
  1611. savesize:=sizetbl[typ];
  1612. end;
  1613. procedure torddef.ppuwrite(ppufile:tcompilerppufile);
  1614. begin
  1615. inherited ppuwritedef(ppufile);
  1616. ppufile.putbyte(byte(typ));
  1617. if sizeof(TConstExprInt)=8 then
  1618. begin
  1619. ppufile.putlongint(longint(lo(low)));
  1620. ppufile.putlongint(longint(hi(low)));
  1621. end
  1622. else
  1623. ppufile.putlongint(low);
  1624. if sizeof(TConstExprInt)=8 then
  1625. begin
  1626. ppufile.putlongint(longint(lo(high)));
  1627. ppufile.putlongint(longint(hi(high)));
  1628. end
  1629. else
  1630. ppufile.putlongint(high);
  1631. ppufile.writeentry(iborddef);
  1632. end;
  1633. {$ifdef GDB}
  1634. function torddef.stabstring : pchar;
  1635. begin
  1636. case typ of
  1637. uvoid : stabstring := strpnew(numberstring+';');
  1638. {GDB 4.12 for go32 doesn't like boolean as range for 0 to 1 !!!}
  1639. {$ifdef Use_integer_types_for_boolean}
  1640. bool8bit,
  1641. bool16bit,
  1642. bool32bit : stabstring := strpnew('r'+numberstring+';0;255;');
  1643. {$else : not Use_integer_types_for_boolean}
  1644. uchar : stabstring := strpnew('-20;');
  1645. uwidechar : stabstring := strpnew('-30;');
  1646. bool8bit : stabstring := strpnew('-21;');
  1647. bool16bit : stabstring := strpnew('-22;');
  1648. bool32bit : stabstring := strpnew('-23;');
  1649. u64bit : stabstring := strpnew('-32;');
  1650. s64bit : stabstring := strpnew('-31;');
  1651. {$endif not Use_integer_types_for_boolean}
  1652. {u32bit : stabstring := tstoreddef(s32bittype.def).numberstring+';0;-1;'); }
  1653. else
  1654. stabstring := strpnew('r'+tstoreddef(s32bittype.def).numberstring+';'+tostr(longint(low))+';'+tostr(longint(high))+';');
  1655. end;
  1656. end;
  1657. {$endif GDB}
  1658. procedure torddef.write_rtti_data(rt:trttitype);
  1659. procedure dointeger;
  1660. const
  1661. trans : array[tbasetype] of byte =
  1662. (otUByte{otNone},
  1663. otUByte,otUWord,otULong,otUByte{otNone},
  1664. otSByte,otSWord,otSLong,otUByte{otNone},
  1665. otUByte,otUWord,otULong,
  1666. otUByte,otUWord,otUByte);
  1667. begin
  1668. write_rtti_name;
  1669. rttiList.concat(Tai_const.Create_8bit(byte(trans[typ])));
  1670. rttiList.concat(Tai_const.Create_32bit(longint(low)));
  1671. rttiList.concat(Tai_const.Create_32bit(longint(high)));
  1672. end;
  1673. begin
  1674. case typ of
  1675. s64bit :
  1676. begin
  1677. rttiList.concat(Tai_const.Create_8bit(tkInt64));
  1678. write_rtti_name;
  1679. if target_info.endian=endian_little then
  1680. begin
  1681. { low }
  1682. rttiList.concat(Tai_const.Create_32bit($0));
  1683. rttiList.concat(Tai_const.Create_32bit(longint($80000000)));
  1684. { high }
  1685. rttiList.concat(Tai_const.Create_32bit(longint($ffffffff)));
  1686. rttiList.concat(Tai_const.Create_32bit($7fffffff));
  1687. end
  1688. else
  1689. begin
  1690. { low }
  1691. rttiList.concat(Tai_const.Create_32bit(longint($80000000)));
  1692. rttiList.concat(Tai_const.Create_32bit($0));
  1693. { high }
  1694. rttiList.concat(Tai_const.Create_32bit($7fffffff));
  1695. rttiList.concat(Tai_const.Create_32bit(longint($ffffffff)));
  1696. end;
  1697. end;
  1698. u64bit :
  1699. begin
  1700. rttiList.concat(Tai_const.Create_8bit(tkQWord));
  1701. write_rtti_name;
  1702. { low }
  1703. rttiList.concat(Tai_const.Create_32bit($0));
  1704. rttiList.concat(Tai_const.Create_32bit($0));
  1705. { high }
  1706. rttiList.concat(Tai_const.Create_32bit(longint($ffffffff)));
  1707. rttiList.concat(Tai_const.Create_32bit(longint($ffffffff)));
  1708. end;
  1709. bool8bit:
  1710. begin
  1711. rttiList.concat(Tai_const.Create_8bit(tkBool));
  1712. dointeger;
  1713. end;
  1714. uchar:
  1715. begin
  1716. rttiList.concat(Tai_const.Create_8bit(tkChar));
  1717. dointeger;
  1718. end;
  1719. uwidechar:
  1720. begin
  1721. rttiList.concat(Tai_const.Create_8bit(tkWChar));
  1722. dointeger;
  1723. end;
  1724. else
  1725. begin
  1726. rttiList.concat(Tai_const.Create_8bit(tkInteger));
  1727. dointeger;
  1728. end;
  1729. end;
  1730. end;
  1731. function torddef.is_publishable : boolean;
  1732. begin
  1733. is_publishable:=(typ<>uvoid);
  1734. end;
  1735. function torddef.gettypename : string;
  1736. const
  1737. names : array[tbasetype] of string[20] = (
  1738. 'untyped',
  1739. 'Byte','Word','DWord','QWord',
  1740. 'ShortInt','SmallInt','LongInt','Int64',
  1741. 'Boolean','WordBool','LongBool',
  1742. 'Char','WideChar','Currency');
  1743. begin
  1744. gettypename:=names[typ];
  1745. end;
  1746. {****************************************************************************
  1747. TFLOATDEF
  1748. ****************************************************************************}
  1749. constructor tfloatdef.create(t : tfloattype);
  1750. begin
  1751. inherited create;
  1752. deftype:=floatdef;
  1753. typ:=t;
  1754. setsize;
  1755. end;
  1756. constructor tfloatdef.ppuload(ppufile:tcompilerppufile);
  1757. begin
  1758. inherited ppuloaddef(ppufile);
  1759. deftype:=floatdef;
  1760. typ:=tfloattype(ppufile.getbyte);
  1761. setsize;
  1762. end;
  1763. function tfloatdef.getcopy : tstoreddef;
  1764. begin
  1765. result:=tfloatdef.create(typ);
  1766. result.deftype:=floatdef;
  1767. tfloatdef(result).savesize:=savesize;
  1768. end;
  1769. procedure tfloatdef.setsize;
  1770. begin
  1771. case typ of
  1772. s32real : savesize:=4;
  1773. s80real : savesize:=extended_size;
  1774. s64real,
  1775. s64currency,
  1776. s64comp : savesize:=8;
  1777. else
  1778. savesize:=0;
  1779. end;
  1780. end;
  1781. procedure tfloatdef.ppuwrite(ppufile:tcompilerppufile);
  1782. begin
  1783. inherited ppuwritedef(ppufile);
  1784. ppufile.putbyte(byte(typ));
  1785. ppufile.writeentry(ibfloatdef);
  1786. end;
  1787. {$ifdef GDB}
  1788. function tfloatdef.stabstring : pchar;
  1789. begin
  1790. case typ of
  1791. s32real,
  1792. s64real : stabstring := strpnew('r'+
  1793. tstoreddef(s32bittype.def).numberstring+';'+tostr(savesize)+';0;');
  1794. { found this solution in stabsread.c from GDB v4.16 }
  1795. s64currency,
  1796. s64comp : stabstring := strpnew('r'+
  1797. tstoreddef(s32bittype.def).numberstring+';-'+tostr(savesize)+';0;');
  1798. { under dos at least you must give a size of twelve instead of 10 !! }
  1799. { this is probably do to the fact that in gcc all is pushed in 4 bytes size }
  1800. s80real : stabstring := strpnew('r'+tstoreddef(s32bittype.def).numberstring+';12;0;');
  1801. else
  1802. internalerror(10005);
  1803. end;
  1804. end;
  1805. {$endif GDB}
  1806. procedure tfloatdef.write_rtti_data(rt:trttitype);
  1807. const
  1808. {tfloattype = (s32real,s64real,s80real,s64bit,s128bit);}
  1809. translate : array[tfloattype] of byte =
  1810. (ftSingle,ftDouble,ftExtended,ftComp,ftCurr,ftFloat128);
  1811. begin
  1812. rttiList.concat(Tai_const.Create_8bit(tkFloat));
  1813. write_rtti_name;
  1814. rttiList.concat(Tai_const.Create_8bit(translate[typ]));
  1815. end;
  1816. function tfloatdef.is_publishable : boolean;
  1817. begin
  1818. is_publishable:=true;
  1819. end;
  1820. function tfloatdef.gettypename : string;
  1821. const
  1822. names : array[tfloattype] of string[20] = (
  1823. 'Single','Double','Extended','Comp','Currency','Float128');
  1824. begin
  1825. gettypename:=names[typ];
  1826. end;
  1827. {****************************************************************************
  1828. TFILEDEF
  1829. ****************************************************************************}
  1830. constructor tfiledef.createtext;
  1831. begin
  1832. inherited create;
  1833. deftype:=filedef;
  1834. filetyp:=ft_text;
  1835. typedfiletype.reset;
  1836. setsize;
  1837. end;
  1838. constructor tfiledef.createuntyped;
  1839. begin
  1840. inherited create;
  1841. deftype:=filedef;
  1842. filetyp:=ft_untyped;
  1843. typedfiletype.reset;
  1844. setsize;
  1845. end;
  1846. constructor tfiledef.createtyped(const tt : ttype);
  1847. begin
  1848. inherited create;
  1849. deftype:=filedef;
  1850. filetyp:=ft_typed;
  1851. typedfiletype:=tt;
  1852. setsize;
  1853. end;
  1854. constructor tfiledef.ppuload(ppufile:tcompilerppufile);
  1855. begin
  1856. inherited ppuloaddef(ppufile);
  1857. deftype:=filedef;
  1858. filetyp:=tfiletyp(ppufile.getbyte);
  1859. if filetyp=ft_typed then
  1860. ppufile.gettype(typedfiletype)
  1861. else
  1862. typedfiletype.reset;
  1863. setsize;
  1864. end;
  1865. procedure tfiledef.buildderef;
  1866. begin
  1867. inherited buildderef;
  1868. if filetyp=ft_typed then
  1869. typedfiletype.buildderef;
  1870. end;
  1871. procedure tfiledef.deref;
  1872. begin
  1873. inherited deref;
  1874. if filetyp=ft_typed then
  1875. typedfiletype.resolve;
  1876. end;
  1877. procedure tfiledef.setsize;
  1878. begin
  1879. {$ifdef cpu64bit}
  1880. case filetyp of
  1881. ft_text :
  1882. savesize:=592;
  1883. ft_typed,
  1884. ft_untyped :
  1885. savesize:=316;
  1886. end;
  1887. {$else cpu64bit}
  1888. case filetyp of
  1889. ft_text :
  1890. savesize:=572;
  1891. ft_typed,
  1892. ft_untyped :
  1893. savesize:=316;
  1894. end;
  1895. {$endif cpu64bit}
  1896. end;
  1897. procedure tfiledef.ppuwrite(ppufile:tcompilerppufile);
  1898. begin
  1899. inherited ppuwritedef(ppufile);
  1900. ppufile.putbyte(byte(filetyp));
  1901. if filetyp=ft_typed then
  1902. ppufile.puttype(typedfiletype);
  1903. ppufile.writeentry(ibfiledef);
  1904. end;
  1905. {$ifdef GDB}
  1906. function tfiledef.stabstring : pchar;
  1907. begin
  1908. {$IfDef GDBknowsfiles}
  1909. case filetyp of
  1910. ft_typed :
  1911. stabstring := strpnew('d'+typedfiletype.def.numberstring{+';'});
  1912. ft_untyped :
  1913. stabstring := strpnew('d'+voiddef.numberstring{+';'});
  1914. ft_text :
  1915. stabstring := strpnew('d'+cchartype^.numberstring{+';'});
  1916. end;
  1917. {$Else}
  1918. {based on
  1919. FileRec = Packed Record
  1920. Handle,
  1921. Mode,
  1922. RecSize : longint;
  1923. _private : array[1..32] of byte;
  1924. UserData : array[1..16] of byte;
  1925. name : array[0..255] of char;
  1926. End; }
  1927. { the buffer part is still missing !! (PM) }
  1928. { but the string could become too long !! }
  1929. stabstring := strpnew('s'+tostr(savesize)+
  1930. 'HANDLE:'+typeglobalnumber('longint')+',0,32;'+
  1931. 'MODE:'+typeglobalnumber('longint')+',32,32;'+
  1932. 'RECSIZE:'+typeglobalnumber('longint')+',64,32;'+
  1933. '_PRIVATE:ar'+typeglobalnumber('word')+';1;32;'+typeglobalnumber('byte')
  1934. +',96,256;'+
  1935. 'USERDATA:ar'+typeglobalnumber('word')+';1;16;'+typeglobalnumber('byte')
  1936. +',352,128;'+
  1937. 'NAME:ar'+typeglobalnumber('word')+';0;255;'+typeglobalnumber('char')
  1938. +',480,2048;;');
  1939. {$EndIf}
  1940. end;
  1941. procedure tfiledef.concatstabto(asmlist : taasmoutput);
  1942. begin
  1943. { most file defs are unnamed !!! }
  1944. if ((typesym = nil) or ttypesym(typesym).isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1945. (is_def_stab_written = not_written) then
  1946. begin
  1947. if assigned(typedfiletype.def) then
  1948. forcestabto(asmlist,typedfiletype.def);
  1949. inherited concatstabto(asmlist);
  1950. end;
  1951. end;
  1952. {$endif GDB}
  1953. function tfiledef.gettypename : string;
  1954. begin
  1955. case filetyp of
  1956. ft_untyped:
  1957. gettypename:='File';
  1958. ft_typed:
  1959. gettypename:='File Of '+typedfiletype.def.typename;
  1960. ft_text:
  1961. gettypename:='Text'
  1962. end;
  1963. end;
  1964. function tfiledef.getmangledparaname : string;
  1965. begin
  1966. case filetyp of
  1967. ft_untyped:
  1968. getmangledparaname:='FILE';
  1969. ft_typed:
  1970. getmangledparaname:='FILE$OF$'+typedfiletype.def.mangledparaname;
  1971. ft_text:
  1972. getmangledparaname:='TEXT'
  1973. end;
  1974. end;
  1975. {****************************************************************************
  1976. TVARIANTDEF
  1977. ****************************************************************************}
  1978. constructor tvariantdef.create(v : tvarianttype);
  1979. begin
  1980. inherited create;
  1981. varianttype:=v;
  1982. deftype:=variantdef;
  1983. setsize;
  1984. end;
  1985. constructor tvariantdef.ppuload(ppufile:tcompilerppufile);
  1986. begin
  1987. inherited ppuloaddef(ppufile);
  1988. varianttype:=tvarianttype(ppufile.getbyte);
  1989. deftype:=variantdef;
  1990. setsize;
  1991. end;
  1992. procedure tvariantdef.ppuwrite(ppufile:tcompilerppufile);
  1993. begin
  1994. inherited ppuwritedef(ppufile);
  1995. ppufile.putbyte(byte(varianttype));
  1996. ppufile.writeentry(ibvariantdef);
  1997. end;
  1998. procedure tvariantdef.setsize;
  1999. begin
  2000. savesize:=16;
  2001. end;
  2002. function tvariantdef.gettypename : string;
  2003. begin
  2004. case varianttype of
  2005. vt_normalvariant:
  2006. gettypename:='Variant';
  2007. vt_olevariant:
  2008. gettypename:='OleVariant';
  2009. end;
  2010. end;
  2011. procedure tvariantdef.write_rtti_data(rt:trttitype);
  2012. begin
  2013. rttiList.concat(Tai_const.Create_8bit(tkVariant));
  2014. end;
  2015. function tvariantdef.needs_inittable : boolean;
  2016. begin
  2017. needs_inittable:=true;
  2018. end;
  2019. {$ifdef GDB}
  2020. procedure tvariantdef.concatstabto(asmlist : taasmoutput);
  2021. begin
  2022. { don't know how to handle this }
  2023. end;
  2024. {$endif GDB}
  2025. {****************************************************************************
  2026. TPOINTERDEF
  2027. ****************************************************************************}
  2028. constructor tpointerdef.create(const tt : ttype);
  2029. begin
  2030. inherited create;
  2031. deftype:=pointerdef;
  2032. pointertype:=tt;
  2033. is_far:=false;
  2034. savesize:=POINTER_SIZE;
  2035. end;
  2036. constructor tpointerdef.createfar(const tt : ttype);
  2037. begin
  2038. inherited create;
  2039. deftype:=pointerdef;
  2040. pointertype:=tt;
  2041. is_far:=true;
  2042. savesize:=POINTER_SIZE;
  2043. end;
  2044. constructor tpointerdef.ppuload(ppufile:tcompilerppufile);
  2045. begin
  2046. inherited ppuloaddef(ppufile);
  2047. deftype:=pointerdef;
  2048. ppufile.gettype(pointertype);
  2049. is_far:=(ppufile.getbyte<>0);
  2050. savesize:=POINTER_SIZE;
  2051. end;
  2052. procedure tpointerdef.buildderef;
  2053. begin
  2054. inherited buildderef;
  2055. pointertype.buildderef;
  2056. end;
  2057. procedure tpointerdef.deref;
  2058. begin
  2059. inherited deref;
  2060. pointertype.resolve;
  2061. end;
  2062. procedure tpointerdef.ppuwrite(ppufile:tcompilerppufile);
  2063. begin
  2064. inherited ppuwritedef(ppufile);
  2065. ppufile.puttype(pointertype);
  2066. ppufile.putbyte(byte(is_far));
  2067. ppufile.writeentry(ibpointerdef);
  2068. end;
  2069. {$ifdef GDB}
  2070. function tpointerdef.stabstring : pchar;
  2071. begin
  2072. stabstring := strpnew('*'+tstoreddef(pointertype.def).numberstring);
  2073. end;
  2074. procedure tpointerdef.concatstabto(asmlist : taasmoutput);
  2075. var st,nb : string;
  2076. sym_line_no : longint;
  2077. begin
  2078. if assigned(pointertype.def) and
  2079. (pointertype.def.deftype=forwarddef) then
  2080. exit;
  2081. if ( (typesym=nil) or ttypesym(typesym).isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  2082. (is_def_stab_written = not_written) then
  2083. begin
  2084. is_def_stab_written := being_written;
  2085. if assigned(pointertype.def) and
  2086. (pointertype.def.deftype in [recorddef,objectdef]) then
  2087. begin
  2088. if pointertype.def.deftype=objectdef then
  2089. nb:=tobjectdef(pointertype.def).classnumberstring
  2090. else
  2091. nb:=tstoreddef(pointertype.def).numberstring;
  2092. {to avoid infinite recursion in record with next-like fields }
  2093. if tstoreddef(pointertype.def).is_def_stab_written = being_written then
  2094. begin
  2095. if assigned(pointertype.def.typesym) then
  2096. begin
  2097. if assigned(typesym) then
  2098. begin
  2099. st := ttypesym(typesym).name;
  2100. sym_line_no:=ttypesym(typesym).fileinfo.line;
  2101. end
  2102. else
  2103. begin
  2104. st := ' ';
  2105. sym_line_no:=0;
  2106. end;
  2107. st := '"'+st+':t'+numberstring+'=*'+nb
  2108. +'=xs'+pointertype.def.typesym.name+':",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0';
  2109. asmList.concat(Tai_stabs.Create(strpnew(st)));
  2110. end;
  2111. end
  2112. else
  2113. begin
  2114. is_def_stab_written := not_written;
  2115. inherited concatstabto(asmlist);
  2116. end;
  2117. is_def_stab_written := written;
  2118. end
  2119. else
  2120. begin
  2121. if assigned(pointertype.def) then
  2122. forcestabto(asmlist,pointertype.def);
  2123. is_def_stab_written := not_written;
  2124. inherited concatstabto(asmlist);
  2125. end;
  2126. end;
  2127. end;
  2128. {$endif GDB}
  2129. function tpointerdef.gettypename : string;
  2130. begin
  2131. if is_far then
  2132. gettypename:='^'+pointertype.def.typename+';far'
  2133. else
  2134. gettypename:='^'+pointertype.def.typename;
  2135. end;
  2136. {****************************************************************************
  2137. TCLASSREFDEF
  2138. ****************************************************************************}
  2139. constructor tclassrefdef.create(const t:ttype);
  2140. begin
  2141. inherited create(t);
  2142. deftype:=classrefdef;
  2143. end;
  2144. constructor tclassrefdef.ppuload(ppufile:tcompilerppufile);
  2145. begin
  2146. { be careful, tclassdefref inherits from tpointerdef }
  2147. inherited ppuloaddef(ppufile);
  2148. deftype:=classrefdef;
  2149. ppufile.gettype(pointertype);
  2150. is_far:=false;
  2151. savesize:=POINTER_SIZE;
  2152. end;
  2153. procedure tclassrefdef.ppuwrite(ppufile:tcompilerppufile);
  2154. begin
  2155. { be careful, tclassdefref inherits from tpointerdef }
  2156. inherited ppuwritedef(ppufile);
  2157. ppufile.puttype(pointertype);
  2158. ppufile.writeentry(ibclassrefdef);
  2159. end;
  2160. {$ifdef GDB}
  2161. function tclassrefdef.stabstring : pchar;
  2162. begin
  2163. stabstring:=strpnew(tstoreddef(pvmttype.def).numberstring+';');
  2164. end;
  2165. procedure tclassrefdef.concatstabto(asmlist : taasmoutput);
  2166. begin
  2167. inherited concatstabto(asmlist);
  2168. end;
  2169. {$endif GDB}
  2170. function tclassrefdef.gettypename : string;
  2171. begin
  2172. gettypename:='Class Of '+pointertype.def.typename;
  2173. end;
  2174. {***************************************************************************
  2175. TSETDEF
  2176. ***************************************************************************}
  2177. constructor tsetdef.create(const t:ttype;high : longint);
  2178. begin
  2179. inherited create;
  2180. deftype:=setdef;
  2181. elementtype:=t;
  2182. if high<32 then
  2183. begin
  2184. settype:=smallset;
  2185. {$ifdef testvarsets}
  2186. if aktsetalloc=0 THEN { $PACKSET Fixed?}
  2187. {$endif}
  2188. savesize:=Sizeof(longint)
  2189. {$ifdef testvarsets}
  2190. else {No, use $PACKSET VALUE for rounding}
  2191. savesize:=aktsetalloc*((high+aktsetalloc*8-1) DIV (aktsetalloc*8))
  2192. {$endif}
  2193. ;
  2194. end
  2195. else
  2196. if high<256 then
  2197. begin
  2198. settype:=normset;
  2199. savesize:=32;
  2200. end
  2201. else
  2202. {$ifdef testvarsets}
  2203. if high<$10000 then
  2204. begin
  2205. settype:=varset;
  2206. savesize:=4*((high+31) div 32);
  2207. end
  2208. else
  2209. {$endif testvarsets}
  2210. Message(sym_e_ill_type_decl_set);
  2211. end;
  2212. constructor tsetdef.ppuload(ppufile:tcompilerppufile);
  2213. begin
  2214. inherited ppuloaddef(ppufile);
  2215. deftype:=setdef;
  2216. ppufile.gettype(elementtype);
  2217. settype:=tsettype(ppufile.getbyte);
  2218. case settype of
  2219. normset : savesize:=32;
  2220. varset : savesize:=ppufile.getlongint;
  2221. smallset : savesize:=Sizeof(longint);
  2222. end;
  2223. end;
  2224. destructor tsetdef.destroy;
  2225. begin
  2226. inherited destroy;
  2227. end;
  2228. procedure tsetdef.ppuwrite(ppufile:tcompilerppufile);
  2229. begin
  2230. inherited ppuwritedef(ppufile);
  2231. ppufile.puttype(elementtype);
  2232. ppufile.putbyte(byte(settype));
  2233. if settype=varset then
  2234. ppufile.putlongint(savesize);
  2235. ppufile.writeentry(ibsetdef);
  2236. end;
  2237. {$ifdef GDB}
  2238. function tsetdef.stabstring : pchar;
  2239. begin
  2240. { For small sets write a longint, which can at least be seen
  2241. in the current GDB's (PFV)
  2242. this is obsolete with GDBPAS !!
  2243. and anyhow creates problems with version 4.18!! PM
  2244. if settype=smallset then
  2245. stabstring := strpnew('r'+s32bittype^.numberstring+';0;0xffffffff;')
  2246. else }
  2247. stabstring := strpnew('@s'+tostr(savesize*8)+';S'+tstoreddef(elementtype.def).numberstring);
  2248. end;
  2249. procedure tsetdef.concatstabto(asmlist : taasmoutput);
  2250. begin
  2251. if ( not assigned(typesym) or ttypesym(typesym).isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  2252. (is_def_stab_written = not_written) then
  2253. begin
  2254. if assigned(elementtype.def) then
  2255. forcestabto(asmlist,elementtype.def);
  2256. inherited concatstabto(asmlist);
  2257. end;
  2258. end;
  2259. {$endif GDB}
  2260. procedure tsetdef.buildderef;
  2261. begin
  2262. inherited buildderef;
  2263. elementtype.buildderef;
  2264. end;
  2265. procedure tsetdef.deref;
  2266. begin
  2267. inherited deref;
  2268. elementtype.resolve;
  2269. end;
  2270. procedure tsetdef.write_child_rtti_data(rt:trttitype);
  2271. begin
  2272. tstoreddef(elementtype.def).get_rtti_label(rt);
  2273. end;
  2274. procedure tsetdef.write_rtti_data(rt:trttitype);
  2275. begin
  2276. rttiList.concat(Tai_const.Create_8bit(tkSet));
  2277. write_rtti_name;
  2278. rttiList.concat(Tai_const.Create_8bit(otULong));
  2279. rttiList.concat(Tai_const_symbol.Create(tstoreddef(elementtype.def).get_rtti_label(rt)));
  2280. end;
  2281. function tsetdef.is_publishable : boolean;
  2282. begin
  2283. is_publishable:=(settype=smallset);
  2284. end;
  2285. function tsetdef.gettypename : string;
  2286. begin
  2287. if assigned(elementtype.def) then
  2288. gettypename:='Set Of '+elementtype.def.typename
  2289. else
  2290. gettypename:='Empty Set';
  2291. end;
  2292. {***************************************************************************
  2293. TFORMALDEF
  2294. ***************************************************************************}
  2295. constructor tformaldef.create;
  2296. var
  2297. stregdef : boolean;
  2298. begin
  2299. stregdef:=registerdef;
  2300. registerdef:=false;
  2301. inherited create;
  2302. deftype:=formaldef;
  2303. registerdef:=stregdef;
  2304. { formaldef must be registered at unit level !! }
  2305. if registerdef and assigned(current_module) then
  2306. if assigned(current_module.localsymtable) then
  2307. tsymtable(current_module.localsymtable).registerdef(self)
  2308. else if assigned(current_module.globalsymtable) then
  2309. tsymtable(current_module.globalsymtable).registerdef(self);
  2310. savesize:=0;
  2311. end;
  2312. constructor tformaldef.ppuload(ppufile:tcompilerppufile);
  2313. begin
  2314. inherited ppuloaddef(ppufile);
  2315. deftype:=formaldef;
  2316. savesize:=0;
  2317. end;
  2318. procedure tformaldef.ppuwrite(ppufile:tcompilerppufile);
  2319. begin
  2320. inherited ppuwritedef(ppufile);
  2321. ppufile.writeentry(ibformaldef);
  2322. end;
  2323. {$ifdef GDB}
  2324. function tformaldef.stabstring : pchar;
  2325. begin
  2326. stabstring := strpnew('formal'+numberstring+';');
  2327. end;
  2328. procedure tformaldef.concatstabto(asmlist : taasmoutput);
  2329. begin
  2330. { formaldef can't be stab'ed !}
  2331. end;
  2332. {$endif GDB}
  2333. function tformaldef.gettypename : string;
  2334. begin
  2335. gettypename:='<Formal type>';
  2336. end;
  2337. {***************************************************************************
  2338. TARRAYDEF
  2339. ***************************************************************************}
  2340. constructor tarraydef.create(l,h : longint;const t : ttype);
  2341. begin
  2342. inherited create;
  2343. deftype:=arraydef;
  2344. lowrange:=l;
  2345. highrange:=h;
  2346. rangetype:=t;
  2347. elementtype.reset;
  2348. IsVariant:=false;
  2349. IsConstructor:=false;
  2350. IsArrayOfConst:=false;
  2351. IsDynamicArray:=false;
  2352. end;
  2353. constructor tarraydef.ppuload(ppufile:tcompilerppufile);
  2354. begin
  2355. inherited ppuloaddef(ppufile);
  2356. deftype:=arraydef;
  2357. { the addresses are calculated later }
  2358. ppufile.gettype(_elementtype);
  2359. ppufile.gettype(rangetype);
  2360. lowrange:=ppufile.getlongint;
  2361. highrange:=ppufile.getlongint;
  2362. IsArrayOfConst:=boolean(ppufile.getbyte);
  2363. IsDynamicArray:=boolean(ppufile.getbyte);
  2364. IsVariant:=false;
  2365. IsConstructor:=false;
  2366. end;
  2367. procedure tarraydef.buildderef;
  2368. begin
  2369. inherited buildderef;
  2370. _elementtype.buildderef;
  2371. rangetype.buildderef;
  2372. end;
  2373. procedure tarraydef.deref;
  2374. begin
  2375. inherited deref;
  2376. _elementtype.resolve;
  2377. rangetype.resolve;
  2378. end;
  2379. procedure tarraydef.ppuwrite(ppufile:tcompilerppufile);
  2380. begin
  2381. inherited ppuwritedef(ppufile);
  2382. ppufile.puttype(_elementtype);
  2383. ppufile.puttype(rangetype);
  2384. ppufile.putlongint(lowrange);
  2385. ppufile.putlongint(highrange);
  2386. ppufile.putbyte(byte(IsArrayOfConst));
  2387. ppufile.putbyte(byte(IsDynamicArray));
  2388. ppufile.writeentry(ibarraydef);
  2389. end;
  2390. {$ifdef GDB}
  2391. function tarraydef.stabstring : pchar;
  2392. begin
  2393. stabstring := strpnew('ar'+tstoreddef(rangetype.def).numberstring+';'
  2394. +tostr(lowrange)+';'+tostr(highrange)+';'+tstoreddef(_elementtype.def).numberstring);
  2395. end;
  2396. procedure tarraydef.concatstabto(asmlist : taasmoutput);
  2397. begin
  2398. if (not assigned(typesym) or ttypesym(typesym).isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  2399. and (is_def_stab_written = not_written) then
  2400. begin
  2401. {when array are inserted they have no definition yet !!}
  2402. if assigned(_elementtype.def) then
  2403. inherited concatstabto(asmlist);
  2404. end;
  2405. end;
  2406. {$endif GDB}
  2407. function tarraydef.elesize : longint;
  2408. begin
  2409. elesize:=_elementtype.def.size;
  2410. end;
  2411. function tarraydef.size : longint;
  2412. var
  2413. _resultsize,
  2414. newsize,
  2415. cachedsize: TConstExprInt;
  2416. begin
  2417. if IsDynamicArray then
  2418. begin
  2419. size:=POINTER_SIZE;
  2420. exit;
  2421. end;
  2422. cachedsize := elesize;
  2423. {Tarraydef.size may never be called for an open array!}
  2424. if highrange<lowrange then
  2425. internalerror(99080501);
  2426. newsize:=(int64(highrange)-int64(lowrange)+1)*cachedsize;
  2427. if (cachedsize>0) and
  2428. (
  2429. (TConstExprInt(highrange)-TConstExprInt(lowrange) > $7fffffff) or
  2430. { () are needed around elesize-1 to avoid a possible
  2431. integer overflow for elesize=1 !! PM }
  2432. (($7fffffff div cachedsize + (cachedsize -1)) < (int64(highrange) - int64(lowrange)))
  2433. ) Then
  2434. begin
  2435. Message(sym_e_segment_too_large);
  2436. _resultsize := 4
  2437. end
  2438. else
  2439. begin
  2440. { prevent an overflow }
  2441. if newsize>high(longint) then
  2442. _resultsize:=high(longint)
  2443. else
  2444. _resultsize:=newsize;
  2445. end;
  2446. size := _resultsize;
  2447. end;
  2448. procedure tarraydef.setelementtype(t: ttype);
  2449. begin
  2450. _elementtype:=t;
  2451. If IsDynamicArray then
  2452. exit;
  2453. if (TConstExprInt(highrange)-TConstExprInt(lowrange) > $7fffffff) then
  2454. Message(sym_e_segment_too_large);
  2455. end;
  2456. function tarraydef.alignment : longint;
  2457. begin
  2458. { alignment is the size of the elements }
  2459. if elementtype.def.deftype=recorddef then
  2460. alignment:=elementtype.def.alignment
  2461. else
  2462. alignment:=elesize;
  2463. end;
  2464. function tarraydef.needs_inittable : boolean;
  2465. begin
  2466. needs_inittable:=IsDynamicArray or elementtype.def.needs_inittable;
  2467. end;
  2468. procedure tarraydef.write_child_rtti_data(rt:trttitype);
  2469. begin
  2470. tstoreddef(elementtype.def).get_rtti_label(rt);
  2471. end;
  2472. procedure tarraydef.write_rtti_data(rt:trttitype);
  2473. begin
  2474. if IsDynamicArray then
  2475. rttiList.concat(Tai_const.Create_8bit(tkdynarray))
  2476. else
  2477. rttiList.concat(Tai_const.Create_8bit(tkarray));
  2478. write_rtti_name;
  2479. { size of elements }
  2480. rttiList.concat(Tai_const.Create_32bit(elesize));
  2481. { count of elements }
  2482. if not(IsDynamicArray) then
  2483. rttiList.concat(Tai_const.Create_32bit(highrange-lowrange+1));
  2484. { element type }
  2485. rttiList.concat(Tai_const_symbol.Create(tstoreddef(elementtype.def).get_rtti_label(rt)));
  2486. { variant type }
  2487. // !!!!!!!!!!!!!!!!
  2488. end;
  2489. function tarraydef.gettypename : string;
  2490. begin
  2491. if isarrayofconst or isConstructor then
  2492. begin
  2493. if isvariant or ((highrange=-1) and (lowrange=0)) then
  2494. gettypename:='Array Of Const'
  2495. else
  2496. gettypename:='Array Of '+elementtype.def.typename;
  2497. end
  2498. else if ((highrange=-1) and (lowrange=0)) or IsDynamicArray then
  2499. gettypename:='Array Of '+elementtype.def.typename
  2500. else
  2501. begin
  2502. if rangetype.def.deftype=enumdef then
  2503. gettypename:='Array['+rangetype.def.typename+'] Of '+elementtype.def.typename
  2504. else
  2505. gettypename:='Array['+tostr(lowrange)+'..'+
  2506. tostr(highrange)+'] Of '+elementtype.def.typename
  2507. end;
  2508. end;
  2509. function tarraydef.getmangledparaname : string;
  2510. begin
  2511. if isarrayofconst then
  2512. getmangledparaname:='array_of_const'
  2513. else
  2514. if ((highrange=-1) and (lowrange=0)) then
  2515. getmangledparaname:='array_of_'+elementtype.def.mangledparaname
  2516. else
  2517. internalerror(200204176);
  2518. end;
  2519. {***************************************************************************
  2520. tabstractrecorddef
  2521. ***************************************************************************}
  2522. function tabstractrecorddef.getsymtable(t:tgetsymtable):tsymtable;
  2523. begin
  2524. if t=gs_record then
  2525. getsymtable:=symtable
  2526. else
  2527. getsymtable:=nil;
  2528. end;
  2529. {$ifdef GDB}
  2530. procedure tabstractrecorddef.addname(p : tnamedindexitem;arg:pointer);
  2531. var
  2532. news, newrec : pchar;
  2533. spec : string[3];
  2534. varsize : longint;
  2535. begin
  2536. { static variables from objects are like global objects }
  2537. if (sp_static in tsym(p).symoptions) then
  2538. exit;
  2539. If tsym(p).typ = varsym then
  2540. begin
  2541. if (sp_protected in tsym(p).symoptions) then
  2542. spec:='/1'
  2543. else if (sp_private in tsym(p).symoptions) then
  2544. spec:='/0'
  2545. else
  2546. spec:='';
  2547. if not assigned(tvarsym(p).vartype.def) then
  2548. writeln(tvarsym(p).name);
  2549. { class fields are pointers PM, obsolete now PM }
  2550. {if (tvarsym(p).vartype.def.deftype=objectdef) and
  2551. tobjectdef(tvarsym(p).vartype.def).is_class then
  2552. spec:=spec+'*'; }
  2553. varsize:=tvarsym(p).vartype.def.size;
  2554. { open arrays made overflows !! }
  2555. if varsize>$fffffff then
  2556. varsize:=$fffffff;
  2557. newrec := strpnew(p.name+':'+spec+tstoreddef(tvarsym(p).vartype.def).numberstring
  2558. +','+tostr(tvarsym(p).fieldoffset*8)+','
  2559. +tostr(varsize*8)+';');
  2560. if strlen(StabRecString) + strlen(newrec) >= StabRecSize-256 then
  2561. begin
  2562. getmem(news,stabrecsize+memsizeinc);
  2563. strcopy(news,stabrecstring);
  2564. freemem(stabrecstring,stabrecsize);
  2565. stabrecsize:=stabrecsize+memsizeinc;
  2566. stabrecstring:=news;
  2567. end;
  2568. strcat(StabRecstring,newrec);
  2569. strdispose(newrec);
  2570. {This should be used for case !!}
  2571. inc(RecOffset,tvarsym(p).vartype.def.size);
  2572. end;
  2573. end;
  2574. {$endif GDB}
  2575. procedure tabstractrecorddef.count_field_rtti(sym : tnamedindexitem;arg:pointer);
  2576. begin
  2577. if (FRTTIType=fullrtti) or
  2578. ((tsym(sym).typ=varsym) and
  2579. tvarsym(sym).vartype.def.needs_inittable) then
  2580. inc(Count);
  2581. end;
  2582. procedure tabstractrecorddef.generate_field_rtti(sym:tnamedindexitem;arg:pointer);
  2583. begin
  2584. if (FRTTIType=fullrtti) or
  2585. ((tsym(sym).typ=varsym) and
  2586. tvarsym(sym).vartype.def.needs_inittable) then
  2587. tstoreddef(tvarsym(sym).vartype.def).get_rtti_label(FRTTIType);
  2588. end;
  2589. procedure tabstractrecorddef.write_field_rtti(sym : tnamedindexitem;arg:pointer);
  2590. begin
  2591. if (FRTTIType=fullrtti) or
  2592. ((tsym(sym).typ=varsym) and
  2593. tvarsym(sym).vartype.def.needs_inittable) then
  2594. begin
  2595. rttiList.concat(Tai_const_symbol.Create(tstoreddef(tvarsym(sym).vartype.def).get_rtti_label(FRTTIType)));
  2596. rttiList.concat(Tai_const.Create_32bit(tvarsym(sym).fieldoffset));
  2597. end;
  2598. end;
  2599. {***************************************************************************
  2600. trecorddef
  2601. ***************************************************************************}
  2602. constructor trecorddef.create(p : tsymtable);
  2603. begin
  2604. inherited create;
  2605. deftype:=recorddef;
  2606. symtable:=p;
  2607. symtable.defowner:=self;
  2608. { recordalign -1 means C record packing, that starts
  2609. with an alignment of 1 }
  2610. if aktalignment.recordalignmax=-1 then
  2611. trecordsymtable(symtable).dataalignment:=1
  2612. else
  2613. trecordsymtable(symtable).dataalignment:=aktalignment.recordalignmax;
  2614. isunion:=false;
  2615. end;
  2616. constructor trecorddef.ppuload(ppufile:tcompilerppufile);
  2617. begin
  2618. inherited ppuloaddef(ppufile);
  2619. deftype:=recorddef;
  2620. savesize:=ppufile.getlongint;
  2621. symtable:=trecordsymtable.create;
  2622. trecordsymtable(symtable).datasize:=ppufile.getlongint;
  2623. trecordsymtable(symtable).dataalignment:=ppufile.getbyte;
  2624. trecordsymtable(symtable).ppuload(ppufile);
  2625. symtable.defowner:=self;
  2626. isunion:=false;
  2627. end;
  2628. destructor trecorddef.destroy;
  2629. begin
  2630. if assigned(symtable) then
  2631. symtable.free;
  2632. inherited destroy;
  2633. end;
  2634. function trecorddef.needs_inittable : boolean;
  2635. begin
  2636. needs_inittable:=trecordsymtable(symtable).needs_init_final
  2637. end;
  2638. procedure trecorddef.buildderef;
  2639. var
  2640. oldrecsyms : tsymtable;
  2641. begin
  2642. inherited buildderef;
  2643. oldrecsyms:=aktrecordsymtable;
  2644. aktrecordsymtable:=symtable;
  2645. { now build the definitions }
  2646. tstoredsymtable(symtable).buildderef;
  2647. aktrecordsymtable:=oldrecsyms;
  2648. end;
  2649. procedure trecorddef.deref;
  2650. var
  2651. oldrecsyms : tsymtable;
  2652. begin
  2653. inherited deref;
  2654. oldrecsyms:=aktrecordsymtable;
  2655. aktrecordsymtable:=symtable;
  2656. { now dereference the definitions }
  2657. tstoredsymtable(symtable).deref;
  2658. aktrecordsymtable:=oldrecsyms;
  2659. { assign TGUID? load only from system unit (unitid=1) }
  2660. if not(assigned(rec_tguid)) and
  2661. (upper(typename)='TGUID') and
  2662. assigned(owner) and
  2663. assigned(owner.name) and
  2664. (owner.name^='SYSTEM') then
  2665. rec_tguid:=self;
  2666. end;
  2667. procedure trecorddef.ppuwrite(ppufile:tcompilerppufile);
  2668. begin
  2669. inherited ppuwritedef(ppufile);
  2670. ppufile.putlongint(savesize);
  2671. ppufile.putlongint(trecordsymtable(symtable).datasize);
  2672. ppufile.putbyte(trecordsymtable(symtable).dataalignment);
  2673. ppufile.writeentry(ibrecorddef);
  2674. trecordsymtable(symtable).ppuwrite(ppufile);
  2675. end;
  2676. function trecorddef.size:longint;
  2677. begin
  2678. result:=trecordsymtable(symtable).datasize;
  2679. end;
  2680. function trecorddef.alignment:longint;
  2681. var
  2682. l : longint;
  2683. hp : tvarsym;
  2684. begin
  2685. { also check the first symbol for it's size, because a
  2686. packed record has dataalignment of 1, but the first
  2687. sym could be a longint which should be aligned on 4 bytes,
  2688. this is compatible with C record packing (PFV) }
  2689. hp:=tvarsym(symtable.symindex.first);
  2690. if assigned(hp) then
  2691. begin
  2692. if hp.vartype.def.deftype in [recorddef,arraydef] then
  2693. l:=hp.vartype.def.alignment
  2694. else
  2695. l:=hp.vartype.def.size;
  2696. if l>trecordsymtable(symtable).dataalignment then
  2697. begin
  2698. if l>=4 then
  2699. alignment:=4
  2700. else
  2701. if l>=2 then
  2702. alignment:=2
  2703. else
  2704. alignment:=1;
  2705. end
  2706. else
  2707. alignment:=trecordsymtable(symtable).dataalignment;
  2708. end
  2709. else
  2710. alignment:=trecordsymtable(symtable).dataalignment;
  2711. end;
  2712. {$ifdef GDB}
  2713. function trecorddef.stabstring : pchar;
  2714. begin
  2715. GetMem(stabrecstring,memsizeinc);
  2716. stabrecsize:=memsizeinc;
  2717. strpcopy(stabRecString,'s'+tostr(size));
  2718. RecOffset := 0;
  2719. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}addname,nil);
  2720. strpcopy(strend(StabRecString),';');
  2721. stabstring := strnew(StabRecString);
  2722. Freemem(stabrecstring,stabrecsize);
  2723. end;
  2724. procedure trecorddef.concatstabto(asmlist : taasmoutput);
  2725. begin
  2726. if (not assigned(typesym) or ttypesym(typesym).isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  2727. (is_def_stab_written = not_written) then
  2728. inherited concatstabto(asmlist);
  2729. end;
  2730. {$endif GDB}
  2731. procedure trecorddef.write_child_rtti_data(rt:trttitype);
  2732. begin
  2733. FRTTIType:=rt;
  2734. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}generate_field_rtti,nil);
  2735. end;
  2736. procedure trecorddef.write_rtti_data(rt:trttitype);
  2737. begin
  2738. rttiList.concat(Tai_const.Create_8bit(tkrecord));
  2739. write_rtti_name;
  2740. rttiList.concat(Tai_const.Create_32bit(size));
  2741. Count:=0;
  2742. FRTTIType:=rt;
  2743. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}count_field_rtti,nil);
  2744. rttiList.concat(Tai_const.Create_32bit(Count));
  2745. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}write_field_rtti,nil);
  2746. end;
  2747. function trecorddef.gettypename : string;
  2748. begin
  2749. gettypename:='<record type>'
  2750. end;
  2751. {***************************************************************************
  2752. TABSTRACTPROCDEF
  2753. ***************************************************************************}
  2754. constructor tabstractprocdef.create(level:byte);
  2755. begin
  2756. inherited create;
  2757. parast:=tparasymtable.create(level);
  2758. parast.defowner:=self;
  2759. parast.next:=owner;
  2760. para:=TLinkedList.Create;
  2761. minparacount:=0;
  2762. maxparacount:=0;
  2763. proctypeoption:=potype_none;
  2764. proccalloption:=pocall_none;
  2765. procoptions:=[];
  2766. rettype:=voidtype;
  2767. {$ifdef i386}
  2768. fpu_used:=0;
  2769. {$endif i386}
  2770. savesize:=POINTER_SIZE;
  2771. has_paraloc_info:=false;
  2772. end;
  2773. destructor tabstractprocdef.destroy;
  2774. begin
  2775. if assigned(para) then
  2776. begin
  2777. {$ifdef MEMDEBUG}
  2778. memprocpara.start;
  2779. {$endif MEMDEBUG}
  2780. para.free;
  2781. {$ifdef MEMDEBUG}
  2782. memprocpara.stop;
  2783. {$endif MEMDEBUG}
  2784. end;
  2785. if assigned(parast) then
  2786. begin
  2787. {$ifdef MEMDEBUG}
  2788. memprocparast.start;
  2789. {$endif MEMDEBUG}
  2790. parast.free;
  2791. {$ifdef MEMDEBUG}
  2792. memprocparast.stop;
  2793. {$endif MEMDEBUG}
  2794. end;
  2795. inherited destroy;
  2796. end;
  2797. procedure tabstractprocdef.releasemem;
  2798. begin
  2799. para.free;
  2800. para:=nil;
  2801. parast.free;
  2802. parast:=nil;
  2803. end;
  2804. function tabstractprocdef.concatpara(afterpara:tparaitem;const tt:ttype;sym : tsym;defval:tsym;vhidden:boolean):tparaitem;
  2805. var
  2806. hp : TParaItem;
  2807. begin
  2808. hp:=TParaItem.Create;
  2809. hp.paratyp:=tvarsym(sym).varspez;
  2810. hp.parasym:=sym;
  2811. hp.paratype:=tt;
  2812. hp.is_hidden:=vhidden;
  2813. hp.defaultvalue:=defval;
  2814. { Parameters are stored from left to right }
  2815. if assigned(afterpara) then
  2816. Para.insertafter(hp,afterpara)
  2817. else
  2818. Para.concat(hp);
  2819. { Don't count hidden parameters }
  2820. if not vhidden then
  2821. begin
  2822. if not assigned(defval) then
  2823. inc(minparacount);
  2824. inc(maxparacount);
  2825. end;
  2826. concatpara:=hp;
  2827. end;
  2828. function tabstractprocdef.insertpara(const tt:ttype;sym : tsym;defval:tsym;vhidden:boolean):tparaitem;
  2829. var
  2830. hp : TParaItem;
  2831. begin
  2832. hp:=TParaItem.Create;
  2833. hp.paratyp:=tvarsym(sym).varspez;
  2834. hp.parasym:=sym;
  2835. hp.paratype:=tt;
  2836. hp.is_hidden:=vhidden;
  2837. hp.defaultvalue:=defval;
  2838. { Parameters are stored from left to right }
  2839. Para.insert(hp);
  2840. { Don't count hidden parameters }
  2841. if (not vhidden) then
  2842. begin
  2843. if not assigned(defval) then
  2844. inc(minparacount);
  2845. inc(maxparacount);
  2846. end;
  2847. insertpara:=hp;
  2848. end;
  2849. procedure tabstractprocdef.removepara(currpara:tparaitem);
  2850. begin
  2851. { Don't count hidden parameters }
  2852. if (not currpara.is_hidden) then
  2853. begin
  2854. if not assigned(currpara.defaultvalue) then
  2855. dec(minparacount);
  2856. dec(maxparacount);
  2857. end;
  2858. Para.Remove(currpara);
  2859. currpara.free;
  2860. end;
  2861. { all functions returning in FPU are
  2862. assume to use 2 FPU registers
  2863. until the function implementation
  2864. is processed PM }
  2865. procedure tabstractprocdef.test_if_fpu_result;
  2866. begin
  2867. {$ifdef i386}
  2868. if assigned(rettype.def) and
  2869. (rettype.def.deftype=floatdef) then
  2870. fpu_used:=maxfpuregs;
  2871. {$endif i386}
  2872. end;
  2873. procedure tabstractprocdef.buildderef;
  2874. var
  2875. hp : TParaItem;
  2876. begin
  2877. { released procdef? }
  2878. if not assigned(parast) then
  2879. exit;
  2880. inherited buildderef;
  2881. rettype.buildderef;
  2882. { parast }
  2883. tparasymtable(parast).buildderef;
  2884. { paraitems }
  2885. hp:=TParaItem(Para.first);
  2886. while assigned(hp) do
  2887. begin
  2888. hp.paratype.buildderef;
  2889. hp.defaultvaluederef.build(hp.defaultvalue);
  2890. hp.parasymderef.build(hp.parasym);
  2891. hp:=TParaItem(hp.next);
  2892. end;
  2893. end;
  2894. procedure tabstractprocdef.deref;
  2895. var
  2896. hp : TParaItem;
  2897. begin
  2898. inherited deref;
  2899. rettype.resolve;
  2900. { parast }
  2901. tparasymtable(parast).deref;
  2902. { paraitems }
  2903. hp:=TParaItem(Para.first);
  2904. while assigned(hp) do
  2905. begin
  2906. hp.paratype.resolve;
  2907. hp.defaultvalue:=tsym(hp.defaultvaluederef.resolve);
  2908. hp.parasym:=tvarsym(hp.parasymderef.resolve);
  2909. { connect parasym to paraitem }
  2910. tvarsym(hp.parasym).paraitem:=hp;
  2911. { Don't count hidden parameters }
  2912. if (not hp.is_hidden) then
  2913. begin
  2914. if not assigned(hp.defaultvalue) then
  2915. inc(minparacount);
  2916. inc(maxparacount);
  2917. end;
  2918. hp:=TParaItem(hp.next);
  2919. end;
  2920. end;
  2921. constructor tabstractprocdef.ppuload(ppufile:tcompilerppufile);
  2922. var
  2923. hp : TParaItem;
  2924. count,i : word;
  2925. begin
  2926. inherited ppuloaddef(ppufile);
  2927. parast:=nil;
  2928. Para:=TLinkedList.Create;
  2929. minparacount:=0;
  2930. maxparacount:=0;
  2931. ppufile.gettype(rettype);
  2932. {$ifdef i386}
  2933. fpu_used:=ppufile.getbyte;
  2934. {$else}
  2935. ppufile.getbyte;
  2936. {$endif i386}
  2937. proctypeoption:=tproctypeoption(ppufile.getbyte);
  2938. proccalloption:=tproccalloption(ppufile.getbyte);
  2939. ppufile.getsmallset(procoptions);
  2940. { get the number of parameters }
  2941. count:=ppufile.getbyte;
  2942. savesize:=POINTER_SIZE;
  2943. has_paraloc_info:=false;
  2944. for i:=1 to count do
  2945. begin
  2946. hp:=TParaItem.Create;
  2947. hp.paratyp:=tvarspez(ppufile.getbyte);
  2948. ppufile.gettype(hp.paratype);
  2949. ppufile.getderef(hp.defaultvaluederef);
  2950. hp.defaultvalue:=nil;
  2951. ppufile.getderef(hp.parasymderef);
  2952. hp.parasym:=nil;
  2953. hp.is_hidden:=boolean(ppufile.getbyte);
  2954. { Parameters are stored left to right in both ppu and memory }
  2955. Para.concat(hp);
  2956. end;
  2957. end;
  2958. procedure tabstractprocdef.ppuwrite(ppufile:tcompilerppufile);
  2959. var
  2960. hp : TParaItem;
  2961. oldintfcrc : boolean;
  2962. begin
  2963. { released procdef? }
  2964. if not assigned(parast) then
  2965. exit;
  2966. inherited ppuwritedef(ppufile);
  2967. ppufile.puttype(rettype);
  2968. oldintfcrc:=ppufile.do_interface_crc;
  2969. ppufile.do_interface_crc:=false;
  2970. {$ifdef i386}
  2971. if simplify_ppu then
  2972. fpu_used:=0;
  2973. ppufile.putbyte(fpu_used);
  2974. {$else}
  2975. ppufile.putbyte(0);
  2976. {$endif}
  2977. ppufile.putbyte(ord(proctypeoption));
  2978. ppufile.putbyte(ord(proccalloption));
  2979. ppufile.putsmallset(procoptions);
  2980. ppufile.do_interface_crc:=oldintfcrc;
  2981. { we need to store the count including vs_hidden }
  2982. ppufile.putbyte(para.count);
  2983. hp:=TParaItem(Para.first);
  2984. while assigned(hp) do
  2985. begin
  2986. ppufile.putbyte(byte(hp.paratyp));
  2987. ppufile.puttype(hp.paratype);
  2988. ppufile.putderef(hp.defaultvaluederef);
  2989. ppufile.putderef(hp.parasymderef);
  2990. ppufile.putbyte(byte(hp.is_hidden));
  2991. hp:=TParaItem(hp.next);
  2992. end;
  2993. end;
  2994. function tabstractprocdef.typename_paras(showhidden:boolean) : string;
  2995. var
  2996. hs,s : string;
  2997. hp : TParaItem;
  2998. hpc : tconstsym;
  2999. first : boolean;
  3000. begin
  3001. hp:=TParaItem(Para.first);
  3002. s:='';
  3003. first:=true;
  3004. while assigned(hp) do
  3005. begin
  3006. if (not hp.is_hidden) or
  3007. (showhidden) then
  3008. begin
  3009. if first then
  3010. begin
  3011. s:=s+'(';
  3012. first:=false;
  3013. end
  3014. else
  3015. s:=s+',';
  3016. case hp.paratyp of
  3017. vs_var :
  3018. s:=s+'var';
  3019. vs_const :
  3020. s:=s+'const';
  3021. vs_out :
  3022. s:=s+'out';
  3023. end;
  3024. if assigned(hp.paratype.def.typesym) then
  3025. begin
  3026. if s<>'(' then
  3027. s:=s+' ';
  3028. hs:=hp.paratype.def.typesym.realname;
  3029. if hs[1]<>'$' then
  3030. s:=s+hp.paratype.def.typesym.realname
  3031. else
  3032. s:=s+hp.paratype.def.gettypename;
  3033. end
  3034. else
  3035. s:=s+hp.paratype.def.gettypename;
  3036. { default value }
  3037. if assigned(hp.defaultvalue) then
  3038. begin
  3039. hpc:=tconstsym(hp.defaultvalue);
  3040. hs:='';
  3041. case hpc.consttyp of
  3042. conststring,
  3043. constresourcestring :
  3044. hs:=strpas(pchar(hpc.value.valueptr));
  3045. constreal :
  3046. str(pbestreal(hpc.value.valueptr)^,hs);
  3047. constord :
  3048. hs:=tostr(hpc.value.valueord);
  3049. constpointer :
  3050. hs:=tostr(hpc.value.valueordptr);
  3051. constbool :
  3052. begin
  3053. if hpc.value.valueord<>0 then
  3054. hs:='TRUE'
  3055. else
  3056. hs:='FALSE';
  3057. end;
  3058. constnil :
  3059. hs:='nil';
  3060. constchar :
  3061. hs:=chr(hpc.value.valueord);
  3062. constset :
  3063. hs:='<set>';
  3064. end;
  3065. if hs<>'' then
  3066. s:=s+'="'+hs+'"';
  3067. end;
  3068. end;
  3069. hp:=TParaItem(hp.next);
  3070. end;
  3071. if not first then
  3072. s:=s+')';
  3073. if (po_varargs in procoptions) then
  3074. s:=s+';VarArgs';
  3075. typename_paras:=s;
  3076. end;
  3077. function tabstractprocdef.is_methodpointer:boolean;
  3078. begin
  3079. result:=false;
  3080. end;
  3081. function tabstractprocdef.is_addressonly:boolean;
  3082. begin
  3083. result:=true;
  3084. end;
  3085. {$ifdef GDB}
  3086. function tabstractprocdef.stabstring : pchar;
  3087. begin
  3088. stabstring := strpnew('abstractproc'+numberstring+';');
  3089. end;
  3090. procedure tabstractprocdef.concatstabto(asmlist : taasmoutput);
  3091. begin
  3092. { released procdef? }
  3093. if not assigned(parast) then
  3094. exit;
  3095. if (not assigned(typesym) or ttypesym(typesym).isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  3096. and (is_def_stab_written = not_written) then
  3097. begin
  3098. if assigned(rettype.def) then forcestabto(asmlist,rettype.def);
  3099. inherited concatstabto(asmlist);
  3100. end;
  3101. end;
  3102. {$endif GDB}
  3103. {***************************************************************************
  3104. TPROCDEF
  3105. ***************************************************************************}
  3106. constructor tprocdef.create(level:byte);
  3107. begin
  3108. inherited create(level);
  3109. deftype:=procdef;
  3110. has_mangledname:=false;
  3111. _mangledname:=nil;
  3112. fileinfo:=aktfilepos;
  3113. extnumber:=$ffff;
  3114. aliasnames:=tstringlist.create;
  3115. funcretsym:=nil;
  3116. localst := nil;
  3117. defref:=nil;
  3118. lastwritten:=nil;
  3119. refcount:=0;
  3120. if (cs_browser in aktmoduleswitches) and make_ref then
  3121. begin
  3122. defref:=tref.create(defref,@akttokenpos);
  3123. inc(refcount);
  3124. end;
  3125. lastref:=defref;
  3126. forwarddef:=true;
  3127. interfacedef:=false;
  3128. hasforward:=false;
  3129. _class := nil;
  3130. code:=nil;
  3131. overloadnumber:=0;
  3132. {$ifdef GDB}
  3133. isstabwritten := false;
  3134. {$endif GDB}
  3135. end;
  3136. constructor tprocdef.ppuload(ppufile:tcompilerppufile);
  3137. begin
  3138. inherited ppuload(ppufile);
  3139. deftype:=procdef;
  3140. has_mangledname:=boolean(ppufile.getbyte);
  3141. if has_mangledname then
  3142. _mangledname:=stringdup(ppufile.getstring)
  3143. else
  3144. _mangledname:=nil;
  3145. overloadnumber:=ppufile.getword;
  3146. extnumber:=ppufile.getword;
  3147. ppufile.getderef(_classderef);
  3148. ppufile.getderef(procsymderef);
  3149. ppufile.getposinfo(fileinfo);
  3150. ppufile.getsmallset(symoptions);
  3151. { inline stuff }
  3152. if proccalloption=pocall_inline then
  3153. begin
  3154. ppufile.getderef(funcretsymderef);
  3155. code:=ppuloadnode(ppufile);
  3156. end
  3157. else
  3158. begin
  3159. code := nil;
  3160. funcretsym:=nil;
  3161. end;
  3162. { load para symtable }
  3163. parast:=tparasymtable.create(unknown_level);
  3164. tparasymtable(parast).ppuload(ppufile);
  3165. parast.defowner:=self;
  3166. { load local symtable }
  3167. if (proccalloption=pocall_inline) or
  3168. ((current_module.flags and uf_local_browser)<>0) then
  3169. begin
  3170. localst:=tlocalsymtable.create(unknown_level);
  3171. tlocalsymtable(localst).ppuload(ppufile);
  3172. localst.defowner:=self;
  3173. end
  3174. else
  3175. localst:=nil;
  3176. { default values for no persistent data }
  3177. if (cs_link_deffile in aktglobalswitches) and
  3178. (tf_need_export in target_info.flags) and
  3179. (po_exports in procoptions) then
  3180. deffile.AddExport(mangledname);
  3181. aliasnames:=tstringlist.create;
  3182. forwarddef:=false;
  3183. interfacedef:=false;
  3184. hasforward:=false;
  3185. lastref:=nil;
  3186. lastwritten:=nil;
  3187. defref:=nil;
  3188. refcount:=0;
  3189. {$ifdef GDB}
  3190. isstabwritten := false;
  3191. {$endif GDB}
  3192. end;
  3193. destructor tprocdef.destroy;
  3194. begin
  3195. if assigned(defref) then
  3196. begin
  3197. defref.freechain;
  3198. defref.free;
  3199. end;
  3200. aliasnames.free;
  3201. if assigned(localst) and (localst.symtabletype<>staticsymtable) then
  3202. begin
  3203. {$ifdef MEMDEBUG}
  3204. memproclocalst.start;
  3205. {$endif MEMDEBUG}
  3206. localst.free;
  3207. {$ifdef MEMDEBUG}
  3208. memproclocalst.start;
  3209. {$endif MEMDEBUG}
  3210. end;
  3211. if (proccalloption=pocall_inline) and assigned(code) then
  3212. begin
  3213. {$ifdef MEMDEBUG}
  3214. memprocnodetree.start;
  3215. {$endif MEMDEBUG}
  3216. tnode(code).free;
  3217. {$ifdef MEMDEBUG}
  3218. memprocnodetree.start;
  3219. {$endif MEMDEBUG}
  3220. end;
  3221. if (po_msgstr in procoptions) then
  3222. strdispose(messageinf.str);
  3223. if assigned(_mangledname) then
  3224. begin
  3225. {$ifdef MEMDEBUG}
  3226. memmanglednames.start;
  3227. {$endif MEMDEBUG}
  3228. stringdispose(_mangledname);
  3229. {$ifdef MEMDEBUG}
  3230. memmanglednames.stop;
  3231. {$endif MEMDEBUG}
  3232. end;
  3233. inherited destroy;
  3234. end;
  3235. procedure tprocdef.ppuwrite(ppufile:tcompilerppufile);
  3236. var
  3237. oldintfcrc : boolean;
  3238. oldparasymtable,
  3239. oldlocalsymtable : tsymtable;
  3240. begin
  3241. { released procdef? }
  3242. if not assigned(parast) then
  3243. exit;
  3244. oldparasymtable:=aktparasymtable;
  3245. oldlocalsymtable:=aktlocalsymtable;
  3246. aktparasymtable:=parast;
  3247. aktlocalsymtable:=localst;
  3248. inherited ppuwrite(ppufile);
  3249. oldintfcrc:=ppufile.do_interface_crc;
  3250. ppufile.do_interface_crc:=false;
  3251. ppufile.do_interface_crc:=oldintfcrc;
  3252. ppufile.putbyte(byte(has_mangledname));
  3253. if has_mangledname then
  3254. ppufile.putstring(mangledname);
  3255. ppufile.putword(overloadnumber);
  3256. ppufile.putword(extnumber);
  3257. ppufile.putderef(_classderef);
  3258. ppufile.putderef(procsymderef);
  3259. ppufile.putposinfo(fileinfo);
  3260. ppufile.putsmallset(symoptions);
  3261. { inline stuff references to localsymtable, no influence
  3262. on the crc }
  3263. oldintfcrc:=ppufile.do_crc;
  3264. ppufile.do_crc:=false;
  3265. { inline stuff }
  3266. if proccalloption=pocall_inline then
  3267. begin
  3268. ppufile.putderef(funcretsymderef);
  3269. ppuwritenode(ppufile,code);
  3270. end;
  3271. ppufile.do_crc:=oldintfcrc;
  3272. { write this entry }
  3273. ppufile.writeentry(ibprocdef);
  3274. { Save the para symtable, this is taken from the interface }
  3275. tparasymtable(parast).ppuwrite(ppufile);
  3276. { save localsymtable for inline procedures or when local
  3277. browser info is requested, this has no influence on the crc }
  3278. if (proccalloption=pocall_inline) or
  3279. ((current_module.flags and uf_local_browser)<>0) then
  3280. begin
  3281. oldintfcrc:=ppufile.do_crc;
  3282. ppufile.do_crc:=false;
  3283. if not assigned(localst) then
  3284. begin
  3285. localst:=tlocalsymtable.create(unknown_level);
  3286. localst.defowner:=self;
  3287. end;
  3288. tlocalsymtable(localst).ppuwrite(ppufile);
  3289. ppufile.do_crc:=oldintfcrc;
  3290. end;
  3291. aktparasymtable:=oldparasymtable;
  3292. aktlocalsymtable:=oldlocalsymtable;
  3293. end;
  3294. procedure tprocdef.insert_localst;
  3295. begin
  3296. localst:=tlocalsymtable.create(parast.symtablelevel);
  3297. localst.defowner:=self;
  3298. { this is used by insert
  3299. to check same names in parast and localst }
  3300. localst.next:=parast;
  3301. end;
  3302. function tprocdef.fullprocname(showhidden:boolean):string;
  3303. var
  3304. s : string;
  3305. t : ttoken;
  3306. begin
  3307. {$ifdef EXTDEBUG}
  3308. showhidden:=true;
  3309. {$endif EXTDEBUG}
  3310. s:='';
  3311. if assigned(_class) then
  3312. begin
  3313. if po_classmethod in procoptions then
  3314. s:=s+'class ';
  3315. s:=s+_class.objrealname^+'.';
  3316. end;
  3317. if proctypeoption=potype_operator then
  3318. begin
  3319. for t:=NOTOKEN to last_overloaded do
  3320. if procsym.realname='$'+overloaded_names[t] then
  3321. begin
  3322. s:='operator '+arraytokeninfo[t].str+typename_paras(showhidden);
  3323. break;
  3324. end;
  3325. end
  3326. else
  3327. s:=s+procsym.realname+typename_paras(showhidden);
  3328. case proctypeoption of
  3329. potype_constructor:
  3330. s:='constructor '+s;
  3331. potype_destructor:
  3332. s:='destructor '+s;
  3333. else
  3334. if assigned(rettype.def) and
  3335. not(is_void(rettype.def)) then
  3336. s:=s+':'+rettype.def.gettypename;
  3337. end;
  3338. { forced calling convention? }
  3339. if (po_hascallingconvention in procoptions) then
  3340. s:=s+';'+ProcCallOptionStr[proccalloption];
  3341. fullprocname:=s;
  3342. end;
  3343. function tprocdef.is_methodpointer:boolean;
  3344. begin
  3345. result:=assigned(_class);
  3346. end;
  3347. function tprocdef.is_addressonly:boolean;
  3348. begin
  3349. result:=assigned(owner) and
  3350. (owner.symtabletype<>objectsymtable);
  3351. end;
  3352. function tprocdef.is_visible_for_object(currobjdef:tobjectdef):boolean;
  3353. begin
  3354. is_visible_for_object:=false;
  3355. { private symbols are allowed when we are in the same
  3356. module as they are defined }
  3357. if (sp_private in symoptions) and
  3358. (owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  3359. (owner.defowner.owner.unitid<>0) then
  3360. exit;
  3361. { protected symbols are vissible in the module that defines them and
  3362. also visible to related objects. The related object must be defined
  3363. in the current module }
  3364. if (sp_protected in symoptions) and
  3365. (
  3366. (
  3367. (owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  3368. (owner.defowner.owner.unitid<>0)
  3369. ) and
  3370. not(
  3371. assigned(currobjdef) and
  3372. (currobjdef.owner.unitid=0) and
  3373. currobjdef.is_related(tobjectdef(owner.defowner))
  3374. )
  3375. ) then
  3376. exit;
  3377. is_visible_for_object:=true;
  3378. end;
  3379. function tprocdef.getsymtable(t:tgetsymtable):tsymtable;
  3380. begin
  3381. case t of
  3382. gs_local :
  3383. getsymtable:=localst;
  3384. gs_para :
  3385. getsymtable:=parast;
  3386. else
  3387. getsymtable:=nil;
  3388. end;
  3389. end;
  3390. procedure tprocdef.load_references(ppufile:tcompilerppufile;locals:boolean);
  3391. var
  3392. pos : tfileposinfo;
  3393. move_last : boolean;
  3394. oldparasymtable,
  3395. oldlocalsymtable : tsymtable;
  3396. begin
  3397. oldparasymtable:=aktparasymtable;
  3398. oldlocalsymtable:=aktlocalsymtable;
  3399. aktparasymtable:=parast;
  3400. aktlocalsymtable:=localst;
  3401. move_last:=lastwritten=lastref;
  3402. while (not ppufile.endofentry) do
  3403. begin
  3404. ppufile.getposinfo(pos);
  3405. inc(refcount);
  3406. lastref:=tref.create(lastref,@pos);
  3407. lastref.is_written:=true;
  3408. if refcount=1 then
  3409. defref:=lastref;
  3410. end;
  3411. if move_last then
  3412. lastwritten:=lastref;
  3413. if ((current_module.flags and uf_local_browser)<>0) and
  3414. locals then
  3415. begin
  3416. tparasymtable(parast).load_references(ppufile,locals);
  3417. tlocalsymtable(localst).load_references(ppufile,locals);
  3418. end;
  3419. aktparasymtable:=oldparasymtable;
  3420. aktlocalsymtable:=oldlocalsymtable;
  3421. end;
  3422. Const
  3423. local_symtable_index : word = $8001;
  3424. function tprocdef.write_references(ppufile:tcompilerppufile;locals:boolean):boolean;
  3425. var
  3426. ref : tref;
  3427. pdo : tobjectdef;
  3428. move_last : boolean;
  3429. d : tderef;
  3430. oldparasymtable,
  3431. oldlocalsymtable : tsymtable;
  3432. begin
  3433. d.reset;
  3434. move_last:=lastwritten=lastref;
  3435. if move_last and
  3436. (((current_module.flags and uf_local_browser)=0) or
  3437. not locals) then
  3438. exit;
  3439. oldparasymtable:=aktparasymtable;
  3440. oldlocalsymtable:=aktlocalsymtable;
  3441. aktparasymtable:=parast;
  3442. aktlocalsymtable:=localst;
  3443. { write address of this symbol }
  3444. d.build(self);
  3445. ppufile.putderef(d);
  3446. { write refs }
  3447. if assigned(lastwritten) then
  3448. ref:=lastwritten
  3449. else
  3450. ref:=defref;
  3451. while assigned(ref) do
  3452. begin
  3453. if ref.moduleindex=current_module.unit_index then
  3454. begin
  3455. ppufile.putposinfo(ref.posinfo);
  3456. ref.is_written:=true;
  3457. if move_last then
  3458. lastwritten:=ref;
  3459. end
  3460. else if not ref.is_written then
  3461. move_last:=false
  3462. else if move_last then
  3463. lastwritten:=ref;
  3464. ref:=ref.nextref;
  3465. end;
  3466. ppufile.writeentry(ibdefref);
  3467. write_references:=true;
  3468. if ((current_module.flags and uf_local_browser)<>0) and
  3469. locals then
  3470. begin
  3471. pdo:=_class;
  3472. if (owner.symtabletype<>localsymtable) then
  3473. while assigned(pdo) do
  3474. begin
  3475. if pdo.symtable<>aktrecordsymtable then
  3476. begin
  3477. pdo.symtable.unitid:=local_symtable_index;
  3478. inc(local_symtable_index);
  3479. end;
  3480. pdo:=pdo.childof;
  3481. end;
  3482. parast.unitid:=local_symtable_index;
  3483. inc(local_symtable_index);
  3484. localst.unitid:=local_symtable_index;
  3485. inc(local_symtable_index);
  3486. tstoredsymtable(parast).write_references(ppufile,locals);
  3487. tstoredsymtable(localst).write_references(ppufile,locals);
  3488. { decrement for }
  3489. local_symtable_index:=local_symtable_index-2;
  3490. pdo:=_class;
  3491. if (owner.symtabletype<>localsymtable) then
  3492. while assigned(pdo) do
  3493. begin
  3494. if pdo.symtable<>aktrecordsymtable then
  3495. dec(local_symtable_index);
  3496. pdo:=pdo.childof;
  3497. end;
  3498. end;
  3499. aktparasymtable:=oldparasymtable;
  3500. aktlocalsymtable:=oldlocalsymtable;
  3501. end;
  3502. {$ifdef GDB}
  3503. {$ifdef unused}
  3504. { procedure addparaname(p : tsym);
  3505. var vs : char;
  3506. begin
  3507. if tvarsym(p).varspez = vs_value then vs := '1'
  3508. else vs := '0';
  3509. strpcopy(strend(StabRecString),p^.name+':'+tstoreddef(tvarsym(p).vartype.def).numberstring+','+vs+';');
  3510. end; }
  3511. function tprocdef.stabstring : pchar;
  3512. var
  3513. i : longint;
  3514. stabrecstring : pchar;
  3515. begin
  3516. getmem(StabRecString,1024);
  3517. strpcopy(StabRecString,'f'+tstoreddef(rettype.def).numberstring);
  3518. i:=maxparacount;
  3519. if i>0 then
  3520. begin
  3521. strpcopy(strend(StabRecString),','+tostr(i)+';');
  3522. (* confuse gdb !! PM
  3523. if assigned(parast) then
  3524. parast.foreach({$ifdef FPCPROCVAR}@{$endif}addparaname)
  3525. else
  3526. begin
  3527. param := para1;
  3528. i := 0;
  3529. while assigned(param) do
  3530. begin
  3531. inc(i);
  3532. if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
  3533. {Here we have lost the parameter names !!}
  3534. {using lower case parameters }
  3535. strpcopy(strend(stabrecstring),'p'+tostr(i)
  3536. +':'+param^.paratype.def.numberstring+','+vartyp+';');
  3537. param := param^.next;
  3538. end;
  3539. end; *)
  3540. {strpcopy(strend(StabRecString),';');}
  3541. end;
  3542. stabstring := strnew(stabrecstring);
  3543. freemem(stabrecstring,1024);
  3544. end;
  3545. {$endif unused}
  3546. function tprocdef.stabstring: pchar;
  3547. Var RType : Char;
  3548. Obj,Info : String;
  3549. stabsstr : string;
  3550. p : pchar;
  3551. begin
  3552. obj := procsym.name;
  3553. info := '';
  3554. if tprocsym(procsym).is_global then
  3555. RType := 'F'
  3556. else
  3557. RType := 'f';
  3558. if assigned(owner) then
  3559. begin
  3560. if (owner.symtabletype = objectsymtable) then
  3561. obj := owner.name^+'__'+procsym.name;
  3562. { this code was correct only as long as the local symboltable
  3563. of the parent had the same name as the function
  3564. but this is no true anymore !! PM
  3565. if (owner.symtabletype=localsymtable) and assigned(owner.name) then
  3566. info := ','+name+','+owner.name^; }
  3567. if (owner.symtabletype=localsymtable) and
  3568. assigned(owner.defowner) and
  3569. assigned(tprocdef(owner.defowner).procsym) then
  3570. info := ','+procsym.name+','+tprocdef(owner.defowner).procsym.name;
  3571. end;
  3572. stabsstr:=mangledname;
  3573. getmem(p,length(stabsstr)+255);
  3574. strpcopy(p,'"'+obj+':'+RType
  3575. +tstoreddef(rettype.def).numberstring+info+'",'+tostr(n_function)
  3576. +',0,'+
  3577. tostr(fileinfo.line)
  3578. +',');
  3579. strpcopy(strend(p),stabsstr);
  3580. stabstring:=strnew(p);
  3581. freemem(p,length(stabsstr)+255);
  3582. end;
  3583. procedure tprocdef.concatstabto(asmlist : taasmoutput);
  3584. begin
  3585. { released procdef? }
  3586. if not assigned(parast) then
  3587. exit;
  3588. if (proccalloption=pocall_internproc) then
  3589. exit;
  3590. if not isstabwritten then
  3591. asmList.concat(Tai_stabs.Create(stabstring));
  3592. isstabwritten := true;
  3593. if not(po_external in procoptions) then
  3594. begin
  3595. tstoredsymtable(parast).concatstabto(asmlist);
  3596. { local type defs and vars should not be written
  3597. inside the main proc stab }
  3598. if assigned(localst) and
  3599. (localst.symtablelevel>main_program_level) then
  3600. tstoredsymtable(localst).concatstabto(asmlist);
  3601. end;
  3602. is_def_stab_written := written;
  3603. end;
  3604. {$endif GDB}
  3605. procedure tprocdef.buildderef;
  3606. var
  3607. oldparasymtable,
  3608. oldlocalsymtable : tsymtable;
  3609. begin
  3610. oldparasymtable:=aktparasymtable;
  3611. oldlocalsymtable:=aktlocalsymtable;
  3612. aktparasymtable:=parast;
  3613. aktlocalsymtable:=localst;
  3614. inherited buildderef;
  3615. _classderef.build(_class);
  3616. { procsym that originaly defined this definition, should be in the
  3617. same symtable }
  3618. procsymderef.build(procsym);
  3619. aktparasymtable:=oldparasymtable;
  3620. aktlocalsymtable:=oldlocalsymtable;
  3621. end;
  3622. procedure tprocdef.buildderefimpl;
  3623. var
  3624. oldparasymtable,
  3625. oldlocalsymtable : tsymtable;
  3626. begin
  3627. { released procdef? }
  3628. if not assigned(parast) then
  3629. exit;
  3630. oldparasymtable:=aktparasymtable;
  3631. oldlocalsymtable:=aktlocalsymtable;
  3632. aktparasymtable:=parast;
  3633. aktlocalsymtable:=localst;
  3634. inherited buildderefimpl;
  3635. { locals }
  3636. if assigned(localst) then
  3637. begin
  3638. tlocalsymtable(localst).buildderefimpl;
  3639. funcretsymderef.build(funcretsym);
  3640. end;
  3641. { inline tree }
  3642. if (proccalloption=pocall_inline) then
  3643. code.buildderefimpl;
  3644. aktparasymtable:=oldparasymtable;
  3645. aktlocalsymtable:=oldlocalsymtable;
  3646. end;
  3647. procedure tprocdef.deref;
  3648. var
  3649. oldparasymtable,
  3650. oldlocalsymtable : tsymtable;
  3651. begin
  3652. { released procdef? }
  3653. if not assigned(parast) then
  3654. exit;
  3655. oldparasymtable:=aktparasymtable;
  3656. oldlocalsymtable:=aktlocalsymtable;
  3657. aktparasymtable:=parast;
  3658. aktlocalsymtable:=localst;
  3659. inherited deref;
  3660. _class:=tobjectdef(_classderef.resolve);
  3661. { procsym that originaly defined this definition, should be in the
  3662. same symtable }
  3663. procsym:=tprocsym(procsymderef.resolve);
  3664. aktparasymtable:=oldparasymtable;
  3665. aktlocalsymtable:=oldlocalsymtable;
  3666. end;
  3667. procedure tprocdef.derefimpl;
  3668. var
  3669. oldparasymtable,
  3670. oldlocalsymtable : tsymtable;
  3671. begin
  3672. oldparasymtable:=aktparasymtable;
  3673. oldlocalsymtable:=aktlocalsymtable;
  3674. aktparasymtable:=parast;
  3675. aktlocalsymtable:=localst;
  3676. { locals }
  3677. if assigned(localst) then
  3678. begin
  3679. { localst }
  3680. { we can deref both interface and implementation parts }
  3681. tlocalsymtable(localst).deref;
  3682. tlocalsymtable(localst).derefimpl;
  3683. { funcretsym, this is always located in the localst }
  3684. funcretsym:=tsym(funcretsymderef.resolve);
  3685. end
  3686. else
  3687. begin
  3688. { safety }
  3689. funcretsym:=nil;
  3690. end;
  3691. { inline tree }
  3692. if (proccalloption=pocall_inline) then
  3693. code.derefimpl;
  3694. aktparasymtable:=oldparasymtable;
  3695. aktlocalsymtable:=oldlocalsymtable;
  3696. end;
  3697. function tprocdef.gettypename : string;
  3698. begin
  3699. gettypename := FullProcName(false);
  3700. end;
  3701. function tprocdef.mangledname : string;
  3702. var
  3703. s : string;
  3704. hp : TParaItem;
  3705. begin
  3706. if assigned(_mangledname) then
  3707. begin
  3708. mangledname:=_mangledname^;
  3709. exit;
  3710. end;
  3711. { we need to use the symtable where the procsym is inserted,
  3712. because that is visible to the world }
  3713. s:=mangledname_prefix('',procsym.owner)+procsym.name;
  3714. if overloadnumber>0 then
  3715. s:=s+'$'+tostr(overloadnumber);
  3716. { add parameter types }
  3717. hp:=TParaItem(Para.first);
  3718. while assigned(hp) do
  3719. begin
  3720. if not hp.is_hidden then
  3721. s:=s+'$'+hp.paratype.def.mangledparaname;
  3722. hp:=TParaItem(hp.next);
  3723. end;
  3724. _mangledname:=stringdup(s);
  3725. mangledname:=_mangledname^;
  3726. end;
  3727. function tprocdef.cplusplusmangledname : string;
  3728. function getcppparaname(p : tdef) : string;
  3729. const
  3730. ordtype2str : array[tbasetype] of string[2] = (
  3731. '',
  3732. 'Uc','Us','Ui','Us',
  3733. 'Sc','s','i','x',
  3734. 'b','b','b',
  3735. 'c','w','x');
  3736. var
  3737. s : string;
  3738. begin
  3739. case p.deftype of
  3740. orddef:
  3741. s:=ordtype2str[torddef(p).typ];
  3742. pointerdef:
  3743. s:='P'+getcppparaname(tpointerdef(p).pointertype.def);
  3744. else
  3745. internalerror(2103001);
  3746. end;
  3747. getcppparaname:=s;
  3748. end;
  3749. var
  3750. s,s2 : string;
  3751. param : TParaItem;
  3752. begin
  3753. s := procsym.realname;
  3754. if procsym.owner.symtabletype=objectsymtable then
  3755. begin
  3756. s2:=upper(tobjectdef(procsym.owner.defowner).typesym.realname);
  3757. case proctypeoption of
  3758. potype_destructor:
  3759. s:='_$_'+tostr(length(s2))+s2;
  3760. potype_constructor:
  3761. s:='___'+tostr(length(s2))+s2;
  3762. else
  3763. s:='_'+s+'__'+tostr(length(s2))+s2;
  3764. end;
  3765. end
  3766. else s:=s+'__';
  3767. s:=s+'F';
  3768. { concat modifiers }
  3769. { !!!!! }
  3770. { now we handle the parameters }
  3771. param := TParaItem(Para.first);
  3772. if assigned(param) then
  3773. while assigned(param) do
  3774. begin
  3775. s2:=getcppparaname(param.paratype.def);
  3776. if param.paratyp in [vs_var,vs_out] then
  3777. s2:='R'+s2;
  3778. s:=s+s2;
  3779. param:=TParaItem(param.next);
  3780. end
  3781. else
  3782. s:=s+'v';
  3783. cplusplusmangledname:=s;
  3784. end;
  3785. procedure tprocdef.setmangledname(const s : string);
  3786. begin
  3787. stringdispose(_mangledname);
  3788. _mangledname:=stringdup(s);
  3789. has_mangledname:=true;
  3790. end;
  3791. {***************************************************************************
  3792. TPROCVARDEF
  3793. ***************************************************************************}
  3794. constructor tprocvardef.create(level:byte);
  3795. begin
  3796. inherited create(level);
  3797. deftype:=procvardef;
  3798. end;
  3799. constructor tprocvardef.ppuload(ppufile:tcompilerppufile);
  3800. begin
  3801. inherited ppuload(ppufile);
  3802. deftype:=procvardef;
  3803. { load para symtable }
  3804. parast:=tparasymtable.create(unknown_level);
  3805. tparasymtable(parast).ppuload(ppufile);
  3806. parast.defowner:=self;
  3807. end;
  3808. procedure tprocvardef.ppuwrite(ppufile:tcompilerppufile);
  3809. var
  3810. oldparasymtable,
  3811. oldlocalsymtable : tsymtable;
  3812. begin
  3813. oldparasymtable:=aktparasymtable;
  3814. oldlocalsymtable:=aktlocalsymtable;
  3815. aktparasymtable:=parast;
  3816. aktlocalsymtable:=nil;
  3817. { here we cannot get a real good value so just give something }
  3818. { plausible (PM) }
  3819. { a more secure way would be
  3820. to allways store in a temp }
  3821. {$ifdef i386}
  3822. if is_fpu(rettype.def) then
  3823. fpu_used:={2}maxfpuregs
  3824. else
  3825. fpu_used:=0;
  3826. {$endif i386}
  3827. inherited ppuwrite(ppufile);
  3828. { Write this entry }
  3829. ppufile.writeentry(ibprocvardef);
  3830. { Save the para symtable, this is taken from the interface }
  3831. tparasymtable(parast).ppuwrite(ppufile);
  3832. aktparasymtable:=oldparasymtable;
  3833. aktlocalsymtable:=oldlocalsymtable;
  3834. end;
  3835. procedure tprocvardef.buildderef;
  3836. var
  3837. oldparasymtable,
  3838. oldlocalsymtable : tsymtable;
  3839. begin
  3840. oldparasymtable:=aktparasymtable;
  3841. oldlocalsymtable:=aktlocalsymtable;
  3842. aktparasymtable:=parast;
  3843. aktlocalsymtable:=nil;
  3844. inherited buildderef;
  3845. aktparasymtable:=oldparasymtable;
  3846. aktlocalsymtable:=oldlocalsymtable;
  3847. end;
  3848. procedure tprocvardef.deref;
  3849. var
  3850. oldparasymtable,
  3851. oldlocalsymtable : tsymtable;
  3852. begin
  3853. oldparasymtable:=aktparasymtable;
  3854. oldlocalsymtable:=aktlocalsymtable;
  3855. aktparasymtable:=parast;
  3856. aktlocalsymtable:=nil;
  3857. inherited deref;
  3858. aktparasymtable:=oldparasymtable;
  3859. aktlocalsymtable:=oldlocalsymtable;
  3860. end;
  3861. function tprocvardef.getsymtable(t:tgetsymtable):tsymtable;
  3862. begin
  3863. case t of
  3864. gs_para :
  3865. getsymtable:=parast;
  3866. else
  3867. getsymtable:=nil;
  3868. end;
  3869. end;
  3870. function tprocvardef.size : longint;
  3871. begin
  3872. if (po_methodpointer in procoptions) and
  3873. not(po_addressonly in procoptions) then
  3874. size:=2*POINTER_SIZE
  3875. else
  3876. size:=POINTER_SIZE;
  3877. end;
  3878. function tprocvardef.is_methodpointer:boolean;
  3879. begin
  3880. result:=(po_methodpointer in procoptions);
  3881. end;
  3882. function tprocvardef.is_addressonly:boolean;
  3883. begin
  3884. result:=not(po_methodpointer in procoptions) or
  3885. (po_addressonly in procoptions);
  3886. end;
  3887. {$ifdef GDB}
  3888. function tprocvardef.stabstring : pchar;
  3889. var
  3890. nss : pchar;
  3891. { i : longint; }
  3892. begin
  3893. { i := maxparacount; }
  3894. getmem(nss,1024);
  3895. { it is not a function but a function pointer !! (PM) }
  3896. strpcopy(nss,'*f'+tstoreddef(rettype.def).numberstring{+','+tostr(i)}+';');
  3897. { this confuses gdb !!
  3898. we should use 'F' instead of 'f' but
  3899. as we use c++ language mode
  3900. it does not like that either
  3901. Please do not remove this part
  3902. might be used once
  3903. gdb for pascal is ready PM }
  3904. (*
  3905. param := para1;
  3906. i := 0;
  3907. while assigned(param) do
  3908. begin
  3909. inc(i);
  3910. if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
  3911. {Here we have lost the parameter names !!}
  3912. pst := strpnew('p'+tostr(i)+':'+param^.paratype.def.numberstring+','+vartyp+';');
  3913. strcat(nss,pst);
  3914. strdispose(pst);
  3915. param := param^.next;
  3916. end; *)
  3917. {strpcopy(strend(nss),';');}
  3918. stabstring := strnew(nss);
  3919. freemem(nss,1024);
  3920. end;
  3921. procedure tprocvardef.concatstabto(asmlist : taasmoutput);
  3922. begin
  3923. if ( not assigned(typesym) or ttypesym(typesym).isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  3924. and (is_def_stab_written = not_written) then
  3925. inherited concatstabto(asmlist);
  3926. is_def_stab_written:=written;
  3927. end;
  3928. {$endif GDB}
  3929. procedure tprocvardef.write_rtti_data(rt:trttitype);
  3930. var
  3931. pdc : TParaItem;
  3932. methodkind, paraspec : byte;
  3933. begin
  3934. if po_methodpointer in procoptions then
  3935. begin
  3936. { write method id and name }
  3937. rttiList.concat(Tai_const.Create_8bit(tkmethod));
  3938. write_rtti_name;
  3939. { write kind of method (can only be function or procedure)}
  3940. if rettype.def = voidtype.def then
  3941. methodkind := mkProcedure
  3942. else
  3943. methodkind := mkFunction;
  3944. rttiList.concat(Tai_const.Create_8bit(methodkind));
  3945. { get # of parameters }
  3946. rttiList.concat(Tai_const.Create_8bit(maxparacount));
  3947. { write parameter info. The parameters must be written in reverse order
  3948. if this method uses right to left parameter pushing! }
  3949. if proccalloption in pushleftright_pocalls then
  3950. pdc:=TParaItem(Para.first)
  3951. else
  3952. pdc:=TParaItem(Para.last);
  3953. while assigned(pdc) do
  3954. begin
  3955. case pdc.paratyp of
  3956. vs_value: paraspec := 0;
  3957. vs_const: paraspec := pfConst;
  3958. vs_var : paraspec := pfVar;
  3959. vs_out : paraspec := pfOut;
  3960. end;
  3961. { write flags for current parameter }
  3962. rttiList.concat(Tai_const.Create_8bit(paraspec));
  3963. { write name of current parameter ### how can I get this??? (sg)}
  3964. rttiList.concat(Tai_const.Create_8bit(0));
  3965. { write name of type of current parameter }
  3966. tstoreddef(pdc.paratype.def).write_rtti_name;
  3967. if proccalloption in pushleftright_pocalls then
  3968. pdc:=TParaItem(pdc.next)
  3969. else
  3970. pdc:=TParaItem(pdc.previous);
  3971. end;
  3972. { write name of result type }
  3973. tstoreddef(rettype.def).write_rtti_name;
  3974. end;
  3975. end;
  3976. function tprocvardef.is_publishable : boolean;
  3977. begin
  3978. is_publishable:=(po_methodpointer in procoptions);
  3979. end;
  3980. function tprocvardef.gettypename : string;
  3981. var
  3982. s: string;
  3983. showhidden : boolean;
  3984. begin
  3985. {$ifdef EXTDEBUG}
  3986. showhidden:=true;
  3987. {$else EXTDEBUG}
  3988. showhidden:=false;
  3989. {$endif EXTDEBUG}
  3990. s:='<';
  3991. if po_classmethod in procoptions then
  3992. s := s+'class method type of'
  3993. else
  3994. if po_addressonly in procoptions then
  3995. s := s+'address of'
  3996. else
  3997. s := s+'procedure variable type of';
  3998. if assigned(rettype.def) and
  3999. (rettype.def<>voidtype.def) then
  4000. s:=s+' function'+typename_paras(showhidden)+':'+rettype.def.gettypename
  4001. else
  4002. s:=s+' procedure'+typename_paras(showhidden);
  4003. if po_methodpointer in procoptions then
  4004. s := s+' of object';
  4005. gettypename := s+';'+ProcCallOptionStr[proccalloption]+'>';
  4006. end;
  4007. {***************************************************************************
  4008. TOBJECTDEF
  4009. ***************************************************************************}
  4010. constructor tobjectdef.create(ot : tobjectdeftype;const n : string;c : tobjectdef);
  4011. begin
  4012. inherited create;
  4013. objecttype:=ot;
  4014. deftype:=objectdef;
  4015. objectoptions:=[];
  4016. childof:=nil;
  4017. symtable:=tobjectsymtable.create(n);
  4018. { create space for vmt !! }
  4019. vmt_offset:=0;
  4020. symtable.defowner:=self;
  4021. { recordalign -1 means C record packing, that starts
  4022. with an alignment of 1 }
  4023. if aktalignment.recordalignmax=-1 then
  4024. tobjectsymtable(symtable).dataalignment:=1
  4025. else
  4026. tobjectsymtable(symtable).dataalignment:=aktalignment.recordalignmax;
  4027. lastvtableindex:=0;
  4028. set_parent(c);
  4029. objname:=stringdup(upper(n));
  4030. objrealname:=stringdup(n);
  4031. if objecttype in [odt_interfacecorba,odt_interfacecom] then
  4032. prepareguid;
  4033. { setup implemented interfaces }
  4034. if objecttype in [odt_class,odt_interfacecorba] then
  4035. implementedinterfaces:=timplementedinterfaces.create
  4036. else
  4037. implementedinterfaces:=nil;
  4038. {$ifdef GDB}
  4039. writing_class_record_stab:=false;
  4040. {$endif GDB}
  4041. end;
  4042. constructor tobjectdef.ppuload(ppufile:tcompilerppufile);
  4043. var
  4044. i,implintfcount: longint;
  4045. d : tderef;
  4046. begin
  4047. inherited ppuloaddef(ppufile);
  4048. deftype:=objectdef;
  4049. objecttype:=tobjectdeftype(ppufile.getbyte);
  4050. savesize:=ppufile.getlongint;
  4051. vmt_offset:=ppufile.getlongint;
  4052. objrealname:=stringdup(ppufile.getstring);
  4053. objname:=stringdup(upper(objrealname^));
  4054. ppufile.getderef(childofderef);
  4055. ppufile.getsmallset(objectoptions);
  4056. { load guid }
  4057. iidstr:=nil;
  4058. if objecttype in [odt_interfacecom,odt_interfacecorba] then
  4059. begin
  4060. new(iidguid);
  4061. ppufile.getguid(iidguid^);
  4062. iidstr:=stringdup(ppufile.getstring);
  4063. lastvtableindex:=ppufile.getlongint;
  4064. end;
  4065. { load implemented interfaces }
  4066. if objecttype in [odt_class,odt_interfacecorba] then
  4067. begin
  4068. implementedinterfaces:=timplementedinterfaces.create;
  4069. implintfcount:=ppufile.getlongint;
  4070. for i:=1 to implintfcount do
  4071. begin
  4072. ppufile.getderef(d);
  4073. implementedinterfaces.addintf_deref(d);
  4074. implementedinterfaces.ioffsets(i)^:=ppufile.getlongint;
  4075. end;
  4076. end
  4077. else
  4078. implementedinterfaces:=nil;
  4079. symtable:=tobjectsymtable.create(objrealname^);
  4080. tobjectsymtable(symtable).datasize:=ppufile.getlongint;
  4081. tobjectsymtable(symtable).dataalignment:=ppufile.getbyte;
  4082. tobjectsymtable(symtable).ppuload(ppufile);
  4083. symtable.defowner:=self;
  4084. { handles the predefined class tobject }
  4085. { the last TOBJECT which is loaded gets }
  4086. { it ! }
  4087. if (childof=nil) and
  4088. (objecttype=odt_class) and
  4089. (objname^='TOBJECT') then
  4090. class_tobject:=self;
  4091. if (childof=nil) and
  4092. (objecttype=odt_interfacecom) and
  4093. (objname^='IUNKNOWN') then
  4094. interface_iunknown:=self;
  4095. {$ifdef GDB}
  4096. writing_class_record_stab:=false;
  4097. {$endif GDB}
  4098. end;
  4099. destructor tobjectdef.destroy;
  4100. begin
  4101. if assigned(symtable) then
  4102. symtable.free;
  4103. stringdispose(objname);
  4104. stringdispose(objrealname);
  4105. if assigned(iidstr) then
  4106. stringdispose(iidstr);
  4107. if assigned(implementedinterfaces) then
  4108. implementedinterfaces.free;
  4109. if assigned(iidguid) then
  4110. dispose(iidguid);
  4111. inherited destroy;
  4112. end;
  4113. procedure tobjectdef.ppuwrite(ppufile:tcompilerppufile);
  4114. var
  4115. implintfcount : longint;
  4116. i : longint;
  4117. begin
  4118. inherited ppuwritedef(ppufile);
  4119. ppufile.putbyte(byte(objecttype));
  4120. ppufile.putlongint(size);
  4121. ppufile.putlongint(vmt_offset);
  4122. ppufile.putstring(objrealname^);
  4123. ppufile.putderef(childofderef);
  4124. ppufile.putsmallset(objectoptions);
  4125. if objecttype in [odt_interfacecom,odt_interfacecorba] then
  4126. begin
  4127. ppufile.putguid(iidguid^);
  4128. ppufile.putstring(iidstr^);
  4129. ppufile.putlongint(lastvtableindex);
  4130. end;
  4131. if objecttype in [odt_class,odt_interfacecorba] then
  4132. begin
  4133. implintfcount:=implementedinterfaces.count;
  4134. ppufile.putlongint(implintfcount);
  4135. for i:=1 to implintfcount do
  4136. begin
  4137. ppufile.putderef(implementedinterfaces.interfacesderef(i));
  4138. ppufile.putlongint(implementedinterfaces.ioffsets(i)^);
  4139. end;
  4140. end;
  4141. ppufile.putlongint(tobjectsymtable(symtable).datasize);
  4142. ppufile.putbyte(tobjectsymtable(symtable).dataalignment);
  4143. ppufile.writeentry(ibobjectdef);
  4144. tobjectsymtable(symtable).ppuwrite(ppufile);
  4145. end;
  4146. function tobjectdef.gettypename:string;
  4147. begin
  4148. gettypename:=typename;
  4149. end;
  4150. procedure tobjectdef.buildderef;
  4151. var
  4152. oldrecsyms : tsymtable;
  4153. begin
  4154. inherited buildderef;
  4155. childofderef.build(childof);
  4156. oldrecsyms:=aktrecordsymtable;
  4157. aktrecordsymtable:=symtable;
  4158. tstoredsymtable(symtable).buildderef;
  4159. aktrecordsymtable:=oldrecsyms;
  4160. if objecttype in [odt_class,odt_interfacecorba] then
  4161. implementedinterfaces.buildderef;
  4162. end;
  4163. procedure tobjectdef.deref;
  4164. var
  4165. oldrecsyms : tsymtable;
  4166. begin
  4167. inherited deref;
  4168. childof:=tobjectdef(childofderef.resolve);
  4169. oldrecsyms:=aktrecordsymtable;
  4170. aktrecordsymtable:=symtable;
  4171. tstoredsymtable(symtable).deref;
  4172. aktrecordsymtable:=oldrecsyms;
  4173. if objecttype in [odt_class,odt_interfacecorba] then
  4174. implementedinterfaces.deref;
  4175. end;
  4176. function tobjectdef.getparentdef:tdef;
  4177. begin
  4178. result:=childof;
  4179. end;
  4180. procedure tobjectdef.prepareguid;
  4181. begin
  4182. { set up guid }
  4183. if not assigned(iidguid) then
  4184. begin
  4185. new(iidguid);
  4186. fillchar(iidguid^,sizeof(iidguid^),0); { default null guid }
  4187. end;
  4188. { setup iidstring }
  4189. if not assigned(iidstr) then
  4190. iidstr:=stringdup(''); { default is empty string }
  4191. end;
  4192. procedure tobjectdef.set_parent( c : tobjectdef);
  4193. begin
  4194. { nothing to do if the parent was not forward !}
  4195. if assigned(childof) then
  4196. exit;
  4197. childof:=c;
  4198. { some options are inherited !! }
  4199. if assigned(c) then
  4200. begin
  4201. { only important for classes }
  4202. lastvtableindex:=c.lastvtableindex;
  4203. objectoptions:=objectoptions+(c.objectoptions*
  4204. [oo_has_virtual,oo_has_private,oo_has_protected,
  4205. oo_has_constructor,oo_has_destructor]);
  4206. if not (objecttype in [odt_interfacecom,odt_interfacecorba]) then
  4207. begin
  4208. { add the data of the anchestor class }
  4209. inc(tobjectsymtable(symtable).datasize,tobjectsymtable(c.symtable).datasize);
  4210. if (oo_has_vmt in objectoptions) and
  4211. (oo_has_vmt in c.objectoptions) then
  4212. dec(tobjectsymtable(symtable).datasize,POINTER_SIZE);
  4213. { if parent has a vmt field then
  4214. the offset is the same for the child PM }
  4215. if (oo_has_vmt in c.objectoptions) or is_class(self) then
  4216. begin
  4217. vmt_offset:=c.vmt_offset;
  4218. include(objectoptions,oo_has_vmt);
  4219. end;
  4220. end;
  4221. end;
  4222. savesize := tobjectsymtable(symtable).datasize;
  4223. end;
  4224. procedure tobjectdef.insertvmt;
  4225. begin
  4226. if objecttype in [odt_interfacecom,odt_interfacecorba] then
  4227. exit;
  4228. if (oo_has_vmt in objectoptions) then
  4229. internalerror(12345)
  4230. else
  4231. begin
  4232. tobjectsymtable(symtable).datasize:=align(tobjectsymtable(symtable).datasize,
  4233. tobjectsymtable(symtable).dataalignment);
  4234. vmt_offset:=tobjectsymtable(symtable).datasize;
  4235. inc(tobjectsymtable(symtable).datasize,POINTER_SIZE);
  4236. include(objectoptions,oo_has_vmt);
  4237. end;
  4238. end;
  4239. procedure tobjectdef.check_forwards;
  4240. begin
  4241. if not(objecttype in [odt_interfacecom,odt_interfacecorba]) then
  4242. tstoredsymtable(symtable).check_forwards;
  4243. if (oo_is_forward in objectoptions) then
  4244. begin
  4245. { ok, in future, the forward can be resolved }
  4246. Message1(sym_e_class_forward_not_resolved,objrealname^);
  4247. exclude(objectoptions,oo_is_forward);
  4248. end;
  4249. end;
  4250. { true, if self inherits from d (or if they are equal) }
  4251. function tobjectdef.is_related(d : tobjectdef) : boolean;
  4252. var
  4253. hp : tobjectdef;
  4254. begin
  4255. hp:=self;
  4256. while assigned(hp) do
  4257. begin
  4258. if hp=d then
  4259. begin
  4260. is_related:=true;
  4261. exit;
  4262. end;
  4263. hp:=hp.childof;
  4264. end;
  4265. is_related:=false;
  4266. end;
  4267. (* procedure tobjectdef._searchdestructor(sym : tnamedindexitem;arg:pointer);
  4268. var
  4269. p : pprocdeflist;
  4270. begin
  4271. { if we found already a destructor, then we exit }
  4272. if assigned(sd) then
  4273. exit;
  4274. if tsym(sym).typ=procsym then
  4275. begin
  4276. p:=tprocsym(sym).defs;
  4277. while assigned(p) do
  4278. begin
  4279. if p^.def.proctypeoption=potype_destructor then
  4280. begin
  4281. sd:=p^.def;
  4282. exit;
  4283. end;
  4284. p:=p^.next;
  4285. end;
  4286. end;
  4287. end;*)
  4288. procedure _searchdestructor(sym:Tnamedindexitem;sd:pointer);
  4289. begin
  4290. { if we found already a destructor, then we exit }
  4291. if (ppointer(sd)^=nil) and
  4292. (Tsym(sym).typ=procsym) then
  4293. ppointer(sd)^:=Tprocsym(sym).search_procdef_bytype(potype_destructor);
  4294. end;
  4295. function tobjectdef.searchdestructor : tprocdef;
  4296. var
  4297. o : tobjectdef;
  4298. sd : tprocdef;
  4299. begin
  4300. searchdestructor:=nil;
  4301. o:=self;
  4302. sd:=nil;
  4303. while assigned(o) do
  4304. begin
  4305. o.symtable.foreach_static({$ifdef FPCPROCVAR}@{$endif}_searchdestructor,@sd);
  4306. if assigned(sd) then
  4307. begin
  4308. searchdestructor:=sd;
  4309. exit;
  4310. end;
  4311. o:=o.childof;
  4312. end;
  4313. end;
  4314. function tobjectdef.size : longint;
  4315. begin
  4316. if objecttype in [odt_class,odt_interfacecom,odt_interfacecorba] then
  4317. result:=POINTER_SIZE
  4318. else
  4319. result:=tobjectsymtable(symtable).datasize;
  4320. end;
  4321. function tobjectdef.alignment:longint;
  4322. begin
  4323. alignment:=tobjectsymtable(symtable).dataalignment;
  4324. end;
  4325. function tobjectdef.vmtmethodoffset(index:longint):longint;
  4326. begin
  4327. { for offset of methods for classes, see rtl/inc/objpash.inc }
  4328. case objecttype of
  4329. odt_class:
  4330. vmtmethodoffset:=(index+12)*POINTER_SIZE;
  4331. odt_interfacecom,odt_interfacecorba:
  4332. vmtmethodoffset:=index*POINTER_SIZE;
  4333. else
  4334. {$ifdef WITHDMT}
  4335. vmtmethodoffset:=(index+4)*POINTER_SIZE;
  4336. {$else WITHDMT}
  4337. vmtmethodoffset:=(index+3)*POINTER_SIZE;
  4338. {$endif WITHDMT}
  4339. end;
  4340. end;
  4341. function tobjectdef.vmt_mangledname : string;
  4342. begin
  4343. if not(oo_has_vmt in objectoptions) then
  4344. Message1(parser_n_object_has_no_vmt,objrealname^);
  4345. vmt_mangledname:=mangledname_prefix('VMT',owner)+objname^;
  4346. end;
  4347. function tobjectdef.rtti_name : string;
  4348. begin
  4349. rtti_name:=mangledname_prefix('RTTI',owner)+objname^;
  4350. end;
  4351. {$ifdef GDB}
  4352. procedure tobjectdef.addprocname(p :tnamedindexitem;arg:pointer);
  4353. var virtualind,argnames : string;
  4354. news, newrec : pchar;
  4355. pd,ipd : tprocdef;
  4356. lindex : longint;
  4357. para : TParaItem;
  4358. arglength : byte;
  4359. sp : char;
  4360. begin
  4361. If tsym(p).typ = procsym then
  4362. begin
  4363. pd := tprocsym(p).first_procdef;
  4364. { this will be used for full implementation of object stabs
  4365. not yet done }
  4366. ipd := Tprocsym(p).last_procdef;
  4367. if (po_virtualmethod in pd.procoptions) then
  4368. begin
  4369. lindex := pd.extnumber;
  4370. {doesnt seem to be necessary
  4371. lindex := lindex or $80000000;}
  4372. virtualind := '*'+tostr(lindex)+';'+ipd._class.classnumberstring+';'
  4373. end
  4374. else
  4375. virtualind := '.';
  4376. { used by gdbpas to recognize constructor and destructors }
  4377. if (pd.proctypeoption=potype_constructor) then
  4378. argnames:='__ct__'
  4379. else if (pd.proctypeoption=potype_destructor) then
  4380. argnames:='__dt__'
  4381. else
  4382. argnames := '';
  4383. { arguments are not listed here }
  4384. {we don't need another definition}
  4385. para := TParaItem(pd.Para.first);
  4386. while assigned(para) do
  4387. begin
  4388. if Para.paratype.def.deftype = formaldef then
  4389. begin
  4390. if Para.paratyp=vs_var then
  4391. argnames := argnames+'3var'
  4392. else if Para.paratyp=vs_const then
  4393. argnames:=argnames+'5const'
  4394. else if Para.paratyp=vs_out then
  4395. argnames:=argnames+'3out';
  4396. end
  4397. else
  4398. begin
  4399. { if the arg definition is like (v: ^byte;..
  4400. there is no sym attached to data !!! }
  4401. if assigned(Para.paratype.def.typesym) then
  4402. begin
  4403. arglength := length(Para.paratype.def.typesym.name);
  4404. argnames := argnames + tostr(arglength)+Para.paratype.def.typesym.name;
  4405. end
  4406. else
  4407. begin
  4408. argnames:=argnames+'11unnamedtype';
  4409. end;
  4410. end;
  4411. para := TParaItem(Para.next);
  4412. end;
  4413. ipd.is_def_stab_written := written;
  4414. { here 2A must be changed for private and protected }
  4415. { 0 is private 1 protected and 2 public }
  4416. if (sp_private in tsym(p).symoptions) then sp:='0'
  4417. else if (sp_protected in tsym(p).symoptions) then sp:='1'
  4418. else sp:='2';
  4419. newrec := strpnew(p.name+'::'+ipd.numberstring
  4420. +'=##'+tstoreddef(pd.rettype.def).numberstring+';:'+argnames+';'+sp+'A'
  4421. +virtualind+';');
  4422. { get spare place for a string at the end }
  4423. if strlen(StabRecString) + strlen(newrec) >= StabRecSize-256 then
  4424. begin
  4425. getmem(news,stabrecsize+memsizeinc);
  4426. strcopy(news,stabrecstring);
  4427. freemem(stabrecstring,stabrecsize);
  4428. stabrecsize:=stabrecsize+memsizeinc;
  4429. stabrecstring:=news;
  4430. end;
  4431. strcat(StabRecstring,newrec);
  4432. {freemem(newrec,memsizeinc); }
  4433. strdispose(newrec);
  4434. {This should be used for case !!
  4435. RecOffset := RecOffset + pd.size;}
  4436. end;
  4437. end;
  4438. function tobjectdef.stabstring : pchar;
  4439. var anc : tobjectdef;
  4440. oldrec : pchar;
  4441. oldrecsize,oldrecoffset : longint;
  4442. str_end : string;
  4443. begin
  4444. if not (objecttype=odt_class) or writing_class_record_stab then
  4445. begin
  4446. oldrec := stabrecstring;
  4447. oldrecsize:=stabrecsize;
  4448. stabrecsize:=memsizeinc;
  4449. GetMem(stabrecstring,stabrecsize);
  4450. strpcopy(stabRecString,'s'+tostr(tobjectsymtable(symtable).datasize));
  4451. if assigned(childof) then
  4452. begin
  4453. {only one ancestor not virtual, public, at base offset 0 }
  4454. { !1 , 0 2 0 , }
  4455. strpcopy(strend(stabrecstring),'!1,020,'+childof.classnumberstring+';');
  4456. end;
  4457. {virtual table to implement yet}
  4458. OldRecOffset:=RecOffset;
  4459. RecOffset := 0;
  4460. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}addname,nil);
  4461. RecOffset:=OldRecOffset;
  4462. if (oo_has_vmt in objectoptions) then
  4463. if not assigned(childof) or not(oo_has_vmt in childof.objectoptions) then
  4464. begin
  4465. strpcopy(strend(stabrecstring),'$vf'+classnumberstring+':'+typeglobalnumber('vtblarray')
  4466. +','+tostr(vmt_offset*8)+';');
  4467. end;
  4468. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}addprocname,nil);
  4469. if (oo_has_vmt in objectoptions) then
  4470. begin
  4471. anc := self;
  4472. while assigned(anc.childof) and (oo_has_vmt in anc.childof.objectoptions) do
  4473. anc := anc.childof;
  4474. { just in case anc = self }
  4475. str_end:=';~%'+anc.classnumberstring+';';
  4476. end
  4477. else
  4478. str_end:=';';
  4479. strpcopy(strend(stabrecstring),str_end);
  4480. stabstring := strnew(StabRecString);
  4481. freemem(stabrecstring,stabrecsize);
  4482. stabrecstring := oldrec;
  4483. stabrecsize:=oldrecsize;
  4484. end
  4485. else
  4486. begin
  4487. stabstring:=strpnew('*'+classnumberstring);
  4488. end;
  4489. end;
  4490. procedure tobjectdef.set_globalnb;
  4491. begin
  4492. globalnb:=PglobalTypeCount^;
  4493. inc(PglobalTypeCount^);
  4494. { classes need two type numbers, the globalnb is set to the ptr }
  4495. if objecttype=odt_class then
  4496. begin
  4497. globalnb:=PGlobalTypeCount^;
  4498. inc(PglobalTypeCount^);
  4499. end;
  4500. end;
  4501. function tobjectdef.classnumberstring : string;
  4502. begin
  4503. { write stabs again if needed }
  4504. numberstring;
  4505. if objecttype=odt_class then
  4506. begin
  4507. dec(globalnb);
  4508. classnumberstring:=numberstring;
  4509. inc(globalnb);
  4510. end
  4511. else
  4512. classnumberstring:=numberstring;
  4513. end;
  4514. function tobjectdef.allstabstring : pchar;
  4515. var stabchar : string[2];
  4516. ss,st : pchar;
  4517. sname : string;
  4518. sym_line_no : longint;
  4519. begin
  4520. ss := stabstring;
  4521. getmem(st,strlen(ss)+512);
  4522. stabchar := 't';
  4523. if deftype in tagtypes then
  4524. stabchar := 'Tt';
  4525. if assigned(typesym) then
  4526. begin
  4527. sname := typesym.name;
  4528. sym_line_no:=typesym.fileinfo.line;
  4529. end
  4530. else
  4531. begin
  4532. sname := ' ';
  4533. sym_line_no:=0;
  4534. end;
  4535. if writing_class_record_stab then
  4536. strpcopy(st,'"'+sname+':'+stabchar+classnumberstring+'=')
  4537. else
  4538. strpcopy(st,'"'+sname+':'+stabchar+numberstring+'=');
  4539. strpcopy(strecopy(strend(st),ss),'",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0');
  4540. allstabstring := strnew(st);
  4541. freemem(st,strlen(ss)+512);
  4542. strdispose(ss);
  4543. end;
  4544. procedure tobjectdef.concatstabto(asmlist : taasmoutput);
  4545. var st : pstring;
  4546. begin
  4547. if objecttype<>odt_class then
  4548. begin
  4549. inherited concatstabto(asmlist);
  4550. exit;
  4551. end;
  4552. if ((typesym=nil) or ttypesym(typesym).isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  4553. (is_def_stab_written = not_written) then
  4554. begin
  4555. if globalnb=0 then
  4556. set_globalnb;
  4557. { Write the record class itself }
  4558. writing_class_record_stab:=true;
  4559. inherited concatstabto(asmlist);
  4560. writing_class_record_stab:=false;
  4561. { Write the invisible pointer class }
  4562. is_def_stab_written:=not_written;
  4563. if assigned(typesym) then
  4564. begin
  4565. st:=typesym.FName;
  4566. typesym.FName:=stringdup(' ');
  4567. end;
  4568. inherited concatstabto(asmlist);
  4569. if assigned(typesym) then
  4570. begin
  4571. stringdispose(typesym.FName);
  4572. typesym.FName:=st;
  4573. end;
  4574. end;
  4575. end;
  4576. {$endif GDB}
  4577. function tobjectdef.needs_inittable : boolean;
  4578. begin
  4579. case objecttype of
  4580. odt_class :
  4581. needs_inittable:=false;
  4582. odt_interfacecom:
  4583. needs_inittable:=true;
  4584. odt_interfacecorba:
  4585. needs_inittable:=is_related(interface_iunknown);
  4586. odt_object:
  4587. needs_inittable:=tobjectsymtable(symtable).needs_init_final;
  4588. else
  4589. internalerror(200108267);
  4590. end;
  4591. end;
  4592. function tobjectdef.members_need_inittable : boolean;
  4593. begin
  4594. members_need_inittable:=tobjectsymtable(symtable).needs_init_final;
  4595. end;
  4596. procedure tobjectdef.count_published_properties(sym:tnamedindexitem;arg:pointer);
  4597. begin
  4598. if needs_prop_entry(tsym(sym)) and
  4599. (tsym(sym).typ<>varsym) then
  4600. inc(count);
  4601. end;
  4602. procedure tobjectdef.write_property_info(sym : tnamedindexitem;arg:pointer);
  4603. var
  4604. proctypesinfo : byte;
  4605. procedure writeproc(proc : tsymlist; shiftvalue : byte);
  4606. var
  4607. typvalue : byte;
  4608. hp : psymlistitem;
  4609. address : longint;
  4610. begin
  4611. if not(assigned(proc) and assigned(proc.firstsym)) then
  4612. begin
  4613. rttiList.concat(Tai_const.Create_32bit(1));
  4614. typvalue:=3;
  4615. end
  4616. else if proc.firstsym^.sym.typ=varsym then
  4617. begin
  4618. address:=0;
  4619. hp:=proc.firstsym;
  4620. while assigned(hp) do
  4621. begin
  4622. inc(address,tvarsym(hp^.sym).fieldoffset);
  4623. hp:=hp^.next;
  4624. end;
  4625. rttiList.concat(Tai_const.Create_32bit(address));
  4626. typvalue:=0;
  4627. end
  4628. else
  4629. begin
  4630. if not assigned(proc.procdef) then
  4631. internalerror(200310074);
  4632. if not(po_virtualmethod in tprocdef(proc.procdef).procoptions) then
  4633. begin
  4634. rttiList.concat(Tai_const_symbol.Createname(tprocdef(proc.procdef).mangledname));
  4635. typvalue:=1;
  4636. end
  4637. else
  4638. begin
  4639. { virtual method, write vmt offset }
  4640. rttiList.concat(Tai_const.Create_32bit(
  4641. tprocdef(proc.procdef)._class.vmtmethodoffset(tprocdef(proc.procdef).extnumber)));
  4642. typvalue:=2;
  4643. end;
  4644. end;
  4645. proctypesinfo:=proctypesinfo or (typvalue shl shiftvalue);
  4646. end;
  4647. begin
  4648. if needs_prop_entry(tsym(sym)) then
  4649. case tsym(sym).typ of
  4650. varsym:
  4651. begin
  4652. {$ifdef dummy}
  4653. if not(tvarsym(sym).vartype.def.deftype=objectdef) or
  4654. not(tobjectdef(tvarsym(sym).vartype.def).is_class) then
  4655. internalerror(1509992);
  4656. { access to implicit class property as field }
  4657. proctypesinfo:=(0 shl 0) or (0 shl 2) or (0 shl 4);
  4658. rttiList.concat(Tai_const_symbol.Createname(tvarsym(sym.vartype.def.get_rtti_label)));
  4659. rttiList.concat(Tai_const.Create_32bit(tvarsym(sym.address)));
  4660. rttiList.concat(Tai_const.Create_32bit(tvarsym(sym.address)));
  4661. { per default stored }
  4662. rttiList.concat(Tai_const.Create_32bit(1));
  4663. { index as well as ... }
  4664. rttiList.concat(Tai_const.Create_32bit(0));
  4665. { default value are zero }
  4666. rttiList.concat(Tai_const.Create_32bit(0));
  4667. rttiList.concat(Tai_const.Create_16bit(count));
  4668. inc(count);
  4669. rttiList.concat(Tai_const.Create_8bit(proctypesinfo));
  4670. rttiList.concat(Tai_const.Create_8bit(length(tvarsym(sym.realname))));
  4671. rttiList.concat(Tai_string.Create(tvarsym(sym.realname)));
  4672. {$endif dummy}
  4673. end;
  4674. propertysym:
  4675. begin
  4676. if ppo_indexed in tpropertysym(sym).propoptions then
  4677. proctypesinfo:=$40
  4678. else
  4679. proctypesinfo:=0;
  4680. rttiList.concat(Tai_const_symbol.Create(tstoreddef(tpropertysym(sym).proptype.def).get_rtti_label(fullrtti)));
  4681. writeproc(tpropertysym(sym).readaccess,0);
  4682. writeproc(tpropertysym(sym).writeaccess,2);
  4683. { isn't it stored ? }
  4684. if not(ppo_stored in tpropertysym(sym).propoptions) then
  4685. begin
  4686. rttiList.concat(Tai_const.Create_32bit(0));
  4687. proctypesinfo:=proctypesinfo or (3 shl 4);
  4688. end
  4689. else
  4690. writeproc(tpropertysym(sym).storedaccess,4);
  4691. rttiList.concat(Tai_const.Create_32bit(tpropertysym(sym).index));
  4692. rttiList.concat(Tai_const.Create_32bit(tpropertysym(sym).default));
  4693. rttiList.concat(Tai_const.Create_16bit(count));
  4694. inc(count);
  4695. rttiList.concat(Tai_const.Create_8bit(proctypesinfo));
  4696. rttiList.concat(Tai_const.Create_8bit(length(tpropertysym(sym).realname)));
  4697. rttiList.concat(Tai_string.Create(tpropertysym(sym).realname));
  4698. end;
  4699. else internalerror(1509992);
  4700. end;
  4701. end;
  4702. procedure tobjectdef.generate_published_child_rtti(sym : tnamedindexitem;arg:pointer);
  4703. begin
  4704. if needs_prop_entry(tsym(sym)) then
  4705. begin
  4706. case tsym(sym).typ of
  4707. propertysym:
  4708. tstoreddef(tpropertysym(sym).proptype.def).get_rtti_label(fullrtti);
  4709. varsym:
  4710. tstoreddef(tvarsym(sym).vartype.def).get_rtti_label(fullrtti);
  4711. else
  4712. internalerror(1509991);
  4713. end;
  4714. end;
  4715. end;
  4716. procedure tobjectdef.write_child_rtti_data(rt:trttitype);
  4717. begin
  4718. FRTTIType:=rt;
  4719. case rt of
  4720. initrtti :
  4721. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}generate_field_rtti,nil);
  4722. fullrtti :
  4723. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}generate_published_child_rtti,nil);
  4724. else
  4725. internalerror(200108301);
  4726. end;
  4727. end;
  4728. type
  4729. tclasslistitem = class(TLinkedListItem)
  4730. index : longint;
  4731. p : tobjectdef;
  4732. end;
  4733. var
  4734. classtablelist : tlinkedlist;
  4735. tablecount : longint;
  4736. function searchclasstablelist(p : tobjectdef) : tclasslistitem;
  4737. var
  4738. hp : tclasslistitem;
  4739. begin
  4740. hp:=tclasslistitem(classtablelist.first);
  4741. while assigned(hp) do
  4742. if hp.p=p then
  4743. begin
  4744. searchclasstablelist:=hp;
  4745. exit;
  4746. end
  4747. else
  4748. hp:=tclasslistitem(hp.next);
  4749. searchclasstablelist:=nil;
  4750. end;
  4751. procedure tobjectdef.count_published_fields(sym:tnamedindexitem;arg:pointer);
  4752. var
  4753. hp : tclasslistitem;
  4754. begin
  4755. if needs_prop_entry(tsym(sym)) and
  4756. (tsym(sym).typ=varsym) then
  4757. begin
  4758. if tvarsym(sym).vartype.def.deftype<>objectdef then
  4759. internalerror(0206001);
  4760. hp:=searchclasstablelist(tobjectdef(tvarsym(sym).vartype.def));
  4761. if not(assigned(hp)) then
  4762. begin
  4763. hp:=tclasslistitem.create;
  4764. hp.p:=tobjectdef(tvarsym(sym).vartype.def);
  4765. hp.index:=tablecount;
  4766. classtablelist.concat(hp);
  4767. inc(tablecount);
  4768. end;
  4769. inc(count);
  4770. end;
  4771. end;
  4772. procedure tobjectdef.writefields(sym:tnamedindexitem;arg:pointer);
  4773. var
  4774. hp : tclasslistitem;
  4775. begin
  4776. if needs_prop_entry(tsym(sym)) and
  4777. (tsym(sym).typ=varsym) then
  4778. begin
  4779. rttiList.concat(Tai_const.Create_32bit(tvarsym(sym).fieldoffset));
  4780. hp:=searchclasstablelist(tobjectdef(tvarsym(sym).vartype.def));
  4781. if not(assigned(hp)) then
  4782. internalerror(0206002);
  4783. rttiList.concat(Tai_const.Create_16bit(hp.index));
  4784. rttiList.concat(Tai_const.Create_8bit(length(tvarsym(sym).realname)));
  4785. rttiList.concat(Tai_string.Create(tvarsym(sym).realname));
  4786. end;
  4787. end;
  4788. function tobjectdef.generate_field_table : tasmlabel;
  4789. var
  4790. fieldtable,
  4791. classtable : tasmlabel;
  4792. hp : tclasslistitem;
  4793. begin
  4794. classtablelist:=TLinkedList.Create;
  4795. objectlibrary.getdatalabel(fieldtable);
  4796. objectlibrary.getdatalabel(classtable);
  4797. count:=0;
  4798. tablecount:=0;
  4799. symtable.foreach({$ifdef FPC}@{$endif}count_published_fields,nil);
  4800. if (cs_create_smart in aktmoduleswitches) then
  4801. rttiList.concat(Tai_cut.Create);
  4802. rttilist.concat(tai_align.create(const_align(pointer_size)));
  4803. rttiList.concat(Tai_label.Create(fieldtable));
  4804. rttiList.concat(Tai_const.Create_16bit(count));
  4805. rttiList.concat(Tai_const_symbol.Create(classtable));
  4806. symtable.foreach({$ifdef FPC}@{$endif}writefields,nil);
  4807. { generate the class table }
  4808. rttilist.concat(tai_align.create(const_align(pointer_size)));
  4809. rttiList.concat(Tai_label.Create(classtable));
  4810. rttiList.concat(Tai_const.Create_16bit(tablecount));
  4811. hp:=tclasslistitem(classtablelist.first);
  4812. while assigned(hp) do
  4813. begin
  4814. rttiList.concat(Tai_const_symbol.Createname(tobjectdef(hp.p).vmt_mangledname));
  4815. hp:=tclasslistitem(hp.next);
  4816. end;
  4817. generate_field_table:=fieldtable;
  4818. classtablelist.free;
  4819. end;
  4820. function tobjectdef.next_free_name_index : longint;
  4821. var
  4822. i : longint;
  4823. begin
  4824. if assigned(childof) and (oo_can_have_published in childof.objectoptions) then
  4825. i:=childof.next_free_name_index
  4826. else
  4827. i:=0;
  4828. count:=0;
  4829. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}count_published_properties,nil);
  4830. next_free_name_index:=i+count;
  4831. end;
  4832. procedure tobjectdef.write_rtti_data(rt:trttitype);
  4833. begin
  4834. case objecttype of
  4835. odt_class:
  4836. rttiList.concat(Tai_const.Create_8bit(tkclass));
  4837. odt_object:
  4838. rttiList.concat(Tai_const.Create_8bit(tkobject));
  4839. odt_interfacecom:
  4840. rttiList.concat(Tai_const.Create_8bit(tkinterface));
  4841. odt_interfacecorba:
  4842. rttiList.concat(Tai_const.Create_8bit(tkinterfaceCorba));
  4843. else
  4844. exit;
  4845. end;
  4846. { generate the name }
  4847. rttiList.concat(Tai_const.Create_8bit(length(objrealname^)));
  4848. rttiList.concat(Tai_string.Create(objrealname^));
  4849. case rt of
  4850. initrtti :
  4851. begin
  4852. rttiList.concat(Tai_const.Create_32bit(size));
  4853. if objecttype in [odt_class,odt_object] then
  4854. begin
  4855. count:=0;
  4856. FRTTIType:=rt;
  4857. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}count_field_rtti,nil);
  4858. rttiList.concat(Tai_const.Create_32bit(count));
  4859. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}write_field_rtti,nil);
  4860. end;
  4861. end;
  4862. fullrtti :
  4863. begin
  4864. if objecttype in [odt_interfacecom,odt_interfacecorba] then
  4865. rttiList.concat(Tai_const.Create_32bit(0))
  4866. else
  4867. rttiList.concat(Tai_const_symbol.Createname(vmt_mangledname));
  4868. { write owner typeinfo }
  4869. if assigned(childof) and (oo_can_have_published in childof.objectoptions) then
  4870. rttiList.concat(Tai_const_symbol.Create(childof.get_rtti_label(fullrtti)))
  4871. else
  4872. rttiList.concat(Tai_const.Create_32bit(0));
  4873. { count total number of properties }
  4874. if assigned(childof) and (oo_can_have_published in childof.objectoptions) then
  4875. count:=childof.next_free_name_index
  4876. else
  4877. count:=0;
  4878. { write it }
  4879. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}count_published_properties,nil);
  4880. rttiList.concat(Tai_const.Create_16bit(count));
  4881. { write unit name }
  4882. rttiList.concat(Tai_const.Create_8bit(length(current_module.realmodulename^)));
  4883. rttiList.concat(Tai_string.Create(current_module.realmodulename^));
  4884. { write published properties count }
  4885. count:=0;
  4886. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}count_published_properties,nil);
  4887. rttiList.concat(Tai_const.Create_16bit(count));
  4888. { count is used to write nameindex }
  4889. { but we need an offset of the owner }
  4890. { to give each property an own slot }
  4891. if assigned(childof) and (oo_can_have_published in childof.objectoptions) then
  4892. count:=childof.next_free_name_index
  4893. else
  4894. count:=0;
  4895. symtable.foreach({$ifdef FPCPROCVAR}@{$endif}write_property_info,nil);
  4896. end;
  4897. end;
  4898. end;
  4899. function tobjectdef.is_publishable : boolean;
  4900. begin
  4901. is_publishable:=objecttype in [odt_class,odt_interfacecom,odt_interfacecorba];
  4902. end;
  4903. {****************************************************************************
  4904. TIMPLEMENTEDINTERFACES
  4905. ****************************************************************************}
  4906. type
  4907. tnamemap = class(TNamedIndexItem)
  4908. newname: pstring;
  4909. constructor create(const aname, anewname: string);
  4910. destructor destroy; override;
  4911. end;
  4912. constructor tnamemap.create(const aname, anewname: string);
  4913. begin
  4914. inherited createname(name);
  4915. newname:=stringdup(anewname);
  4916. end;
  4917. destructor tnamemap.destroy;
  4918. begin
  4919. stringdispose(newname);
  4920. inherited destroy;
  4921. end;
  4922. type
  4923. tprocdefstore = class(TNamedIndexItem)
  4924. procdef: tprocdef;
  4925. constructor create(aprocdef: tprocdef);
  4926. end;
  4927. constructor tprocdefstore.create(aprocdef: tprocdef);
  4928. begin
  4929. inherited create;
  4930. procdef:=aprocdef;
  4931. end;
  4932. type
  4933. timplintfentry = class(TNamedIndexItem)
  4934. intf: tobjectdef;
  4935. intfderef : tderef;
  4936. ioffs: longint;
  4937. namemappings: tdictionary;
  4938. procdefs: TIndexArray;
  4939. constructor create(aintf: tobjectdef);
  4940. constructor create_deref(const d:tderef);
  4941. destructor destroy; override;
  4942. end;
  4943. constructor timplintfentry.create(aintf: tobjectdef);
  4944. begin
  4945. inherited create;
  4946. intf:=aintf;
  4947. ioffs:=-1;
  4948. namemappings:=nil;
  4949. procdefs:=nil;
  4950. end;
  4951. constructor timplintfentry.create_deref(const d:tderef);
  4952. begin
  4953. inherited create;
  4954. intf:=nil;
  4955. intfderef:=d;
  4956. ioffs:=-1;
  4957. namemappings:=nil;
  4958. procdefs:=nil;
  4959. end;
  4960. destructor timplintfentry.destroy;
  4961. begin
  4962. if assigned(namemappings) then
  4963. namemappings.free;
  4964. if assigned(procdefs) then
  4965. procdefs.free;
  4966. inherited destroy;
  4967. end;
  4968. constructor timplementedinterfaces.create;
  4969. begin
  4970. finterfaces:=tindexarray.create(1);
  4971. end;
  4972. destructor timplementedinterfaces.destroy;
  4973. begin
  4974. finterfaces.destroy;
  4975. end;
  4976. function timplementedinterfaces.count: longint;
  4977. begin
  4978. count:=finterfaces.count;
  4979. end;
  4980. procedure timplementedinterfaces.checkindex(intfindex: longint);
  4981. begin
  4982. if (intfindex<1) or (intfindex>count) then
  4983. InternalError(200006123);
  4984. end;
  4985. function timplementedinterfaces.interfaces(intfindex: longint): tobjectdef;
  4986. begin
  4987. checkindex(intfindex);
  4988. interfaces:=timplintfentry(finterfaces.search(intfindex)).intf;
  4989. end;
  4990. function timplementedinterfaces.interfacesderef(intfindex: longint): tderef;
  4991. begin
  4992. checkindex(intfindex);
  4993. interfacesderef:=timplintfentry(finterfaces.search(intfindex)).intfderef;
  4994. end;
  4995. function timplementedinterfaces.ioffsets(intfindex: longint): plongint;
  4996. begin
  4997. checkindex(intfindex);
  4998. ioffsets:=@timplintfentry(finterfaces.search(intfindex)).ioffs;
  4999. end;
  5000. function timplementedinterfaces.searchintf(def: tdef): longint;
  5001. var
  5002. i: longint;
  5003. begin
  5004. i:=1;
  5005. while (i<=count) and (tdef(interfaces(i))<>def) do inc(i);
  5006. if i<=count then
  5007. searchintf:=i
  5008. else
  5009. searchintf:=-1;
  5010. end;
  5011. procedure timplementedinterfaces.buildderef;
  5012. var
  5013. i: longint;
  5014. begin
  5015. for i:=1 to count do
  5016. with timplintfentry(finterfaces.search(i)) do
  5017. intfderef.build(intf);
  5018. end;
  5019. procedure timplementedinterfaces.deref;
  5020. var
  5021. i: longint;
  5022. begin
  5023. for i:=1 to count do
  5024. with timplintfentry(finterfaces.search(i)) do
  5025. intf:=tobjectdef(intfderef.resolve);
  5026. end;
  5027. procedure timplementedinterfaces.addintf_deref(const d:tderef);
  5028. begin
  5029. finterfaces.insert(timplintfentry.create_deref(d));
  5030. end;
  5031. procedure timplementedinterfaces.addintf(def: tdef);
  5032. begin
  5033. if not assigned(def) or (searchintf(def)<>-1) or (def.deftype<>objectdef) or
  5034. not (tobjectdef(def).objecttype in [odt_interfacecom,odt_interfacecorba]) then
  5035. internalerror(200006124);
  5036. finterfaces.insert(timplintfentry.create(tobjectdef(def)));
  5037. end;
  5038. procedure timplementedinterfaces.clearmappings;
  5039. var
  5040. i: longint;
  5041. begin
  5042. for i:=1 to count do
  5043. with timplintfentry(finterfaces.search(i)) do
  5044. begin
  5045. if assigned(namemappings) then
  5046. namemappings.free;
  5047. namemappings:=nil;
  5048. end;
  5049. end;
  5050. procedure timplementedinterfaces.addmappings(intfindex: longint; const name, newname: string);
  5051. begin
  5052. checkindex(intfindex);
  5053. with timplintfentry(finterfaces.search(intfindex)) do
  5054. begin
  5055. if not assigned(namemappings) then
  5056. namemappings:=tdictionary.create;
  5057. namemappings.insert(tnamemap.create(name,newname));
  5058. end;
  5059. end;
  5060. function timplementedinterfaces.getmappings(intfindex: longint; const name: string; var nextexist: pointer): string;
  5061. begin
  5062. checkindex(intfindex);
  5063. if not assigned(nextexist) then
  5064. with timplintfentry(finterfaces.search(intfindex)) do
  5065. begin
  5066. if assigned(namemappings) then
  5067. nextexist:=namemappings.search(name)
  5068. else
  5069. nextexist:=nil;
  5070. end;
  5071. if assigned(nextexist) then
  5072. begin
  5073. getmappings:=tnamemap(nextexist).newname^;
  5074. nextexist:=tnamemap(nextexist).listnext;
  5075. end
  5076. else
  5077. getmappings:='';
  5078. end;
  5079. procedure timplementedinterfaces.clearimplprocs;
  5080. var
  5081. i: longint;
  5082. begin
  5083. for i:=1 to count do
  5084. with timplintfentry(finterfaces.search(i)) do
  5085. begin
  5086. if assigned(procdefs) then
  5087. procdefs.free;
  5088. procdefs:=nil;
  5089. end;
  5090. end;
  5091. procedure timplementedinterfaces.addimplproc(intfindex: longint; procdef: tprocdef);
  5092. begin
  5093. checkindex(intfindex);
  5094. with timplintfentry(finterfaces.search(intfindex)) do
  5095. begin
  5096. if not assigned(procdefs) then
  5097. procdefs:=tindexarray.create(4);
  5098. procdefs.insert(tprocdefstore.create(procdef));
  5099. end;
  5100. end;
  5101. function timplementedinterfaces.implproccount(intfindex: longint): longint;
  5102. begin
  5103. checkindex(intfindex);
  5104. with timplintfentry(finterfaces.search(intfindex)) do
  5105. if assigned(procdefs) then
  5106. implproccount:=procdefs.count
  5107. else
  5108. implproccount:=0;
  5109. end;
  5110. function timplementedinterfaces.implprocs(intfindex: longint; procindex: longint): tprocdef;
  5111. begin
  5112. checkindex(intfindex);
  5113. with timplintfentry(finterfaces.search(intfindex)) do
  5114. if assigned(procdefs) then
  5115. implprocs:=tprocdefstore(procdefs.search(procindex)).procdef
  5116. else
  5117. internalerror(200006131);
  5118. end;
  5119. function timplementedinterfaces.isimplmergepossible(intfindex, remainindex: longint; var weight: longint): boolean;
  5120. var
  5121. possible: boolean;
  5122. i: longint;
  5123. iiep1: TIndexArray;
  5124. iiep2: TIndexArray;
  5125. begin
  5126. checkindex(intfindex);
  5127. checkindex(remainindex);
  5128. iiep1:=timplintfentry(finterfaces.search(intfindex)).procdefs;
  5129. iiep2:=timplintfentry(finterfaces.search(remainindex)).procdefs;
  5130. if not assigned(iiep1) then { empty interface is mergeable :-) }
  5131. begin
  5132. possible:=true;
  5133. weight:=0;
  5134. end
  5135. else
  5136. begin
  5137. possible:=assigned(iiep2) and (iiep1.count<=iiep2.count);
  5138. i:=1;
  5139. while (possible) and (i<=iiep1.count) do
  5140. begin
  5141. possible:=
  5142. (tprocdefstore(iiep1.search(i)).procdef=tprocdefstore(iiep2.search(i)).procdef);
  5143. inc(i);
  5144. end;
  5145. if possible then
  5146. weight:=iiep1.count;
  5147. end;
  5148. isimplmergepossible:=possible;
  5149. end;
  5150. {****************************************************************************
  5151. TFORWARDDEF
  5152. ****************************************************************************}
  5153. constructor tforwarddef.create(const s:string;const pos : tfileposinfo);
  5154. var
  5155. oldregisterdef : boolean;
  5156. begin
  5157. { never register the forwarddefs, they are disposed at the
  5158. end of the type declaration block }
  5159. oldregisterdef:=registerdef;
  5160. registerdef:=false;
  5161. inherited create;
  5162. registerdef:=oldregisterdef;
  5163. deftype:=forwarddef;
  5164. tosymname:=stringdup(s);
  5165. forwardpos:=pos;
  5166. end;
  5167. function tforwarddef.gettypename:string;
  5168. begin
  5169. gettypename:='unresolved forward to '+tosymname^;
  5170. end;
  5171. destructor tforwarddef.destroy;
  5172. begin
  5173. if assigned(tosymname) then
  5174. stringdispose(tosymname);
  5175. inherited destroy;
  5176. end;
  5177. {****************************************************************************
  5178. TERRORDEF
  5179. ****************************************************************************}
  5180. constructor terrordef.create;
  5181. begin
  5182. inherited create;
  5183. deftype:=errordef;
  5184. end;
  5185. {$ifdef GDB}
  5186. function terrordef.stabstring : pchar;
  5187. begin
  5188. stabstring:=strpnew('error'+numberstring);
  5189. end;
  5190. procedure terrordef.concatstabto(asmlist : taasmoutput);
  5191. begin
  5192. { No internal error needed, an normal error is already
  5193. thrown }
  5194. end;
  5195. {$endif GDB}
  5196. function terrordef.gettypename:string;
  5197. begin
  5198. gettypename:='<erroneous type>';
  5199. end;
  5200. function terrordef.getmangledparaname:string;
  5201. begin
  5202. getmangledparaname:='error';
  5203. end;
  5204. {****************************************************************************
  5205. GDB Helpers
  5206. ****************************************************************************}
  5207. {$ifdef GDB}
  5208. function typeglobalnumber(const s : string) : string;
  5209. var st : string;
  5210. symt : tsymtable;
  5211. srsym : tsym;
  5212. srsymtable : tsymtable;
  5213. old_make_ref : boolean;
  5214. begin
  5215. old_make_ref:=make_ref;
  5216. make_ref:=false;
  5217. typeglobalnumber := '0';
  5218. srsym := nil;
  5219. if pos('.',s) > 0 then
  5220. begin
  5221. st := copy(s,1,pos('.',s)-1);
  5222. searchsym(st,srsym,srsymtable);
  5223. st := copy(s,pos('.',s)+1,255);
  5224. if assigned(srsym) then
  5225. begin
  5226. if srsym.typ = unitsym then
  5227. begin
  5228. symt := tunitsym(srsym).unitsymtable;
  5229. srsym := tsym(symt.search(st));
  5230. end else srsym := nil;
  5231. end;
  5232. end else st := s;
  5233. if srsym = nil then
  5234. searchsym(st,srsym,srsymtable);
  5235. if (srsym=nil) or
  5236. (srsym.typ<>typesym) then
  5237. begin
  5238. Message(type_e_type_id_expected);
  5239. exit;
  5240. end;
  5241. typeglobalnumber := tstoreddef(ttypesym(srsym).restype.def).numberstring;
  5242. make_ref:=old_make_ref;
  5243. end;
  5244. {$endif GDB}
  5245. {****************************************************************************
  5246. Definition Helpers
  5247. ****************************************************************************}
  5248. procedure reset_global_defs;
  5249. var
  5250. def : tstoreddef;
  5251. {$ifdef debug}
  5252. prevdef : tstoreddef;
  5253. {$endif debug}
  5254. begin
  5255. {$ifdef debug}
  5256. prevdef:=nil;
  5257. {$endif debug}
  5258. {$ifdef GDB}
  5259. pglobaltypecount:=@globaltypecount;
  5260. {$endif GDB}
  5261. def:=firstglobaldef;
  5262. while assigned(def) do
  5263. begin
  5264. {$ifdef GDB}
  5265. if assigned(def.typesym) then
  5266. ttypesym(def.typesym).isusedinstab:=false;
  5267. def.is_def_stab_written:=not_written;
  5268. {$endif GDB}
  5269. if assigned(def.rttitablesym) then
  5270. trttisym(def.rttitablesym).lab := nil;
  5271. if assigned(def.inittablesym) then
  5272. trttisym(def.inittablesym).lab := nil;
  5273. def.localrttilab[initrtti]:=nil;
  5274. def.localrttilab[fullrtti]:=nil;
  5275. {$ifdef debug}
  5276. prevdef:=def;
  5277. {$endif debug}
  5278. def:=def.nextglobal;
  5279. end;
  5280. end;
  5281. function is_interfacecom(def: tdef): boolean;
  5282. begin
  5283. is_interfacecom:=
  5284. assigned(def) and
  5285. (def.deftype=objectdef) and
  5286. (tobjectdef(def).objecttype=odt_interfacecom);
  5287. end;
  5288. function is_interfacecorba(def: tdef): boolean;
  5289. begin
  5290. is_interfacecorba:=
  5291. assigned(def) and
  5292. (def.deftype=objectdef) and
  5293. (tobjectdef(def).objecttype=odt_interfacecorba);
  5294. end;
  5295. function is_interface(def: tdef): boolean;
  5296. begin
  5297. is_interface:=
  5298. assigned(def) and
  5299. (def.deftype=objectdef) and
  5300. (tobjectdef(def).objecttype in [odt_interfacecom,odt_interfacecorba]);
  5301. end;
  5302. function is_class(def: tdef): boolean;
  5303. begin
  5304. is_class:=
  5305. assigned(def) and
  5306. (def.deftype=objectdef) and
  5307. (tobjectdef(def).objecttype=odt_class);
  5308. end;
  5309. function is_object(def: tdef): boolean;
  5310. begin
  5311. is_object:=
  5312. assigned(def) and
  5313. (def.deftype=objectdef) and
  5314. (tobjectdef(def).objecttype=odt_object);
  5315. end;
  5316. function is_cppclass(def: tdef): boolean;
  5317. begin
  5318. is_cppclass:=
  5319. assigned(def) and
  5320. (def.deftype=objectdef) and
  5321. (tobjectdef(def).objecttype=odt_cppclass);
  5322. end;
  5323. function is_class_or_interface(def: tdef): boolean;
  5324. begin
  5325. is_class_or_interface:=
  5326. assigned(def) and
  5327. (def.deftype=objectdef) and
  5328. (tobjectdef(def).objecttype in [odt_class,odt_interfacecom,odt_interfacecorba]);
  5329. end;
  5330. end.
  5331. {
  5332. $Log$
  5333. Revision 1.184 2003-10-23 14:44:07 peter
  5334. * splitted buildderef and buildderefimpl to fix interface crc
  5335. calculation
  5336. Revision 1.183 2003/10/22 20:40:00 peter
  5337. * write derefdata in a separate ppu entry
  5338. Revision 1.182 2003/10/21 18:14:49 peter
  5339. * fix counting of parameters when loading ppu
  5340. Revision 1.181 2003/10/17 15:08:34 peter
  5341. * commented out more obsolete constants
  5342. Revision 1.180 2003/10/17 14:52:07 peter
  5343. * fixed ppc build
  5344. Revision 1.179 2003/10/17 14:38:32 peter
  5345. * 64k registers supported
  5346. * fixed some memory leaks
  5347. Revision 1.178 2003/10/13 14:05:12 peter
  5348. * removed is_visible_for_proc
  5349. * search also for class overloads when finding interface
  5350. implementations
  5351. Revision 1.177 2003/10/11 16:06:42 florian
  5352. * fixed some MMX<->SSE
  5353. * started to fix ppc, needs an overhaul
  5354. + stabs info improve for spilling, not sure if it works correctly/completly
  5355. - MMX_SUPPORT removed from Makefile.fpc
  5356. Revision 1.176 2003/10/10 17:48:14 peter
  5357. * old trgobj moved to x86/rgcpu and renamed to trgx86fpu
  5358. * tregisteralloctor renamed to trgobj
  5359. * removed rgobj from a lot of units
  5360. * moved location_* and reference_* to cgobj
  5361. * first things for mmx register allocation
  5362. Revision 1.175 2003/10/07 20:43:49 peter
  5363. * Add calling convention in fullprocname when it is specified
  5364. Revision 1.174 2003/10/07 16:06:30 peter
  5365. * tsymlist.def renamed to tsymlist.procdef
  5366. * tsymlist.procdef is now only used to store the procdef
  5367. Revision 1.173 2003/10/06 22:23:41 florian
  5368. + added basic olevariant support
  5369. Revision 1.172 2003/10/05 21:21:52 peter
  5370. * c style array of const generates callparanodes
  5371. * varargs paraloc fixes
  5372. Revision 1.171 2003/10/05 12:56:35 peter
  5373. * don't write procdefs that are released to ppu
  5374. Revision 1.170 2003/10/03 22:00:33 peter
  5375. * parameter alignment fixes
  5376. Revision 1.169 2003/10/02 21:19:42 peter
  5377. * protected visibility fixes
  5378. Revision 1.168 2003/10/01 20:34:49 peter
  5379. * procinfo unit contains tprocinfo
  5380. * cginfo renamed to cgbase
  5381. * moved cgmessage to verbose
  5382. * fixed ppc and sparc compiles
  5383. Revision 1.167 2003/10/01 16:49:05 florian
  5384. * para items are now reversed for pascal calling conventions
  5385. Revision 1.166 2003/10/01 15:32:58 florian
  5386. * fixed FullProcName to handle constructors, destructors and operators correctly
  5387. Revision 1.165 2003/10/01 15:00:02 peter
  5388. * don't write parast,localst debug info for externals
  5389. Revision 1.164 2003/09/23 21:03:35 peter
  5390. * connect parasym to paraitem
  5391. Revision 1.163 2003/09/23 17:56:06 peter
  5392. * locals and paras are allocated in the code generation
  5393. * tvarsym.localloc contains the location of para/local when
  5394. generating code for the current procedure
  5395. Revision 1.162 2003/09/07 22:09:35 peter
  5396. * preparations for different default calling conventions
  5397. * various RA fixes
  5398. Revision 1.161 2003/09/06 22:27:09 florian
  5399. * fixed web bug 2669
  5400. * cosmetic fix in printnode
  5401. * tobjectdef.gettypename implemented
  5402. Revision 1.160 2003/09/03 15:55:01 peter
  5403. * NEWRA branch merged
  5404. Revision 1.159 2003/09/03 11:18:37 florian
  5405. * fixed arm concatcopy
  5406. + arm support in the common compiler sources added
  5407. * moved some generic cg code around
  5408. + tfputype added
  5409. * ...
  5410. Revision 1.158.2.2 2003/08/29 17:28:59 peter
  5411. * next batch of updates
  5412. Revision 1.158.2.1 2003/08/27 19:55:54 peter
  5413. * first tregister patch
  5414. Revision 1.158 2003/08/11 21:18:20 peter
  5415. * start of sparc support for newra
  5416. Revision 1.157 2003/07/08 15:20:56 peter
  5417. * don't allow add/assignments for formaldef
  5418. * formaldef size changed to 0
  5419. Revision 1.156 2003/07/06 21:50:33 jonas
  5420. * fixed ppc compilation problems and changed VOLATILE_REGISTERS for x86
  5421. so that it doesn't include ebp and esp anymore
  5422. Revision 1.155 2003/07/06 15:31:21 daniel
  5423. * Fixed register allocator. *Lots* of fixes.
  5424. Revision 1.154 2003/07/02 22:18:04 peter
  5425. * paraloc splitted in callerparaloc,calleeparaloc
  5426. * sparc calling convention updates
  5427. Revision 1.153 2003/06/25 18:31:23 peter
  5428. * sym,def resolving partly rewritten to support also parent objects
  5429. not directly available through the uses clause
  5430. Revision 1.152 2003/06/17 16:34:44 jonas
  5431. * lots of newra fixes (need getfuncretparaloc implementation for i386)!
  5432. * renamed all_intregisters to paramanager.get_volatile_registers_int(pocall_default) and made it
  5433. processor dependent
  5434. Revision 1.151 2003/06/08 11:41:21 peter
  5435. * set parast.next to the owner of the procdef
  5436. Revision 1.150 2003/06/07 20:26:32 peter
  5437. * re-resolving added instead of reloading from ppu
  5438. * tderef object added to store deref info for resolving
  5439. Revision 1.149 2003/06/05 20:05:55 peter
  5440. * removed changesettype because that will change the definition
  5441. of the setdef forever and can result in a different between
  5442. original interface and current implementation definition
  5443. Revision 1.148 2003/06/03 13:01:59 daniel
  5444. * Register allocator finished
  5445. Revision 1.147 2003/06/02 22:55:28 florian
  5446. * classes and interfaces can be stored in integer registers
  5447. Revision 1.146 2003/05/26 21:17:18 peter
  5448. * procinlinenode removed
  5449. * aktexit2label removed, fast exit removed
  5450. + tcallnode.inlined_pass_2 added
  5451. Revision 1.145 2003/05/25 11:34:17 peter
  5452. * methodpointer self pushing fixed
  5453. Revision 1.144 2003/05/15 18:58:53 peter
  5454. * removed selfpointer_offset, vmtpointer_offset
  5455. * tvarsym.adjusted_address
  5456. * address in localsymtable is now in the real direction
  5457. * removed some obsolete globals
  5458. Revision 1.143 2003/05/13 08:13:16 jonas
  5459. * patch from Peter for rtti symbols
  5460. Revision 1.142 2003/05/11 21:37:03 peter
  5461. * moved implicit exception frame from ncgutil to psub
  5462. * constructor/destructor helpers moved from cobj/ncgutil to psub
  5463. Revision 1.141 2003/05/09 17:47:03 peter
  5464. * self moved to hidden parameter
  5465. * removed hdisposen,hnewn,selfn
  5466. Revision 1.140 2003/05/05 14:53:16 peter
  5467. * vs_hidden replaced by is_hidden boolean
  5468. Revision 1.139 2003/05/01 07:59:43 florian
  5469. * introduced defaultordconsttype to decribe the default size of ordinal constants
  5470. on 64 bit CPUs it's equal to cs64bitdef while on 32 bit CPUs it's equal to s32bitdef
  5471. + added defines CPU32 and CPU64 for 32 bit and 64 bit CPUs
  5472. * int64s/qwords are allowed as for loop counter on 64 bit CPUs
  5473. Revision 1.138 2003/04/27 11:21:34 peter
  5474. * aktprocdef renamed to current_procdef
  5475. * procinfo renamed to current_procinfo
  5476. * procinfo will now be stored in current_module so it can be
  5477. cleaned up properly
  5478. * gen_main_procsym changed to create_main_proc and release_main_proc
  5479. to also generate a tprocinfo structure
  5480. * fixed unit implicit initfinal
  5481. Revision 1.137 2003/04/27 07:29:51 peter
  5482. * current_procdef cleanup, current_procdef is now always nil when parsing
  5483. a new procdef declaration
  5484. * aktprocsym removed
  5485. * lexlevel removed, use symtable.symtablelevel instead
  5486. * implicit init/final code uses the normal genentry/genexit
  5487. * funcret state checking updated for new funcret handling
  5488. Revision 1.136 2003/04/25 20:59:35 peter
  5489. * removed funcretn,funcretsym, function result is now in varsym
  5490. and aliases for result and function name are added using absolutesym
  5491. * vs_hidden parameter for funcret passed in parameter
  5492. * vs_hidden fixes
  5493. * writenode changed to printnode and released from extdebug
  5494. * -vp option added to generate a tree.log with the nodetree
  5495. * nicer printnode for statements, callnode
  5496. Revision 1.135 2003/04/23 20:16:04 peter
  5497. + added currency support based on int64
  5498. + is_64bit for use in cg units instead of is_64bitint
  5499. * removed cgmessage from n386add, replace with internalerrors
  5500. Revision 1.134 2003/04/23 12:35:34 florian
  5501. * fixed several issues with powerpc
  5502. + applied a patch from Jonas for nested function calls (PowerPC only)
  5503. * ...
  5504. Revision 1.133 2003/04/10 17:57:53 peter
  5505. * vs_hidden released
  5506. Revision 1.132 2003/03/18 16:25:50 peter
  5507. * no itnernalerror for errordef.concatstabto()
  5508. Revision 1.131 2003/03/17 16:54:41 peter
  5509. * support DefaultHandler and anonymous inheritance fixed
  5510. for message methods
  5511. Revision 1.130 2003/03/17 15:54:22 peter
  5512. * store symoptions also for procdef
  5513. * check symoptions (private,public) when calculating possible
  5514. overload candidates
  5515. Revision 1.129 2003/02/19 22:00:14 daniel
  5516. * Code generator converted to new register notation
  5517. - Horribily outdated todo.txt removed
  5518. Revision 1.128 2003/02/02 19:25:54 carl
  5519. * Several bugfixes for m68k target (register alloc., opcode emission)
  5520. + VIS target
  5521. + Generic add more complete (still not verified)
  5522. Revision 1.127 2003/01/21 14:36:44 pierre
  5523. * set sizes needs to be passes in bits not bytes to stabs info
  5524. Revision 1.126 2003/01/16 22:11:33 peter
  5525. * fixed tprocdef.is_addressonly
  5526. Revision 1.125 2003/01/15 01:44:33 peter
  5527. * merged methodpointer fixes from 1.0.x
  5528. Revision 1.124 2003/01/09 21:52:37 peter
  5529. * merged some verbosity options.
  5530. * V_LineInfo is a verbosity flag to include line info
  5531. Revision 1.123 2003/01/06 21:16:52 peter
  5532. * po_addressonly added to retrieve the address of a methodpointer
  5533. only, this is used for @tclass.method which has no self pointer
  5534. Revision 1.122 2003/01/05 15:54:15 florian
  5535. + added proper support of type = type <type>; for simple types
  5536. Revision 1.121 2003/01/05 13:36:53 florian
  5537. * x86-64 compiles
  5538. + very basic support for float128 type (x86-64 only)
  5539. Revision 1.120 2003/01/02 19:49:00 peter
  5540. * update self parameter only for methodpointer and methods
  5541. Revision 1.119 2002/12/29 18:25:59 peter
  5542. * tprocdef.gettypename implemented
  5543. Revision 1.118 2002/12/27 15:23:09 peter
  5544. * write class methods in fullname
  5545. Revision 1.117 2002/12/15 19:34:31 florian
  5546. + some front end stuff for vs_hidden added
  5547. Revision 1.116 2002/12/15 11:26:02 peter
  5548. * ignore vs_hidden parameters when choosing overloaded proc
  5549. Revision 1.115 2002/12/07 14:27:09 carl
  5550. * 3% memory optimization
  5551. * changed some types
  5552. + added type checking with different size for call node and for
  5553. parameters
  5554. Revision 1.114 2002/12/01 22:05:27 carl
  5555. * no more warnings for structures over 32K since this is
  5556. handled correctly in this version of the compiler.
  5557. Revision 1.113 2002/11/27 20:04:09 peter
  5558. * tvarsym.get_push_size replaced by paramanager.push_size
  5559. Revision 1.112 2002/11/25 21:05:53 carl
  5560. * several mistakes fixed in message files
  5561. Revision 1.111 2002/11/25 18:43:33 carl
  5562. - removed the invalid if <> checking (Delphi is strange on this)
  5563. + implemented abstract warning on instance creation of class with
  5564. abstract methods.
  5565. * some error message cleanups
  5566. Revision 1.110 2002/11/25 17:43:24 peter
  5567. * splitted defbase in defutil,symutil,defcmp
  5568. * merged isconvertable and is_equal into compare_defs(_ext)
  5569. * made operator search faster by walking the list only once
  5570. Revision 1.109 2002/11/23 22:50:06 carl
  5571. * some small speed optimizations
  5572. + added several new warnings/hints
  5573. Revision 1.108 2002/11/22 22:48:10 carl
  5574. * memory optimization with tconstsym (1.5%)
  5575. Revision 1.107 2002/11/19 16:21:29 pierre
  5576. * correct several stabs generation problems
  5577. Revision 1.106 2002/11/18 17:31:59 peter
  5578. * pass proccalloption to ret_in_xxx and push_xxx functions
  5579. Revision 1.105 2002/11/17 16:31:57 carl
  5580. * memory optimization (3-4%) : cleanup of tai fields,
  5581. cleanup of tdef and tsym fields.
  5582. * make it work for m68k
  5583. Revision 1.104 2002/11/16 19:53:18 carl
  5584. * avoid Range check errors
  5585. Revision 1.103 2002/11/15 16:29:09 peter
  5586. * fixed rtti for int64 (merged)
  5587. Revision 1.102 2002/11/15 01:58:54 peter
  5588. * merged changes from 1.0.7 up to 04-11
  5589. - -V option for generating bug report tracing
  5590. - more tracing for option parsing
  5591. - errors for cdecl and high()
  5592. - win32 import stabs
  5593. - win32 records<=8 are returned in eax:edx (turned off by default)
  5594. - heaptrc update
  5595. - more info for temp management in .s file with EXTDEBUG
  5596. Revision 1.101 2002/11/09 15:31:02 carl
  5597. + align RTTI tables
  5598. Revision 1.100 2002/10/19 15:09:25 peter
  5599. + tobjectdef.members_need_inittable that is used to generate only the
  5600. inittable when it is really used. This saves a lot of useless calls
  5601. to fpc_finalize when destroying classes
  5602. Revision 1.99 2002/10/07 21:30:27 peter
  5603. * removed obsolete rangecheck stuff
  5604. Revision 1.98 2002/10/05 15:14:26 peter
  5605. * getparamangeldname for errordef
  5606. Revision 1.97 2002/10/05 12:43:28 carl
  5607. * fixes for Delphi 6 compilation
  5608. (warning : Some features do not work under Delphi)
  5609. Revision 1.96 2002/09/27 21:13:29 carl
  5610. * low-highval always checked if limit ober 2GB is reached (to avoid overflow)
  5611. Revision 1.95 2002/09/16 09:31:10 florian
  5612. * fixed currency size
  5613. Revision 1.94 2002/09/09 17:34:15 peter
  5614. * tdicationary.replace added to replace and item in a dictionary. This
  5615. is only allowed for the same name
  5616. * varsyms are inserted in symtable before the types are parsed. This
  5617. fixes the long standing "var longint : longint" bug
  5618. - consume_idlist and idstringlist removed. The loops are inserted
  5619. at the callers place and uses the symtable for duplicate id checking
  5620. Revision 1.93 2002/09/07 15:25:07 peter
  5621. * old logs removed and tabs fixed
  5622. Revision 1.92 2002/09/05 19:29:42 peter
  5623. * memdebug enhancements
  5624. Revision 1.91 2002/08/25 19:25:20 peter
  5625. * sym.insert_in_data removed
  5626. * symtable.insertvardata/insertconstdata added
  5627. * removed insert_in_data call from symtable.insert, it needs to be
  5628. called separatly. This allows to deref the address calculation
  5629. * procedures now calculate the parast addresses after the procedure
  5630. directives are parsed. This fixes the cdecl parast problem
  5631. * push_addr_param has an extra argument that specifies if cdecl is used
  5632. or not
  5633. Revision 1.90 2002/08/18 20:06:25 peter
  5634. * inlining is now also allowed in interface
  5635. * renamed write/load to ppuwrite/ppuload
  5636. * tnode storing in ppu
  5637. * nld,ncon,nbas are already updated for storing in ppu
  5638. Revision 1.89 2002/08/11 15:28:00 florian
  5639. + support of explicit type case <any ordinal type>->pointer
  5640. (delphi mode only)
  5641. Revision 1.88 2002/08/11 14:32:28 peter
  5642. * renamed current_library to objectlibrary
  5643. Revision 1.87 2002/08/11 13:24:13 peter
  5644. * saving of asmsymbols in ppu supported
  5645. * asmsymbollist global is removed and moved into a new class
  5646. tasmlibrarydata that will hold the info of a .a file which
  5647. corresponds with a single module. Added librarydata to tmodule
  5648. to keep the library info stored for the module. In the future the
  5649. objectfiles will also be stored to the tasmlibrarydata class
  5650. * all getlabel/newasmsymbol and friends are moved to the new class
  5651. Revision 1.86 2002/08/09 07:33:03 florian
  5652. * a couple of interface related fixes
  5653. Revision 1.85 2002/07/23 09:51:24 daniel
  5654. * Tried to make Tprocsym.defs protected. I didn't succeed but the cleanups
  5655. are worth comitting.
  5656. Revision 1.84 2002/07/20 11:57:57 florian
  5657. * types.pas renamed to defbase.pas because D6 contains a types
  5658. unit so this would conflicts if D6 programms are compiled
  5659. + Willamette/SSE2 instructions to assembler added
  5660. Revision 1.83 2002/07/11 14:41:30 florian
  5661. * start of the new generic parameter handling
  5662. Revision 1.82 2002/07/07 09:52:32 florian
  5663. * powerpc target fixed, very simple units can be compiled
  5664. * some basic stuff for better callparanode handling, far from being finished
  5665. Revision 1.81 2002/07/01 18:46:26 peter
  5666. * internal linker
  5667. * reorganized aasm layer
  5668. Revision 1.80 2002/07/01 16:23:54 peter
  5669. * cg64 patch
  5670. * basics for currency
  5671. * asnode updates for class and interface (not finished)
  5672. Revision 1.79 2002/05/18 13:34:18 peter
  5673. * readded missing revisions
  5674. Revision 1.78 2002/05/16 19:46:44 carl
  5675. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  5676. + try to fix temp allocation (still in ifdef)
  5677. + generic constructor calls
  5678. + start of tassembler / tmodulebase class cleanup
  5679. Revision 1.76 2002/05/12 16:53:10 peter
  5680. * moved entry and exitcode to ncgutil and cgobj
  5681. * foreach gets extra argument for passing local data to the
  5682. iterator function
  5683. * -CR checks also class typecasts at runtime by changing them
  5684. into as
  5685. * fixed compiler to cycle with the -CR option
  5686. * fixed stabs with elf writer, finally the global variables can
  5687. be watched
  5688. * removed a lot of routines from cga unit and replaced them by
  5689. calls to cgobj
  5690. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  5691. u32bit then the other is typecasted also to u32bit without giving
  5692. a rangecheck warning/error.
  5693. * fixed pascal calling method with reversing also the high tree in
  5694. the parast, detected by tcalcst3 test
  5695. Revision 1.75 2002/04/25 20:16:39 peter
  5696. * moved more routines from cga/n386util
  5697. Revision 1.74 2002/04/23 19:16:35 peter
  5698. * add pinline unit that inserts compiler supported functions using
  5699. one or more statements
  5700. * moved finalize and setlength from ninl to pinline
  5701. Revision 1.73 2002/04/21 19:02:05 peter
  5702. * removed newn and disposen nodes, the code is now directly
  5703. inlined from pexpr
  5704. * -an option that will write the secondpass nodes to the .s file, this
  5705. requires EXTDEBUG define to actually write the info
  5706. * fixed various internal errors and crashes due recent code changes
  5707. Revision 1.72 2002/04/20 21:32:25 carl
  5708. + generic FPC_CHECKPOINTER
  5709. + first parameter offset in stack now portable
  5710. * rename some constants
  5711. + move some cpu stuff to other units
  5712. - remove unused constents
  5713. * fix stacksize for some targets
  5714. * fix generic size problems which depend now on EXTEND_SIZE constant
  5715. }