symdef.inc 131 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484
  1. {
  2. $Id$
  3. Copyright (c) 1993-99 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. {****************************************************************************
  19. TDEF (base class for definitions)
  20. ****************************************************************************}
  21. const
  22. { if you change one of the following contants, }
  23. { you have also to change the typinfo unit }
  24. { and the rtl/i386,template/rttip.inc files }
  25. tkUnknown = 0;
  26. tkInteger = 1;
  27. tkChar = 2;
  28. tkEnumeration = 3;
  29. tkFloat = 4;
  30. tkSet = 5;
  31. tkMethod = 6;
  32. tkSString = 7;
  33. tkString = tkSString;
  34. tkLString = 8;
  35. tkAString = 9;
  36. tkWString = 10;
  37. tkVariant = 11;
  38. tkArray = 12;
  39. tkRecord = 13;
  40. tkInterface = 14;
  41. tkClass = 15;
  42. tkObject = 16;
  43. tkWChar = 17;
  44. tkBool = 18;
  45. otSByte = 0;
  46. otUByte = 1;
  47. otSWord = 2;
  48. otUWord = 3;
  49. otSLong = 4;
  50. otULong = 5;
  51. ftSingle = 0;
  52. ftDouble = 1;
  53. ftExtended = 2;
  54. ftComp = 3;
  55. ftCurr = 4;
  56. ftFixed16 = 5;
  57. ftFixed32 = 6;
  58. mkProcedure = 0;
  59. mkFunction = 1;
  60. mkConstructor = 2;
  61. mkDestructor = 3;
  62. mkClassProcedure= 4;
  63. mkClassFunction = 5;
  64. pfvar = 1;
  65. pfConst = 2;
  66. pfArray = 4;
  67. pfAddress = 8;
  68. pfReference = 16;
  69. pfOut = 32;
  70. constructor tdef.init;
  71. begin
  72. inherited init;
  73. deftype:=abstractdef;
  74. owner := nil;
  75. sym := nil;
  76. savesize := 0;
  77. if registerdef then
  78. symtablestack^.registerdef(@self);
  79. has_rtti:=false;
  80. has_inittable:=false;
  81. {$ifdef GDB}
  82. is_def_stab_written := false;
  83. globalnb := 0;
  84. {$endif GDB}
  85. if assigned(lastglobaldef) then
  86. begin
  87. lastglobaldef^.nextglobal := @self;
  88. previousglobal:=lastglobaldef;
  89. end
  90. else
  91. begin
  92. firstglobaldef := @self;
  93. previousglobal := nil;
  94. end;
  95. lastglobaldef := @self;
  96. nextglobal := nil;
  97. end;
  98. constructor tdef.load;
  99. begin
  100. deftype:=abstractdef;
  101. next := nil;
  102. owner := nil;
  103. has_rtti:=false;
  104. has_inittable:=false;
  105. {$ifdef GDB}
  106. is_def_stab_written := false;
  107. globalnb := 0;
  108. {$endif GDB}
  109. if assigned(lastglobaldef) then
  110. begin
  111. lastglobaldef^.nextglobal := @self;
  112. previousglobal:=lastglobaldef;
  113. end
  114. else
  115. begin
  116. firstglobaldef := @self;
  117. previousglobal:=nil;
  118. end;
  119. lastglobaldef := @self;
  120. nextglobal := nil;
  121. { load }
  122. indexnr:=readword;
  123. sym:=ptypesym(readsymref);
  124. end;
  125. destructor tdef.done;
  126. begin
  127. { first element ? }
  128. if not(assigned(previousglobal)) then
  129. begin
  130. firstglobaldef := nextglobal;
  131. if assigned(firstglobaldef) then
  132. firstglobaldef^.previousglobal:=nil;
  133. end
  134. else
  135. begin
  136. { remove reference in the element before }
  137. previousglobal^.nextglobal:=nextglobal;
  138. end;
  139. { last element ? }
  140. if not(assigned(nextglobal)) then
  141. begin
  142. lastglobaldef := previousglobal;
  143. if assigned(lastglobaldef) then
  144. lastglobaldef^.nextglobal:=nil;
  145. end
  146. else
  147. nextglobal^.previousglobal:=previousglobal;
  148. previousglobal:=nil;
  149. nextglobal:=nil;
  150. while assigned(sym) do
  151. begin
  152. sym^.definition:=nil;
  153. sym:=sym^.synonym;
  154. end;
  155. end;
  156. { used for enumdef because the symbols are
  157. inserted in the owner symtable }
  158. procedure tdef.correct_owner_symtable;
  159. var
  160. st : psymtable;
  161. begin
  162. if assigned(owner) and
  163. (owner^.symtabletype in [recordsymtable,objectsymtable]) then
  164. begin
  165. owner^.defindex^.deleteindex(@self);
  166. st:=owner;
  167. while (st^.symtabletype in [recordsymtable,objectsymtable]) do
  168. st:=st^.next;
  169. st^.registerdef(@self);
  170. end;
  171. end;
  172. function tdef.typename:string;
  173. begin
  174. if assigned(sym) then
  175. typename:=Upper(sym^.name)
  176. else
  177. typename:=gettypename;
  178. end;
  179. function tdef.gettypename : string;
  180. begin
  181. gettypename:='<unknown type>'
  182. end;
  183. function tdef.is_in_current : boolean;
  184. var
  185. p : psymtable;
  186. begin
  187. p:=owner;
  188. is_in_current:=false;
  189. while assigned(p) do
  190. begin
  191. if (p=current_module^.globalsymtable) or (p=current_module^.localsymtable)
  192. or (p^.symtabletype in [globalsymtable,staticsymtable]) then
  193. begin
  194. is_in_current:=true;
  195. exit;
  196. end
  197. else if p^.symtabletype=objectsymtable then
  198. begin
  199. if assigned(p^.defowner) then
  200. p:=pobjectdef(p^.defowner)^.owner
  201. else
  202. exit;
  203. end
  204. else
  205. exit;
  206. end;
  207. end;
  208. procedure tdef.write;
  209. begin
  210. writeword(indexnr);
  211. writesymref(sym);
  212. {$ifdef GDB}
  213. if globalnb = 0 then
  214. begin
  215. if assigned(owner) then
  216. globalnb := owner^.getnewtypecount
  217. else
  218. begin
  219. globalnb := PGlobalTypeCount^;
  220. Inc(PGlobalTypeCount^);
  221. end;
  222. end;
  223. {$endif GDB}
  224. end;
  225. function tdef.size : longint;
  226. begin
  227. size:=savesize;
  228. end;
  229. function tdef.alignment : longint;
  230. begin
  231. { normal alignment by default }
  232. alignment:=0;
  233. end;
  234. {$ifdef GDB}
  235. procedure tdef.set_globalnb;
  236. begin
  237. globalnb :=PGlobalTypeCount^;
  238. inc(PglobalTypeCount^);
  239. end;
  240. function tdef.stabstring : pchar;
  241. begin
  242. stabstring := strpnew('t'+numberstring+';');
  243. end;
  244. function tdef.numberstring : string;
  245. var table : psymtable;
  246. begin
  247. {formal def have no type !}
  248. if deftype = formaldef then
  249. begin
  250. numberstring := voiddef^.numberstring;
  251. exit;
  252. end;
  253. if (not assigned(sym)) or (not sym^.isusedinstab) then
  254. begin
  255. {set even if debuglist is not defined}
  256. if assigned(sym) then
  257. sym^.isusedinstab := true;
  258. if assigned(debuglist) and not is_def_stab_written then
  259. concatstabto(debuglist);
  260. end;
  261. if not (cs_gdb_dbx in aktglobalswitches) then
  262. begin
  263. if globalnb = 0 then
  264. set_globalnb;
  265. numberstring := tostr(globalnb);
  266. end
  267. else
  268. begin
  269. if globalnb = 0 then
  270. begin
  271. if assigned(owner) then
  272. globalnb := owner^.getnewtypecount
  273. else
  274. begin
  275. globalnb := PGlobalTypeCount^;
  276. Inc(PGlobalTypeCount^);
  277. end;
  278. end;
  279. if assigned(sym) then
  280. begin
  281. table := sym^.owner;
  282. if table^.unitid > 0 then
  283. numberstring := '('+tostr(table^.unitid)+','
  284. +tostr(sym^.definition^.globalnb)+')'
  285. else
  286. numberstring := tostr(globalnb);
  287. exit;
  288. end;
  289. numberstring := tostr(globalnb);
  290. end;
  291. end;
  292. function tdef.allstabstring : pchar;
  293. var stabchar : string[2];
  294. ss,st : pchar;
  295. sname : string;
  296. sym_line_no : longint;
  297. begin
  298. ss := stabstring;
  299. getmem(st,strlen(ss)+512);
  300. stabchar := 't';
  301. if deftype in tagtypes then
  302. stabchar := 'Tt';
  303. if assigned(sym) then
  304. begin
  305. sname := sym^.name;
  306. sym_line_no:=sym^.fileinfo.line;
  307. end
  308. else
  309. begin
  310. sname := ' ';
  311. sym_line_no:=0;
  312. end;
  313. strpcopy(st,'"'+sname+':'+stabchar+numberstring+'=');
  314. strpcopy(strecopy(strend(st),ss),'",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0');
  315. allstabstring := strnew(st);
  316. freemem(st,strlen(ss)+512);
  317. strdispose(ss);
  318. end;
  319. procedure tdef.concatstabto(asmlist : paasmoutput);
  320. var stab_str : pchar;
  321. begin
  322. if ((sym = nil) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  323. and not is_def_stab_written then
  324. begin
  325. If cs_gdb_dbx in aktglobalswitches then
  326. begin
  327. { otherwise you get two of each def }
  328. If assigned(sym) then
  329. begin
  330. if sym^.typ=typesym then
  331. sym^.isusedinstab:=true;
  332. if (sym^.owner = nil) or
  333. ((sym^.owner^.symtabletype = unitsymtable) and
  334. punitsymtable(sym^.owner)^.dbx_count_ok) then
  335. begin
  336. {with DBX we get the definition from the other objects }
  337. is_def_stab_written := true;
  338. exit;
  339. end;
  340. end;
  341. end;
  342. { to avoid infinite loops }
  343. is_def_stab_written := true;
  344. stab_str := allstabstring;
  345. if asmlist = debuglist then do_count_dbx := true;
  346. { count_dbx(stab_str); moved to GDB.PAS}
  347. asmlist^.concat(new(pai_stabs,init(stab_str)));
  348. end;
  349. end;
  350. {$endif GDB}
  351. procedure tdef.deref;
  352. begin
  353. end;
  354. procedure tdef.symderef;
  355. begin
  356. resolvesym(psym(sym));
  357. end;
  358. { rtti generation }
  359. procedure tdef.generate_rtti;
  360. begin
  361. has_rtti:=true;
  362. getdatalabel(rtti_label);
  363. write_child_rtti_data;
  364. rttilist^.concat(new(pai_symbol,init(rtti_label,0)));
  365. write_rtti_data;
  366. rttilist^.concat(new(pai_symbol_end,init(rtti_label)));
  367. end;
  368. function tdef.get_rtti_label : string;
  369. begin
  370. if not(has_rtti) then
  371. generate_rtti;
  372. get_rtti_label:=rtti_label^.name;
  373. end;
  374. { init table handling }
  375. function tdef.needs_inittable : boolean;
  376. begin
  377. needs_inittable:=false;
  378. end;
  379. procedure tdef.generate_inittable;
  380. begin
  381. has_inittable:=true;
  382. getdatalabel(inittable_label);
  383. write_child_init_data;
  384. rttilist^.concat(new(pai_label,init(inittable_label)));
  385. write_init_data;
  386. end;
  387. procedure tdef.write_init_data;
  388. begin
  389. write_rtti_data;
  390. end;
  391. procedure tdef.write_child_init_data;
  392. begin
  393. write_child_rtti_data;
  394. end;
  395. function tdef.get_inittable_label : pasmlabel;
  396. begin
  397. if not(has_inittable) then
  398. generate_inittable;
  399. get_inittable_label:=inittable_label;
  400. end;
  401. procedure tdef.write_rtti_name;
  402. var
  403. str : string;
  404. begin
  405. { name }
  406. if assigned(sym) then
  407. begin
  408. str:=sym^.name;
  409. rttilist^.concat(new(pai_string,init(chr(length(str))+str)));
  410. end
  411. else
  412. rttilist^.concat(new(pai_string,init(#0)))
  413. end;
  414. { returns true, if the definition can be published }
  415. function tdef.is_publishable : boolean;
  416. begin
  417. is_publishable:=false;
  418. end;
  419. procedure tdef.write_rtti_data;
  420. begin
  421. end;
  422. procedure tdef.write_child_rtti_data;
  423. begin
  424. end;
  425. function tdef.is_intregable : boolean;
  426. begin
  427. is_intregable:=false;
  428. case deftype of
  429. pointerdef,
  430. enumdef,
  431. procvardef :
  432. is_intregable:=true;
  433. orddef :
  434. case porddef(@self)^.typ of
  435. bool8bit,bool16bit,bool32bit,
  436. u8bit,u16bit,u32bit,
  437. s8bit,s16bit,s32bit:
  438. is_intregable:=true;
  439. end;
  440. setdef:
  441. is_intregable:=is_smallset(@self);
  442. end;
  443. end;
  444. function tdef.is_fpuregable : boolean;
  445. begin
  446. is_fpuregable:=(deftype=floatdef) and not(pfloatdef(@self)^.typ in [f32bit,f16bit]);
  447. end;
  448. {****************************************************************************
  449. TSTRINGDEF
  450. ****************************************************************************}
  451. constructor tstringdef.shortinit(l : byte);
  452. begin
  453. tdef.init;
  454. string_typ:=st_shortstring;
  455. deftype:=stringdef;
  456. len:=l;
  457. savesize:=len+1;
  458. end;
  459. constructor tstringdef.shortload;
  460. begin
  461. tdef.load;
  462. string_typ:=st_shortstring;
  463. deftype:=stringdef;
  464. len:=readbyte;
  465. savesize:=len+1;
  466. end;
  467. constructor tstringdef.longinit(l : longint);
  468. begin
  469. tdef.init;
  470. string_typ:=st_longstring;
  471. deftype:=stringdef;
  472. len:=l;
  473. savesize:=target_os.size_of_pointer;
  474. end;
  475. constructor tstringdef.longload;
  476. begin
  477. tdef.load;
  478. deftype:=stringdef;
  479. string_typ:=st_longstring;
  480. len:=readlong;
  481. savesize:=target_os.size_of_pointer;
  482. end;
  483. constructor tstringdef.ansiinit(l : longint);
  484. begin
  485. tdef.init;
  486. string_typ:=st_ansistring;
  487. deftype:=stringdef;
  488. len:=l;
  489. savesize:=target_os.size_of_pointer;
  490. end;
  491. constructor tstringdef.ansiload;
  492. begin
  493. tdef.load;
  494. deftype:=stringdef;
  495. string_typ:=st_ansistring;
  496. len:=readlong;
  497. savesize:=target_os.size_of_pointer;
  498. end;
  499. constructor tstringdef.wideinit(l : longint);
  500. begin
  501. tdef.init;
  502. string_typ:=st_widestring;
  503. deftype:=stringdef;
  504. len:=l;
  505. savesize:=target_os.size_of_pointer;
  506. end;
  507. constructor tstringdef.wideload;
  508. begin
  509. tdef.load;
  510. deftype:=stringdef;
  511. string_typ:=st_widestring;
  512. len:=readlong;
  513. savesize:=target_os.size_of_pointer;
  514. end;
  515. function tstringdef.stringtypname:string;
  516. const
  517. typname:array[tstringtype] of string[8]=(
  518. 'SHORTSTR','LONGSTR','ANSISTR','WIDESTR'
  519. );
  520. begin
  521. stringtypname:=typname[string_typ];
  522. end;
  523. function tstringdef.size : longint;
  524. begin
  525. size:=savesize;
  526. end;
  527. procedure tstringdef.write;
  528. begin
  529. tdef.write;
  530. if string_typ=st_shortstring then
  531. writebyte(len)
  532. else
  533. writelong(len);
  534. case string_typ of
  535. st_shortstring : current_ppu^.writeentry(ibshortstringdef);
  536. st_longstring : current_ppu^.writeentry(iblongstringdef);
  537. st_ansistring : current_ppu^.writeentry(ibansistringdef);
  538. st_widestring : current_ppu^.writeentry(ibwidestringdef);
  539. end;
  540. end;
  541. {$ifdef GDB}
  542. function tstringdef.stabstring : pchar;
  543. var
  544. bytest,charst,longst : string;
  545. begin
  546. case string_typ of
  547. st_shortstring:
  548. begin
  549. charst := typeglobalnumber('char');
  550. { this is what I found in stabs.texinfo but
  551. gdb 4.12 for go32 doesn't understand that !! }
  552. {$IfDef GDBknowsstrings}
  553. stabstring := strpnew('n'+charst+';'+tostr(len));
  554. {$else}
  555. bytest := typeglobalnumber('byte');
  556. stabstring := strpnew('s'+tostr(len+1)+'length:'+bytest
  557. +',0,8;st:ar'+bytest
  558. +';1;'+tostr(len)+';'+charst+',8,'+tostr(len*8)+';;');
  559. {$EndIf}
  560. end;
  561. st_longstring:
  562. begin
  563. charst := typeglobalnumber('char');
  564. { this is what I found in stabs.texinfo but
  565. gdb 4.12 for go32 doesn't understand that !! }
  566. {$IfDef GDBknowsstrings}
  567. stabstring := strpnew('n'+charst+';'+tostr(len));
  568. {$else}
  569. bytest := typeglobalnumber('byte');
  570. longst := typeglobalnumber('longint');
  571. stabstring := strpnew('s'+tostr(len+5)+'length:'+longst
  572. +',0,32;dummy:'+bytest+',32,8;st:ar'+bytest
  573. +';1;'+tostr(len)+';'+charst+',40,'+tostr(len*8)+';;');
  574. {$EndIf}
  575. end;
  576. st_ansistring:
  577. begin
  578. { an ansi string looks like a pchar easy !! }
  579. stabstring:=strpnew('*'+typeglobalnumber('char'));
  580. end;
  581. st_widestring:
  582. begin
  583. { an ansi string looks like a pchar easy !! }
  584. stabstring:=strpnew('*'+typeglobalnumber('char'));
  585. end;
  586. end;
  587. end;
  588. procedure tstringdef.concatstabto(asmlist : paasmoutput);
  589. begin
  590. inherited concatstabto(asmlist);
  591. end;
  592. {$endif GDB}
  593. function tstringdef.needs_inittable : boolean;
  594. begin
  595. needs_inittable:=string_typ in [st_ansistring,st_widestring];
  596. end;
  597. function tstringdef.gettypename : string;
  598. const
  599. names : array[tstringtype] of string[20] =
  600. ('ShortString','LongString','AnsiString','WideString');
  601. begin
  602. gettypename:=names[string_typ];
  603. end;
  604. procedure tstringdef.write_rtti_data;
  605. begin
  606. case string_typ of
  607. st_ansistring:
  608. begin
  609. rttilist^.concat(new(pai_const,init_8bit(tkAString)));
  610. write_rtti_name;
  611. end;
  612. st_widestring:
  613. begin
  614. rttilist^.concat(new(pai_const,init_8bit(tkWString)));
  615. write_rtti_name;
  616. end;
  617. st_longstring:
  618. begin
  619. rttilist^.concat(new(pai_const,init_8bit(tkLString)));
  620. write_rtti_name;
  621. end;
  622. st_shortstring:
  623. begin
  624. rttilist^.concat(new(pai_const,init_8bit(tkSString)));
  625. write_rtti_name;
  626. rttilist^.concat(new(pai_const,init_8bit(len)));
  627. end;
  628. end;
  629. end;
  630. function tstringdef.is_publishable : boolean;
  631. begin
  632. is_publishable:=true;
  633. end;
  634. {****************************************************************************
  635. TENUMDEF
  636. ****************************************************************************}
  637. constructor tenumdef.init;
  638. begin
  639. tdef.init;
  640. deftype:=enumdef;
  641. minval:=0;
  642. maxval:=0;
  643. calcsavesize;
  644. has_jumps:=false;
  645. basedef:=nil;
  646. rangenr:=0;
  647. firstenum:=nil;
  648. correct_owner_symtable;
  649. end;
  650. constructor tenumdef.init_subrange(_basedef:penumdef;_min,_max:longint);
  651. begin
  652. tdef.init;
  653. deftype:=enumdef;
  654. minval:=_min;
  655. maxval:=_max;
  656. basedef:=_basedef;
  657. calcsavesize;
  658. has_jumps:=false;
  659. rangenr:=0;
  660. firstenum:=basedef^.firstenum;
  661. while assigned(firstenum) and (penumsym(firstenum)^.value<>minval) do
  662. firstenum:=firstenum^.nextenum;
  663. correct_owner_symtable;
  664. end;
  665. constructor tenumdef.load;
  666. begin
  667. tdef.load;
  668. deftype:=enumdef;
  669. basedef:=penumdef(readdefref);
  670. minval:=readlong;
  671. maxval:=readlong;
  672. savesize:=readlong;
  673. has_jumps:=false;
  674. firstenum:=Nil;
  675. end;
  676. procedure tenumdef.calcsavesize;
  677. begin
  678. if (aktpackenum=4) or (min<0) or (max>65535) then
  679. savesize:=4
  680. else
  681. if (aktpackenum=2) or (min<0) or (max>255) then
  682. savesize:=2
  683. else
  684. savesize:=1;
  685. end;
  686. procedure tenumdef.setmax(_max:longint);
  687. begin
  688. maxval:=_max;
  689. calcsavesize;
  690. end;
  691. procedure tenumdef.setmin(_min:longint);
  692. begin
  693. minval:=_min;
  694. calcsavesize;
  695. end;
  696. function tenumdef.min:longint;
  697. begin
  698. min:=minval;
  699. end;
  700. function tenumdef.max:longint;
  701. begin
  702. max:=maxval;
  703. end;
  704. procedure tenumdef.deref;
  705. begin
  706. resolvedef(pdef(basedef));
  707. end;
  708. destructor tenumdef.done;
  709. begin
  710. inherited done;
  711. end;
  712. procedure tenumdef.write;
  713. begin
  714. tdef.write;
  715. writedefref(basedef);
  716. writelong(min);
  717. writelong(max);
  718. writelong(savesize);
  719. current_ppu^.writeentry(ibenumdef);
  720. end;
  721. function tenumdef.getrangecheckstring : string;
  722. begin
  723. if (cs_create_smart in aktmoduleswitches) then
  724. getrangecheckstring:='R_'+current_module^.modulename^+tostr(rangenr)
  725. else
  726. getrangecheckstring:='R_'+tostr(rangenr);
  727. end;
  728. procedure tenumdef.genrangecheck;
  729. begin
  730. if rangenr=0 then
  731. begin
  732. { generate two constant for bounds }
  733. getlabelnr(rangenr);
  734. if (cs_create_smart in aktmoduleswitches) then
  735. datasegment^.concat(new(pai_symbol,initname_global(getrangecheckstring,8)))
  736. else
  737. datasegment^.concat(new(pai_symbol,initname(getrangecheckstring,8)));
  738. datasegment^.concat(new(pai_const,init_32bit(min)));
  739. datasegment^.concat(new(pai_const,init_32bit(max)));
  740. end;
  741. end;
  742. {$ifdef GDB}
  743. function tenumdef.stabstring : pchar;
  744. var st,st2 : pchar;
  745. p : penumsym;
  746. s : string;
  747. memsize : word;
  748. begin
  749. memsize := memsizeinc;
  750. getmem(st,memsize);
  751. strpcopy(st,'e');
  752. p := firstenum;
  753. while assigned(p) do
  754. begin
  755. s :=p^.name+':'+tostr(p^.value)+',';
  756. { place for the ending ';' also }
  757. if (strlen(st)+length(s)+1<memsize) then
  758. strpcopy(strend(st),s)
  759. else
  760. begin
  761. getmem(st2,memsize+memsizeinc);
  762. strcopy(st2,st);
  763. freemem(st,memsize);
  764. st := st2;
  765. memsize := memsize+memsizeinc;
  766. strpcopy(strend(st),s);
  767. end;
  768. p := p^.nextenum;
  769. end;
  770. strpcopy(strend(st),';');
  771. stabstring := strnew(st);
  772. freemem(st,memsize);
  773. end;
  774. {$endif GDB}
  775. procedure tenumdef.write_child_rtti_data;
  776. begin
  777. if assigned(basedef) then
  778. basedef^.get_rtti_label;
  779. end;
  780. procedure tenumdef.write_rtti_data;
  781. var
  782. hp : penumsym;
  783. begin
  784. rttilist^.concat(new(pai_const,init_8bit(tkEnumeration)));
  785. write_rtti_name;
  786. case savesize of
  787. 1:
  788. rttilist^.concat(new(pai_const,init_8bit(otUByte)));
  789. 2:
  790. rttilist^.concat(new(pai_const,init_8bit(otUWord)));
  791. 4:
  792. rttilist^.concat(new(pai_const,init_8bit(otULong)));
  793. end;
  794. rttilist^.concat(new(pai_const,init_32bit(min)));
  795. rttilist^.concat(new(pai_const,init_32bit(max)));
  796. if assigned(basedef) then
  797. rttilist^.concat(new(pai_const_symbol,initname(basedef^.get_rtti_label)))
  798. else
  799. rttilist^.concat(new(pai_const,init_32bit(0)));
  800. hp:=firstenum;
  801. while assigned(hp) do
  802. begin
  803. rttilist^.concat(new(pai_const,init_8bit(length(hp^.name))));
  804. rttilist^.concat(new(pai_string,init(globals.lower(hp^.name))));
  805. hp:=hp^.nextenum;
  806. end;
  807. rttilist^.concat(new(pai_const,init_8bit(0)));
  808. end;
  809. function tenumdef.is_publishable : boolean;
  810. begin
  811. is_publishable:=true;
  812. end;
  813. function tenumdef.gettypename : string;
  814. begin
  815. gettypename:='<enumeration type>';
  816. end;
  817. {****************************************************************************
  818. TORDDEF
  819. ****************************************************************************}
  820. constructor torddef.init(t : tbasetype;v,b : longint);
  821. begin
  822. inherited init;
  823. deftype:=orddef;
  824. low:=v;
  825. high:=b;
  826. typ:=t;
  827. rangenr:=0;
  828. setsize;
  829. end;
  830. constructor torddef.load;
  831. begin
  832. inherited load;
  833. deftype:=orddef;
  834. typ:=tbasetype(readbyte);
  835. low:=readlong;
  836. high:=readlong;
  837. rangenr:=0;
  838. setsize;
  839. end;
  840. procedure torddef.setsize;
  841. begin
  842. if typ=uauto then
  843. begin
  844. { generate a unsigned range if high<0 and low>=0 }
  845. if (low>=0) and (high<0) then
  846. begin
  847. savesize:=4;
  848. typ:=u32bit;
  849. end
  850. else if (low>=0) and (high<=255) then
  851. begin
  852. savesize:=1;
  853. typ:=u8bit;
  854. end
  855. else if (low>=-128) and (high<=127) then
  856. begin
  857. savesize:=1;
  858. typ:=s8bit;
  859. end
  860. else if (low>=0) and (high<=65536) then
  861. begin
  862. savesize:=2;
  863. typ:=u16bit;
  864. end
  865. else if (low>=-32768) and (high<=32767) then
  866. begin
  867. savesize:=2;
  868. typ:=s16bit;
  869. end
  870. else
  871. begin
  872. savesize:=4;
  873. typ:=s32bit;
  874. end;
  875. end
  876. else
  877. begin
  878. case typ of
  879. u8bit,s8bit,
  880. uchar,bool8bit:
  881. savesize:=1;
  882. u16bit,s16bit,
  883. bool16bit:
  884. savesize:=2;
  885. s32bit,u32bit,
  886. bool32bit:
  887. savesize:=4;
  888. u64bit,s64bit:
  889. savesize:=8;
  890. else
  891. savesize:=0;
  892. end;
  893. end;
  894. { there are no entrys for range checking }
  895. rangenr:=0;
  896. end;
  897. function torddef.getrangecheckstring : string;
  898. begin
  899. if (cs_create_smart in aktmoduleswitches) then
  900. getrangecheckstring:='R_'+current_module^.modulename^+tostr(rangenr)
  901. else
  902. getrangecheckstring:='R_'+tostr(rangenr);
  903. end;
  904. procedure torddef.genrangecheck;
  905. var
  906. rangechecksize : longint;
  907. begin
  908. if rangenr=0 then
  909. begin
  910. if low<=high then
  911. rangechecksize:=8
  912. else
  913. rangechecksize:=16;
  914. { generate two constant for bounds }
  915. getlabelnr(rangenr);
  916. if (cs_create_smart in aktmoduleswitches) then
  917. datasegment^.concat(new(pai_symbol,initname_global(getrangecheckstring,rangechecksize)))
  918. else
  919. datasegment^.concat(new(pai_symbol,initname(getrangecheckstring,rangechecksize)));
  920. if low<=high then
  921. begin
  922. datasegment^.concat(new(pai_const,init_32bit(low)));
  923. datasegment^.concat(new(pai_const,init_32bit(high)));
  924. end
  925. { for u32bit we need two bounds }
  926. else
  927. begin
  928. datasegment^.concat(new(pai_const,init_32bit(low)));
  929. datasegment^.concat(new(pai_const,init_32bit($7fffffff)));
  930. datasegment^.concat(new(pai_const,init_32bit($80000000)));
  931. datasegment^.concat(new(pai_const,init_32bit(high)));
  932. end;
  933. end;
  934. end;
  935. procedure torddef.write;
  936. begin
  937. tdef.write;
  938. writebyte(byte(typ));
  939. writelong(low);
  940. writelong(high);
  941. current_ppu^.writeentry(iborddef);
  942. end;
  943. {$ifdef GDB}
  944. function torddef.stabstring : pchar;
  945. begin
  946. case typ of
  947. uvoid : stabstring := strpnew(numberstring+';');
  948. {GDB 4.12 for go32 doesn't like boolean as range for 0 to 1 !!!}
  949. {$ifdef Use_integer_types_for_boolean}
  950. bool8bit,
  951. bool16bit,
  952. bool32bit : stabstring := strpnew('r'+numberstring+';0;255;');
  953. {$else : not Use_integer_types_for_boolean}
  954. bool8bit : stabstring := strpnew('-21;');
  955. bool16bit : stabstring := strpnew('-22;');
  956. bool32bit : stabstring := strpnew('-23;');
  957. u64bit : stabstring := strpnew('-32;');
  958. s64bit : stabstring := strpnew('-31;');
  959. {$endif not Use_integer_types_for_boolean}
  960. { u32bit : stabstring := strpnew('r'+
  961. s32bitdef^.numberstring+';0;-1;'); }
  962. else
  963. stabstring := strpnew('r'+s32bitdef^.numberstring+';'+tostr(low)+';'+tostr(high)+';');
  964. end;
  965. end;
  966. {$endif GDB}
  967. procedure torddef.write_rtti_data;
  968. const
  969. trans : array[uchar..bool8bit] of byte =
  970. (otUByte,otUByte,otUWord,otULong,otSByte,otSWord,otSLong,otUByte);
  971. begin
  972. case typ of
  973. bool8bit:
  974. rttilist^.concat(new(pai_const,init_8bit(tkBool)));
  975. uchar:
  976. rttilist^.concat(new(pai_const,init_8bit(tkChar)));
  977. else
  978. rttilist^.concat(new(pai_const,init_8bit(tkInteger)));
  979. end;
  980. write_rtti_name;
  981. rttilist^.concat(new(pai_const,init_8bit(byte(trans[typ]))));
  982. rttilist^.concat(new(pai_const,init_32bit(low)));
  983. rttilist^.concat(new(pai_const,init_32bit(high)));
  984. end;
  985. function torddef.is_publishable : boolean;
  986. begin
  987. is_publishable:=typ in [uchar..bool8bit];
  988. end;
  989. function torddef.gettypename : string;
  990. const
  991. names : array[tbasetype] of string[20] = ('<unknown type>',
  992. 'untyped','Char','Byte','Word','DWord','ShortInt',
  993. 'SmallInt','LongInt','Boolean','WordBool',
  994. 'LongBool','QWord','Int64');
  995. begin
  996. gettypename:=names[typ];
  997. end;
  998. {****************************************************************************
  999. TFLOATDEF
  1000. ****************************************************************************}
  1001. constructor tfloatdef.init(t : tfloattype);
  1002. begin
  1003. inherited init;
  1004. deftype:=floatdef;
  1005. typ:=t;
  1006. setsize;
  1007. end;
  1008. constructor tfloatdef.load;
  1009. begin
  1010. inherited load;
  1011. deftype:=floatdef;
  1012. typ:=tfloattype(readbyte);
  1013. setsize;
  1014. end;
  1015. procedure tfloatdef.setsize;
  1016. begin
  1017. case typ of
  1018. f16bit : savesize:=2;
  1019. f32bit,
  1020. s32real : savesize:=4;
  1021. s64real : savesize:=8;
  1022. s80real : savesize:=extended_size;
  1023. s64comp : savesize:=8;
  1024. else
  1025. savesize:=0;
  1026. end;
  1027. end;
  1028. procedure tfloatdef.write;
  1029. begin
  1030. inherited write;
  1031. writebyte(byte(typ));
  1032. current_ppu^.writeentry(ibfloatdef);
  1033. end;
  1034. {$ifdef GDB}
  1035. function tfloatdef.stabstring : pchar;
  1036. begin
  1037. case typ of
  1038. s32real,
  1039. s64real : stabstring := strpnew('r'+
  1040. s32bitdef^.numberstring+';'+tostr(savesize)+';0;');
  1041. { for fixed real use longint instead to be able to }
  1042. { debug something at least }
  1043. f32bit:
  1044. stabstring := s32bitdef^.stabstring;
  1045. f16bit:
  1046. stabstring := strpnew('r'+s32bitdef^.numberstring+';0;'+
  1047. tostr($ffff)+';');
  1048. { found this solution in stabsread.c from GDB v4.16 }
  1049. s64comp : stabstring := strpnew('r'+
  1050. s32bitdef^.numberstring+';-'+tostr(savesize)+';0;');
  1051. {$ifdef i386}
  1052. { under dos at least you must give a size of twelve instead of 10 !! }
  1053. { this is probably do to the fact that in gcc all is pushed in 4 bytes size }
  1054. s80real : stabstring := strpnew('r'+s32bitdef^.numberstring+';12;0;');
  1055. {$endif i386}
  1056. else
  1057. internalerror(10005);
  1058. end;
  1059. end;
  1060. {$endif GDB}
  1061. procedure tfloatdef.write_rtti_data;
  1062. const
  1063. {tfloattype = (s32real,s64real,s80real,s64bit,f16bit,f32bit);}
  1064. translate : array[tfloattype] of byte =
  1065. (ftSingle,ftDouble,ftExtended,ftComp,ftFixed16,ftFixed32);
  1066. begin
  1067. rttilist^.concat(new(pai_const,init_8bit(tkFloat)));
  1068. write_rtti_name;
  1069. rttilist^.concat(new(pai_const,init_8bit(translate[typ])));
  1070. end;
  1071. function tfloatdef.is_publishable : boolean;
  1072. begin
  1073. is_publishable:=true;
  1074. end;
  1075. function tfloatdef.gettypename : string;
  1076. const
  1077. names : array[tfloattype] of string[20] = (
  1078. 'Single','Double','Extended','Comp','Fixed','Fixed16');
  1079. begin
  1080. gettypename:=names[typ];
  1081. end;
  1082. {****************************************************************************
  1083. TFILEDEF
  1084. ****************************************************************************}
  1085. constructor tfiledef.init(ft : tfiletype;tas : pdef);
  1086. begin
  1087. inherited init;
  1088. deftype:=filedef;
  1089. filetype:=ft;
  1090. typed_as:=tas;
  1091. setsize;
  1092. end;
  1093. constructor tfiledef.load;
  1094. begin
  1095. inherited load;
  1096. deftype:=filedef;
  1097. filetype:=tfiletype(readbyte);
  1098. if filetype=ft_typed then
  1099. typed_as:=readdefref
  1100. else
  1101. typed_as:=nil;
  1102. setsize;
  1103. end;
  1104. procedure tfiledef.deref;
  1105. begin
  1106. if filetype=ft_typed then
  1107. resolvedef(typed_as);
  1108. end;
  1109. procedure tfiledef.setsize;
  1110. begin
  1111. case filetype of
  1112. ft_text : savesize:=572;
  1113. ft_typed,
  1114. ft_untyped : savesize:=316;
  1115. end;
  1116. end;
  1117. procedure tfiledef.write;
  1118. begin
  1119. inherited write;
  1120. writebyte(byte(filetype));
  1121. if filetype=ft_typed then
  1122. writedefref(typed_as);
  1123. current_ppu^.writeentry(ibfiledef);
  1124. end;
  1125. {$ifdef GDB}
  1126. function tfiledef.stabstring : pchar;
  1127. begin
  1128. {$IfDef GDBknowsfiles}
  1129. case filetyp of
  1130. ft_typed : stabstring := strpnew('d'+typed_as^.numberstring{+';'});
  1131. ft_untyped : stabstring := strpnew('d'+voiddef^.numberstring{+';'});
  1132. ft_text : stabstring := strpnew('d'+cchardef^.numberstring{+';'});
  1133. end;
  1134. {$Else}
  1135. {based on
  1136. FileRec = Packed Record
  1137. Handle,
  1138. Mode,
  1139. RecSize : longint;
  1140. _private : array[1..32] of byte;
  1141. UserData : array[1..16] of byte;
  1142. name : array[0..255] of char;
  1143. End; }
  1144. { the buffer part is still missing !! (PM) }
  1145. { but the string could become too long !! }
  1146. stabstring := strpnew('s'+tostr(savesize)+
  1147. 'HANDLE:'+typeglobalnumber('longint')+',0,32;'+
  1148. 'MODE:'+typeglobalnumber('longint')+',32,32;'+
  1149. 'RECSIZE:'+typeglobalnumber('longint')+',64,32;'+
  1150. '_PRIVATE:ar'+typeglobalnumber('word')+';1;32;'+typeglobalnumber('byte')
  1151. +',96,256;'+
  1152. 'USERDATA:ar'+typeglobalnumber('word')+';1;16;'+typeglobalnumber('byte')
  1153. +',352,128;'+
  1154. 'NAME:ar'+typeglobalnumber('word')+';0;255;'+typeglobalnumber('char')
  1155. +',480,2048;;');
  1156. {$EndIf}
  1157. end;
  1158. procedure tfiledef.concatstabto(asmlist : paasmoutput);
  1159. begin
  1160. { most file defs are unnamed !!! }
  1161. if ((sym = nil) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1162. not is_def_stab_written then
  1163. begin
  1164. if assigned(typed_as) then forcestabto(asmlist,typed_as);
  1165. inherited concatstabto(asmlist);
  1166. end;
  1167. end;
  1168. {$endif GDB}
  1169. function tfiledef.gettypename : string;
  1170. begin
  1171. case filetype of
  1172. ft_untyped:
  1173. gettypename:='File';
  1174. ft_typed:
  1175. gettypename:='File Of '+typed_as^.typename;
  1176. ft_text:
  1177. gettypename:='Text'
  1178. end;
  1179. end;
  1180. {****************************************************************************
  1181. TPOINTERDEF
  1182. ****************************************************************************}
  1183. constructor tpointerdef.init(def : pdef);
  1184. begin
  1185. inherited init;
  1186. deftype:=pointerdef;
  1187. definition:=def;
  1188. is_far:=false;
  1189. savesize:=target_os.size_of_pointer;
  1190. end;
  1191. constructor tpointerdef.initfar(def : pdef);
  1192. begin
  1193. inherited init;
  1194. deftype:=pointerdef;
  1195. definition:=def;
  1196. is_far:=true;
  1197. savesize:=target_os.size_of_pointer;
  1198. end;
  1199. constructor tpointerdef.load;
  1200. begin
  1201. inherited load;
  1202. deftype:=pointerdef;
  1203. { the real address in memory is calculated later (deref) }
  1204. definition:=readdefref;
  1205. is_far:=(readbyte<>0);
  1206. savesize:=target_os.size_of_pointer;
  1207. end;
  1208. destructor tpointerdef.done;
  1209. begin
  1210. if assigned(definition) and
  1211. (definition^.deftype=forwarddef) then
  1212. begin
  1213. dispose(definition,done);
  1214. definition:=nil;
  1215. end;
  1216. inherited done;
  1217. end;
  1218. procedure tpointerdef.deref;
  1219. begin
  1220. resolvedef(definition);
  1221. end;
  1222. procedure tpointerdef.write;
  1223. begin
  1224. inherited write;
  1225. writedefref(definition);
  1226. writebyte(byte(is_far));
  1227. current_ppu^.writeentry(ibpointerdef);
  1228. end;
  1229. {$ifdef GDB}
  1230. function tpointerdef.stabstring : pchar;
  1231. begin
  1232. stabstring := strpnew('*'+definition^.numberstring);
  1233. end;
  1234. procedure tpointerdef.concatstabto(asmlist : paasmoutput);
  1235. var st,nb : string;
  1236. sym_line_no : longint;
  1237. begin
  1238. if assigned(definition) and
  1239. (definition^.deftype=forwarddef) then
  1240. exit;
  1241. if ( (sym=nil) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1242. not is_def_stab_written then
  1243. begin
  1244. if assigned(definition) then
  1245. if definition^.deftype in [recorddef,objectdef] then
  1246. begin
  1247. is_def_stab_written := true;
  1248. {to avoid infinite recursion in record with next-like fields }
  1249. nb := definition^.numberstring;
  1250. is_def_stab_written := false;
  1251. if not definition^.is_def_stab_written then
  1252. begin
  1253. if assigned(definition^.sym) then
  1254. begin
  1255. if assigned(sym) then
  1256. begin
  1257. st := sym^.name;
  1258. sym_line_no:=sym^.fileinfo.line;
  1259. end
  1260. else
  1261. begin
  1262. st := ' ';
  1263. sym_line_no:=0;
  1264. end;
  1265. st := '"'+st+':t'+numberstring+'=*'+definition^.numberstring
  1266. +'=xs'+definition^.sym^.name+':",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0';
  1267. if asmlist = debuglist then do_count_dbx := true;
  1268. asmlist^.concat(new(pai_stabs,init(strpnew(st))));
  1269. end;
  1270. end else inherited concatstabto(asmlist);
  1271. is_def_stab_written := true;
  1272. end else
  1273. begin
  1274. { p =^p1; p1=^p problem }
  1275. is_def_stab_written := true;
  1276. forcestabto(asmlist,definition);
  1277. is_def_stab_written := false;
  1278. inherited concatstabto(asmlist);
  1279. end;
  1280. end;
  1281. end;
  1282. {$endif GDB}
  1283. function tpointerdef.gettypename : string;
  1284. begin
  1285. gettypename:='^'+definition^.typename;
  1286. end;
  1287. {****************************************************************************
  1288. TCLASSREFDEF
  1289. ****************************************************************************}
  1290. constructor tclassrefdef.init(def : pdef);
  1291. begin
  1292. inherited init(def);
  1293. deftype:=classrefdef;
  1294. definition:=def;
  1295. savesize:=target_os.size_of_pointer;
  1296. end;
  1297. constructor tclassrefdef.load;
  1298. begin
  1299. { be careful, tclassdefref inherits from tpointerdef }
  1300. tdef.load;
  1301. deftype:=classrefdef;
  1302. definition:=readdefref;
  1303. is_far:=false;
  1304. savesize:=target_os.size_of_pointer;
  1305. end;
  1306. procedure tclassrefdef.write;
  1307. begin
  1308. { be careful, tclassdefref inherits from tpointerdef }
  1309. tdef.write;
  1310. writedefref(definition);
  1311. current_ppu^.writeentry(ibclassrefdef);
  1312. end;
  1313. {$ifdef GDB}
  1314. function tclassrefdef.stabstring : pchar;
  1315. begin
  1316. stabstring:=strpnew(pvmtdef^.numberstring+';');
  1317. end;
  1318. procedure tclassrefdef.concatstabto(asmlist : paasmoutput);
  1319. begin
  1320. inherited concatstabto(asmlist);
  1321. end;
  1322. {$endif GDB}
  1323. function tclassrefdef.gettypename : string;
  1324. begin
  1325. gettypename:='Class Of '+definition^.typename;
  1326. end;
  1327. {***************************************************************************
  1328. TSETDEF
  1329. ***************************************************************************}
  1330. { For i386 smallsets work,
  1331. for m68k there are problems
  1332. can be test by compiling with -dusesmallset PM }
  1333. {$ifdef i386}
  1334. {$define usesmallset}
  1335. {$endif i386}
  1336. constructor tsetdef.init(s : pdef;high : longint);
  1337. begin
  1338. inherited init;
  1339. deftype:=setdef;
  1340. setof:=s;
  1341. {$ifdef usesmallset}
  1342. { small sets only working for i386 PM }
  1343. if high<32 then
  1344. begin
  1345. settype:=smallset;
  1346. savesize:=Sizeof(longint);
  1347. end
  1348. else
  1349. {$endif usesmallset}
  1350. if high<256 then
  1351. begin
  1352. settype:=normset;
  1353. savesize:=32;
  1354. end
  1355. else
  1356. {$ifdef testvarsets}
  1357. if high<$10000 then
  1358. begin
  1359. settype:=varset;
  1360. savesize:=4*((high+31) div 32);
  1361. end
  1362. else
  1363. {$endif testvarsets}
  1364. Message(sym_e_ill_type_decl_set);
  1365. end;
  1366. constructor tsetdef.load;
  1367. begin
  1368. inherited load;
  1369. deftype:=setdef;
  1370. setof:=readdefref;
  1371. settype:=tsettype(readbyte);
  1372. case settype of
  1373. normset : savesize:=32;
  1374. varset : savesize:=readlong;
  1375. smallset : savesize:=Sizeof(longint);
  1376. end;
  1377. end;
  1378. procedure tsetdef.write;
  1379. begin
  1380. inherited write;
  1381. writedefref(setof);
  1382. writebyte(byte(settype));
  1383. if settype=varset then
  1384. writelong(savesize);
  1385. current_ppu^.writeentry(ibsetdef);
  1386. end;
  1387. {$ifdef GDB}
  1388. function tsetdef.stabstring : pchar;
  1389. begin
  1390. { For small sets write a longint, which can at least be seen
  1391. in the current GDB's (PFV)
  1392. this is obsolete with GDBPAS !!
  1393. and anyhow creates problems with version 4.18!! PM
  1394. if settype=smallset then
  1395. stabstring := strpnew('r'+s32bitdef^.numberstring+';0;0xffffffff;')
  1396. else }
  1397. stabstring := strpnew('S'+setof^.numberstring);
  1398. end;
  1399. procedure tsetdef.concatstabto(asmlist : paasmoutput);
  1400. begin
  1401. if ( not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1402. not is_def_stab_written then
  1403. begin
  1404. if assigned(setof) then
  1405. forcestabto(asmlist,setof);
  1406. inherited concatstabto(asmlist);
  1407. end;
  1408. end;
  1409. {$endif GDB}
  1410. procedure tsetdef.deref;
  1411. begin
  1412. resolvedef(setof);
  1413. end;
  1414. procedure tsetdef.write_rtti_data;
  1415. begin
  1416. rttilist^.concat(new(pai_const,init_8bit(tkSet)));
  1417. write_rtti_name;
  1418. rttilist^.concat(new(pai_const,init_8bit(otULong)));
  1419. rttilist^.concat(new(pai_const_symbol,initname(setof^.get_rtti_label)));
  1420. end;
  1421. procedure tsetdef.write_child_rtti_data;
  1422. begin
  1423. setof^.get_rtti_label;
  1424. end;
  1425. function tsetdef.is_publishable : boolean;
  1426. begin
  1427. is_publishable:=settype=smallset;
  1428. end;
  1429. function tsetdef.gettypename : string;
  1430. begin
  1431. gettypename:='Set Of '+setof^.typename;
  1432. end;
  1433. {***************************************************************************
  1434. TFORMALDEF
  1435. ***************************************************************************}
  1436. constructor tformaldef.init;
  1437. var
  1438. stregdef : boolean;
  1439. begin
  1440. stregdef:=registerdef;
  1441. registerdef:=false;
  1442. inherited init;
  1443. deftype:=formaldef;
  1444. registerdef:=stregdef;
  1445. { formaldef must be registered at unit level !! }
  1446. if registerdef and assigned(current_module) then
  1447. if assigned(current_module^.localsymtable) then
  1448. psymtable(current_module^.localsymtable)^.registerdef(@self)
  1449. else if assigned(current_module^.globalsymtable) then
  1450. psymtable(current_module^.globalsymtable)^.registerdef(@self);
  1451. savesize:=target_os.size_of_pointer;
  1452. end;
  1453. constructor tformaldef.load;
  1454. begin
  1455. inherited load;
  1456. deftype:=formaldef;
  1457. savesize:=target_os.size_of_pointer;
  1458. end;
  1459. procedure tformaldef.write;
  1460. begin
  1461. inherited write;
  1462. current_ppu^.writeentry(ibformaldef);
  1463. end;
  1464. {$ifdef GDB}
  1465. function tformaldef.stabstring : pchar;
  1466. begin
  1467. stabstring := strpnew('formal'+numberstring+';');
  1468. end;
  1469. procedure tformaldef.concatstabto(asmlist : paasmoutput);
  1470. begin
  1471. { formaldef can't be stab'ed !}
  1472. end;
  1473. {$endif GDB}
  1474. function tformaldef.gettypename : string;
  1475. begin
  1476. gettypename:='Var';
  1477. end;
  1478. {***************************************************************************
  1479. TARRAYDEF
  1480. ***************************************************************************}
  1481. constructor tarraydef.init(l,h : longint;rd : pdef);
  1482. begin
  1483. inherited init;
  1484. deftype:=arraydef;
  1485. lowrange:=l;
  1486. highrange:=h;
  1487. rangedef:=rd;
  1488. definition:=nil;
  1489. IsVariant:=false;
  1490. IsConstructor:=false;
  1491. IsArrayOfConst:=false;
  1492. rangenr:=0;
  1493. end;
  1494. constructor tarraydef.load;
  1495. begin
  1496. inherited load;
  1497. deftype:=arraydef;
  1498. { the addresses are calculated later }
  1499. definition:=readdefref;
  1500. rangedef:=readdefref;
  1501. lowrange:=readlong;
  1502. highrange:=readlong;
  1503. IsArrayOfConst:=boolean(readbyte);
  1504. IsVariant:=false;
  1505. IsConstructor:=false;
  1506. rangenr:=0;
  1507. end;
  1508. function tarraydef.getrangecheckstring : string;
  1509. begin
  1510. if (cs_create_smart in aktmoduleswitches) then
  1511. getrangecheckstring:='R_'+current_module^.modulename^+tostr(rangenr)
  1512. else
  1513. getrangecheckstring:='R_'+tostr(rangenr);
  1514. end;
  1515. procedure tarraydef.genrangecheck;
  1516. begin
  1517. if rangenr=0 then
  1518. begin
  1519. { generates the data for range checking }
  1520. getlabelnr(rangenr);
  1521. if (cs_create_smart in aktmoduleswitches) then
  1522. datasegment^.concat(new(pai_symbol,initname_global(getrangecheckstring,8)))
  1523. else
  1524. datasegment^.concat(new(pai_symbol,initname(getrangecheckstring,8)));
  1525. datasegment^.concat(new(pai_const,init_32bit(lowrange)));
  1526. datasegment^.concat(new(pai_const,init_32bit(highrange)));
  1527. end;
  1528. end;
  1529. procedure tarraydef.deref;
  1530. begin
  1531. resolvedef(definition);
  1532. resolvedef(rangedef);
  1533. end;
  1534. procedure tarraydef.write;
  1535. begin
  1536. inherited write;
  1537. writedefref(definition);
  1538. writedefref(rangedef);
  1539. writelong(lowrange);
  1540. writelong(highrange);
  1541. writebyte(byte(IsArrayOfConst));
  1542. current_ppu^.writeentry(ibarraydef);
  1543. end;
  1544. {$ifdef GDB}
  1545. function tarraydef.stabstring : pchar;
  1546. begin
  1547. stabstring := strpnew('ar'+rangedef^.numberstring+';'
  1548. +tostr(lowrange)+';'+tostr(highrange)+';'+definition^.numberstring);
  1549. end;
  1550. procedure tarraydef.concatstabto(asmlist : paasmoutput);
  1551. begin
  1552. if (not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  1553. and not is_def_stab_written then
  1554. begin
  1555. {when array are inserted they have no definition yet !!}
  1556. if assigned(definition) then
  1557. inherited concatstabto(asmlist);
  1558. end;
  1559. end;
  1560. {$endif GDB}
  1561. function tarraydef.elesize : longint;
  1562. begin
  1563. elesize:=definition^.size;
  1564. end;
  1565. function tarraydef.size : longint;
  1566. begin
  1567. {Tarraydef.size may never be called for an open array!}
  1568. if highrange<lowrange then
  1569. internalerror(99080501);
  1570. If (elesize>0) and
  1571. (
  1572. (highrange-lowrange = $7fffffff) or
  1573. { () are needed around elesize-1 to avoid a possible
  1574. integer overflow for elesize=1 !! PM }
  1575. (($7fffffff div elesize + (elesize -1)) < (highrange - lowrange))
  1576. ) Then
  1577. Begin
  1578. Message(sym_e_segment_too_large);
  1579. size := 4
  1580. End
  1581. Else size:=(highrange-lowrange+1)*elesize;
  1582. end;
  1583. function tarraydef.alignment : longint;
  1584. begin
  1585. { alignment is the size of the elements }
  1586. alignment:=definition^.size;
  1587. end;
  1588. function tarraydef.needs_inittable : boolean;
  1589. begin
  1590. needs_inittable:=definition^.needs_inittable;
  1591. end;
  1592. procedure tarraydef.write_child_rtti_data;
  1593. begin
  1594. definition^.get_rtti_label;
  1595. end;
  1596. procedure tarraydef.write_rtti_data;
  1597. begin
  1598. rttilist^.concat(new(pai_const,init_8bit(13)));
  1599. write_rtti_name;
  1600. { size of elements }
  1601. rttilist^.concat(new(pai_const,init_32bit(definition^.size)));
  1602. { count of elements }
  1603. rttilist^.concat(new(pai_const,init_32bit(highrange-lowrange+1)));
  1604. { element type }
  1605. rttilist^.concat(new(pai_const_symbol,initname(definition^.get_rtti_label)));
  1606. end;
  1607. function tarraydef.gettypename : string;
  1608. begin
  1609. if isarrayofconst or isConstructor then
  1610. begin
  1611. if isvariant then
  1612. gettypename:='Array Of Const'
  1613. else
  1614. gettypename:='Array Of '+definition^.typename;
  1615. end
  1616. else if is_open_array(@self) then
  1617. gettypename:='Array Of '+definition^.typename
  1618. else
  1619. begin
  1620. if rangedef^.deftype=enumdef then
  1621. gettypename:='Array['+rangedef^.typename+'] Of '+definition^.typename
  1622. else
  1623. gettypename:='Array['+tostr(lowrange)+'..'+
  1624. tostr(highrange)+'] Of '+definition^.typename
  1625. end;
  1626. end;
  1627. {***************************************************************************
  1628. trecorddef
  1629. ***************************************************************************}
  1630. constructor trecorddef.init(p : psymtable);
  1631. begin
  1632. inherited init;
  1633. deftype:=recorddef;
  1634. symtable:=p;
  1635. symtable^.defowner := @self;
  1636. symtable^.dataalignment:=packrecordalignment[aktpackrecords];
  1637. end;
  1638. constructor trecorddef.load;
  1639. var
  1640. oldread_member : boolean;
  1641. begin
  1642. inherited load;
  1643. deftype:=recorddef;
  1644. savesize:=readlong;
  1645. oldread_member:=read_member;
  1646. read_member:=true;
  1647. symtable:=new(psymtable,loadas(recordsymtable));
  1648. read_member:=oldread_member;
  1649. symtable^.defowner := @self;
  1650. end;
  1651. destructor trecorddef.done;
  1652. begin
  1653. if assigned(symtable) then
  1654. dispose(symtable,done);
  1655. inherited done;
  1656. end;
  1657. var
  1658. binittable : boolean;
  1659. procedure check_rec_inittable(s : pnamedindexobject);
  1660. begin
  1661. if (not binittable) and
  1662. (psym(s)^.typ=varsym) then
  1663. begin
  1664. if ((pvarsym(s)^.definition^.deftype<>objectdef) or
  1665. not(pobjectdef(pvarsym(s)^.definition)^.is_class)) then
  1666. binittable:=pvarsym(s)^.definition^.needs_inittable;
  1667. end;
  1668. end;
  1669. function trecorddef.needs_inittable : boolean;
  1670. var
  1671. oldb : boolean;
  1672. begin
  1673. { there are recursive calls to needs_rtti possible, }
  1674. { so we have to change to old value how else should }
  1675. { we do that ? check_rec_rtti can't be a nested }
  1676. { procedure of needs_rtti ! }
  1677. oldb:=binittable;
  1678. binittable:=false;
  1679. symtable^.foreach({$ifndef TP}@{$endif}check_rec_inittable);
  1680. needs_inittable:=binittable;
  1681. binittable:=oldb;
  1682. end;
  1683. procedure trecorddef.deref;
  1684. var
  1685. oldrecsyms : psymtable;
  1686. begin
  1687. oldrecsyms:=aktrecordsymtable;
  1688. aktrecordsymtable:=symtable;
  1689. { now dereference the definitions }
  1690. symtable^.deref;
  1691. aktrecordsymtable:=oldrecsyms;
  1692. end;
  1693. procedure trecorddef.write;
  1694. var
  1695. oldread_member : boolean;
  1696. begin
  1697. oldread_member:=read_member;
  1698. read_member:=true;
  1699. inherited write;
  1700. writelong(savesize);
  1701. current_ppu^.writeentry(ibrecorddef);
  1702. self.symtable^.writeas;
  1703. read_member:=oldread_member;
  1704. end;
  1705. function trecorddef.size:longint;
  1706. begin
  1707. size:=symtable^.datasize;
  1708. end;
  1709. function trecorddef.alignment:longint;
  1710. begin
  1711. alignment:=symtable^.dataalignment;
  1712. end;
  1713. {$ifdef GDB}
  1714. Const StabRecString : pchar = Nil;
  1715. StabRecSize : longint = 0;
  1716. RecOffset : Longint = 0;
  1717. procedure addname(p : pnamedindexobject);
  1718. var
  1719. news, newrec : pchar;
  1720. spec : string[3];
  1721. size : longint;
  1722. begin
  1723. { static variables from objects are like global objects }
  1724. if (sp_static in psym(p)^.symoptions) then
  1725. exit;
  1726. If psym(p)^.typ = varsym then
  1727. begin
  1728. if (sp_protected in psym(p)^.symoptions) then
  1729. spec:='/1'
  1730. else if (sp_private in psym(p)^.symoptions) then
  1731. spec:='/0'
  1732. else
  1733. spec:='';
  1734. { class fields are pointers PM }
  1735. if (pvarsym(p)^.definition^.deftype=objectdef) and
  1736. pobjectdef(pvarsym(p)^.definition)^.is_class then
  1737. spec:=spec+'*';
  1738. size:=pvarsym(p)^.definition^.size;
  1739. { open arrays made overflows !! }
  1740. if size>$fffffff then
  1741. size:=$fffffff;
  1742. newrec := strpnew(p^.name+':'+spec+pvarsym(p)^.definition^.numberstring
  1743. +','+tostr(pvarsym(p)^.address*8)+','
  1744. +tostr(size*8)+';');
  1745. if strlen(StabRecString) + strlen(newrec) >= StabRecSize-256 then
  1746. begin
  1747. getmem(news,stabrecsize+memsizeinc);
  1748. strcopy(news,stabrecstring);
  1749. freemem(stabrecstring,stabrecsize);
  1750. stabrecsize:=stabrecsize+memsizeinc;
  1751. stabrecstring:=news;
  1752. end;
  1753. strcat(StabRecstring,newrec);
  1754. strdispose(newrec);
  1755. {This should be used for case !!}
  1756. RecOffset := RecOffset + pvarsym(p)^.definition^.size;
  1757. end;
  1758. end;
  1759. function trecorddef.stabstring : pchar;
  1760. Var oldrec : pchar;
  1761. oldsize : longint;
  1762. begin
  1763. oldrec := stabrecstring;
  1764. oldsize:=stabrecsize;
  1765. GetMem(stabrecstring,memsizeinc);
  1766. stabrecsize:=memsizeinc;
  1767. strpcopy(stabRecString,'s'+tostr(size));
  1768. RecOffset := 0;
  1769. symtable^.foreach({$ifndef TP}@{$endif}addname);
  1770. { FPC doesn't want to convert a char to a pchar}
  1771. { is this a bug ? }
  1772. strpcopy(strend(StabRecString),';');
  1773. stabstring := strnew(StabRecString);
  1774. Freemem(stabrecstring,stabrecsize);
  1775. stabrecstring := oldrec;
  1776. stabrecsize:=oldsize;
  1777. end;
  1778. procedure trecorddef.concatstabto(asmlist : paasmoutput);
  1779. begin
  1780. if (not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1781. (not is_def_stab_written) then
  1782. inherited concatstabto(asmlist);
  1783. end;
  1784. {$endif GDB}
  1785. var
  1786. count : longint;
  1787. procedure count_inittable_fields(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1788. begin
  1789. if ((psym(sym)^.typ=varsym) and
  1790. pvarsym(sym)^.definition^.needs_inittable)
  1791. and ((pvarsym(sym)^.definition^.deftype<>objectdef) or
  1792. (not pobjectdef(pvarsym(sym)^.definition)^.is_class)) then
  1793. inc(count);
  1794. end;
  1795. procedure count_fields(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1796. begin
  1797. inc(count);
  1798. end;
  1799. procedure write_field_inittable(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1800. begin
  1801. if ((psym(sym)^.typ=varsym) and
  1802. pvarsym(sym)^.definition^.needs_inittable)
  1803. and ((pvarsym(sym)^.definition^.deftype<>objectdef) or
  1804. (not pobjectdef(pvarsym(sym)^.definition)^.is_class)) then
  1805. begin
  1806. rttilist^.concat(new(pai_const_symbol,init(pvarsym(sym)^.definition^.get_inittable_label)));
  1807. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  1808. end;
  1809. end;
  1810. procedure write_field_rtti(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1811. begin
  1812. rttilist^.concat(new(pai_const_symbol,initname(pvarsym(sym)^.definition^.get_rtti_label)));
  1813. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  1814. end;
  1815. procedure generate_child_inittable(sym:pnamedindexobject);{$ifndef fpc}far;{$endif}
  1816. begin
  1817. if (psym(sym)^.typ=varsym) and
  1818. pvarsym(sym)^.definition^.needs_inittable then
  1819. { force inittable generation }
  1820. pvarsym(sym)^.definition^.get_inittable_label;
  1821. end;
  1822. procedure generate_child_rtti(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1823. begin
  1824. pvarsym(sym)^.definition^.get_rtti_label;
  1825. end;
  1826. procedure trecorddef.write_child_rtti_data;
  1827. begin
  1828. symtable^.foreach({$ifndef TP}@{$endif}generate_child_rtti);
  1829. end;
  1830. procedure trecorddef.write_child_init_data;
  1831. begin
  1832. symtable^.foreach({$ifndef TP}@{$endif}generate_child_inittable);
  1833. end;
  1834. procedure trecorddef.write_rtti_data;
  1835. begin
  1836. rttilist^.concat(new(pai_const,init_8bit(tkrecord)));
  1837. write_rtti_name;
  1838. rttilist^.concat(new(pai_const,init_32bit(size)));
  1839. count:=0;
  1840. symtable^.foreach({$ifndef TP}@{$endif}count_fields);
  1841. rttilist^.concat(new(pai_const,init_32bit(count)));
  1842. symtable^.foreach({$ifndef TP}@{$endif}write_field_rtti);
  1843. end;
  1844. procedure trecorddef.write_init_data;
  1845. begin
  1846. rttilist^.concat(new(pai_const,init_8bit(14)));
  1847. write_rtti_name;
  1848. rttilist^.concat(new(pai_const,init_32bit(size)));
  1849. count:=0;
  1850. symtable^.foreach({$ifndef TP}@{$endif}count_inittable_fields);
  1851. rttilist^.concat(new(pai_const,init_32bit(count)));
  1852. symtable^.foreach({$ifndef TP}@{$endif}write_field_inittable);
  1853. end;
  1854. function trecorddef.gettypename : string;
  1855. begin
  1856. gettypename:='<record type>'
  1857. end;
  1858. {***************************************************************************
  1859. TABSTRACTPROCDEF
  1860. ***************************************************************************}
  1861. constructor tabstractprocdef.init;
  1862. begin
  1863. inherited init;
  1864. new(para,init);
  1865. fpu_used:=0;
  1866. proctypeoption:=potype_none;
  1867. proccalloptions:=[];
  1868. procoptions:=[];
  1869. retdef:=voiddef;
  1870. symtablelevel:=0;
  1871. savesize:=target_os.size_of_pointer;
  1872. end;
  1873. destructor tabstractprocdef.done;
  1874. begin
  1875. dispose(para,done);
  1876. inherited done;
  1877. end;
  1878. procedure tabstractprocdef.concatdef(p : pdef;vsp : tvarspez);
  1879. var
  1880. hp : pparaitem;
  1881. begin
  1882. new(hp,init);
  1883. hp^.paratyp:=vsp;
  1884. hp^.datasym:=nil;
  1885. hp^.data:=p;
  1886. hp^.register:=R_NO;
  1887. para^.insert(hp);
  1888. end;
  1889. procedure tabstractprocdef.concattypesym(p : ptypesym;vsp : tvarspez);
  1890. var
  1891. hp : pparaitem;
  1892. begin
  1893. new(hp,init);
  1894. hp^.paratyp:=vsp;
  1895. hp^.datasym:=p;
  1896. hp^.data:=p^.definition;
  1897. hp^.register:=R_NO;
  1898. para^.insert(hp);
  1899. end;
  1900. { all functions returning in FPU are
  1901. assume to use 2 FPU registers
  1902. until the function implementation
  1903. is processed PM }
  1904. procedure tabstractprocdef.test_if_fpu_result;
  1905. begin
  1906. if assigned(retdef) and is_fpu(retdef) then
  1907. fpu_used:=2;
  1908. end;
  1909. procedure tabstractprocdef.deref;
  1910. var
  1911. hp : pparaitem;
  1912. begin
  1913. inherited deref;
  1914. resolvedef(retdef);
  1915. hp:=pparaitem(para^.first);
  1916. while assigned(hp) do
  1917. begin
  1918. if assigned(hp^.datasym) then
  1919. begin
  1920. resolvesym(psym(hp^.datasym));
  1921. hp^.data:=hp^.datasym^.definition;
  1922. end
  1923. else
  1924. resolvedef(hp^.data);
  1925. hp:=pparaitem(hp^.next);
  1926. end;
  1927. end;
  1928. constructor tabstractprocdef.load;
  1929. var
  1930. hp : pparaitem;
  1931. count,i : word;
  1932. begin
  1933. inherited load;
  1934. new(para,init);
  1935. retdef:=readdefref;
  1936. fpu_used:=readbyte;
  1937. proctypeoption:=tproctypeoption(readlong);
  1938. readsmallset(proccalloptions);
  1939. readsmallset(procoptions);
  1940. count:=readword;
  1941. savesize:=target_os.size_of_pointer;
  1942. for i:=1 to count do
  1943. begin
  1944. new(hp,init);
  1945. hp^.paratyp:=tvarspez(readbyte);
  1946. { hp^.register:=tregister(readbyte); }
  1947. hp^.register:=R_NO;
  1948. hp^.data:=readdefref;
  1949. hp^.datasym:=ptypesym(readsymref);
  1950. para^.concat(hp);
  1951. end;
  1952. end;
  1953. procedure tabstractprocdef.write;
  1954. var
  1955. hp : pparaitem;
  1956. begin
  1957. inherited write;
  1958. writedefref(retdef);
  1959. current_ppu^.do_interface_crc:=false;
  1960. writebyte(fpu_used);
  1961. writelong(ord(proctypeoption));
  1962. writesmallset(proccalloptions);
  1963. writesmallset(procoptions);
  1964. writeword(para^.count);
  1965. hp:=pparaitem(para^.first);
  1966. while assigned(hp) do
  1967. begin
  1968. writebyte(byte(hp^.paratyp));
  1969. { writebyte(byte(hp^.register)); }
  1970. if assigned(hp^.datasym) then
  1971. begin
  1972. writedefref(nil);
  1973. writesymref(psym(hp^.datasym));
  1974. end
  1975. else
  1976. begin
  1977. writedefref(hp^.data);
  1978. writesymref(nil);
  1979. end;
  1980. hp:=pparaitem(hp^.next);
  1981. end;
  1982. end;
  1983. function tabstractprocdef.para_size : longint;
  1984. var
  1985. pdc : pparaitem;
  1986. l : longint;
  1987. begin
  1988. l:=0;
  1989. pdc:=pparaitem(para^.first);
  1990. while assigned(pdc) do
  1991. begin
  1992. case pdc^.paratyp of
  1993. vs_var : inc(l,target_os.size_of_pointer);
  1994. vs_value,
  1995. vs_const : if push_addr_param(pdc^.data) then
  1996. inc(l,target_os.size_of_pointer)
  1997. else
  1998. inc(l,align(pdc^.data^.size,target_os.stackalignment));
  1999. end;
  2000. pdc:=pparaitem(pdc^.next);
  2001. end;
  2002. para_size:=l;
  2003. end;
  2004. function tabstractprocdef.demangled_paras : string;
  2005. var
  2006. s : string;
  2007. hp : pparaitem;
  2008. begin
  2009. s:='(';
  2010. hp:=pparaitem(para^.last);
  2011. while assigned(hp) do
  2012. begin
  2013. if assigned(hp^.data^.sym) then
  2014. s:=s+hp^.data^.sym^.name
  2015. else if hp^.paratyp=vs_var then
  2016. s:=s+'var'
  2017. else if hp^.paratyp=vs_const then
  2018. s:=s+'const';
  2019. hp:=pparaitem(hp^.previous);
  2020. if assigned(hp) then
  2021. s:=s+',';
  2022. end;
  2023. s:=s+')';
  2024. demangled_paras:=s;
  2025. end;
  2026. function tabstractprocdef.proccalloption2str : string;
  2027. type
  2028. tproccallopt=record
  2029. mask : tproccalloption;
  2030. str : string[30];
  2031. end;
  2032. const
  2033. proccallopts=12;
  2034. proccallopt : array[1..proccallopts] of tproccallopt=(
  2035. (mask:pocall_none; str:''),
  2036. (mask:pocall_clearstack; str:'ClearStack'),
  2037. (mask:pocall_leftright; str:'LeftRight'),
  2038. (mask:pocall_cdecl; str:'Cdecl'),
  2039. (mask:pocall_register; str:'Register'),
  2040. (mask:pocall_stdcall; str:'StdCall'),
  2041. (mask:pocall_safecall; str:'SafeCall'),
  2042. (mask:pocall_palmossyscall;str:'PalmOSSysCall'),
  2043. (mask:pocall_system; str:'System'),
  2044. (mask:pocall_inline; str:'Inline'),
  2045. (mask:pocall_internproc; str:'InternProc'),
  2046. (mask:pocall_internconst; str:'InternConst')
  2047. );
  2048. var
  2049. s : string;
  2050. i : longint;
  2051. first : boolean;
  2052. begin
  2053. s:='';
  2054. first:=true;
  2055. for i:=1to proccallopts do
  2056. if (proccallopt[i].mask in proccalloptions) then
  2057. begin
  2058. if first then
  2059. first:=false
  2060. else
  2061. s:=s+';';
  2062. s:=s+proccallopt[i].str;
  2063. end;
  2064. proccalloption2str:=s;
  2065. end;
  2066. {$ifdef GDB}
  2067. function tabstractprocdef.stabstring : pchar;
  2068. begin
  2069. stabstring := strpnew('abstractproc'+numberstring+';');
  2070. end;
  2071. procedure tabstractprocdef.concatstabto(asmlist : paasmoutput);
  2072. begin
  2073. if (not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  2074. and not is_def_stab_written then
  2075. begin
  2076. if assigned(retdef) then forcestabto(asmlist,retdef);
  2077. inherited concatstabto(asmlist);
  2078. end;
  2079. end;
  2080. {$endif GDB}
  2081. {***************************************************************************
  2082. TPROCDEF
  2083. ***************************************************************************}
  2084. constructor tprocdef.init;
  2085. begin
  2086. inherited init;
  2087. deftype:=procdef;
  2088. _mangledname:=nil;
  2089. nextoverloaded:=nil;
  2090. fileinfo:=aktfilepos;
  2091. extnumber:=-1;
  2092. localst:=new(psymtable,init(localsymtable));
  2093. parast:=new(psymtable,init(parasymtable));
  2094. localst^.defowner:=@self;
  2095. parast^.defowner:=@self;
  2096. { this is used by insert
  2097. to check same names in parast and localst }
  2098. localst^.next:=parast;
  2099. defref:=nil;
  2100. crossref:=nil;
  2101. lastwritten:=nil;
  2102. refcount:=0;
  2103. if (cs_browser in aktmoduleswitches) and make_ref then
  2104. begin
  2105. defref:=new(pref,init(defref,@tokenpos));
  2106. inc(refcount);
  2107. end;
  2108. lastref:=defref;
  2109. { first, we assume that all registers are used }
  2110. {$ifdef newcg}
  2111. usedregisters:=[firstreg..lastreg];
  2112. {$else newcg}
  2113. {$ifdef i386}
  2114. usedregisters:=$ff;
  2115. {$endif i386}
  2116. {$ifdef m68k}
  2117. usedregisters:=$FFFF;
  2118. {$endif}
  2119. {$endif newcg}
  2120. forwarddef:=true;
  2121. interfacedef:=false;
  2122. _class := nil;
  2123. code:=nil;
  2124. count:=false;
  2125. is_used:=false;
  2126. end;
  2127. constructor tprocdef.load;
  2128. var
  2129. s : string;
  2130. begin
  2131. inherited load;
  2132. deftype:=procdef;
  2133. {$ifdef newcg}
  2134. readnormalset(usedregisters);
  2135. {$else newcg}
  2136. {$ifdef i386}
  2137. usedregisters:=readbyte;
  2138. {$endif i386}
  2139. {$ifdef m68k}
  2140. usedregisters:=readword;
  2141. {$endif}
  2142. {$endif newcg}
  2143. s:=readstring;
  2144. setstring(_mangledname,s);
  2145. extnumber:=readlong;
  2146. nextoverloaded:=pprocdef(readdefref);
  2147. _class := pobjectdef(readdefref);
  2148. readposinfo(fileinfo);
  2149. if (cs_link_deffile in aktglobalswitches) and
  2150. (tf_need_export in target_info.flags) and
  2151. (po_exports in procoptions) then
  2152. deffile.AddExport(mangledname);
  2153. parast:=nil;
  2154. localst:=nil;
  2155. forwarddef:=false;
  2156. interfacedef:=false;
  2157. lastref:=nil;
  2158. lastwritten:=nil;
  2159. defref:=nil;
  2160. refcount:=0;
  2161. count:=true;
  2162. is_used:=false;
  2163. end;
  2164. Const local_symtable_index : longint = $8001;
  2165. procedure tprocdef.load_references;
  2166. var
  2167. pos : tfileposinfo;
  2168. {$ifndef NOLOCALBROWSER}
  2169. pdo : pobjectdef;
  2170. {$endif ndef NOLOCALBROWSER}
  2171. move_last : boolean;
  2172. begin
  2173. move_last:=lastwritten=lastref;
  2174. while (not current_ppu^.endofentry) do
  2175. begin
  2176. readposinfo(pos);
  2177. inc(refcount);
  2178. lastref:=new(pref,init(lastref,@pos));
  2179. lastref^.is_written:=true;
  2180. if refcount=1 then
  2181. defref:=lastref;
  2182. end;
  2183. if move_last then
  2184. lastwritten:=lastref;
  2185. if ((current_module^.flags and uf_local_browser)<>0)
  2186. and is_in_current then
  2187. begin
  2188. {$ifndef NOLOCALBROWSER}
  2189. pdo:=_class;
  2190. new(parast,loadas(parasymtable));
  2191. parast^.next:=owner;
  2192. parast^.load_browser;
  2193. new(localst,loadas(localsymtable));
  2194. localst^.next:=parast;
  2195. localst^.load_browser;
  2196. {$endif ndef NOLOCALBROWSER}
  2197. end;
  2198. end;
  2199. function tprocdef.write_references : boolean;
  2200. var
  2201. ref : pref;
  2202. {$ifndef NOLOCALBROWSER}
  2203. pdo : pobjectdef;
  2204. {$endif ndef NOLOCALBROWSER}
  2205. move_last : boolean;
  2206. begin
  2207. move_last:=lastwritten=lastref;
  2208. if move_last and (((current_module^.flags and uf_local_browser)=0)
  2209. or not is_in_current) then
  2210. exit;
  2211. { write address of this symbol }
  2212. writedefref(@self);
  2213. { write refs }
  2214. if assigned(lastwritten) then
  2215. ref:=lastwritten
  2216. else
  2217. ref:=defref;
  2218. while assigned(ref) do
  2219. begin
  2220. if ref^.moduleindex=current_module^.unit_index then
  2221. begin
  2222. writeposinfo(ref^.posinfo);
  2223. ref^.is_written:=true;
  2224. if move_last then
  2225. lastwritten:=ref;
  2226. end
  2227. else if not ref^.is_written then
  2228. move_last:=false
  2229. else if move_last then
  2230. lastwritten:=ref;
  2231. ref:=ref^.nextref;
  2232. end;
  2233. current_ppu^.writeentry(ibdefref);
  2234. write_references:=true;
  2235. if ((current_module^.flags and uf_local_browser)<>0)
  2236. and is_in_current then
  2237. begin
  2238. {$ifndef NOLOCALBROWSER}
  2239. pdo:=_class;
  2240. if (owner^.symtabletype<>localsymtable) then
  2241. while assigned(pdo) do
  2242. begin
  2243. if pdo^.symtable<>aktrecordsymtable then
  2244. begin
  2245. pdo^.symtable^.unitid:=local_symtable_index;
  2246. inc(local_symtable_index);
  2247. end;
  2248. pdo:=pdo^.childof;
  2249. end;
  2250. { we need TESTLOCALBROWSER para and local symtables
  2251. PPU files are then easier to read PM }
  2252. if not assigned(parast) then
  2253. parast:=new(psymtable,init(parasymtable));
  2254. parast^.writeas;
  2255. parast^.unitid:=local_symtable_index;
  2256. inc(local_symtable_index);
  2257. parast^.write_browser;
  2258. if not assigned(localst) then
  2259. localst:=new(psymtable,init(localsymtable));
  2260. localst^.writeas;
  2261. localst^.unitid:=local_symtable_index;
  2262. inc(local_symtable_index);
  2263. localst^.write_browser;
  2264. { decrement for }
  2265. local_symtable_index:=local_symtable_index-2;
  2266. pdo:=_class;
  2267. if (owner^.symtabletype<>localsymtable) then
  2268. while assigned(pdo) do
  2269. begin
  2270. if pdo^.symtable<>aktrecordsymtable then
  2271. dec(local_symtable_index);
  2272. pdo:=pdo^.childof;
  2273. end;
  2274. {$endif ndef NOLOCALBROWSER}
  2275. end;
  2276. end;
  2277. {$ifdef BrowserLog}
  2278. procedure tprocdef.add_to_browserlog;
  2279. begin
  2280. if assigned(defref) then
  2281. begin
  2282. browserlog.AddLog('***'+mangledname);
  2283. browserlog.AddLogRefs(defref);
  2284. if (current_module^.flags and uf_local_browser)<>0 then
  2285. begin
  2286. if assigned(parast) then
  2287. parast^.writebrowserlog;
  2288. if assigned(localst) then
  2289. localst^.writebrowserlog;
  2290. end;
  2291. end;
  2292. end;
  2293. {$endif BrowserLog}
  2294. destructor tprocdef.done;
  2295. begin
  2296. if assigned(defref) then
  2297. dispose(defref,done);
  2298. if assigned(parast) then
  2299. dispose(parast,done);
  2300. if assigned(localst) and (localst^.symtabletype<>staticsymtable) then
  2301. dispose(localst,done);
  2302. if (pocall_inline in proccalloptions) and assigned(code) then
  2303. disposetree(ptree(code));
  2304. if (po_msgstr in procoptions) then
  2305. strdispose(messageinf.str);
  2306. if
  2307. {$ifdef tp}
  2308. not(use_big) and
  2309. {$endif}
  2310. assigned(_mangledname) then
  2311. globals.strdispose(_mangledname);
  2312. inherited done;
  2313. end;
  2314. procedure tprocdef.write;
  2315. begin
  2316. inherited write;
  2317. current_ppu^.do_interface_crc:=false;
  2318. { set all registers to used for simplified compilation PM }
  2319. if simplify_ppu then
  2320. begin
  2321. {$ifdef newcg}
  2322. usedregisters:=[firstreg..lastreg];
  2323. {$else newcg}
  2324. {$ifdef i386}
  2325. usedregisters:=$ff;
  2326. {$endif i386}
  2327. {$ifdef m68k}
  2328. usedregisters:=$ffff;
  2329. {$endif}
  2330. {$endif newcg}
  2331. end;
  2332. {$ifdef newcg}
  2333. writenormalset(usedregisters);
  2334. {$else newcg}
  2335. {$ifdef i386}
  2336. writebyte(usedregisters);
  2337. {$endif i386}
  2338. {$ifdef m68k}
  2339. writeword(usedregisters);
  2340. {$endif}
  2341. {$endif newcg}
  2342. current_ppu^.do_interface_crc:=true;
  2343. writestring(mangledname);
  2344. writelong(extnumber);
  2345. if (proctypeoption<>potype_operator) then
  2346. writedefref(nextoverloaded)
  2347. else
  2348. begin
  2349. { only write the overloads from the same unit }
  2350. if assigned(nextoverloaded) and
  2351. (nextoverloaded^.owner=owner) then
  2352. writedefref(nextoverloaded)
  2353. else
  2354. writedefref(nil);
  2355. end;
  2356. writedefref(_class);
  2357. writeposinfo(fileinfo);
  2358. if (pocall_inline in proccalloptions) then
  2359. begin
  2360. { we need to save
  2361. - the para and the local symtable
  2362. - the code ptree !! PM
  2363. writesymtable(parast);
  2364. writesymtable(localst);
  2365. writeptree(ptree(code));
  2366. }
  2367. end;
  2368. current_ppu^.writeentry(ibprocdef);
  2369. end;
  2370. function tprocdef.haspara:boolean;
  2371. begin
  2372. haspara:=assigned(aktprocsym^.definition^.parast^.symindex^.first);
  2373. end;
  2374. {$ifdef GDB}
  2375. procedure addparaname(p : psym);
  2376. var vs : char;
  2377. begin
  2378. if pvarsym(p)^.varspez = vs_value then vs := '1'
  2379. else vs := '0';
  2380. strpcopy(strend(StabRecString),p^.name+':'+pvarsym(p)^.definition^.numberstring+','+vs+';');
  2381. end;
  2382. function tprocdef.stabstring : pchar;
  2383. var
  2384. i : longint;
  2385. oldrec : pchar;
  2386. begin
  2387. oldrec := stabrecstring;
  2388. getmem(StabRecString,1024);
  2389. strpcopy(StabRecString,'f'+retdef^.numberstring);
  2390. i:=para^.count;
  2391. if i>0 then
  2392. begin
  2393. strpcopy(strend(StabRecString),','+tostr(i)+';');
  2394. (* confuse gdb !! PM
  2395. if assigned(parast) then
  2396. parast^.foreach({$ifndef TP}@{$endif}addparaname)
  2397. else
  2398. begin
  2399. param := para1;
  2400. i := 0;
  2401. while assigned(param) do
  2402. begin
  2403. inc(i);
  2404. if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
  2405. {Here we have lost the parameter names !!}
  2406. {using lower case parameters }
  2407. strpcopy(strend(stabrecstring),'p'+tostr(i)
  2408. +':'+param^.data^.numberstring+','+vartyp+';');
  2409. param := param^.next;
  2410. end;
  2411. end; *)
  2412. {strpcopy(strend(StabRecString),';');}
  2413. end;
  2414. stabstring := strnew(stabrecstring);
  2415. freemem(stabrecstring,1024);
  2416. stabrecstring := oldrec;
  2417. end;
  2418. procedure tprocdef.concatstabto(asmlist : paasmoutput);
  2419. begin
  2420. end;
  2421. {$endif GDB}
  2422. procedure tprocdef.deref;
  2423. begin
  2424. inherited deref;
  2425. resolvedef(pdef(nextoverloaded));
  2426. resolvedef(pdef(_class));
  2427. end;
  2428. function tprocdef.mangledname : string;
  2429. {$ifdef tp}
  2430. var
  2431. oldpos : longint;
  2432. s : string;
  2433. b : byte;
  2434. {$endif tp}
  2435. begin
  2436. {$ifndef Delphi}
  2437. {$ifdef tp}
  2438. if use_big then
  2439. begin
  2440. symbolstream.seek(longint(_mangledname));
  2441. symbolstream.read(b,1);
  2442. symbolstream.read(s[1],b);
  2443. s[0]:=chr(b);
  2444. mangledname:=s;
  2445. end
  2446. else
  2447. {$endif}
  2448. {$endif Delphi}
  2449. mangledname:=strpas(_mangledname);
  2450. if count then
  2451. is_used:=true;
  2452. end;
  2453. function tprocdef.procname: string;
  2454. var
  2455. s : string;
  2456. l : longint;
  2457. begin
  2458. s:=mangledname;
  2459. { delete leading $$'s }
  2460. l:=pos('$$',s);
  2461. while l<>0 do
  2462. begin
  2463. delete(s,1,l+1);
  2464. l:=pos('$$',s);
  2465. end;
  2466. { delete leading _$'s }
  2467. l:=pos('_$',s);
  2468. while l<>0 do
  2469. begin
  2470. delete(s,1,l+1);
  2471. l:=pos('_$',s);
  2472. end;
  2473. l:=pos('$',s);
  2474. if l=0 then
  2475. procname:=s
  2476. else
  2477. procname:=Copy(s,1,l-1);
  2478. end;
  2479. {$IfDef GDB}
  2480. function tprocdef.cplusplusmangledname : string;
  2481. var
  2482. s,s2 : string;
  2483. param : pparaitem;
  2484. begin
  2485. s := sym^.name;
  2486. if _class <> nil then
  2487. begin
  2488. s2 := _class^.objname^;
  2489. s := s+'__'+tostr(length(s2))+s2;
  2490. end else s := s + '_';
  2491. param := pparaitem(para^.first);
  2492. while assigned(param) do
  2493. begin
  2494. s2 := param^.data^.sym^.name;
  2495. s := s+tostr(length(s2))+s2;
  2496. param := pparaitem(param^.next);
  2497. end;
  2498. cplusplusmangledname:=s;
  2499. end;
  2500. {$EndIf GDB}
  2501. procedure tprocdef.setmangledname(const s : string);
  2502. begin
  2503. if {$ifdef tp}not(use_big) and{$endif} (assigned(_mangledname)) then
  2504. strdispose(_mangledname);
  2505. setstring(_mangledname,s);
  2506. if assigned(parast) then
  2507. begin
  2508. stringdispose(parast^.name);
  2509. parast^.name:=stringdup('args of '+s);
  2510. end;
  2511. if assigned(localst) then
  2512. begin
  2513. stringdispose(localst^.name);
  2514. localst^.name:=stringdup('locals of '+s);
  2515. end;
  2516. end;
  2517. {***************************************************************************
  2518. TPROCVARDEF
  2519. ***************************************************************************}
  2520. constructor tprocvardef.init;
  2521. begin
  2522. inherited init;
  2523. deftype:=procvardef;
  2524. end;
  2525. constructor tprocvardef.load;
  2526. begin
  2527. inherited load;
  2528. deftype:=procvardef;
  2529. end;
  2530. procedure tprocvardef.write;
  2531. begin
  2532. { here we cannot get a real good value so just give something }
  2533. { plausible (PM) }
  2534. { a more secure way would be
  2535. to allways store in a temp }
  2536. if is_fpu(retdef) then
  2537. fpu_used:=2
  2538. else
  2539. fpu_used:=0;
  2540. inherited write;
  2541. current_ppu^.writeentry(ibprocvardef);
  2542. end;
  2543. function tprocvardef.size : longint;
  2544. begin
  2545. if (po_methodpointer in procoptions) then
  2546. size:=2*target_os.size_of_pointer
  2547. else
  2548. size:=target_os.size_of_pointer;
  2549. end;
  2550. {$ifdef GDB}
  2551. function tprocvardef.stabstring : pchar;
  2552. var
  2553. nss : pchar;
  2554. i : longint;
  2555. begin
  2556. i := para^.count;
  2557. getmem(nss,1024);
  2558. { it is not a function but a function pointer !! (PM) }
  2559. strpcopy(nss,'*f'+retdef^.numberstring{+','+tostr(i)}+';');
  2560. { this confuses gdb !!
  2561. we should use 'F' instead of 'f' but
  2562. as we use c++ language mode
  2563. it does not like that either
  2564. Please do not remove this part
  2565. might be used once
  2566. gdb for pascal is ready PM }
  2567. (*
  2568. param := para1;
  2569. i := 0;
  2570. while assigned(param) do
  2571. begin
  2572. inc(i);
  2573. if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
  2574. {Here we have lost the parameter names !!}
  2575. pst := strpnew('p'+tostr(i)+':'+param^.data^.numberstring+','+vartyp+';');
  2576. strcat(nss,pst);
  2577. strdispose(pst);
  2578. param := param^.next;
  2579. end; *)
  2580. {strpcopy(strend(nss),';');}
  2581. stabstring := strnew(nss);
  2582. freemem(nss,1024);
  2583. end;
  2584. procedure tprocvardef.concatstabto(asmlist : paasmoutput);
  2585. begin
  2586. if ( not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  2587. and not is_def_stab_written then
  2588. inherited concatstabto(asmlist);
  2589. is_def_stab_written:=true;
  2590. end;
  2591. {$endif GDB}
  2592. procedure tprocvardef.write_rtti_data;
  2593. var
  2594. pdc : pparaitem;
  2595. methodkind, paraspec : byte;
  2596. begin
  2597. if po_methodpointer in procoptions then
  2598. begin
  2599. { write method id and name }
  2600. rttilist^.concat(new(pai_const,init_8bit(tkmethod)));
  2601. write_rtti_name;
  2602. { write kind of method (can only be function or procedure)}
  2603. if retdef = pdef(voiddef) then { ### typecast shoudln't be necessary! (sg) }
  2604. methodkind := mkProcedure
  2605. else
  2606. methodkind := mkFunction;
  2607. rttilist^.concat(new(pai_const,init_8bit(methodkind)));
  2608. { get # of parameters }
  2609. rttilist^.concat(new(pai_const,init_8bit(para^.count)));
  2610. { write parameter info. The parameters must be written in reverse order
  2611. if this method uses right to left parameter pushing! }
  2612. if (pocall_leftright in proccalloptions) then
  2613. pdc:=pparaitem(para^.last)
  2614. else
  2615. pdc:=pparaitem(para^.first);
  2616. while assigned(pdc) do
  2617. begin
  2618. case pdc^.paratyp of
  2619. vs_value: paraspec := 0;
  2620. vs_const: paraspec := pfConst;
  2621. vs_var : paraspec := pfVar;
  2622. end;
  2623. { write flags for current parameter }
  2624. rttilist^.concat(new(pai_const,init_8bit(paraspec)));
  2625. { write name of current parameter ### how can I get this??? (sg)}
  2626. rttilist^.concat(new(pai_const,init_8bit(0)));
  2627. { write name of type of current parameter }
  2628. pdc^.data^.write_rtti_name;
  2629. if (pocall_leftright in proccalloptions) then
  2630. pdc:=pparaitem(pdc^.previous)
  2631. else
  2632. pdc:=pparaitem(pdc^.next);
  2633. end;
  2634. { write name of result type }
  2635. retdef^.write_rtti_name;
  2636. end;
  2637. end;
  2638. procedure tprocvardef.write_child_rtti_data;
  2639. begin
  2640. {!!!!!!!!}
  2641. end;
  2642. function tprocvardef.is_publishable : boolean;
  2643. begin
  2644. is_publishable:=(po_methodpointer in procoptions);
  2645. end;
  2646. function tprocvardef.gettypename : string;
  2647. begin
  2648. if assigned(retdef) and
  2649. (retdef<>pdef(voiddef)) then
  2650. gettypename:='<procedure variable type of function'+demangled_paras+
  2651. ':'+retdef^.gettypename+';'+proccalloption2str+'>'
  2652. else
  2653. gettypename:='<procedure variable type of procedure'+demangled_paras+
  2654. ';'+proccalloption2str+'>';
  2655. end;
  2656. {***************************************************************************
  2657. TOBJECTDEF
  2658. ***************************************************************************}
  2659. {$ifdef GDB}
  2660. const
  2661. vtabletype : word = 0;
  2662. vtableassigned : boolean = false;
  2663. {$endif GDB}
  2664. constructor tobjectdef.init(const n : string;c : pobjectdef);
  2665. begin
  2666. tdef.init;
  2667. deftype:=objectdef;
  2668. objectoptions:=[];
  2669. childof:=nil;
  2670. symtable:=new(psymtable,init(objectsymtable));
  2671. symtable^.name := stringdup(n);
  2672. { create space for vmt !! }
  2673. vmt_offset:=0;
  2674. symtable^.datasize:=0;
  2675. symtable^.defowner:=@self;
  2676. symtable^.dataalignment:=packrecordalignment[aktpackrecords];
  2677. set_parent(c);
  2678. objname:=stringdup(n);
  2679. end;
  2680. constructor tobjectdef.load;
  2681. var
  2682. oldread_member : boolean;
  2683. begin
  2684. tdef.load;
  2685. deftype:=objectdef;
  2686. savesize:=readlong;
  2687. vmt_offset:=readlong;
  2688. objname:=stringdup(readstring);
  2689. childof:=pobjectdef(readdefref);
  2690. readsmallset(objectoptions);
  2691. oldread_member:=read_member;
  2692. read_member:=true;
  2693. symtable:=new(psymtable,loadas(objectsymtable));
  2694. read_member:=oldread_member;
  2695. symtable^.defowner:=@self;
  2696. symtable^.name := stringdup(objname^);
  2697. { handles the predefined class tobject }
  2698. { the last TOBJECT which is loaded gets }
  2699. { it ! }
  2700. if (childof=nil) and
  2701. is_class and
  2702. (objname^='TOBJECT') then
  2703. class_tobject:=@self;
  2704. has_rtti:=true;
  2705. end;
  2706. destructor tobjectdef.done;
  2707. begin
  2708. if assigned(symtable) then
  2709. dispose(symtable,done);
  2710. if (oo_is_forward in objectoptions) then
  2711. Message1(sym_e_class_forward_not_resolved,objname^);
  2712. stringdispose(objname);
  2713. tdef.done;
  2714. end;
  2715. procedure tobjectdef.write;
  2716. var
  2717. oldread_member : boolean;
  2718. begin
  2719. tdef.write;
  2720. writelong(size);
  2721. writelong(vmt_offset);
  2722. writestring(objname^);
  2723. writedefref(childof);
  2724. writesmallset(objectoptions);
  2725. current_ppu^.writeentry(ibobjectdef);
  2726. oldread_member:=read_member;
  2727. read_member:=true;
  2728. symtable^.writeas;
  2729. read_member:=oldread_member;
  2730. end;
  2731. procedure tobjectdef.deref;
  2732. var
  2733. oldrecsyms : psymtable;
  2734. begin
  2735. resolvedef(pdef(childof));
  2736. oldrecsyms:=aktrecordsymtable;
  2737. aktrecordsymtable:=symtable;
  2738. symtable^.deref;
  2739. aktrecordsymtable:=oldrecsyms;
  2740. end;
  2741. procedure tobjectdef.set_parent( c : pobjectdef);
  2742. begin
  2743. { nothing to do if the parent was not forward !}
  2744. if assigned(childof) then
  2745. exit;
  2746. childof:=c;
  2747. { some options are inherited !! }
  2748. if assigned(c) then
  2749. begin
  2750. objectoptions:=objectoptions+(c^.objectoptions*
  2751. [oo_has_virtual,oo_has_private,oo_has_protected,oo_has_constructor,oo_has_destructor]);
  2752. { add the data of the anchestor class }
  2753. inc(symtable^.datasize,c^.symtable^.datasize);
  2754. if (oo_has_vmt in objectoptions) and
  2755. (oo_has_vmt in c^.objectoptions) then
  2756. dec(symtable^.datasize,target_os.size_of_pointer);
  2757. { if parent has a vmt field then
  2758. the offset is the same for the child PM }
  2759. if (oo_has_vmt in c^.objectoptions) or is_class then
  2760. begin
  2761. vmt_offset:=c^.vmt_offset;
  2762. {$ifdef INCLUDEOK}
  2763. include(objectoptions,oo_has_vmt);
  2764. {$else}
  2765. objectoptions:=objectoptions+[oo_has_vmt];
  2766. {$endif}
  2767. end;
  2768. end;
  2769. savesize := symtable^.datasize;
  2770. end;
  2771. procedure tobjectdef.insertvmt;
  2772. begin
  2773. if (oo_has_vmt in objectoptions) then
  2774. internalerror(12345)
  2775. else
  2776. begin
  2777. { first round up to multiple of 4 }
  2778. if (symtable^.dataalignment=2) then
  2779. begin
  2780. if (symtable^.datasize and 1)<>0 then
  2781. inc(symtable^.datasize);
  2782. end
  2783. else
  2784. if (symtable^.dataalignment>=4) then
  2785. begin
  2786. if (symtable^.datasize mod 4) <> 0 then
  2787. inc(symtable^.datasize,4-(symtable^.datasize mod 4));
  2788. end;
  2789. vmt_offset:=symtable^.datasize;
  2790. inc(symtable^.datasize,target_os.size_of_pointer);
  2791. {$ifdef INCLUDEOK}
  2792. include(objectoptions,oo_has_vmt);
  2793. {$else}
  2794. objectoptions:=objectoptions+[oo_has_vmt];
  2795. {$endif}
  2796. end;
  2797. end;
  2798. procedure tobjectdef.check_forwards;
  2799. begin
  2800. symtable^.check_forwards;
  2801. if (oo_is_forward in objectoptions) then
  2802. begin
  2803. { ok, in future, the forward can be resolved }
  2804. Message1(sym_e_class_forward_not_resolved,objname^);
  2805. {$ifdef INCLUDEOK}
  2806. exclude(objectoptions,oo_is_forward);
  2807. {$else}
  2808. objectoptions:=objectoptions-[oo_is_forward];
  2809. {$endif}
  2810. end;
  2811. end;
  2812. { true, if self inherits from d (or if they are equal) }
  2813. function tobjectdef.is_related(d : pobjectdef) : boolean;
  2814. var
  2815. hp : pobjectdef;
  2816. begin
  2817. hp:=@self;
  2818. while assigned(hp) do
  2819. begin
  2820. if hp=d then
  2821. begin
  2822. is_related:=true;
  2823. exit;
  2824. end;
  2825. hp:=hp^.childof;
  2826. end;
  2827. is_related:=false;
  2828. end;
  2829. function tobjectdef.size : longint;
  2830. begin
  2831. if (oo_is_class in objectoptions) then
  2832. size:=target_os.size_of_pointer
  2833. else
  2834. size:=symtable^.datasize;
  2835. end;
  2836. function tobjectdef.alignment:longint;
  2837. begin
  2838. alignment:=symtable^.dataalignment;
  2839. end;
  2840. function tobjectdef.vmtmethodoffset(index:longint):longint;
  2841. begin
  2842. { for offset of methods for classes, see rtl/inc/objpash.inc }
  2843. if is_class then
  2844. vmtmethodoffset:=(index+12)*target_os.size_of_pointer
  2845. else
  2846. vmtmethodoffset:=(index+3)*target_os.size_of_pointer;
  2847. end;
  2848. function tobjectdef.vmt_mangledname : string;
  2849. {DM: I get a nil pointer on the owner name. I don't know if this
  2850. mayhappen, and I have therefore fixed the problem by doing nil pointer
  2851. checks.}
  2852. var
  2853. s1,s2:string;
  2854. begin
  2855. if not(oo_has_vmt in objectoptions) then
  2856. Message1(parser_object_has_no_vmt,objname^);
  2857. if owner^.name=nil then
  2858. s1:=''
  2859. else
  2860. s1:=owner^.name^;
  2861. if objname=nil then
  2862. s2:=''
  2863. else
  2864. s2:=objname^;
  2865. vmt_mangledname:='VMT_'+s1+'$_'+s2;
  2866. end;
  2867. function tobjectdef.rtti_name : string;
  2868. var
  2869. s1,s2:string;
  2870. begin
  2871. if owner^.name=nil then
  2872. s1:=''
  2873. else
  2874. s1:=owner^.name^;
  2875. if objname=nil then
  2876. s2:=''
  2877. else
  2878. s2:=objname^;
  2879. rtti_name:='RTTI_'+s1+'$_'+s2;
  2880. end;
  2881. function tobjectdef.is_class : boolean;
  2882. begin
  2883. is_class:=(oo_is_class in objectoptions);
  2884. end;
  2885. {$ifdef GDB}
  2886. procedure addprocname(p :pnamedindexobject);
  2887. var virtualind,argnames : string;
  2888. news, newrec : pchar;
  2889. pd,ipd : pprocdef;
  2890. lindex : longint;
  2891. para : pparaitem;
  2892. arglength : byte;
  2893. sp : char;
  2894. begin
  2895. If psym(p)^.typ = procsym then
  2896. begin
  2897. pd := pprocsym(p)^.definition;
  2898. { this will be used for full implementation of object stabs
  2899. not yet done }
  2900. ipd := pd;
  2901. while assigned(ipd^.nextoverloaded) do ipd := ipd^.nextoverloaded;
  2902. if (po_virtualmethod in pd^.procoptions) then
  2903. begin
  2904. lindex := pd^.extnumber;
  2905. {doesnt seem to be necessary
  2906. lindex := lindex or $80000000;}
  2907. virtualind := '*'+tostr(lindex)+';'+ipd^._class^.numberstring+';'
  2908. end else virtualind := '.';
  2909. { used by gdbpas to recognize constructor and destructors }
  2910. if (pd^.proctypeoption=potype_constructor) then
  2911. argnames:='__ct__'
  2912. else if (pd^.proctypeoption=potype_destructor) then
  2913. argnames:='__dt__'
  2914. else
  2915. argnames := '';
  2916. { arguments are not listed here }
  2917. {we don't need another definition}
  2918. para := pparaitem(pd^.para^.first);
  2919. while assigned(para) do
  2920. begin
  2921. if para^.data^.deftype = formaldef then
  2922. begin
  2923. if para^.paratyp=vs_var then
  2924. argnames := argnames+'3var'
  2925. else if para^.paratyp=vs_const then
  2926. argnames:=argnames+'5const';
  2927. end
  2928. else
  2929. begin
  2930. { if the arg definition is like (v: ^byte;..
  2931. there is no sym attached to data !!! }
  2932. if assigned(para^.data^.sym) then
  2933. begin
  2934. arglength := length(para^.data^.sym^.name);
  2935. argnames := argnames + tostr(arglength)+para^.data^.sym^.name;
  2936. end
  2937. else
  2938. begin
  2939. argnames:=argnames+'11unnamedtype';
  2940. end;
  2941. end;
  2942. para := pparaitem(para^.next);
  2943. end;
  2944. ipd^.is_def_stab_written := true;
  2945. { here 2A must be changed for private and protected }
  2946. { 0 is private 1 protected and 2 public }
  2947. if (sp_private in psym(p)^.symoptions) then sp:='0'
  2948. else if (sp_protected in psym(p)^.symoptions) then sp:='1'
  2949. else sp:='2';
  2950. newrec := strpnew(p^.name+'::'+ipd^.numberstring
  2951. +'=##'+pd^.retdef^.numberstring+';:'+argnames+';'+sp+'A'
  2952. +virtualind+';');
  2953. { get spare place for a string at the end }
  2954. if strlen(StabRecString) + strlen(newrec) >= StabRecSize-256 then
  2955. begin
  2956. getmem(news,stabrecsize+memsizeinc);
  2957. strcopy(news,stabrecstring);
  2958. freemem(stabrecstring,stabrecsize);
  2959. stabrecsize:=stabrecsize+memsizeinc;
  2960. stabrecstring:=news;
  2961. end;
  2962. strcat(StabRecstring,newrec);
  2963. {freemem(newrec,memsizeinc); }
  2964. strdispose(newrec);
  2965. {This should be used for case !!}
  2966. RecOffset := RecOffset + pd^.size;
  2967. end;
  2968. end;
  2969. function tobjectdef.stabstring : pchar;
  2970. var anc : pobjectdef;
  2971. oldrec : pchar;
  2972. oldrecsize : longint;
  2973. str_end : string;
  2974. begin
  2975. oldrec := stabrecstring;
  2976. oldrecsize:=stabrecsize;
  2977. stabrecsize:=memsizeinc;
  2978. GetMem(stabrecstring,stabrecsize);
  2979. strpcopy(stabRecString,'s'+tostr(symtable^.datasize));
  2980. if assigned(childof) then
  2981. {only one ancestor not virtual, public, at base offset 0 }
  2982. { !1 , 0 2 0 , }
  2983. strpcopy(strend(stabrecstring),'!1,020,'+childof^.numberstring+';');
  2984. {virtual table to implement yet}
  2985. RecOffset := 0;
  2986. symtable^.foreach({$ifndef TP}@{$endif}addname);
  2987. if (oo_has_vmt in objectoptions) then
  2988. if not assigned(childof) or not(oo_has_vmt in childof^.objectoptions) then
  2989. begin
  2990. strpcopy(strend(stabrecstring),'$vf'+numberstring+':'+typeglobalnumber('vtblarray')
  2991. +','+tostr(vmt_offset*8)+';');
  2992. end;
  2993. symtable^.foreach({$ifndef TP}@{$endif}addprocname);
  2994. if (oo_has_vmt in objectoptions) then
  2995. begin
  2996. anc := @self;
  2997. while assigned(anc^.childof) and (oo_has_vmt in anc^.childof^.objectoptions) do
  2998. anc := anc^.childof;
  2999. str_end:=';~%'+anc^.numberstring+';';
  3000. end
  3001. else
  3002. str_end:=';';
  3003. strpcopy(strend(stabrecstring),str_end);
  3004. stabstring := strnew(StabRecString);
  3005. freemem(stabrecstring,stabrecsize);
  3006. stabrecstring := oldrec;
  3007. stabrecsize:=oldrecsize;
  3008. end;
  3009. {$endif GDB}
  3010. procedure tobjectdef.write_child_init_data;
  3011. begin
  3012. symtable^.foreach({$ifndef TP}@{$endif}generate_child_inittable);
  3013. end;
  3014. procedure tobjectdef.write_init_data;
  3015. begin
  3016. if is_class then
  3017. rttilist^.concat(new(pai_const,init_8bit(tkclass)))
  3018. else
  3019. rttilist^.concat(new(pai_const,init_8bit(tkobject)));
  3020. { generate the name }
  3021. rttilist^.concat(new(pai_const,init_8bit(length(objname^))));
  3022. rttilist^.concat(new(pai_string,init(objname^)));
  3023. rttilist^.concat(new(pai_const,init_32bit(size)));
  3024. count:=0;
  3025. symtable^.foreach({$ifndef TP}@{$endif}count_inittable_fields);
  3026. rttilist^.concat(new(pai_const,init_32bit(count)));
  3027. symtable^.foreach({$ifndef TP}@{$endif}write_field_inittable);
  3028. end;
  3029. function tobjectdef.needs_inittable : boolean;
  3030. var
  3031. oldb : boolean;
  3032. begin
  3033. { there are recursive calls to needs_inittable possible, }
  3034. { so we have to change to old value how else should }
  3035. { we do that ? check_rec_rtti can't be a nested }
  3036. { procedure of needs_rtti ! }
  3037. oldb:=binittable;
  3038. binittable:=false;
  3039. symtable^.foreach({$ifndef TP}@{$endif}check_rec_inittable);
  3040. needs_inittable:=binittable;
  3041. binittable:=oldb;
  3042. end;
  3043. procedure count_published_properties(sym:pnamedindexobject);
  3044. {$ifndef fpc}far;{$endif}
  3045. begin
  3046. if needs_prop_entry(psym(sym)) then
  3047. inc(count);
  3048. end;
  3049. procedure write_property_info(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  3050. var
  3051. proctypesinfo : byte;
  3052. procedure writeproc(sym : ppropsymlist;def : pdef;shiftvalue : byte);
  3053. var
  3054. typvalue : byte;
  3055. hp : ppropsymlist;
  3056. address : longint;
  3057. begin
  3058. if not(assigned(sym) and assigned(sym^.sym)) then
  3059. begin
  3060. rttilist^.concat(new(pai_const,init_32bit(1)));
  3061. typvalue:=3;
  3062. end
  3063. else if sym^.sym^.typ=varsym then
  3064. begin
  3065. address:=0;
  3066. hp:=sym;
  3067. while assigned(hp) do
  3068. begin
  3069. inc(address,pvarsym(hp^.sym)^.address);
  3070. hp:=hp^.next;
  3071. end;
  3072. rttilist^.concat(new(pai_const,init_32bit(address)));
  3073. typvalue:=0;
  3074. end
  3075. else
  3076. begin
  3077. if not(po_virtualmethod in pprocdef(def)^.procoptions) then
  3078. begin
  3079. rttilist^.concat(new(pai_const_symbol,initname(pprocdef(def)^.mangledname)));
  3080. typvalue:=1;
  3081. end
  3082. else
  3083. begin
  3084. { virtual method, write vmt offset }
  3085. rttilist^.concat(new(pai_const,init_32bit(
  3086. pprocdef(def)^._class^.vmtmethodoffset(pprocdef(def)^.extnumber))));
  3087. typvalue:=2;
  3088. end;
  3089. end;
  3090. proctypesinfo:=proctypesinfo or (typvalue shl shiftvalue);
  3091. end;
  3092. begin
  3093. if needs_prop_entry(psym(sym)) then
  3094. case psym(sym)^.typ of
  3095. varsym:
  3096. begin
  3097. if not(pvarsym(sym)^.definition^.deftype=objectdef) or
  3098. not(pobjectdef(pvarsym(sym)^.definition)^.is_class) then
  3099. internalerror(1509992);
  3100. { access to implicit class property as field }
  3101. proctypesinfo:=(0 shl 0) or (0 shl 2) or (0 shl 4);
  3102. rttilist^.concat(new(pai_const_symbol,initname(pvarsym(sym)^.definition^.get_rtti_label)));
  3103. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  3104. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  3105. { per default stored }
  3106. rttilist^.concat(new(pai_const,init_32bit(1)));
  3107. { index as well as ... }
  3108. rttilist^.concat(new(pai_const,init_32bit(0)));
  3109. { default value are zero }
  3110. rttilist^.concat(new(pai_const,init_32bit(0)));
  3111. rttilist^.concat(new(pai_const,init_16bit(count)));
  3112. inc(count);
  3113. rttilist^.concat(new(pai_const,init_8bit(proctypesinfo)));
  3114. rttilist^.concat(new(pai_const,init_8bit(length(pvarsym(sym)^.name))));
  3115. rttilist^.concat(new(pai_string,init(pvarsym(sym)^.name)));
  3116. end;
  3117. propertysym:
  3118. begin
  3119. if ppo_indexed in ppropertysym(sym)^.propoptions then
  3120. proctypesinfo:=$40
  3121. else
  3122. proctypesinfo:=0;
  3123. rttilist^.concat(new(pai_const_symbol,initname(ppropertysym(sym)^.proptype^.get_rtti_label)));
  3124. writeproc(ppropertysym(sym)^.readaccesssym,ppropertysym(sym)^.readaccessdef,0);
  3125. writeproc(ppropertysym(sym)^.writeaccesssym,ppropertysym(sym)^.writeaccessdef,2);
  3126. { isn't it stored ? }
  3127. if not(ppo_stored in ppropertysym(sym)^.propoptions) then
  3128. begin
  3129. rttilist^.concat(new(pai_const,init_32bit(0)));
  3130. proctypesinfo:=proctypesinfo or (3 shl 4);
  3131. end
  3132. else
  3133. writeproc(ppropertysym(sym)^.storedsym,ppropertysym(sym)^.storeddef,4);
  3134. rttilist^.concat(new(pai_const,init_32bit(ppropertysym(sym)^.index)));
  3135. rttilist^.concat(new(pai_const,init_32bit(ppropertysym(sym)^.default)));
  3136. rttilist^.concat(new(pai_const,init_16bit(count)));
  3137. inc(count);
  3138. rttilist^.concat(new(pai_const,init_8bit(proctypesinfo)));
  3139. rttilist^.concat(new(pai_const,init_8bit(length(ppropertysym(sym)^.name))));
  3140. rttilist^.concat(new(pai_string,init(ppropertysym(sym)^.name)));
  3141. end;
  3142. else internalerror(1509992);
  3143. end;
  3144. end;
  3145. procedure generate_published_child_rtti(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  3146. begin
  3147. if needs_prop_entry(psym(sym)) then
  3148. case psym(sym)^.typ of
  3149. varsym:
  3150. pvarsym(sym)^.definition^.get_rtti_label;
  3151. propertysym:
  3152. ppropertysym(sym)^.proptype^.get_rtti_label;
  3153. else internalerror(1509991);
  3154. end;
  3155. end;
  3156. procedure tobjectdef.write_child_rtti_data;
  3157. begin
  3158. symtable^.foreach({$ifndef TP}@{$endif}generate_published_child_rtti);
  3159. end;
  3160. procedure tobjectdef.generate_rtti;
  3161. begin
  3162. has_rtti:=true;
  3163. getdatalabel(rtti_label);
  3164. write_child_rtti_data;
  3165. rttilist^.concat(new(pai_symbol,initname_global(rtti_name,0)));
  3166. rttilist^.concat(new(pai_label,init(rtti_label)));
  3167. write_rtti_data;
  3168. rttilist^.concat(new(pai_symbol_end,initname(rtti_name)));
  3169. end;
  3170. function tobjectdef.next_free_name_index : longint;
  3171. var
  3172. i : longint;
  3173. begin
  3174. if assigned(childof) and (oo_can_have_published in childof^.objectoptions) then
  3175. i:=childof^.next_free_name_index
  3176. else
  3177. i:=0;
  3178. count:=0;
  3179. symtable^.foreach({$ifndef TP}@{$endif}count_published_properties);
  3180. next_free_name_index:=i+count;
  3181. end;
  3182. procedure tobjectdef.write_rtti_data;
  3183. begin
  3184. if is_class then
  3185. rttilist^.concat(new(pai_const,init_8bit(tkclass)))
  3186. else
  3187. rttilist^.concat(new(pai_const,init_8bit(tkobject)));
  3188. { generate the name }
  3189. rttilist^.concat(new(pai_const,init_8bit(length(objname^))));
  3190. rttilist^.concat(new(pai_string,init(objname^)));
  3191. { write class type }
  3192. rttilist^.concat(new(pai_const_symbol,initname(vmt_mangledname)));
  3193. { write owner typeinfo }
  3194. if assigned(childof) and (oo_can_have_published in childof^.objectoptions) then
  3195. rttilist^.concat(new(pai_const_symbol,initname(childof^.get_rtti_label)))
  3196. else
  3197. rttilist^.concat(new(pai_const,init_32bit(0)));
  3198. { count total number of properties }
  3199. if assigned(childof) and (oo_can_have_published in childof^.objectoptions) then
  3200. count:=childof^.next_free_name_index
  3201. else
  3202. count:=0;
  3203. { write it }
  3204. symtable^.foreach({$ifndef TP}@{$endif}count_published_properties);
  3205. rttilist^.concat(new(pai_const,init_16bit(count)));
  3206. { write unit name }
  3207. if assigned(owner^.name) then
  3208. begin
  3209. rttilist^.concat(new(pai_const,init_8bit(length(owner^.name^))));
  3210. rttilist^.concat(new(pai_string,init(owner^.name^)));
  3211. end
  3212. else
  3213. rttilist^.concat(new(pai_const,init_8bit(0)));
  3214. { write published properties count }
  3215. count:=0;
  3216. symtable^.foreach({$ifndef TP}@{$endif}count_published_properties);
  3217. rttilist^.concat(new(pai_const,init_16bit(count)));
  3218. { count is used to write nameindex }
  3219. { but we need an offset of the owner }
  3220. { to give each property an own slot }
  3221. if assigned(childof) and (oo_can_have_published in childof^.objectoptions) then
  3222. count:=childof^.next_free_name_index
  3223. else
  3224. count:=0;
  3225. symtable^.foreach({$ifndef TP}@{$endif}write_property_info);
  3226. end;
  3227. function tobjectdef.is_publishable : boolean;
  3228. begin
  3229. is_publishable:=is_class;
  3230. end;
  3231. function tobjectdef.get_rtti_label : string;
  3232. begin
  3233. get_rtti_label:=rtti_name;
  3234. end;
  3235. {****************************************************************************
  3236. TFORWARDDEF
  3237. ****************************************************************************}
  3238. constructor tforwarddef.init(const s:string);
  3239. var
  3240. oldregisterdef : boolean;
  3241. begin
  3242. { never register the forwarddefs, they are disposed at the
  3243. end of the type declaration block }
  3244. oldregisterdef:=registerdef;
  3245. registerdef:=false;
  3246. inherited init;
  3247. registerdef:=oldregisterdef;
  3248. deftype:=forwarddef;
  3249. tosymname:=s;
  3250. end;
  3251. function tforwarddef.gettypename:string;
  3252. begin
  3253. gettypename:='unresolved forward to '+tosymname;
  3254. end;
  3255. {****************************************************************************
  3256. TERRORDEF
  3257. ****************************************************************************}
  3258. constructor terrordef.init;
  3259. begin
  3260. inherited init;
  3261. deftype:=errordef;
  3262. end;
  3263. {$ifdef GDB}
  3264. function terrordef.stabstring : pchar;
  3265. begin
  3266. stabstring:=strpnew('error'+numberstring);
  3267. end;
  3268. {$endif GDB}
  3269. function terrordef.gettypename:string;
  3270. begin
  3271. gettypename:='<erroneous type>';
  3272. end;
  3273. {
  3274. $Log$
  3275. Revision 1.172 1999-10-26 12:30:45 peter
  3276. * const parameter is now checked
  3277. * better and generic check if a node can be used for assigning
  3278. * export fixes
  3279. * procvar equal works now (it never had worked at least from 0.99.8)
  3280. * defcoll changed to linkedlist with pparaitem so it can easily be
  3281. walked both directions
  3282. Revision 1.171 1999/10/06 17:39:15 peter
  3283. * fixed stabs writting for forward types
  3284. Revision 1.170 1999/10/04 13:46:04 michael
  3285. * patch from peter for classes
  3286. Revision 1.169 1999/10/03 19:41:38 peter
  3287. * inittable for record fixed (it was only checking for classes)
  3288. Revision 1.168 1999/10/01 10:05:44 peter
  3289. + procedure directive support in const declarations, fixes bug 232
  3290. Revision 1.167 1999/10/01 08:02:48 peter
  3291. * forward type declaration rewritten
  3292. Revision 1.166 1999/09/26 21:30:21 peter
  3293. + constant pointer support which can happend with typecasting like
  3294. const p=pointer(1)
  3295. * better procvar parsing in typed consts
  3296. Revision 1.165 1999/09/20 16:39:02 peter
  3297. * cs_create_smart instead of cs_smartlink
  3298. * -CX is create smartlink
  3299. * -CD is create dynamic, but does nothing atm.
  3300. Revision 1.164 1999/09/15 22:09:26 florian
  3301. + rtti is now automatically generated for published classes, i.e.
  3302. they are handled like an implicit property
  3303. Revision 1.163 1999/09/15 20:35:44 florian
  3304. * small fix to operator overloading when in MMX mode
  3305. + the compiler uses now fldz and fld1 if possible
  3306. + some fixes to floating point registers
  3307. + some math. functions (arctan, ln, sin, cos, sqrt, sqr, pi) are now inlined
  3308. * .... ???
  3309. Revision 1.162 1999/09/12 08:48:09 florian
  3310. * bugs 593 and 607 fixed
  3311. * some other potential bugs with array constructors fixed
  3312. * for classes compiled in $M+ and it's childs, the default access method
  3313. is now published
  3314. * fixed copyright message (it is now 1993-99)
  3315. Revision 1.161 1999/09/10 18:48:09 florian
  3316. * some bug fixes (e.g. must_be_valid and procinfo.funcret_is_valid)
  3317. * most things for stored properties fixed
  3318. Revision 1.160 1999/09/02 17:07:40 florian
  3319. * problems with -Or fixed: tdef.isfpuregable was wrong!
  3320. Revision 1.159 1999/08/27 10:52:19 pierre
  3321. + simplify_ppu code added :
  3322. sets all registers used at PPU writing
  3323. * tprocdef mangledname writing is CRC relevant
  3324. Revision 1.158 1999/08/27 10:24:34 michael
  3325. + Inittables should not contain fields which are classes
  3326. Revision 1.157 1999/08/26 21:13:58 peter
  3327. * array elementsize of 0 doesn't crash anymore
  3328. Revision 1.156 1999/08/17 13:58:56 michael
  3329. RTTI writing patch
  3330. Revision 1.155 1999/08/16 16:26:04 pierre
  3331. * error in stabs for tclassrefdef corrected
  3332. Revision 1.154 1999/08/14 00:38:58 peter
  3333. * hack to support property with record fields
  3334. Revision 1.153 1999/08/13 21:33:11 peter
  3335. * support for array constructors extended and more error checking
  3336. Revision 1.152 1999/08/13 14:24:18 pierre
  3337. + stabs for classes and classref working,
  3338. a class still needs an ^ to get that content of it,
  3339. but the class fields inside a class don't result into an
  3340. infinite loop anymore!
  3341. Revision 1.151 1999/08/12 14:31:20 peter
  3342. * long line fix
  3343. Revision 1.150 1999/08/11 08:56:53 michael
  3344. * RTTI fix from Sebastian Guenther
  3345. Revision 1.149 1999/08/10 13:22:08 pierre
  3346. * vmtmethodoffset made cross target compatible
  3347. Revision 1.148 1999/08/10 12:32:13 pierre
  3348. * avoid overflow in tarraydef.size
  3349. Revision 1.147 1999/08/09 22:19:55 peter
  3350. * classes vmt changed to only positive addresses
  3351. * sharedlib creation is working
  3352. Revision 1.146 1999/08/07 14:21:00 florian
  3353. * some small problems fixed
  3354. Revision 1.145 1999/08/07 13:36:54 daniel
  3355. * Recommitted the arraydef overflow bugfix.
  3356. Revision 1.143 1999/08/06 11:13:30 peter
  3357. * fixed message which was wrong styled
  3358. Revision 1.142 1999/08/05 22:41:34 daniel
  3359. *** empty log message ***
  3360. Revision 1.141 1999/08/05 16:53:13 peter
  3361. * V_Fatal=1, all other V_ are also increased
  3362. * Check for local procedure when assigning procvar
  3363. * fixed comment parsing because directives
  3364. * oldtp mode directives better supported
  3365. * added some messages to errore.msg
  3366. Revision 1.140 1999/08/04 13:03:07 jonas
  3367. * all tokens now start with an underscore
  3368. * PowerPC compiles!!
  3369. Revision 1.139 1999/08/03 22:03:14 peter
  3370. * moved bitmask constants to sets
  3371. * some other type/const renamings
  3372. Revision 1.138 1999/08/02 21:29:02 florian
  3373. * the main branch psub.pas is now used for
  3374. newcg compiler
  3375. Revision 1.137 1999/07/31 22:37:17 michael
  3376. * Fix of initialization information generation
  3377. Revision 1.136 1999/07/29 20:54:07 peter
  3378. * write .size also
  3379. Revision 1.135 1999/07/27 23:42:18 peter
  3380. * indirect type referencing is now allowed
  3381. Revision 1.134 1999/07/23 23:07:03 peter
  3382. * fixed stabs for record which still used savesize
  3383. Revision 1.133 1999/07/23 16:05:28 peter
  3384. * alignment is now saved in the symtable
  3385. * C alignment added for records
  3386. * PPU version increased to solve .12 <-> .13 probs
  3387. Revision 1.132 1999/07/18 14:47:32 florian
  3388. * bug 487 fixed, (inc(<property>) isn't allowed)
  3389. * more fixes to compile with Delphi
  3390. Revision 1.131 1999/07/06 21:48:27 florian
  3391. * a lot bug fixes:
  3392. - po_external isn't any longer necessary for procedure compatibility
  3393. - m_tp_procvar is in -Sd now available
  3394. - error messages of procedure variables improved
  3395. - return values with init./finalization fixed
  3396. - data types with init./finalization aren't any longer allowed in variant
  3397. record
  3398. Revision 1.130 1999/06/22 16:24:44 pierre
  3399. * local browser stuff corrected
  3400. Revision 1.129 1999/06/02 22:44:21 pierre
  3401. * previous wrong log corrected
  3402. Revision 1.128 1999/06/02 22:25:52 pierre
  3403. * changed $ifdef FPC @ into $ifndef TP
  3404. Revision 1.127 1999/06/02 10:26:50 florian
  3405. * corrected order of parameter type for -vb
  3406. Revision 1.126 1999/06/02 10:11:50 florian
  3407. * make cycle fixed i.e. compilation with 0.99.10
  3408. * some fixes for qword
  3409. * start of register calling conventions
  3410. Revision 1.125 1999/06/01 14:45:56 peter
  3411. * @procvar is now always needed for FPC
  3412. Revision 1.124 1999/05/31 16:42:33 peter
  3413. * interfacedef flag for procdef if it's defined in the interface, to
  3414. make a difference with 'forward;' directive forwarddef. Fixes 253
  3415. Revision 1.123 1999/05/27 19:45:02 peter
  3416. * removed oldasm
  3417. * plabel -> pasmlabel
  3418. * -a switches to source writing automaticly
  3419. * assembler readers OOPed
  3420. * asmsymbol automaticly external
  3421. * jumptables and other label fixes for asm readers
  3422. Revision 1.122 1999/05/23 18:42:14 florian
  3423. * better error recovering in typed constants
  3424. * some problems with arrays of const fixed, some problems
  3425. due my previous
  3426. - the location type of array constructor is now LOC_MEM
  3427. - the pushing of high fixed
  3428. - parameter copying fixed
  3429. - zero temp. allocation removed
  3430. * small problem in the assembler writers fixed:
  3431. ref to nil wasn't written correctly
  3432. Revision 1.121 1999/05/21 13:55:19 peter
  3433. * NEWLAB for label as symbol
  3434. Revision 1.120 1999/05/20 22:22:43 pierre
  3435. + added synonym filed for ttypesym
  3436. allows a clean disposal of tdefs and related ttypesyms
  3437. Revision 1.119 1999/05/19 16:48:26 florian
  3438. * tdef.typename: returns a now a proper type name for the most types
  3439. Revision 1.118 1999/05/19 12:08:11 florian
  3440. * tobject wasn't set as default anchestor, was a problem with the new ppu
  3441. handling
  3442. Revision 1.117 1999/05/17 21:57:15 florian
  3443. * new temporary ansistring handling
  3444. Revision 1.116 1999/05/16 02:26:51 peter
  3445. * fixed loading of classrefdef
  3446. Revision 1.115 1999/05/14 17:52:26 peter
  3447. * new deref code
  3448. Revision 1.114 1999/05/13 21:59:41 peter
  3449. * removed oldppu code
  3450. * warning if objpas is loaded from uses
  3451. * first things for new deref writing
  3452. Revision 1.113 1999/05/12 00:19:58 peter
  3453. * removed R_DEFAULT_SEG
  3454. * uniform float names
  3455. Revision 1.112 1999/05/08 19:52:35 peter
  3456. + MessagePos() which is enhanced Message() function but also gets the
  3457. position info
  3458. * Removed comp warnings
  3459. Revision 1.111 1999/05/07 11:06:37 florian
  3460. * enumeration type names are now written in lowercase (rtti)
  3461. Revision 1.110 1999/05/06 09:05:28 peter
  3462. * generic write_float and str_float
  3463. * fixed constant float conversions
  3464. Revision 1.109 1999/05/05 10:05:56 florian
  3465. * a delphi compiled compiler recompiles ppc
  3466. Revision 1.108 1999/04/28 22:30:52 pierre
  3467. * delete -> deleteindex in tdef.correct_owner_symtable
  3468. Revision 1.107 1999/04/28 06:02:11 florian
  3469. * changes of Bruessel:
  3470. + message handler can now take an explicit self
  3471. * typinfo fixed: sometimes the type names weren't written
  3472. * the type checking for pointer comparisations and subtraction
  3473. and are now more strict (was also buggy)
  3474. * small bug fix to link.pas to support compiling on another
  3475. drive
  3476. * probable bug in popt386 fixed: call/jmp => push/jmp
  3477. transformation didn't count correctly the jmp references
  3478. + threadvar support
  3479. * warning if ln/sqrt gets an invalid constant argument
  3480. Revision 1.106 1999/04/26 18:30:01 peter
  3481. * farpointerdef moved into pointerdef.is_far
  3482. Revision 1.105 1999/04/26 13:31:47 peter
  3483. * release storenumber,double_checksum
  3484. Revision 1.104 1999/04/21 09:43:50 peter
  3485. * storenumber works
  3486. * fixed some typos in double_checksum
  3487. + incompatible types type1 and type2 message (with storenumber)
  3488. Revision 1.103 1999/04/19 09:28:20 peter
  3489. * fixed crash when writing overload operator to ppu
  3490. Revision 1.102 1999/04/17 22:01:28 pierre
  3491. * typo error fix in STORENUMBER code
  3492. Revision 1.101 1999/04/14 09:14:58 peter
  3493. * first things to store the symbol/def number in the ppu
  3494. Revision 1.100 1999/04/08 15:57:51 peter
  3495. + subrange checking for readln()
  3496. Revision 1.99 1999/04/07 15:39:32 pierre
  3497. + double_checksum code added
  3498. Revision 1.98 1999/03/06 17:24:16 peter
  3499. * reset savesize in tdef.init
  3500. Revision 1.97 1999/03/01 13:45:04 pierre
  3501. + added staticppusymtable symtable type for local browsing
  3502. Revision 1.96 1999/02/25 21:02:52 peter
  3503. * ag386bin updates
  3504. + coff writer
  3505. Revision 1.95 1999/02/23 18:29:23 pierre
  3506. * win32 compilation error fix
  3507. + some work for local browser (not cl=omplete yet)
  3508. Revision 1.94 1999/02/22 20:13:38 florian
  3509. + first implementation of message keyword
  3510. Revision 1.93 1999/02/22 13:07:07 pierre
  3511. + -b and -bl options work !
  3512. + cs_local_browser ($L+) is disabled if cs_browser ($Y+)
  3513. is not enabled when quitting global section
  3514. * local vars and procedures are not yet stored into PPU
  3515. Revision 1.92 1999/02/17 10:14:20 peter
  3516. * set the first enumsym also for subrange types
  3517. Revision 1.91 1999/02/08 09:51:21 pierre
  3518. * gdb info for local functions was wrong
  3519. Revision 1.90 1999/01/26 09:57:29 pierre
  3520. * open arrays stabs changed
  3521. Revision 1.89 1999/01/22 17:29:30 pierre
  3522. * overflow in addname for open arrays removed
  3523. Revision 1.88 1999/01/20 14:18:39 pierre
  3524. * bugs related to mangledname solved
  3525. - linux external without name
  3526. -external procs already used
  3527. (added count and is_used boolean fiels in tprocvar)
  3528. Revision 1.87 1999/01/19 10:56:05 pierre
  3529. typeof(object) without vmt generates an error instead of an internalerror
  3530. Revision 1.86 1999/01/12 14:25:32 peter
  3531. + BrowserLog for browser.log generation
  3532. + BrowserCol for browser info in TCollections
  3533. * released all other UseBrowser
  3534. Revision 1.85 1998/12/30 22:15:52 peter
  3535. + farpointer type
  3536. * absolutesym now also stores if its far
  3537. Revision 1.84 1998/12/30 13:41:12 peter
  3538. * released valuepara
  3539. Revision 1.83 1998/12/21 14:03:08 pierre
  3540. * procvar stabs correction
  3541. Revision 1.82 1998/12/19 00:23:52 florian
  3542. * ansistring memory leaks fixed
  3543. Revision 1.81 1998/12/11 08:57:22 pierre
  3544. * internal gdb types for booleans and 64bit integers
  3545. Revision 1.80 1998/12/10 09:47:26 florian
  3546. + basic operations with int64/qord (compiler with -dint64)
  3547. + rtti of enumerations extended: names are now written
  3548. Revision 1.79 1998/12/08 10:18:12 peter
  3549. + -gh for heaptrc unit
  3550. Revision 1.78 1998/12/08 09:06:30 pierre
  3551. + constructor destructor info for gdbpas
  3552. Revision 1.77 1998/12/01 23:37:39 pierre
  3553. * function type problem for gdb fix
  3554. Revision 1.76 1998/11/29 21:45:48 florian
  3555. * problem with arrays with init tables fixed
  3556. Revision 1.75 1998/11/29 12:45:59 peter
  3557. * hack for arraydef.size overflow
  3558. Revision 1.74 1998/11/27 14:50:47 peter
  3559. + open strings, $P switch support
  3560. Revision 1.73 1998/11/26 14:47:00 michael
  3561. + Fixed RTTI constants
  3562. Revision 1.72 1998/11/25 14:35:28 florian
  3563. * writting of rtti for properties fixed
  3564. Revision 1.71 1998/11/20 15:35:59 florian
  3565. * problems with rtti fixed, hope it works
  3566. Revision 1.70 1998/11/18 15:44:16 peter
  3567. * VALUEPARA for tp7 compatible value parameters
  3568. Revision 1.69 1998/11/10 17:54:56 peter
  3569. * removed warning
  3570. Revision 1.68 1998/11/05 23:34:36 peter
  3571. * don't dispose staticsymtable (caused crash under tp7 after a fatal
  3572. error)
  3573. Revision 1.67 1998/11/05 12:02:56 peter
  3574. * released useansistring
  3575. * removed -Sv, its now available in fpc modes
  3576. Revision 1.66 1998/10/26 22:58:22 florian
  3577. * new introduded problem with classes fix, the parent class wasn't set
  3578. correct, if the class was defined forward before
  3579. Revision 1.65 1998/10/26 14:19:28 pierre
  3580. + added options -lS and -lT for source and target os output
  3581. (to have a easier way to test OS_SOURCE abd OS_TARGET in makefiles)
  3582. * several problems with rtti data
  3583. (type of sym was not checked)
  3584. assumed to be varsym when they could be procsym or property syms !!
  3585. Revision 1.64 1998/10/22 17:11:21 pierre
  3586. + terminated the include exclude implementation for i386
  3587. * enums inside records fixed
  3588. Revision 1.63 1998/10/20 09:32:56 peter
  3589. * removed some unused vars
  3590. Revision 1.62 1998/10/20 08:06:58 pierre
  3591. * several memory corruptions due to double freemem solved
  3592. => never use p^.loc.location:=p^.left^.loc.location;
  3593. + finally I added now by default
  3594. that ra386dir translates global and unit symbols
  3595. + added a first field in tsymtable and
  3596. a nextsym field in tsym
  3597. (this allows to obtain ordered type info for
  3598. records and objects in gdb !)
  3599. Revision 1.61 1998/10/19 08:55:05 pierre
  3600. * wrong stabs info corrected once again !!
  3601. + variable vmt offset with vmt field only if required
  3602. implemented now !!!
  3603. Revision 1.60 1998/10/16 13:12:53 pierre
  3604. * added vmt_offsets in destructors code also !!!
  3605. * vmt_offset code for m68k
  3606. Revision 1.59 1998/10/16 08:51:51 peter
  3607. + target_os.stackalignment
  3608. + stack can be aligned at 2 or 4 byte boundaries
  3609. Revision 1.58 1998/10/15 15:13:30 pierre
  3610. + added oo_hasconstructor and oo_hasdestructor
  3611. for objects options
  3612. Revision 1.57 1998/10/14 15:54:20 pierre
  3613. * smallsets are not entirely implemented for
  3614. m68k added a ifdef usesmallset
  3615. that is allways defined for i386
  3616. (enables testing for m68k)
  3617. Revision 1.56 1998/10/09 11:47:56 pierre
  3618. * still more memory leaks fixes !!
  3619. Revision 1.55 1998/10/06 17:16:55 pierre
  3620. * some memory leaks fixed (thanks to Peter for heaptrc !)
  3621. Revision 1.54 1998/10/05 21:33:28 peter
  3622. * fixed 161,165,166,167,168
  3623. Revision 1.53 1998/10/05 12:48:39 pierre
  3624. * wrong handling of range check for arrays fixed
  3625. Revision 1.52 1998/10/02 07:20:38 florian
  3626. * range checking in units doesn't work if the units are smartlinked, fixed
  3627. Revision 1.51 1998/09/25 12:01:41 florian
  3628. * tobjectdef.symtable.datasize was set to savesize, this is wrong now
  3629. because the symtable size is read from the ppu file
  3630. Revision 1.50 1998/09/23 15:46:40 florian
  3631. * problem with with and classes fixed
  3632. Revision 1.49 1998/09/23 12:03:55 peter
  3633. * overloading fix for array of const
  3634. Revision 1.48 1998/09/22 15:37:23 peter
  3635. + array of const start
  3636. Revision 1.47 1998/09/21 15:46:01 michael
  3637. Applied florians fix for check_rec_inittable
  3638. Revision 1.46 1998/09/21 08:45:21 pierre
  3639. + added vmt_offset in tobjectdef.write for fututre use
  3640. (first steps to have objects without vmt if no virtual !!)
  3641. + added fpu_used field for tabstractprocdef :
  3642. sets this level to 2 if the functions return with value in FPU
  3643. (is then set to correct value at parsing of implementation)
  3644. THIS MIGHT refuse some code with FPU expression too complex
  3645. that were accepted before and even in some cases
  3646. that don't overflow in fact
  3647. ( like if f : float; is a forward that finally in implementation
  3648. only uses one fpu register !!)
  3649. Nevertheless I think that it will improve security on
  3650. FPU operations !!
  3651. * most other changes only for UseBrowser code
  3652. (added symtable references for record and objects)
  3653. local switch for refs to args and local of each function
  3654. (static symtable still missing)
  3655. UseBrowser still not stable and probably broken by
  3656. the definition hash array !!
  3657. Revision 1.45 1998/09/20 08:31:29 florian
  3658. + bit 6 of tpropinfo.propprocs is set, if the property contains a
  3659. constant index
  3660. Revision 1.44 1998/09/19 15:23:58 florian
  3661. * rtti for ordtypes corrected
  3662. Revision 1.43 1998/09/18 17:12:40 florian
  3663. * problem with writing of class references fixed
  3664. Revision 1.42 1998/09/17 13:41:20 pierre
  3665. sizeof(TPOINT) problem
  3666. Revision 1.40.2.2 1998/09/17 08:42:33 pierre
  3667. TPOINT sizeof fix
  3668. Revision 1.41 1998/09/15 17:39:30 jonas
  3669. + bugfix from bugfix branch
  3670. Revision 1.40.2.1 1998/09/15 17:35:32 jonas
  3671. * chenged string_typ in tstringdef.wideload from ansistring to widestring
  3672. Revision 1.40 1998/09/09 15:34:00 peter
  3673. * removed warnings
  3674. Revision 1.39 1998/09/08 10:23:44 pierre
  3675. * name field of filedef corrected
  3676. Revision 1.38 1998/09/07 23:10:23 florian
  3677. * a lot of stuff fixed regarding rtti and publishing of properties,
  3678. basics should now work
  3679. Revision 1.37 1998/09/07 19:33:24 florian
  3680. + some stuff for property rtti added:
  3681. - NameIndex of the TPropInfo record is now written correctly
  3682. - the DEFAULT/NODEFAULT keyword is supported now
  3683. - the default value and the storedsym/def are now written to
  3684. the PPU fiel
  3685. Revision 1.36 1998/09/07 17:37:01 florian
  3686. * first fixes for published properties
  3687. Revision 1.35 1998/09/06 22:42:02 florian
  3688. + rtti genreation for properties added
  3689. Revision 1.34 1998/09/04 18:15:02 peter
  3690. * filedef updated
  3691. Revision 1.33 1998/09/03 17:08:49 pierre
  3692. * better lines for stabs
  3693. (no scroll back to if before else part
  3694. no return to case line at jump outside case)
  3695. + source lines also if not in order
  3696. Revision 1.32 1998/09/03 16:03:20 florian
  3697. + rtti generation
  3698. * init table generation changed
  3699. Revision 1.31 1998/09/02 15:14:28 peter
  3700. * enum packing changed from len to max
  3701. Revision 1.30 1998/09/01 17:37:29 peter
  3702. * removed debug writeln :(
  3703. Revision 1.29 1998/09/01 12:53:25 peter
  3704. + aktpackenum
  3705. Revision 1.28 1998/09/01 07:54:22 pierre
  3706. * UseBrowser a little updated (might still be buggy !!)
  3707. * bug in psub.pas in function specifier removed
  3708. * stdcall allowed in interface and in implementation
  3709. (FPC will not yet complain if it is missing in either part
  3710. because stdcall is only a dummy !!)
  3711. Revision 1.27 1998/08/28 12:51:43 florian
  3712. + ansistring to pchar type cast fixed
  3713. Revision 1.26 1998/08/25 12:42:44 pierre
  3714. * CDECL changed to CVAR for variables
  3715. specifications are read in structures also
  3716. + started adding GPC compatibility mode ( option -Sp)
  3717. * names changed to lowercase
  3718. Revision 1.25 1998/08/23 21:04:38 florian
  3719. + rtti generation for classes added
  3720. + new/dispose do now also a call to INITIALIZE/FINALIZE, if necessaray
  3721. Revision 1.24 1998/08/20 12:53:26 peter
  3722. * object_options are always written for object syms
  3723. Revision 1.23 1998/08/19 00:42:42 peter
  3724. + subrange types for enums
  3725. + checking for bounds type with ranges
  3726. Revision 1.22 1998/08/17 10:10:10 peter
  3727. - removed OLDPPU
  3728. Revision 1.21 1998/08/10 14:50:28 peter
  3729. + localswitches, moduleswitches, globalswitches splitting
  3730. Revision 1.20 1998/07/18 22:54:30 florian
  3731. * some ansi/wide/longstring support fixed:
  3732. o parameter passing
  3733. o returning as result from functions
  3734. Revision 1.19 1998/07/14 14:47:05 peter
  3735. * released NEWINPUT
  3736. Revision 1.18 1998/07/10 10:51:04 peter
  3737. * m68k updates
  3738. Revision 1.16 1998/07/07 11:20:13 peter
  3739. + NEWINPUT for a better inputfile and scanner object
  3740. Revision 1.15 1998/06/24 14:48:37 peter
  3741. * ifdef newppu -> ifndef oldppu
  3742. Revision 1.14 1998/06/16 08:56:31 peter
  3743. + targetcpu
  3744. * cleaner pmodules for newppu
  3745. Revision 1.13 1998/06/15 15:38:09 pierre
  3746. * small bug in systems.pas corrected
  3747. + operators in different units better hanlded
  3748. Revision 1.12 1998/06/15 14:30:12 daniel
  3749. * Reverted my changes.
  3750. Revision 1.10 1998/06/13 00:10:16 peter
  3751. * working browser and newppu
  3752. * some small fixes against crashes which occured in bp7 (but not in
  3753. fpc?!)
  3754. Revision 1.9 1998/06/12 14:10:37 michael
  3755. * Fixed wrong code for ansistring
  3756. Revision 1.8 1998/06/11 10:11:58 peter
  3757. * -gb works again
  3758. Revision 1.7 1998/06/07 15:30:25 florian
  3759. + first working rtti
  3760. + data init/final. for local variables
  3761. Revision 1.6 1998/06/05 14:37:37 pierre
  3762. * fixes for inline for operators
  3763. * inline procedure more correctly restricted
  3764. Revision 1.5 1998/06/04 23:52:01 peter
  3765. * m68k compiles
  3766. + .def file creation moved to gendef.pas so it could also be used
  3767. for win32
  3768. Revision 1.4 1998/06/04 09:55:45 pierre
  3769. * demangled name of procsym reworked to become independant of the mangling
  3770. scheme
  3771. Revision 1.3 1998/06/03 22:49:03 peter
  3772. + wordbool,longbool
  3773. * rename bis,von -> high,low
  3774. * moved some systemunit loading/creating to psystem.pas
  3775. Revision 1.2 1998/05/31 14:13:37 peter
  3776. * fixed call bugs with assembler readers
  3777. + OPR_SYMBOL to hold a symbol in the asm parser
  3778. * fixed staticsymtable vars which were acessed through %ebp instead of
  3779. name
  3780. Revision 1.1 1998/05/27 19:45:09 peter
  3781. * symtable.pas splitted into includefiles
  3782. * symtable adapted for $ifndef OLDPPU
  3783. }