symdef.inc 129 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433
  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. procedure tpointerdef.deref;
  1209. begin
  1210. resolvedef(definition);
  1211. end;
  1212. procedure tpointerdef.write;
  1213. begin
  1214. inherited write;
  1215. writedefref(definition);
  1216. writebyte(byte(is_far));
  1217. current_ppu^.writeentry(ibpointerdef);
  1218. end;
  1219. {$ifdef GDB}
  1220. function tpointerdef.stabstring : pchar;
  1221. begin
  1222. stabstring := strpnew('*'+definition^.numberstring);
  1223. end;
  1224. procedure tpointerdef.concatstabto(asmlist : paasmoutput);
  1225. var st,nb : string;
  1226. sym_line_no : longint;
  1227. begin
  1228. if ( (sym=nil) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1229. not is_def_stab_written then
  1230. begin
  1231. if assigned(definition) then
  1232. if definition^.deftype in [recorddef,objectdef] then
  1233. begin
  1234. is_def_stab_written := true;
  1235. {to avoid infinite recursion in record with next-like fields }
  1236. nb := definition^.numberstring;
  1237. is_def_stab_written := false;
  1238. if not definition^.is_def_stab_written then
  1239. begin
  1240. if assigned(definition^.sym) then
  1241. begin
  1242. if assigned(sym) then
  1243. begin
  1244. st := sym^.name;
  1245. sym_line_no:=sym^.fileinfo.line;
  1246. end
  1247. else
  1248. begin
  1249. st := ' ';
  1250. sym_line_no:=0;
  1251. end;
  1252. st := '"'+st+':t'+numberstring+'=*'+definition^.numberstring
  1253. +'=xs'+definition^.sym^.name+':",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0';
  1254. if asmlist = debuglist then do_count_dbx := true;
  1255. asmlist^.concat(new(pai_stabs,init(strpnew(st))));
  1256. end;
  1257. end else inherited concatstabto(asmlist);
  1258. is_def_stab_written := true;
  1259. end else
  1260. begin
  1261. { p =^p1; p1=^p problem }
  1262. is_def_stab_written := true;
  1263. forcestabto(asmlist,definition);
  1264. is_def_stab_written := false;
  1265. inherited concatstabto(asmlist);
  1266. end;
  1267. end;
  1268. end;
  1269. {$endif GDB}
  1270. function tpointerdef.gettypename : string;
  1271. begin
  1272. gettypename:='^'+definition^.typename;
  1273. end;
  1274. {****************************************************************************
  1275. TCLASSREFDEF
  1276. ****************************************************************************}
  1277. constructor tclassrefdef.init(def : pdef);
  1278. begin
  1279. inherited init(def);
  1280. deftype:=classrefdef;
  1281. definition:=def;
  1282. savesize:=target_os.size_of_pointer;
  1283. end;
  1284. constructor tclassrefdef.load;
  1285. begin
  1286. { be careful, tclassdefref inherits from tpointerdef }
  1287. tdef.load;
  1288. deftype:=classrefdef;
  1289. definition:=readdefref;
  1290. is_far:=false;
  1291. savesize:=target_os.size_of_pointer;
  1292. end;
  1293. procedure tclassrefdef.write;
  1294. begin
  1295. { be careful, tclassdefref inherits from tpointerdef }
  1296. tdef.write;
  1297. writedefref(definition);
  1298. current_ppu^.writeentry(ibclassrefdef);
  1299. end;
  1300. {$ifdef GDB}
  1301. function tclassrefdef.stabstring : pchar;
  1302. begin
  1303. stabstring:=strpnew(pvmtdef^.numberstring+';');
  1304. end;
  1305. procedure tclassrefdef.concatstabto(asmlist : paasmoutput);
  1306. begin
  1307. inherited concatstabto(asmlist);
  1308. end;
  1309. {$endif GDB}
  1310. function tclassrefdef.gettypename : string;
  1311. begin
  1312. gettypename:='Class Of '+definition^.typename;
  1313. end;
  1314. {***************************************************************************
  1315. TSETDEF
  1316. ***************************************************************************}
  1317. { For i386 smallsets work,
  1318. for m68k there are problems
  1319. can be test by compiling with -dusesmallset PM }
  1320. {$ifdef i386}
  1321. {$define usesmallset}
  1322. {$endif i386}
  1323. constructor tsetdef.init(s : pdef;high : longint);
  1324. begin
  1325. inherited init;
  1326. deftype:=setdef;
  1327. setof:=s;
  1328. {$ifdef usesmallset}
  1329. { small sets only working for i386 PM }
  1330. if high<32 then
  1331. begin
  1332. settype:=smallset;
  1333. savesize:=Sizeof(longint);
  1334. end
  1335. else
  1336. {$endif usesmallset}
  1337. if high<256 then
  1338. begin
  1339. settype:=normset;
  1340. savesize:=32;
  1341. end
  1342. else
  1343. {$ifdef testvarsets}
  1344. if high<$10000 then
  1345. begin
  1346. settype:=varset;
  1347. savesize:=4*((high+31) div 32);
  1348. end
  1349. else
  1350. {$endif testvarsets}
  1351. Message(sym_e_ill_type_decl_set);
  1352. end;
  1353. constructor tsetdef.load;
  1354. begin
  1355. inherited load;
  1356. deftype:=setdef;
  1357. setof:=readdefref;
  1358. settype:=tsettype(readbyte);
  1359. case settype of
  1360. normset : savesize:=32;
  1361. varset : savesize:=readlong;
  1362. smallset : savesize:=Sizeof(longint);
  1363. end;
  1364. end;
  1365. procedure tsetdef.write;
  1366. begin
  1367. inherited write;
  1368. writedefref(setof);
  1369. writebyte(byte(settype));
  1370. if settype=varset then
  1371. writelong(savesize);
  1372. current_ppu^.writeentry(ibsetdef);
  1373. end;
  1374. {$ifdef GDB}
  1375. function tsetdef.stabstring : pchar;
  1376. begin
  1377. { For small sets write a longint, which can at least be seen
  1378. in the current GDB's (PFV)
  1379. this is obsolete with GDBPAS !!
  1380. and anyhow creates problems with version 4.18!! PM
  1381. if settype=smallset then
  1382. stabstring := strpnew('r'+s32bitdef^.numberstring+';0;0xffffffff;')
  1383. else }
  1384. stabstring := strpnew('S'+setof^.numberstring);
  1385. end;
  1386. procedure tsetdef.concatstabto(asmlist : paasmoutput);
  1387. begin
  1388. if ( not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1389. not is_def_stab_written then
  1390. begin
  1391. if assigned(setof) then
  1392. forcestabto(asmlist,setof);
  1393. inherited concatstabto(asmlist);
  1394. end;
  1395. end;
  1396. {$endif GDB}
  1397. procedure tsetdef.deref;
  1398. begin
  1399. resolvedef(setof);
  1400. end;
  1401. procedure tsetdef.write_rtti_data;
  1402. begin
  1403. rttilist^.concat(new(pai_const,init_8bit(tkSet)));
  1404. write_rtti_name;
  1405. rttilist^.concat(new(pai_const,init_8bit(otULong)));
  1406. rttilist^.concat(new(pai_const_symbol,initname(setof^.get_rtti_label)));
  1407. end;
  1408. procedure tsetdef.write_child_rtti_data;
  1409. begin
  1410. setof^.get_rtti_label;
  1411. end;
  1412. function tsetdef.is_publishable : boolean;
  1413. begin
  1414. is_publishable:=settype=smallset;
  1415. end;
  1416. function tsetdef.gettypename : string;
  1417. begin
  1418. gettypename:='Set Of '+setof^.typename;
  1419. end;
  1420. {***************************************************************************
  1421. TFORMALDEF
  1422. ***************************************************************************}
  1423. constructor tformaldef.init;
  1424. var
  1425. stregdef : boolean;
  1426. begin
  1427. stregdef:=registerdef;
  1428. registerdef:=false;
  1429. inherited init;
  1430. deftype:=formaldef;
  1431. registerdef:=stregdef;
  1432. { formaldef must be registered at unit level !! }
  1433. if registerdef and assigned(current_module) then
  1434. if assigned(current_module^.localsymtable) then
  1435. psymtable(current_module^.localsymtable)^.registerdef(@self)
  1436. else if assigned(current_module^.globalsymtable) then
  1437. psymtable(current_module^.globalsymtable)^.registerdef(@self);
  1438. savesize:=target_os.size_of_pointer;
  1439. end;
  1440. constructor tformaldef.load;
  1441. begin
  1442. inherited load;
  1443. deftype:=formaldef;
  1444. savesize:=target_os.size_of_pointer;
  1445. end;
  1446. procedure tformaldef.write;
  1447. begin
  1448. inherited write;
  1449. current_ppu^.writeentry(ibformaldef);
  1450. end;
  1451. {$ifdef GDB}
  1452. function tformaldef.stabstring : pchar;
  1453. begin
  1454. stabstring := strpnew('formal'+numberstring+';');
  1455. end;
  1456. procedure tformaldef.concatstabto(asmlist : paasmoutput);
  1457. begin
  1458. { formaldef can't be stab'ed !}
  1459. end;
  1460. {$endif GDB}
  1461. function tformaldef.gettypename : string;
  1462. begin
  1463. gettypename:='Var';
  1464. end;
  1465. {***************************************************************************
  1466. TARRAYDEF
  1467. ***************************************************************************}
  1468. constructor tarraydef.init(l,h : longint;rd : pdef);
  1469. begin
  1470. inherited init;
  1471. deftype:=arraydef;
  1472. lowrange:=l;
  1473. highrange:=h;
  1474. rangedef:=rd;
  1475. definition:=nil;
  1476. IsVariant:=false;
  1477. IsConstructor:=false;
  1478. IsArrayOfConst:=false;
  1479. rangenr:=0;
  1480. end;
  1481. constructor tarraydef.load;
  1482. begin
  1483. inherited load;
  1484. deftype:=arraydef;
  1485. { the addresses are calculated later }
  1486. definition:=readdefref;
  1487. rangedef:=readdefref;
  1488. lowrange:=readlong;
  1489. highrange:=readlong;
  1490. IsArrayOfConst:=boolean(readbyte);
  1491. IsVariant:=false;
  1492. IsConstructor:=false;
  1493. rangenr:=0;
  1494. end;
  1495. function tarraydef.getrangecheckstring : string;
  1496. begin
  1497. if (cs_create_smart in aktmoduleswitches) then
  1498. getrangecheckstring:='R_'+current_module^.modulename^+tostr(rangenr)
  1499. else
  1500. getrangecheckstring:='R_'+tostr(rangenr);
  1501. end;
  1502. procedure tarraydef.genrangecheck;
  1503. begin
  1504. if rangenr=0 then
  1505. begin
  1506. { generates the data for range checking }
  1507. getlabelnr(rangenr);
  1508. if (cs_create_smart in aktmoduleswitches) then
  1509. datasegment^.concat(new(pai_symbol,initname_global(getrangecheckstring,8)))
  1510. else
  1511. datasegment^.concat(new(pai_symbol,initname(getrangecheckstring,8)));
  1512. datasegment^.concat(new(pai_const,init_32bit(lowrange)));
  1513. datasegment^.concat(new(pai_const,init_32bit(highrange)));
  1514. end;
  1515. end;
  1516. procedure tarraydef.deref;
  1517. begin
  1518. resolvedef(definition);
  1519. resolvedef(rangedef);
  1520. end;
  1521. procedure tarraydef.write;
  1522. begin
  1523. inherited write;
  1524. writedefref(definition);
  1525. writedefref(rangedef);
  1526. writelong(lowrange);
  1527. writelong(highrange);
  1528. writebyte(byte(IsArrayOfConst));
  1529. current_ppu^.writeentry(ibarraydef);
  1530. end;
  1531. {$ifdef GDB}
  1532. function tarraydef.stabstring : pchar;
  1533. begin
  1534. stabstring := strpnew('ar'+rangedef^.numberstring+';'
  1535. +tostr(lowrange)+';'+tostr(highrange)+';'+definition^.numberstring);
  1536. end;
  1537. procedure tarraydef.concatstabto(asmlist : paasmoutput);
  1538. begin
  1539. if (not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  1540. and not is_def_stab_written then
  1541. begin
  1542. {when array are inserted they have no definition yet !!}
  1543. if assigned(definition) then
  1544. inherited concatstabto(asmlist);
  1545. end;
  1546. end;
  1547. {$endif GDB}
  1548. function tarraydef.elesize : longint;
  1549. begin
  1550. elesize:=definition^.size;
  1551. end;
  1552. function tarraydef.size : longint;
  1553. begin
  1554. {Tarraydef.size may never be called for an open array!}
  1555. if highrange<lowrange then
  1556. internalerror(99080501);
  1557. If (elesize>0) and
  1558. (
  1559. (highrange-lowrange = $7fffffff) or
  1560. { () are needed around elesize-1 to avoid a possible
  1561. integer overflow for elesize=1 !! PM }
  1562. (($7fffffff div elesize + (elesize -1)) < (highrange - lowrange))
  1563. ) Then
  1564. Begin
  1565. Message(sym_e_segment_too_large);
  1566. size := 4
  1567. End
  1568. Else size:=(highrange-lowrange+1)*elesize;
  1569. end;
  1570. function tarraydef.alignment : longint;
  1571. begin
  1572. { alignment is the size of the elements }
  1573. alignment:=definition^.size;
  1574. end;
  1575. function tarraydef.needs_inittable : boolean;
  1576. begin
  1577. needs_inittable:=definition^.needs_inittable;
  1578. end;
  1579. procedure tarraydef.write_child_rtti_data;
  1580. begin
  1581. definition^.get_rtti_label;
  1582. end;
  1583. procedure tarraydef.write_rtti_data;
  1584. begin
  1585. rttilist^.concat(new(pai_const,init_8bit(13)));
  1586. write_rtti_name;
  1587. { size of elements }
  1588. rttilist^.concat(new(pai_const,init_32bit(definition^.size)));
  1589. { count of elements }
  1590. rttilist^.concat(new(pai_const,init_32bit(highrange-lowrange+1)));
  1591. { element type }
  1592. rttilist^.concat(new(pai_const_symbol,initname(definition^.get_rtti_label)));
  1593. end;
  1594. function tarraydef.gettypename : string;
  1595. begin
  1596. if isarrayofconst or isConstructor then
  1597. begin
  1598. if isvariant then
  1599. gettypename:='Array Of Const'
  1600. else
  1601. gettypename:='Array Of '+definition^.typename;
  1602. end
  1603. else if is_open_array(@self) then
  1604. gettypename:='Array Of '+definition^.typename
  1605. else
  1606. begin
  1607. if rangedef^.deftype=enumdef then
  1608. gettypename:='Array['+rangedef^.typename+'] Of '+definition^.typename
  1609. else
  1610. gettypename:='Array['+tostr(lowrange)+'..'+
  1611. tostr(highrange)+'] Of '+definition^.typename
  1612. end;
  1613. end;
  1614. {***************************************************************************
  1615. trecorddef
  1616. ***************************************************************************}
  1617. constructor trecorddef.init(p : psymtable);
  1618. begin
  1619. inherited init;
  1620. deftype:=recorddef;
  1621. symtable:=p;
  1622. symtable^.defowner := @self;
  1623. symtable^.dataalignment:=packrecordalignment[aktpackrecords];
  1624. end;
  1625. constructor trecorddef.load;
  1626. var
  1627. oldread_member : boolean;
  1628. begin
  1629. inherited load;
  1630. deftype:=recorddef;
  1631. savesize:=readlong;
  1632. oldread_member:=read_member;
  1633. read_member:=true;
  1634. symtable:=new(psymtable,loadas(recordsymtable));
  1635. read_member:=oldread_member;
  1636. symtable^.defowner := @self;
  1637. end;
  1638. destructor trecorddef.done;
  1639. begin
  1640. if assigned(symtable) then
  1641. dispose(symtable,done);
  1642. inherited done;
  1643. end;
  1644. var
  1645. binittable : boolean;
  1646. procedure check_rec_inittable(s : pnamedindexobject);
  1647. begin
  1648. if (psym(s)^.typ=varsym) and
  1649. ((pvarsym(s)^.definition^.deftype<>objectdef) or
  1650. not(pobjectdef(pvarsym(s)^.definition)^.is_class)) then
  1651. binittable:=pvarsym(s)^.definition^.needs_inittable;
  1652. end;
  1653. function trecorddef.needs_inittable : boolean;
  1654. var
  1655. oldb : boolean;
  1656. begin
  1657. { there are recursive calls to needs_rtti possible, }
  1658. { so we have to change to old value how else should }
  1659. { we do that ? check_rec_rtti can't be a nested }
  1660. { procedure of needs_rtti ! }
  1661. oldb:=binittable;
  1662. binittable:=false;
  1663. symtable^.foreach({$ifndef TP}@{$endif}check_rec_inittable);
  1664. needs_inittable:=binittable;
  1665. binittable:=oldb;
  1666. end;
  1667. procedure trecorddef.deref;
  1668. var
  1669. oldrecsyms : psymtable;
  1670. begin
  1671. oldrecsyms:=aktrecordsymtable;
  1672. aktrecordsymtable:=symtable;
  1673. { now dereference the definitions }
  1674. symtable^.deref;
  1675. aktrecordsymtable:=oldrecsyms;
  1676. end;
  1677. procedure trecorddef.write;
  1678. var
  1679. oldread_member : boolean;
  1680. begin
  1681. oldread_member:=read_member;
  1682. read_member:=true;
  1683. inherited write;
  1684. writelong(savesize);
  1685. current_ppu^.writeentry(ibrecorddef);
  1686. self.symtable^.writeas;
  1687. read_member:=oldread_member;
  1688. end;
  1689. function trecorddef.size:longint;
  1690. begin
  1691. size:=symtable^.datasize;
  1692. end;
  1693. function trecorddef.alignment:longint;
  1694. begin
  1695. alignment:=symtable^.dataalignment;
  1696. end;
  1697. {$ifdef GDB}
  1698. Const StabRecString : pchar = Nil;
  1699. StabRecSize : longint = 0;
  1700. RecOffset : Longint = 0;
  1701. procedure addname(p : pnamedindexobject);
  1702. var
  1703. news, newrec : pchar;
  1704. spec : string[3];
  1705. size : longint;
  1706. begin
  1707. { static variables from objects are like global objects }
  1708. if (sp_static in psym(p)^.symoptions) then
  1709. exit;
  1710. If psym(p)^.typ = varsym then
  1711. begin
  1712. if (sp_protected in psym(p)^.symoptions) then
  1713. spec:='/1'
  1714. else if (sp_private in psym(p)^.symoptions) then
  1715. spec:='/0'
  1716. else
  1717. spec:='';
  1718. { class fields are pointers PM }
  1719. if (pvarsym(p)^.definition^.deftype=objectdef) and
  1720. pobjectdef(pvarsym(p)^.definition)^.is_class then
  1721. spec:=spec+'*';
  1722. size:=pvarsym(p)^.definition^.size;
  1723. { open arrays made overflows !! }
  1724. if size>$fffffff then
  1725. size:=$fffffff;
  1726. newrec := strpnew(p^.name+':'+spec+pvarsym(p)^.definition^.numberstring
  1727. +','+tostr(pvarsym(p)^.address*8)+','
  1728. +tostr(size*8)+';');
  1729. if strlen(StabRecString) + strlen(newrec) >= StabRecSize-256 then
  1730. begin
  1731. getmem(news,stabrecsize+memsizeinc);
  1732. strcopy(news,stabrecstring);
  1733. freemem(stabrecstring,stabrecsize);
  1734. stabrecsize:=stabrecsize+memsizeinc;
  1735. stabrecstring:=news;
  1736. end;
  1737. strcat(StabRecstring,newrec);
  1738. strdispose(newrec);
  1739. {This should be used for case !!}
  1740. RecOffset := RecOffset + pvarsym(p)^.definition^.size;
  1741. end;
  1742. end;
  1743. function trecorddef.stabstring : pchar;
  1744. Var oldrec : pchar;
  1745. oldsize : longint;
  1746. begin
  1747. oldrec := stabrecstring;
  1748. oldsize:=stabrecsize;
  1749. GetMem(stabrecstring,memsizeinc);
  1750. stabrecsize:=memsizeinc;
  1751. strpcopy(stabRecString,'s'+tostr(size));
  1752. RecOffset := 0;
  1753. symtable^.foreach({$ifndef TP}@{$endif}addname);
  1754. { FPC doesn't want to convert a char to a pchar}
  1755. { is this a bug ? }
  1756. strpcopy(strend(StabRecString),';');
  1757. stabstring := strnew(StabRecString);
  1758. Freemem(stabrecstring,stabrecsize);
  1759. stabrecstring := oldrec;
  1760. stabrecsize:=oldsize;
  1761. end;
  1762. procedure trecorddef.concatstabto(asmlist : paasmoutput);
  1763. begin
  1764. if (not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
  1765. (not is_def_stab_written) then
  1766. inherited concatstabto(asmlist);
  1767. end;
  1768. {$endif GDB}
  1769. var
  1770. count : longint;
  1771. procedure count_inittable_fields(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1772. begin
  1773. if ((psym(sym)^.typ=varsym) and
  1774. pvarsym(sym)^.definition^.needs_inittable)
  1775. and ((pvarsym(sym)^.definition^.deftype<>objectdef) or
  1776. (not pobjectdef(pvarsym(sym)^.definition)^.is_class)) then
  1777. inc(count);
  1778. end;
  1779. procedure count_fields(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1780. begin
  1781. inc(count);
  1782. end;
  1783. procedure write_field_inittable(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1784. begin
  1785. if ((psym(sym)^.typ=varsym) and
  1786. pvarsym(sym)^.definition^.needs_inittable)
  1787. and ((pvarsym(sym)^.definition^.deftype<>objectdef) or
  1788. (not pobjectdef(pvarsym(sym)^.definition)^.is_class)) then
  1789. begin
  1790. rttilist^.concat(new(pai_const_symbol,init(pvarsym(sym)^.definition^.get_inittable_label)));
  1791. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  1792. end;
  1793. end;
  1794. procedure write_field_rtti(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1795. begin
  1796. rttilist^.concat(new(pai_const_symbol,initname(pvarsym(sym)^.definition^.get_rtti_label)));
  1797. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  1798. end;
  1799. procedure generate_child_inittable(sym:pnamedindexobject);{$ifndef fpc}far;{$endif}
  1800. begin
  1801. if (psym(sym)^.typ=varsym) and
  1802. pvarsym(sym)^.definition^.needs_inittable then
  1803. { force inittable generation }
  1804. pvarsym(sym)^.definition^.get_inittable_label;
  1805. end;
  1806. procedure generate_child_rtti(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  1807. begin
  1808. pvarsym(sym)^.definition^.get_rtti_label;
  1809. end;
  1810. procedure trecorddef.write_child_rtti_data;
  1811. begin
  1812. symtable^.foreach({$ifndef TP}@{$endif}generate_child_rtti);
  1813. end;
  1814. procedure trecorddef.write_child_init_data;
  1815. begin
  1816. symtable^.foreach({$ifndef TP}@{$endif}generate_child_inittable);
  1817. end;
  1818. procedure trecorddef.write_rtti_data;
  1819. begin
  1820. rttilist^.concat(new(pai_const,init_8bit(tkrecord)));
  1821. write_rtti_name;
  1822. rttilist^.concat(new(pai_const,init_32bit(size)));
  1823. count:=0;
  1824. symtable^.foreach({$ifndef TP}@{$endif}count_fields);
  1825. rttilist^.concat(new(pai_const,init_32bit(count)));
  1826. symtable^.foreach({$ifndef TP}@{$endif}write_field_rtti);
  1827. end;
  1828. procedure trecorddef.write_init_data;
  1829. begin
  1830. rttilist^.concat(new(pai_const,init_8bit(14)));
  1831. write_rtti_name;
  1832. rttilist^.concat(new(pai_const,init_32bit(size)));
  1833. count:=0;
  1834. symtable^.foreach({$ifndef TP}@{$endif}count_inittable_fields);
  1835. rttilist^.concat(new(pai_const,init_32bit(count)));
  1836. symtable^.foreach({$ifndef TP}@{$endif}write_field_inittable);
  1837. end;
  1838. function trecorddef.gettypename : string;
  1839. begin
  1840. gettypename:='<record type>'
  1841. end;
  1842. {***************************************************************************
  1843. TABSTRACTPROCDEF
  1844. ***************************************************************************}
  1845. procedure disposepdefcoll(var para1 : pdefcoll);
  1846. var
  1847. hp : pdefcoll;
  1848. begin
  1849. hp:=para1;
  1850. while assigned(hp) do
  1851. begin
  1852. para1:=hp^.next;
  1853. dispose(hp);
  1854. hp:=para1;
  1855. end;
  1856. end;
  1857. constructor tabstractprocdef.init;
  1858. begin
  1859. inherited init;
  1860. para1:=nil;
  1861. fpu_used:=0;
  1862. proctypeoption:=potype_none;
  1863. proccalloptions:=[];
  1864. procoptions:=[];
  1865. retdef:=voiddef;
  1866. symtablelevel:=0;
  1867. savesize:=target_os.size_of_pointer;
  1868. end;
  1869. destructor tabstractprocdef.done;
  1870. begin
  1871. disposepdefcoll(para1);
  1872. inherited done;
  1873. end;
  1874. procedure tabstractprocdef.concatdef(p : pdef;vsp : tvarspez);
  1875. var
  1876. hp : pdefcoll;
  1877. begin
  1878. new(hp);
  1879. hp^.paratyp:=vsp;
  1880. hp^.datasym:=nil;
  1881. hp^.data:=p;
  1882. hp^.next:=para1;
  1883. hp^.register:=R_NO;
  1884. para1:=hp;
  1885. end;
  1886. procedure tabstractprocdef.concattypesym(p : ptypesym;vsp : tvarspez);
  1887. var
  1888. hp : pdefcoll;
  1889. begin
  1890. new(hp);
  1891. hp^.paratyp:=vsp;
  1892. hp^.datasym:=p;
  1893. hp^.data:=p^.definition;
  1894. hp^.next:=para1;
  1895. hp^.register:=R_NO;
  1896. para1:=hp;
  1897. end;
  1898. { all functions returning in FPU are
  1899. assume to use 2 FPU registers
  1900. until the function implementation
  1901. is processed PM }
  1902. procedure tabstractprocdef.test_if_fpu_result;
  1903. begin
  1904. if assigned(retdef) and is_fpu(retdef) then
  1905. fpu_used:=2;
  1906. end;
  1907. procedure tabstractprocdef.deref;
  1908. var
  1909. hp : pdefcoll;
  1910. begin
  1911. inherited deref;
  1912. resolvedef(retdef);
  1913. hp:=para1;
  1914. while assigned(hp) do
  1915. begin
  1916. if assigned(hp^.datasym) then
  1917. begin
  1918. resolvesym(psym(hp^.datasym));
  1919. hp^.data:=hp^.datasym^.definition;
  1920. end
  1921. else
  1922. resolvedef(hp^.data);
  1923. hp:=hp^.next;
  1924. end;
  1925. end;
  1926. constructor tabstractprocdef.load;
  1927. var
  1928. last,hp : pdefcoll;
  1929. count,i : word;
  1930. begin
  1931. inherited load;
  1932. retdef:=readdefref;
  1933. fpu_used:=readbyte;
  1934. proctypeoption:=tproctypeoption(readlong);
  1935. readsmallset(proccalloptions);
  1936. readsmallset(procoptions);
  1937. count:=readword;
  1938. para1:=nil;
  1939. savesize:=target_os.size_of_pointer;
  1940. for i:=1 to count do
  1941. begin
  1942. new(hp);
  1943. hp^.paratyp:=tvarspez(readbyte);
  1944. { hp^.register:=tregister(readbyte); }
  1945. hp^.register:=R_NO;
  1946. hp^.data:=readdefref;
  1947. hp^.datasym:=ptypesym(readsymref);
  1948. hp^.next:=nil;
  1949. if para1=nil then
  1950. para1:=hp
  1951. else
  1952. last^.next:=hp;
  1953. last:=hp;
  1954. end;
  1955. end;
  1956. procedure tabstractprocdef.write;
  1957. var
  1958. count : word;
  1959. hp : pdefcoll;
  1960. begin
  1961. inherited write;
  1962. writedefref(retdef);
  1963. current_ppu^.do_interface_crc:=false;
  1964. writebyte(fpu_used);
  1965. writelong(ord(proctypeoption));
  1966. writesmallset(proccalloptions);
  1967. writesmallset(procoptions);
  1968. hp:=para1;
  1969. count:=0;
  1970. while assigned(hp) do
  1971. begin
  1972. inc(count);
  1973. hp:=hp^.next;
  1974. end;
  1975. writeword(count);
  1976. hp:=para1;
  1977. while assigned(hp) do
  1978. begin
  1979. writebyte(byte(hp^.paratyp));
  1980. { writebyte(byte(hp^.register)); }
  1981. if assigned(hp^.datasym) then
  1982. begin
  1983. writedefref(nil);
  1984. writesymref(psym(hp^.datasym));
  1985. end
  1986. else
  1987. begin
  1988. writedefref(hp^.data);
  1989. writesymref(nil);
  1990. end;
  1991. hp:=hp^.next;
  1992. end;
  1993. end;
  1994. function tabstractprocdef.para_size : longint;
  1995. var
  1996. pdc : pdefcoll;
  1997. l : longint;
  1998. begin
  1999. l:=0;
  2000. pdc:=para1;
  2001. while assigned(pdc) do
  2002. begin
  2003. case pdc^.paratyp of
  2004. vs_var : inc(l,target_os.size_of_pointer);
  2005. vs_value,
  2006. vs_const : if push_addr_param(pdc^.data) then
  2007. inc(l,target_os.size_of_pointer)
  2008. else
  2009. inc(l,align(pdc^.data^.size,target_os.stackalignment));
  2010. end;
  2011. pdc:=pdc^.next;
  2012. end;
  2013. para_size:=l;
  2014. end;
  2015. function tabstractprocdef.demangled_paras : string;
  2016. var s : string;
  2017. procedure doconcat(p : pdefcoll);
  2018. begin
  2019. if assigned(p^.next) then
  2020. doconcat(p^.next)
  2021. else
  2022. s:='(';
  2023. if assigned(p^.data^.sym) then
  2024. s:=s+p^.data^.sym^.name
  2025. else if p^.paratyp=vs_var then
  2026. s:=s+'var'
  2027. else if p^.paratyp=vs_const then
  2028. s:=s+'const';
  2029. if p<>para1 then
  2030. s:=s+','
  2031. else
  2032. s:=s+')';
  2033. end;
  2034. begin
  2035. s:='';
  2036. { a recursive solution is the easiest way to inverse the parameter }
  2037. { collection }
  2038. if assigned(para1) then
  2039. doconcat(para1);
  2040. demangled_paras:=s;
  2041. end;
  2042. {$ifdef GDB}
  2043. function tabstractprocdef.stabstring : pchar;
  2044. begin
  2045. stabstring := strpnew('abstractproc'+numberstring+';');
  2046. end;
  2047. procedure tabstractprocdef.concatstabto(asmlist : paasmoutput);
  2048. begin
  2049. if (not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  2050. and not is_def_stab_written then
  2051. begin
  2052. if assigned(retdef) then forcestabto(asmlist,retdef);
  2053. inherited concatstabto(asmlist);
  2054. end;
  2055. end;
  2056. {$endif GDB}
  2057. {***************************************************************************
  2058. TPROCDEF
  2059. ***************************************************************************}
  2060. constructor tprocdef.init;
  2061. begin
  2062. inherited init;
  2063. deftype:=procdef;
  2064. _mangledname:=nil;
  2065. nextoverloaded:=nil;
  2066. fileinfo:=aktfilepos;
  2067. extnumber:=-1;
  2068. localst:=new(psymtable,init(localsymtable));
  2069. parast:=new(psymtable,init(parasymtable));
  2070. localst^.defowner:=@self;
  2071. parast^.defowner:=@self;
  2072. { this is used by insert
  2073. to check same names in parast and localst }
  2074. localst^.next:=parast;
  2075. defref:=nil;
  2076. crossref:=nil;
  2077. lastwritten:=nil;
  2078. refcount:=0;
  2079. if (cs_browser in aktmoduleswitches) and make_ref then
  2080. begin
  2081. defref:=new(pref,init(defref,@tokenpos));
  2082. inc(refcount);
  2083. end;
  2084. lastref:=defref;
  2085. { first, we assume that all registers are used }
  2086. {$ifdef newcg}
  2087. usedregisters:=[firstreg..lastreg];
  2088. {$else newcg}
  2089. {$ifdef i386}
  2090. usedregisters:=$ff;
  2091. {$endif i386}
  2092. {$ifdef m68k}
  2093. usedregisters:=$FFFF;
  2094. {$endif}
  2095. {$endif newcg}
  2096. forwarddef:=true;
  2097. interfacedef:=false;
  2098. _class := nil;
  2099. code:=nil;
  2100. count:=false;
  2101. is_used:=false;
  2102. end;
  2103. constructor tprocdef.load;
  2104. var
  2105. s : string;
  2106. begin
  2107. inherited load;
  2108. deftype:=procdef;
  2109. {$ifdef newcg}
  2110. readnormalset(usedregisters);
  2111. {$else newcg}
  2112. {$ifdef i386}
  2113. usedregisters:=readbyte;
  2114. {$endif i386}
  2115. {$ifdef m68k}
  2116. usedregisters:=readword;
  2117. {$endif}
  2118. {$endif newcg}
  2119. s:=readstring;
  2120. setstring(_mangledname,s);
  2121. extnumber:=readlong;
  2122. nextoverloaded:=pprocdef(readdefref);
  2123. _class := pobjectdef(readdefref);
  2124. readposinfo(fileinfo);
  2125. if (cs_link_deffile in aktglobalswitches) and
  2126. (tf_need_export in target_info.flags) and
  2127. (po_exports in procoptions) then
  2128. deffile.AddExport(mangledname);
  2129. parast:=nil;
  2130. localst:=nil;
  2131. forwarddef:=false;
  2132. interfacedef:=false;
  2133. lastref:=nil;
  2134. lastwritten:=nil;
  2135. defref:=nil;
  2136. refcount:=0;
  2137. count:=true;
  2138. is_used:=false;
  2139. end;
  2140. Const local_symtable_index : longint = $8001;
  2141. procedure tprocdef.load_references;
  2142. var
  2143. pos : tfileposinfo;
  2144. {$ifndef NOLOCALBROWSER}
  2145. pdo : pobjectdef;
  2146. {$endif ndef NOLOCALBROWSER}
  2147. move_last : boolean;
  2148. begin
  2149. move_last:=lastwritten=lastref;
  2150. while (not current_ppu^.endofentry) do
  2151. begin
  2152. readposinfo(pos);
  2153. inc(refcount);
  2154. lastref:=new(pref,init(lastref,@pos));
  2155. lastref^.is_written:=true;
  2156. if refcount=1 then
  2157. defref:=lastref;
  2158. end;
  2159. if move_last then
  2160. lastwritten:=lastref;
  2161. if ((current_module^.flags and uf_local_browser)<>0)
  2162. and is_in_current then
  2163. begin
  2164. {$ifndef NOLOCALBROWSER}
  2165. pdo:=_class;
  2166. new(parast,loadas(parasymtable));
  2167. parast^.next:=owner;
  2168. parast^.load_browser;
  2169. new(localst,loadas(localsymtable));
  2170. localst^.next:=parast;
  2171. localst^.load_browser;
  2172. {$endif ndef NOLOCALBROWSER}
  2173. end;
  2174. end;
  2175. function tprocdef.write_references : boolean;
  2176. var
  2177. ref : pref;
  2178. {$ifndef NOLOCALBROWSER}
  2179. pdo : pobjectdef;
  2180. {$endif ndef NOLOCALBROWSER}
  2181. move_last : boolean;
  2182. begin
  2183. move_last:=lastwritten=lastref;
  2184. if move_last and (((current_module^.flags and uf_local_browser)=0)
  2185. or not is_in_current) then
  2186. exit;
  2187. { write address of this symbol }
  2188. writedefref(@self);
  2189. { write refs }
  2190. if assigned(lastwritten) then
  2191. ref:=lastwritten
  2192. else
  2193. ref:=defref;
  2194. while assigned(ref) do
  2195. begin
  2196. if ref^.moduleindex=current_module^.unit_index then
  2197. begin
  2198. writeposinfo(ref^.posinfo);
  2199. ref^.is_written:=true;
  2200. if move_last then
  2201. lastwritten:=ref;
  2202. end
  2203. else if not ref^.is_written then
  2204. move_last:=false
  2205. else if move_last then
  2206. lastwritten:=ref;
  2207. ref:=ref^.nextref;
  2208. end;
  2209. current_ppu^.writeentry(ibdefref);
  2210. write_references:=true;
  2211. if ((current_module^.flags and uf_local_browser)<>0)
  2212. and is_in_current then
  2213. begin
  2214. {$ifndef NOLOCALBROWSER}
  2215. pdo:=_class;
  2216. if (owner^.symtabletype<>localsymtable) then
  2217. while assigned(pdo) do
  2218. begin
  2219. if pdo^.symtable<>aktrecordsymtable then
  2220. begin
  2221. pdo^.symtable^.unitid:=local_symtable_index;
  2222. inc(local_symtable_index);
  2223. end;
  2224. pdo:=pdo^.childof;
  2225. end;
  2226. { we need TESTLOCALBROWSER para and local symtables
  2227. PPU files are then easier to read PM }
  2228. if not assigned(parast) then
  2229. parast:=new(psymtable,init(parasymtable));
  2230. parast^.writeas;
  2231. parast^.unitid:=local_symtable_index;
  2232. inc(local_symtable_index);
  2233. parast^.write_browser;
  2234. if not assigned(localst) then
  2235. localst:=new(psymtable,init(localsymtable));
  2236. localst^.writeas;
  2237. localst^.unitid:=local_symtable_index;
  2238. inc(local_symtable_index);
  2239. localst^.write_browser;
  2240. { decrement for }
  2241. local_symtable_index:=local_symtable_index-2;
  2242. pdo:=_class;
  2243. if (owner^.symtabletype<>localsymtable) then
  2244. while assigned(pdo) do
  2245. begin
  2246. if pdo^.symtable<>aktrecordsymtable then
  2247. dec(local_symtable_index);
  2248. pdo:=pdo^.childof;
  2249. end;
  2250. {$endif ndef NOLOCALBROWSER}
  2251. end;
  2252. end;
  2253. {$ifdef BrowserLog}
  2254. procedure tprocdef.add_to_browserlog;
  2255. begin
  2256. if assigned(defref) then
  2257. begin
  2258. browserlog.AddLog('***'+mangledname);
  2259. browserlog.AddLogRefs(defref);
  2260. if (current_module^.flags and uf_local_browser)<>0 then
  2261. begin
  2262. if assigned(parast) then
  2263. parast^.writebrowserlog;
  2264. if assigned(localst) then
  2265. localst^.writebrowserlog;
  2266. end;
  2267. end;
  2268. end;
  2269. {$endif BrowserLog}
  2270. destructor tprocdef.done;
  2271. begin
  2272. if assigned(defref) then
  2273. dispose(defref,done);
  2274. if assigned(parast) then
  2275. dispose(parast,done);
  2276. if assigned(localst) and (localst^.symtabletype<>staticsymtable) then
  2277. dispose(localst,done);
  2278. if (pocall_inline in proccalloptions) and assigned(code) then
  2279. disposetree(ptree(code));
  2280. if (po_msgstr in procoptions) then
  2281. strdispose(messageinf.str);
  2282. if
  2283. {$ifdef tp}
  2284. not(use_big) and
  2285. {$endif}
  2286. assigned(_mangledname) then
  2287. globals.strdispose(_mangledname);
  2288. inherited done;
  2289. end;
  2290. procedure tprocdef.write;
  2291. begin
  2292. inherited write;
  2293. current_ppu^.do_interface_crc:=false;
  2294. { set all registers to used for simplified compilation PM }
  2295. if simplify_ppu then
  2296. begin
  2297. {$ifdef newcg}
  2298. usedregisters:=[firstreg..lastreg];
  2299. {$else newcg}
  2300. {$ifdef i386}
  2301. usedregisters:=$ff;
  2302. {$endif i386}
  2303. {$ifdef m68k}
  2304. usedregisters:=$ffff;
  2305. {$endif}
  2306. {$endif newcg}
  2307. end;
  2308. {$ifdef newcg}
  2309. writenormalset(usedregisters);
  2310. {$else newcg}
  2311. {$ifdef i386}
  2312. writebyte(usedregisters);
  2313. {$endif i386}
  2314. {$ifdef m68k}
  2315. writeword(usedregisters);
  2316. {$endif}
  2317. {$endif newcg}
  2318. current_ppu^.do_interface_crc:=true;
  2319. writestring(mangledname);
  2320. writelong(extnumber);
  2321. if (proctypeoption<>potype_operator) then
  2322. writedefref(nextoverloaded)
  2323. else
  2324. begin
  2325. { only write the overloads from the same unit }
  2326. if assigned(nextoverloaded) and
  2327. (nextoverloaded^.owner=owner) then
  2328. writedefref(nextoverloaded)
  2329. else
  2330. writedefref(nil);
  2331. end;
  2332. writedefref(_class);
  2333. writeposinfo(fileinfo);
  2334. if (pocall_inline in proccalloptions) then
  2335. begin
  2336. { we need to save
  2337. - the para and the local symtable
  2338. - the code ptree !! PM
  2339. writesymtable(parast);
  2340. writesymtable(localst);
  2341. writeptree(ptree(code));
  2342. }
  2343. end;
  2344. current_ppu^.writeentry(ibprocdef);
  2345. end;
  2346. function tprocdef.haspara:boolean;
  2347. begin
  2348. haspara:=assigned(aktprocsym^.definition^.parast^.symindex^.first);
  2349. end;
  2350. {$ifdef GDB}
  2351. procedure addparaname(p : psym);
  2352. var vs : char;
  2353. begin
  2354. if pvarsym(p)^.varspez = vs_value then vs := '1'
  2355. else vs := '0';
  2356. strpcopy(strend(StabRecString),p^.name+':'+pvarsym(p)^.definition^.numberstring+','+vs+';');
  2357. end;
  2358. function tprocdef.stabstring : pchar;
  2359. var param : pdefcoll;
  2360. i : word;
  2361. oldrec : pchar;
  2362. begin
  2363. oldrec := stabrecstring;
  2364. getmem(StabRecString,1024);
  2365. param := para1;
  2366. i := 0;
  2367. while assigned(param) do
  2368. begin
  2369. inc(i);
  2370. param := param^.next;
  2371. end;
  2372. strpcopy(StabRecString,'f'+retdef^.numberstring);
  2373. if i>0 then
  2374. begin
  2375. strpcopy(strend(StabRecString),','+tostr(i)+';');
  2376. (* confuse gdb !! PM
  2377. if assigned(parast) then
  2378. parast^.foreach({$ifndef TP}@{$endif}addparaname)
  2379. else
  2380. begin
  2381. param := para1;
  2382. i := 0;
  2383. while assigned(param) do
  2384. begin
  2385. inc(i);
  2386. if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
  2387. {Here we have lost the parameter names !!}
  2388. {using lower case parameters }
  2389. strpcopy(strend(stabrecstring),'p'+tostr(i)
  2390. +':'+param^.data^.numberstring+','+vartyp+';');
  2391. param := param^.next;
  2392. end;
  2393. end; *)
  2394. {strpcopy(strend(StabRecString),';');}
  2395. end;
  2396. stabstring := strnew(stabrecstring);
  2397. freemem(stabrecstring,1024);
  2398. stabrecstring := oldrec;
  2399. end;
  2400. procedure tprocdef.concatstabto(asmlist : paasmoutput);
  2401. begin
  2402. end;
  2403. {$endif GDB}
  2404. procedure tprocdef.deref;
  2405. begin
  2406. inherited deref;
  2407. resolvedef(pdef(nextoverloaded));
  2408. resolvedef(pdef(_class));
  2409. end;
  2410. function tprocdef.mangledname : string;
  2411. {$ifdef tp}
  2412. var
  2413. oldpos : longint;
  2414. s : string;
  2415. b : byte;
  2416. {$endif tp}
  2417. begin
  2418. {$ifndef Delphi}
  2419. {$ifdef tp}
  2420. if use_big then
  2421. begin
  2422. symbolstream.seek(longint(_mangledname));
  2423. symbolstream.read(b,1);
  2424. symbolstream.read(s[1],b);
  2425. s[0]:=chr(b);
  2426. mangledname:=s;
  2427. end
  2428. else
  2429. {$endif}
  2430. {$endif Delphi}
  2431. mangledname:=strpas(_mangledname);
  2432. if count then
  2433. is_used:=true;
  2434. end;
  2435. function tprocdef.procname: string;
  2436. var
  2437. s : string;
  2438. l : longint;
  2439. begin
  2440. s:=mangledname;
  2441. { delete leading $$'s }
  2442. l:=pos('$$',s);
  2443. while l<>0 do
  2444. begin
  2445. delete(s,1,l+1);
  2446. l:=pos('$$',s);
  2447. end;
  2448. { delete leading _$'s }
  2449. l:=pos('_$',s);
  2450. while l<>0 do
  2451. begin
  2452. delete(s,1,l+1);
  2453. l:=pos('_$',s);
  2454. end;
  2455. l:=pos('$',s);
  2456. if l=0 then
  2457. procname:=s
  2458. else
  2459. procname:=Copy(s,1,l-1);
  2460. end;
  2461. {$IfDef GDB}
  2462. function tprocdef.cplusplusmangledname : string;
  2463. var
  2464. s,s2 : string;
  2465. param : pdefcoll;
  2466. begin
  2467. s := sym^.name;
  2468. if _class <> nil then
  2469. begin
  2470. s2 := _class^.objname^;
  2471. s := s+'__'+tostr(length(s2))+s2;
  2472. end else s := s + '_';
  2473. param := para1;
  2474. while assigned(param) do
  2475. begin
  2476. s2 := param^.data^.sym^.name;
  2477. s := s+tostr(length(s2))+s2;
  2478. param := param^.next;
  2479. end;
  2480. cplusplusmangledname:=s;
  2481. end;
  2482. {$EndIf GDB}
  2483. procedure tprocdef.setmangledname(const s : string);
  2484. begin
  2485. if {$ifdef tp}not(use_big) and{$endif} (assigned(_mangledname)) then
  2486. strdispose(_mangledname);
  2487. setstring(_mangledname,s);
  2488. if assigned(parast) then
  2489. begin
  2490. stringdispose(parast^.name);
  2491. parast^.name:=stringdup('args of '+s);
  2492. end;
  2493. if assigned(localst) then
  2494. begin
  2495. stringdispose(localst^.name);
  2496. localst^.name:=stringdup('locals of '+s);
  2497. end;
  2498. end;
  2499. {***************************************************************************
  2500. TPROCVARDEF
  2501. ***************************************************************************}
  2502. constructor tprocvardef.init;
  2503. begin
  2504. inherited init;
  2505. deftype:=procvardef;
  2506. end;
  2507. constructor tprocvardef.load;
  2508. begin
  2509. inherited load;
  2510. deftype:=procvardef;
  2511. end;
  2512. procedure tprocvardef.write;
  2513. begin
  2514. { here we cannot get a real good value so just give something }
  2515. { plausible (PM) }
  2516. { a more secure way would be
  2517. to allways store in a temp }
  2518. if is_fpu(retdef) then
  2519. fpu_used:=2
  2520. else
  2521. fpu_used:=0;
  2522. inherited write;
  2523. current_ppu^.writeentry(ibprocvardef);
  2524. end;
  2525. function tprocvardef.size : longint;
  2526. begin
  2527. if (po_methodpointer in procoptions) then
  2528. size:=2*target_os.size_of_pointer
  2529. else
  2530. size:=target_os.size_of_pointer;
  2531. end;
  2532. {$ifdef GDB}
  2533. function tprocvardef.stabstring : pchar;
  2534. var
  2535. nss : pchar;
  2536. i : word;
  2537. param : pdefcoll;
  2538. begin
  2539. i := 0;
  2540. param := para1;
  2541. while assigned(param) do
  2542. begin
  2543. inc(i);
  2544. param := param^.next;
  2545. end;
  2546. getmem(nss,1024);
  2547. { it is not a function but a function pointer !! (PM) }
  2548. strpcopy(nss,'*f'+retdef^.numberstring{+','+tostr(i)}+';');
  2549. param := para1;
  2550. i := 0;
  2551. { this confuses gdb !!
  2552. we should use 'F' instead of 'f' but
  2553. as we use c++ language mode
  2554. it does not like that either
  2555. Please do not remove this part
  2556. might be used once
  2557. gdb for pascal is ready PM }
  2558. (* while assigned(param) do
  2559. begin
  2560. inc(i);
  2561. if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
  2562. {Here we have lost the parameter names !!}
  2563. pst := strpnew('p'+tostr(i)+':'+param^.data^.numberstring+','+vartyp+';');
  2564. strcat(nss,pst);
  2565. strdispose(pst);
  2566. param := param^.next;
  2567. end; *)
  2568. {strpcopy(strend(nss),';');}
  2569. stabstring := strnew(nss);
  2570. freemem(nss,1024);
  2571. end;
  2572. procedure tprocvardef.concatstabto(asmlist : paasmoutput);
  2573. begin
  2574. if ( not assigned(sym) or sym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
  2575. and not is_def_stab_written then
  2576. inherited concatstabto(asmlist);
  2577. is_def_stab_written:=true;
  2578. end;
  2579. {$endif GDB}
  2580. procedure tprocvardef.write_rtti_data;
  2581. var
  2582. pdc, pdc2, pdcbefore : pdefcoll;
  2583. methodkind, paracount, paraspec : byte;
  2584. begin
  2585. if po_methodpointer in procoptions then
  2586. begin
  2587. { write method id and name }
  2588. rttilist^.concat(new(pai_const,init_8bit(tkmethod)));
  2589. write_rtti_name;
  2590. { write kind of method (can only be function or procedure)}
  2591. if retdef = pdef(voiddef) then { ### typecast shoudln't be necessary! (sg) }
  2592. methodkind := mkProcedure
  2593. else
  2594. methodkind := mkFunction;
  2595. rttilist^.concat(new(pai_const,init_8bit(methodkind)));
  2596. { get # of parameters }
  2597. paracount:=0;
  2598. pdc:=para1;
  2599. while assigned(pdc) do
  2600. begin
  2601. inc(paracount);
  2602. pdc:=pdc^.next;
  2603. end;
  2604. rttilist^.concat(new(pai_const,init_8bit(paracount)));
  2605. { write parameter info. The parameters must be written in reverse order
  2606. if this method uses right to left parameter pushing! }
  2607. pdc:=para1;
  2608. if assigned(pdc) and not (pocall_leftright in proccalloptions) then
  2609. while assigned(pdc^.next) do pdc := pdc^.next;
  2610. while assigned(pdc) do
  2611. begin
  2612. case pdc^.paratyp of
  2613. vs_value: paraspec := 0;
  2614. vs_const: paraspec := pfConst;
  2615. vs_var : paraspec := pfVar;
  2616. end;
  2617. { write flags for current parameter }
  2618. rttilist^.concat(new(pai_const,init_8bit(paraspec)));
  2619. { write name of current parameter ### how can I get this??? (sg)}
  2620. rttilist^.concat(new(pai_const,init_8bit(0)));
  2621. { write name of type of current parameter }
  2622. pdc^.data^.write_rtti_name;
  2623. if pocall_leftright in proccalloptions then
  2624. pdc:=pdc^.next
  2625. else
  2626. begin
  2627. { find previous argument }
  2628. pdcbefore := nil;
  2629. pdc2 := para1;
  2630. while pdc2 <> pdc do
  2631. begin
  2632. pdcbefore := pdc2;
  2633. pdc2 := pdc2^.next;
  2634. end;
  2635. pdc := pdcbefore;
  2636. end;
  2637. end;
  2638. { write name of result type }
  2639. retdef^.write_rtti_name;
  2640. end;
  2641. end;
  2642. procedure tprocvardef.write_child_rtti_data;
  2643. begin
  2644. {!!!!!!!!}
  2645. end;
  2646. function tprocvardef.is_publishable : boolean;
  2647. begin
  2648. is_publishable:=(po_methodpointer in procoptions);
  2649. end;
  2650. function tprocvardef.gettypename : string;
  2651. begin
  2652. if assigned(retdef) then
  2653. gettypename:='<procedure variable type of function'+demangled_paras+':'+retdef^.gettypename+'>'
  2654. else
  2655. gettypename:='<procedure variable type of procedure'+demangled_paras+'>';
  2656. end;
  2657. {***************************************************************************
  2658. TOBJECTDEF
  2659. ***************************************************************************}
  2660. {$ifdef GDB}
  2661. const
  2662. vtabletype : word = 0;
  2663. vtableassigned : boolean = false;
  2664. {$endif GDB}
  2665. constructor tobjectdef.init(const n : string;c : pobjectdef);
  2666. begin
  2667. tdef.init;
  2668. deftype:=objectdef;
  2669. objectoptions:=[];
  2670. childof:=nil;
  2671. symtable:=new(psymtable,init(objectsymtable));
  2672. symtable^.name := stringdup(n);
  2673. { create space for vmt !! }
  2674. vmt_offset:=0;
  2675. symtable^.datasize:=0;
  2676. symtable^.defowner:=@self;
  2677. symtable^.dataalignment:=packrecordalignment[aktpackrecords];
  2678. set_parent(c);
  2679. objname:=stringdup(n);
  2680. end;
  2681. constructor tobjectdef.load;
  2682. var
  2683. oldread_member : boolean;
  2684. begin
  2685. tdef.load;
  2686. deftype:=objectdef;
  2687. savesize:=readlong;
  2688. vmt_offset:=readlong;
  2689. objname:=stringdup(readstring);
  2690. childof:=pobjectdef(readdefref);
  2691. readsmallset(objectoptions);
  2692. oldread_member:=read_member;
  2693. read_member:=true;
  2694. symtable:=new(psymtable,loadas(objectsymtable));
  2695. read_member:=oldread_member;
  2696. symtable^.defowner:=@self;
  2697. symtable^.name := stringdup(objname^);
  2698. { handles the predefined class tobject }
  2699. { the last TOBJECT which is loaded gets }
  2700. { it ! }
  2701. if (childof=nil) and
  2702. is_class and
  2703. (objname^='TOBJECT') then
  2704. class_tobject:=@self;
  2705. has_rtti:=true;
  2706. end;
  2707. destructor tobjectdef.done;
  2708. begin
  2709. if assigned(symtable) then
  2710. dispose(symtable,done);
  2711. if (oo_is_forward in objectoptions) then
  2712. Message1(sym_e_class_forward_not_resolved,objname^);
  2713. stringdispose(objname);
  2714. tdef.done;
  2715. end;
  2716. procedure tobjectdef.write;
  2717. var
  2718. oldread_member : boolean;
  2719. begin
  2720. tdef.write;
  2721. writelong(size);
  2722. writelong(vmt_offset);
  2723. writestring(objname^);
  2724. writedefref(childof);
  2725. writesmallset(objectoptions);
  2726. current_ppu^.writeentry(ibobjectdef);
  2727. oldread_member:=read_member;
  2728. read_member:=true;
  2729. symtable^.writeas;
  2730. read_member:=oldread_member;
  2731. end;
  2732. procedure tobjectdef.deref;
  2733. var
  2734. oldrecsyms : psymtable;
  2735. begin
  2736. resolvedef(pdef(childof));
  2737. oldrecsyms:=aktrecordsymtable;
  2738. aktrecordsymtable:=symtable;
  2739. symtable^.deref;
  2740. aktrecordsymtable:=oldrecsyms;
  2741. end;
  2742. procedure tobjectdef.set_parent( c : pobjectdef);
  2743. begin
  2744. { nothing to do if the parent was not forward !}
  2745. if assigned(childof) then
  2746. exit;
  2747. childof:=c;
  2748. { some options are inherited !! }
  2749. if assigned(c) then
  2750. begin
  2751. objectoptions:=objectoptions+(c^.objectoptions*
  2752. [oo_has_virtual,oo_has_private,oo_has_protected,oo_has_constructor,oo_has_destructor]);
  2753. { add the data of the anchestor class }
  2754. inc(symtable^.datasize,c^.symtable^.datasize);
  2755. if (oo_has_vmt in objectoptions) and
  2756. (oo_has_vmt in c^.objectoptions) then
  2757. dec(symtable^.datasize,target_os.size_of_pointer);
  2758. { if parent has a vmt field then
  2759. the offset is the same for the child PM }
  2760. if (oo_has_vmt in c^.objectoptions) or is_class then
  2761. begin
  2762. vmt_offset:=c^.vmt_offset;
  2763. {$ifdef INCLUDEOK}
  2764. include(objectoptions,oo_has_vmt);
  2765. {$else}
  2766. objectoptions:=objectoptions+[oo_has_vmt];
  2767. {$endif}
  2768. end;
  2769. end;
  2770. savesize := symtable^.datasize;
  2771. end;
  2772. procedure tobjectdef.insertvmt;
  2773. begin
  2774. if (oo_has_vmt in objectoptions) then
  2775. internalerror(12345)
  2776. else
  2777. begin
  2778. { first round up to multiple of 4 }
  2779. if (symtable^.dataalignment=2) then
  2780. begin
  2781. if (symtable^.datasize and 1)<>0 then
  2782. inc(symtable^.datasize);
  2783. end
  2784. else
  2785. if (symtable^.dataalignment>=4) then
  2786. begin
  2787. if (symtable^.datasize mod 4) <> 0 then
  2788. inc(symtable^.datasize,4-(symtable^.datasize mod 4));
  2789. end;
  2790. vmt_offset:=symtable^.datasize;
  2791. inc(symtable^.datasize,target_os.size_of_pointer);
  2792. {$ifdef INCLUDEOK}
  2793. include(objectoptions,oo_has_vmt);
  2794. {$else}
  2795. objectoptions:=objectoptions+[oo_has_vmt];
  2796. {$endif}
  2797. end;
  2798. end;
  2799. procedure tobjectdef.check_forwards;
  2800. begin
  2801. symtable^.check_forwards;
  2802. if (oo_is_forward in objectoptions) then
  2803. begin
  2804. { ok, in future, the forward can be resolved }
  2805. Message1(sym_e_class_forward_not_resolved,objname^);
  2806. {$ifdef INCLUDEOK}
  2807. exclude(objectoptions,oo_is_forward);
  2808. {$else}
  2809. objectoptions:=objectoptions-[oo_is_forward];
  2810. {$endif}
  2811. end;
  2812. end;
  2813. { true, if self inherits from d (or if they are equal) }
  2814. function tobjectdef.is_related(d : pobjectdef) : boolean;
  2815. var
  2816. hp : pobjectdef;
  2817. begin
  2818. hp:=@self;
  2819. while assigned(hp) do
  2820. begin
  2821. if hp=d then
  2822. begin
  2823. is_related:=true;
  2824. exit;
  2825. end;
  2826. hp:=hp^.childof;
  2827. end;
  2828. is_related:=false;
  2829. end;
  2830. function tobjectdef.size : longint;
  2831. begin
  2832. if (oo_is_class in objectoptions) then
  2833. size:=target_os.size_of_pointer
  2834. else
  2835. size:=symtable^.datasize;
  2836. end;
  2837. function tobjectdef.alignment:longint;
  2838. begin
  2839. alignment:=symtable^.dataalignment;
  2840. end;
  2841. function tobjectdef.vmtmethodoffset(index:longint):longint;
  2842. begin
  2843. { for offset of methods for classes, see rtl/inc/objpash.inc }
  2844. if is_class then
  2845. vmtmethodoffset:=(index+12)*target_os.size_of_pointer
  2846. else
  2847. vmtmethodoffset:=(index+3)*target_os.size_of_pointer;
  2848. end;
  2849. function tobjectdef.vmt_mangledname : string;
  2850. {DM: I get a nil pointer on the owner name. I don't know if this
  2851. mayhappen, and I have therefore fixed the problem by doing nil pointer
  2852. checks.}
  2853. var
  2854. s1,s2:string;
  2855. begin
  2856. if not(oo_has_vmt in objectoptions) then
  2857. Message1(parser_object_has_no_vmt,objname^);
  2858. if owner^.name=nil then
  2859. s1:=''
  2860. else
  2861. s1:=owner^.name^;
  2862. if objname=nil then
  2863. s2:=''
  2864. else
  2865. s2:=objname^;
  2866. vmt_mangledname:='VMT_'+s1+'$_'+s2;
  2867. end;
  2868. function tobjectdef.rtti_name : string;
  2869. var
  2870. s1,s2:string;
  2871. begin
  2872. if owner^.name=nil then
  2873. s1:=''
  2874. else
  2875. s1:=owner^.name^;
  2876. if objname=nil then
  2877. s2:=''
  2878. else
  2879. s2:=objname^;
  2880. rtti_name:='RTTI_'+s1+'$_'+s2;
  2881. end;
  2882. function tobjectdef.is_class : boolean;
  2883. begin
  2884. is_class:=(oo_is_class in objectoptions);
  2885. end;
  2886. {$ifdef GDB}
  2887. procedure addprocname(p :pnamedindexobject);
  2888. var virtualind,argnames : string;
  2889. news, newrec : pchar;
  2890. pd,ipd : pprocdef;
  2891. lindex : longint;
  2892. para : pdefcoll;
  2893. arglength : byte;
  2894. sp : char;
  2895. begin
  2896. If psym(p)^.typ = procsym then
  2897. begin
  2898. pd := pprocsym(p)^.definition;
  2899. { this will be used for full implementation of object stabs
  2900. not yet done }
  2901. ipd := pd;
  2902. while assigned(ipd^.nextoverloaded) do ipd := ipd^.nextoverloaded;
  2903. if (po_virtualmethod in pd^.procoptions) then
  2904. begin
  2905. lindex := pd^.extnumber;
  2906. {doesnt seem to be necessary
  2907. lindex := lindex or $80000000;}
  2908. virtualind := '*'+tostr(lindex)+';'+ipd^._class^.numberstring+';'
  2909. end else virtualind := '.';
  2910. { arguments are not listed here }
  2911. {we don't need another definition}
  2912. para := pd^.para1;
  2913. { used by gdbpas to recognize constructor and destructors }
  2914. if (pd^.proctypeoption=potype_constructor) then
  2915. argnames:='__ct__'
  2916. else if (pd^.proctypeoption=potype_destructor) then
  2917. argnames:='__dt__'
  2918. else
  2919. argnames := '';
  2920. while assigned(para) do
  2921. begin
  2922. if para^.data^.deftype = formaldef then
  2923. begin
  2924. if para^.paratyp=vs_var then
  2925. argnames := argnames+'3var'
  2926. else if para^.paratyp=vs_const then
  2927. argnames:=argnames+'5const';
  2928. end
  2929. else
  2930. begin
  2931. { if the arg definition is like (v: ^byte;..
  2932. there is no sym attached to data !!! }
  2933. if assigned(para^.data^.sym) then
  2934. begin
  2935. arglength := length(para^.data^.sym^.name);
  2936. argnames := argnames + tostr(arglength)+para^.data^.sym^.name;
  2937. end
  2938. else
  2939. begin
  2940. argnames:=argnames+'11unnamedtype';
  2941. end;
  2942. end;
  2943. para := para^.next;
  2944. end;
  2945. ipd^.is_def_stab_written := true;
  2946. { here 2A must be changed for private and protected }
  2947. { 0 is private 1 protected and 2 public }
  2948. if (sp_private in psym(p)^.symoptions) then sp:='0'
  2949. else if (sp_protected in psym(p)^.symoptions) then sp:='1'
  2950. else sp:='2';
  2951. newrec := strpnew(p^.name+'::'+ipd^.numberstring
  2952. +'=##'+pd^.retdef^.numberstring+';:'+argnames+';'+sp+'A'
  2953. +virtualind+';');
  2954. { get spare place for a string at the end }
  2955. if strlen(StabRecString) + strlen(newrec) >= StabRecSize-256 then
  2956. begin
  2957. getmem(news,stabrecsize+memsizeinc);
  2958. strcopy(news,stabrecstring);
  2959. freemem(stabrecstring,stabrecsize);
  2960. stabrecsize:=stabrecsize+memsizeinc;
  2961. stabrecstring:=news;
  2962. end;
  2963. strcat(StabRecstring,newrec);
  2964. {freemem(newrec,memsizeinc); }
  2965. strdispose(newrec);
  2966. {This should be used for case !!}
  2967. RecOffset := RecOffset + pd^.size;
  2968. end;
  2969. end;
  2970. function tobjectdef.stabstring : pchar;
  2971. var anc : pobjectdef;
  2972. oldrec : pchar;
  2973. oldrecsize : longint;
  2974. str_end : string;
  2975. begin
  2976. oldrec := stabrecstring;
  2977. oldrecsize:=stabrecsize;
  2978. stabrecsize:=memsizeinc;
  2979. GetMem(stabrecstring,stabrecsize);
  2980. strpcopy(stabRecString,'s'+tostr(symtable^.datasize));
  2981. if assigned(childof) then
  2982. {only one ancestor not virtual, public, at base offset 0 }
  2983. { !1 , 0 2 0 , }
  2984. strpcopy(strend(stabrecstring),'!1,020,'+childof^.numberstring+';');
  2985. {virtual table to implement yet}
  2986. RecOffset := 0;
  2987. symtable^.foreach({$ifndef TP}@{$endif}addname);
  2988. if (oo_has_vmt in objectoptions) then
  2989. if not assigned(childof) or not(oo_has_vmt in childof^.objectoptions) then
  2990. begin
  2991. strpcopy(strend(stabrecstring),'$vf'+numberstring+':'+typeglobalnumber('vtblarray')
  2992. +','+tostr(vmt_offset*8)+';');
  2993. end;
  2994. symtable^.foreach({$ifndef TP}@{$endif}addprocname);
  2995. if (oo_has_vmt in objectoptions) then
  2996. begin
  2997. anc := @self;
  2998. while assigned(anc^.childof) and (oo_has_vmt in anc^.childof^.objectoptions) do
  2999. anc := anc^.childof;
  3000. str_end:=';~%'+anc^.numberstring+';';
  3001. end
  3002. else
  3003. str_end:=';';
  3004. strpcopy(strend(stabrecstring),str_end);
  3005. stabstring := strnew(StabRecString);
  3006. freemem(stabrecstring,stabrecsize);
  3007. stabrecstring := oldrec;
  3008. stabrecsize:=oldrecsize;
  3009. end;
  3010. {$endif GDB}
  3011. procedure tobjectdef.write_child_init_data;
  3012. begin
  3013. symtable^.foreach({$ifndef TP}@{$endif}generate_child_inittable);
  3014. end;
  3015. procedure tobjectdef.write_init_data;
  3016. begin
  3017. if is_class then
  3018. rttilist^.concat(new(pai_const,init_8bit(tkclass)))
  3019. else
  3020. rttilist^.concat(new(pai_const,init_8bit(tkobject)));
  3021. { generate the name }
  3022. rttilist^.concat(new(pai_const,init_8bit(length(objname^))));
  3023. rttilist^.concat(new(pai_string,init(objname^)));
  3024. rttilist^.concat(new(pai_const,init_32bit(size)));
  3025. count:=0;
  3026. symtable^.foreach({$ifndef TP}@{$endif}count_inittable_fields);
  3027. rttilist^.concat(new(pai_const,init_32bit(count)));
  3028. symtable^.foreach({$ifndef TP}@{$endif}write_field_inittable);
  3029. end;
  3030. function tobjectdef.needs_inittable : boolean;
  3031. var
  3032. oldb : boolean;
  3033. begin
  3034. { there are recursive calls to needs_inittable possible, }
  3035. { so we have to change to old value how else should }
  3036. { we do that ? check_rec_rtti can't be a nested }
  3037. { procedure of needs_rtti ! }
  3038. oldb:=binittable;
  3039. binittable:=false;
  3040. symtable^.foreach({$ifndef TP}@{$endif}check_rec_inittable);
  3041. needs_inittable:=binittable;
  3042. binittable:=oldb;
  3043. end;
  3044. procedure count_published_properties(sym:pnamedindexobject);
  3045. {$ifndef fpc}far;{$endif}
  3046. begin
  3047. if needs_prop_entry(psym(sym)) then
  3048. inc(count);
  3049. end;
  3050. procedure write_property_info(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  3051. var
  3052. proctypesinfo : byte;
  3053. procedure writeproc(sym : ppropsymlist;def : pdef;shiftvalue : byte);
  3054. var
  3055. typvalue : byte;
  3056. hp : ppropsymlist;
  3057. address : longint;
  3058. begin
  3059. if not(assigned(sym) and assigned(sym^.sym)) then
  3060. begin
  3061. rttilist^.concat(new(pai_const,init_32bit(1)));
  3062. typvalue:=3;
  3063. end
  3064. else if sym^.sym^.typ=varsym then
  3065. begin
  3066. address:=0;
  3067. hp:=sym;
  3068. while assigned(hp) do
  3069. begin
  3070. inc(address,pvarsym(hp^.sym)^.address);
  3071. hp:=hp^.next;
  3072. end;
  3073. rttilist^.concat(new(pai_const,init_32bit(address)));
  3074. typvalue:=0;
  3075. end
  3076. else
  3077. begin
  3078. if not(po_virtualmethod in pprocdef(def)^.procoptions) then
  3079. begin
  3080. rttilist^.concat(new(pai_const_symbol,initname(pprocdef(def)^.mangledname)));
  3081. typvalue:=1;
  3082. end
  3083. else
  3084. begin
  3085. { virtual method, write vmt offset }
  3086. rttilist^.concat(new(pai_const,init_32bit(
  3087. pprocdef(def)^._class^.vmtmethodoffset(pprocdef(def)^.extnumber))));
  3088. typvalue:=2;
  3089. end;
  3090. end;
  3091. proctypesinfo:=proctypesinfo or (typvalue shl shiftvalue);
  3092. end;
  3093. begin
  3094. if needs_prop_entry(psym(sym)) then
  3095. case psym(sym)^.typ of
  3096. varsym:
  3097. begin
  3098. if not(pvarsym(sym)^.definition^.deftype=objectdef) or
  3099. not(pobjectdef(pvarsym(sym)^.definition)^.is_class) then
  3100. internalerror(1509992);
  3101. { access to implicit class property as field }
  3102. proctypesinfo:=(0 shl 0) or (0 shl 2) or (0 shl 4);
  3103. rttilist^.concat(new(pai_const_symbol,initname(pvarsym(sym)^.definition^.get_rtti_label)));
  3104. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  3105. rttilist^.concat(new(pai_const,init_32bit(pvarsym(sym)^.address)));
  3106. { per default stored }
  3107. rttilist^.concat(new(pai_const,init_32bit(1)));
  3108. { index as well as ... }
  3109. rttilist^.concat(new(pai_const,init_32bit(0)));
  3110. { default value are zero }
  3111. rttilist^.concat(new(pai_const,init_32bit(0)));
  3112. rttilist^.concat(new(pai_const,init_16bit(count)));
  3113. inc(count);
  3114. rttilist^.concat(new(pai_const,init_8bit(proctypesinfo)));
  3115. rttilist^.concat(new(pai_const,init_8bit(length(pvarsym(sym)^.name))));
  3116. rttilist^.concat(new(pai_string,init(pvarsym(sym)^.name)));
  3117. end;
  3118. propertysym:
  3119. begin
  3120. if ppo_indexed in ppropertysym(sym)^.propoptions then
  3121. proctypesinfo:=$40
  3122. else
  3123. proctypesinfo:=0;
  3124. rttilist^.concat(new(pai_const_symbol,initname(ppropertysym(sym)^.proptype^.get_rtti_label)));
  3125. writeproc(ppropertysym(sym)^.readaccesssym,ppropertysym(sym)^.readaccessdef,0);
  3126. writeproc(ppropertysym(sym)^.writeaccesssym,ppropertysym(sym)^.writeaccessdef,2);
  3127. { isn't it stored ? }
  3128. if not(ppo_stored in ppropertysym(sym)^.propoptions) then
  3129. begin
  3130. rttilist^.concat(new(pai_const,init_32bit(0)));
  3131. proctypesinfo:=proctypesinfo or (3 shl 4);
  3132. end
  3133. else
  3134. writeproc(ppropertysym(sym)^.storedsym,ppropertysym(sym)^.storeddef,4);
  3135. rttilist^.concat(new(pai_const,init_32bit(ppropertysym(sym)^.index)));
  3136. rttilist^.concat(new(pai_const,init_32bit(ppropertysym(sym)^.default)));
  3137. rttilist^.concat(new(pai_const,init_16bit(count)));
  3138. inc(count);
  3139. rttilist^.concat(new(pai_const,init_8bit(proctypesinfo)));
  3140. rttilist^.concat(new(pai_const,init_8bit(length(ppropertysym(sym)^.name))));
  3141. rttilist^.concat(new(pai_string,init(ppropertysym(sym)^.name)));
  3142. end;
  3143. else internalerror(1509992);
  3144. end;
  3145. end;
  3146. procedure generate_published_child_rtti(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
  3147. begin
  3148. if needs_prop_entry(psym(sym)) then
  3149. case psym(sym)^.typ of
  3150. varsym:
  3151. pvarsym(sym)^.definition^.get_rtti_label;
  3152. propertysym:
  3153. ppropertysym(sym)^.proptype^.get_rtti_label;
  3154. else internalerror(1509991);
  3155. end;
  3156. end;
  3157. procedure tobjectdef.write_child_rtti_data;
  3158. begin
  3159. symtable^.foreach({$ifndef TP}@{$endif}generate_published_child_rtti);
  3160. end;
  3161. procedure tobjectdef.generate_rtti;
  3162. begin
  3163. has_rtti:=true;
  3164. getdatalabel(rtti_label);
  3165. write_child_rtti_data;
  3166. rttilist^.concat(new(pai_symbol,initname_global(rtti_name,0)));
  3167. rttilist^.concat(new(pai_label,init(rtti_label)));
  3168. write_rtti_data;
  3169. rttilist^.concat(new(pai_symbol_end,initname(rtti_name)));
  3170. end;
  3171. function tobjectdef.next_free_name_index : longint;
  3172. var
  3173. i : longint;
  3174. begin
  3175. if assigned(childof) and (oo_can_have_published in childof^.objectoptions) then
  3176. i:=childof^.next_free_name_index
  3177. else
  3178. i:=0;
  3179. count:=0;
  3180. symtable^.foreach({$ifndef TP}@{$endif}count_published_properties);
  3181. next_free_name_index:=i+count;
  3182. end;
  3183. procedure tobjectdef.write_rtti_data;
  3184. begin
  3185. if is_class then
  3186. rttilist^.concat(new(pai_const,init_8bit(tkclass)))
  3187. else
  3188. rttilist^.concat(new(pai_const,init_8bit(tkobject)));
  3189. { generate the name }
  3190. rttilist^.concat(new(pai_const,init_8bit(length(objname^))));
  3191. rttilist^.concat(new(pai_string,init(objname^)));
  3192. { write class type }
  3193. rttilist^.concat(new(pai_const_symbol,initname(vmt_mangledname)));
  3194. { write owner typeinfo }
  3195. if assigned(childof) and (oo_can_have_published in childof^.objectoptions) then
  3196. rttilist^.concat(new(pai_const_symbol,initname(childof^.get_rtti_label)))
  3197. else
  3198. rttilist^.concat(new(pai_const,init_32bit(0)));
  3199. { count total number of properties }
  3200. if assigned(childof) and (oo_can_have_published in childof^.objectoptions) then
  3201. count:=childof^.next_free_name_index
  3202. else
  3203. count:=0;
  3204. { write it }
  3205. symtable^.foreach({$ifndef TP}@{$endif}count_published_properties);
  3206. rttilist^.concat(new(pai_const,init_16bit(count)));
  3207. { write unit name }
  3208. if assigned(owner^.name) then
  3209. begin
  3210. rttilist^.concat(new(pai_const,init_8bit(length(owner^.name^))));
  3211. rttilist^.concat(new(pai_string,init(owner^.name^)));
  3212. end
  3213. else
  3214. rttilist^.concat(new(pai_const,init_8bit(0)));
  3215. { write published properties count }
  3216. count:=0;
  3217. symtable^.foreach({$ifndef TP}@{$endif}count_published_properties);
  3218. rttilist^.concat(new(pai_const,init_16bit(count)));
  3219. { count is used to write nameindex }
  3220. { but we need an offset of the owner }
  3221. { to give each property an own slot }
  3222. if assigned(childof) and (oo_can_have_published in childof^.objectoptions) then
  3223. count:=childof^.next_free_name_index
  3224. else
  3225. count:=0;
  3226. symtable^.foreach({$ifndef TP}@{$endif}write_property_info);
  3227. end;
  3228. function tobjectdef.is_publishable : boolean;
  3229. begin
  3230. is_publishable:=is_class;
  3231. end;
  3232. function tobjectdef.get_rtti_label : string;
  3233. begin
  3234. get_rtti_label:=rtti_name;
  3235. end;
  3236. {****************************************************************************
  3237. TERRORDEF
  3238. ****************************************************************************}
  3239. constructor terrordef.init;
  3240. begin
  3241. inherited init;
  3242. deftype:=errordef;
  3243. end;
  3244. {$ifdef GDB}
  3245. function terrordef.stabstring : pchar;
  3246. begin
  3247. stabstring:=strpnew('error'+numberstring);
  3248. end;
  3249. {$endif GDB}
  3250. function terrordef.gettypename:string;
  3251. begin
  3252. gettypename:='<erroneous type>';
  3253. end;
  3254. {
  3255. $Log$
  3256. Revision 1.165 1999-09-20 16:39:02 peter
  3257. * cs_create_smart instead of cs_smartlink
  3258. * -CX is create smartlink
  3259. * -CD is create dynamic, but does nothing atm.
  3260. Revision 1.164 1999/09/15 22:09:26 florian
  3261. + rtti is now automatically generated for published classes, i.e.
  3262. they are handled like an implicit property
  3263. Revision 1.163 1999/09/15 20:35:44 florian
  3264. * small fix to operator overloading when in MMX mode
  3265. + the compiler uses now fldz and fld1 if possible
  3266. + some fixes to floating point registers
  3267. + some math. functions (arctan, ln, sin, cos, sqrt, sqr, pi) are now inlined
  3268. * .... ???
  3269. Revision 1.162 1999/09/12 08:48:09 florian
  3270. * bugs 593 and 607 fixed
  3271. * some other potential bugs with array constructors fixed
  3272. * for classes compiled in $M+ and it's childs, the default access method
  3273. is now published
  3274. * fixed copyright message (it is now 1993-99)
  3275. Revision 1.161 1999/09/10 18:48:09 florian
  3276. * some bug fixes (e.g. must_be_valid and procinfo.funcret_is_valid)
  3277. * most things for stored properties fixed
  3278. Revision 1.160 1999/09/02 17:07:40 florian
  3279. * problems with -Or fixed: tdef.isfpuregable was wrong!
  3280. Revision 1.159 1999/08/27 10:52:19 pierre
  3281. + simplify_ppu code added :
  3282. sets all registers used at PPU writing
  3283. * tprocdef mangledname writing is CRC relevant
  3284. Revision 1.158 1999/08/27 10:24:34 michael
  3285. + Inittables should not contain fields which are classes
  3286. Revision 1.157 1999/08/26 21:13:58 peter
  3287. * array elementsize of 0 doesn't crash anymore
  3288. Revision 1.156 1999/08/17 13:58:56 michael
  3289. RTTI writing patch
  3290. Revision 1.155 1999/08/16 16:26:04 pierre
  3291. * error in stabs for tclassrefdef corrected
  3292. Revision 1.154 1999/08/14 00:38:58 peter
  3293. * hack to support property with record fields
  3294. Revision 1.153 1999/08/13 21:33:11 peter
  3295. * support for array constructors extended and more error checking
  3296. Revision 1.152 1999/08/13 14:24:18 pierre
  3297. + stabs for classes and classref working,
  3298. a class still needs an ^ to get that content of it,
  3299. but the class fields inside a class don't result into an
  3300. infinite loop anymore!
  3301. Revision 1.151 1999/08/12 14:31:20 peter
  3302. * long line fix
  3303. Revision 1.150 1999/08/11 08:56:53 michael
  3304. * RTTI fix from Sebastian Guenther
  3305. Revision 1.149 1999/08/10 13:22:08 pierre
  3306. * vmtmethodoffset made cross target compatible
  3307. Revision 1.148 1999/08/10 12:32:13 pierre
  3308. * avoid overflow in tarraydef.size
  3309. Revision 1.147 1999/08/09 22:19:55 peter
  3310. * classes vmt changed to only positive addresses
  3311. * sharedlib creation is working
  3312. Revision 1.146 1999/08/07 14:21:00 florian
  3313. * some small problems fixed
  3314. Revision 1.145 1999/08/07 13:36:54 daniel
  3315. * Recommitted the arraydef overflow bugfix.
  3316. Revision 1.143 1999/08/06 11:13:30 peter
  3317. * fixed message which was wrong styled
  3318. Revision 1.142 1999/08/05 22:41:34 daniel
  3319. *** empty log message ***
  3320. Revision 1.141 1999/08/05 16:53:13 peter
  3321. * V_Fatal=1, all other V_ are also increased
  3322. * Check for local procedure when assigning procvar
  3323. * fixed comment parsing because directives
  3324. * oldtp mode directives better supported
  3325. * added some messages to errore.msg
  3326. Revision 1.140 1999/08/04 13:03:07 jonas
  3327. * all tokens now start with an underscore
  3328. * PowerPC compiles!!
  3329. Revision 1.139 1999/08/03 22:03:14 peter
  3330. * moved bitmask constants to sets
  3331. * some other type/const renamings
  3332. Revision 1.138 1999/08/02 21:29:02 florian
  3333. * the main branch psub.pas is now used for
  3334. newcg compiler
  3335. Revision 1.137 1999/07/31 22:37:17 michael
  3336. * Fix of initialization information generation
  3337. Revision 1.136 1999/07/29 20:54:07 peter
  3338. * write .size also
  3339. Revision 1.135 1999/07/27 23:42:18 peter
  3340. * indirect type referencing is now allowed
  3341. Revision 1.134 1999/07/23 23:07:03 peter
  3342. * fixed stabs for record which still used savesize
  3343. Revision 1.133 1999/07/23 16:05:28 peter
  3344. * alignment is now saved in the symtable
  3345. * C alignment added for records
  3346. * PPU version increased to solve .12 <-> .13 probs
  3347. Revision 1.132 1999/07/18 14:47:32 florian
  3348. * bug 487 fixed, (inc(<property>) isn't allowed)
  3349. * more fixes to compile with Delphi
  3350. Revision 1.131 1999/07/06 21:48:27 florian
  3351. * a lot bug fixes:
  3352. - po_external isn't any longer necessary for procedure compatibility
  3353. - m_tp_procvar is in -Sd now available
  3354. - error messages of procedure variables improved
  3355. - return values with init./finalization fixed
  3356. - data types with init./finalization aren't any longer allowed in variant
  3357. record
  3358. Revision 1.130 1999/06/22 16:24:44 pierre
  3359. * local browser stuff corrected
  3360. Revision 1.129 1999/06/02 22:44:21 pierre
  3361. * previous wrong log corrected
  3362. Revision 1.128 1999/06/02 22:25:52 pierre
  3363. * changed $ifdef FPC @ into $ifndef TP
  3364. Revision 1.127 1999/06/02 10:26:50 florian
  3365. * corrected order of parameter type for -vb
  3366. Revision 1.126 1999/06/02 10:11:50 florian
  3367. * make cycle fixed i.e. compilation with 0.99.10
  3368. * some fixes for qword
  3369. * start of register calling conventions
  3370. Revision 1.125 1999/06/01 14:45:56 peter
  3371. * @procvar is now always needed for FPC
  3372. Revision 1.124 1999/05/31 16:42:33 peter
  3373. * interfacedef flag for procdef if it's defined in the interface, to
  3374. make a difference with 'forward;' directive forwarddef. Fixes 253
  3375. Revision 1.123 1999/05/27 19:45:02 peter
  3376. * removed oldasm
  3377. * plabel -> pasmlabel
  3378. * -a switches to source writing automaticly
  3379. * assembler readers OOPed
  3380. * asmsymbol automaticly external
  3381. * jumptables and other label fixes for asm readers
  3382. Revision 1.122 1999/05/23 18:42:14 florian
  3383. * better error recovering in typed constants
  3384. * some problems with arrays of const fixed, some problems
  3385. due my previous
  3386. - the location type of array constructor is now LOC_MEM
  3387. - the pushing of high fixed
  3388. - parameter copying fixed
  3389. - zero temp. allocation removed
  3390. * small problem in the assembler writers fixed:
  3391. ref to nil wasn't written correctly
  3392. Revision 1.121 1999/05/21 13:55:19 peter
  3393. * NEWLAB for label as symbol
  3394. Revision 1.120 1999/05/20 22:22:43 pierre
  3395. + added synonym filed for ttypesym
  3396. allows a clean disposal of tdefs and related ttypesyms
  3397. Revision 1.119 1999/05/19 16:48:26 florian
  3398. * tdef.typename: returns a now a proper type name for the most types
  3399. Revision 1.118 1999/05/19 12:08:11 florian
  3400. * tobject wasn't set as default anchestor, was a problem with the new ppu
  3401. handling
  3402. Revision 1.117 1999/05/17 21:57:15 florian
  3403. * new temporary ansistring handling
  3404. Revision 1.116 1999/05/16 02:26:51 peter
  3405. * fixed loading of classrefdef
  3406. Revision 1.115 1999/05/14 17:52:26 peter
  3407. * new deref code
  3408. Revision 1.114 1999/05/13 21:59:41 peter
  3409. * removed oldppu code
  3410. * warning if objpas is loaded from uses
  3411. * first things for new deref writing
  3412. Revision 1.113 1999/05/12 00:19:58 peter
  3413. * removed R_DEFAULT_SEG
  3414. * uniform float names
  3415. Revision 1.112 1999/05/08 19:52:35 peter
  3416. + MessagePos() which is enhanced Message() function but also gets the
  3417. position info
  3418. * Removed comp warnings
  3419. Revision 1.111 1999/05/07 11:06:37 florian
  3420. * enumeration type names are now written in lowercase (rtti)
  3421. Revision 1.110 1999/05/06 09:05:28 peter
  3422. * generic write_float and str_float
  3423. * fixed constant float conversions
  3424. Revision 1.109 1999/05/05 10:05:56 florian
  3425. * a delphi compiled compiler recompiles ppc
  3426. Revision 1.108 1999/04/28 22:30:52 pierre
  3427. * delete -> deleteindex in tdef.correct_owner_symtable
  3428. Revision 1.107 1999/04/28 06:02:11 florian
  3429. * changes of Bruessel:
  3430. + message handler can now take an explicit self
  3431. * typinfo fixed: sometimes the type names weren't written
  3432. * the type checking for pointer comparisations and subtraction
  3433. and are now more strict (was also buggy)
  3434. * small bug fix to link.pas to support compiling on another
  3435. drive
  3436. * probable bug in popt386 fixed: call/jmp => push/jmp
  3437. transformation didn't count correctly the jmp references
  3438. + threadvar support
  3439. * warning if ln/sqrt gets an invalid constant argument
  3440. Revision 1.106 1999/04/26 18:30:01 peter
  3441. * farpointerdef moved into pointerdef.is_far
  3442. Revision 1.105 1999/04/26 13:31:47 peter
  3443. * release storenumber,double_checksum
  3444. Revision 1.104 1999/04/21 09:43:50 peter
  3445. * storenumber works
  3446. * fixed some typos in double_checksum
  3447. + incompatible types type1 and type2 message (with storenumber)
  3448. Revision 1.103 1999/04/19 09:28:20 peter
  3449. * fixed crash when writing overload operator to ppu
  3450. Revision 1.102 1999/04/17 22:01:28 pierre
  3451. * typo error fix in STORENUMBER code
  3452. Revision 1.101 1999/04/14 09:14:58 peter
  3453. * first things to store the symbol/def number in the ppu
  3454. Revision 1.100 1999/04/08 15:57:51 peter
  3455. + subrange checking for readln()
  3456. Revision 1.99 1999/04/07 15:39:32 pierre
  3457. + double_checksum code added
  3458. Revision 1.98 1999/03/06 17:24:16 peter
  3459. * reset savesize in tdef.init
  3460. Revision 1.97 1999/03/01 13:45:04 pierre
  3461. + added staticppusymtable symtable type for local browsing
  3462. Revision 1.96 1999/02/25 21:02:52 peter
  3463. * ag386bin updates
  3464. + coff writer
  3465. Revision 1.95 1999/02/23 18:29:23 pierre
  3466. * win32 compilation error fix
  3467. + some work for local browser (not cl=omplete yet)
  3468. Revision 1.94 1999/02/22 20:13:38 florian
  3469. + first implementation of message keyword
  3470. Revision 1.93 1999/02/22 13:07:07 pierre
  3471. + -b and -bl options work !
  3472. + cs_local_browser ($L+) is disabled if cs_browser ($Y+)
  3473. is not enabled when quitting global section
  3474. * local vars and procedures are not yet stored into PPU
  3475. Revision 1.92 1999/02/17 10:14:20 peter
  3476. * set the first enumsym also for subrange types
  3477. Revision 1.91 1999/02/08 09:51:21 pierre
  3478. * gdb info for local functions was wrong
  3479. Revision 1.90 1999/01/26 09:57:29 pierre
  3480. * open arrays stabs changed
  3481. Revision 1.89 1999/01/22 17:29:30 pierre
  3482. * overflow in addname for open arrays removed
  3483. Revision 1.88 1999/01/20 14:18:39 pierre
  3484. * bugs related to mangledname solved
  3485. - linux external without name
  3486. -external procs already used
  3487. (added count and is_used boolean fiels in tprocvar)
  3488. Revision 1.87 1999/01/19 10:56:05 pierre
  3489. typeof(object) without vmt generates an error instead of an internalerror
  3490. Revision 1.86 1999/01/12 14:25:32 peter
  3491. + BrowserLog for browser.log generation
  3492. + BrowserCol for browser info in TCollections
  3493. * released all other UseBrowser
  3494. Revision 1.85 1998/12/30 22:15:52 peter
  3495. + farpointer type
  3496. * absolutesym now also stores if its far
  3497. Revision 1.84 1998/12/30 13:41:12 peter
  3498. * released valuepara
  3499. Revision 1.83 1998/12/21 14:03:08 pierre
  3500. * procvar stabs correction
  3501. Revision 1.82 1998/12/19 00:23:52 florian
  3502. * ansistring memory leaks fixed
  3503. Revision 1.81 1998/12/11 08:57:22 pierre
  3504. * internal gdb types for booleans and 64bit integers
  3505. Revision 1.80 1998/12/10 09:47:26 florian
  3506. + basic operations with int64/qord (compiler with -dint64)
  3507. + rtti of enumerations extended: names are now written
  3508. Revision 1.79 1998/12/08 10:18:12 peter
  3509. + -gh for heaptrc unit
  3510. Revision 1.78 1998/12/08 09:06:30 pierre
  3511. + constructor destructor info for gdbpas
  3512. Revision 1.77 1998/12/01 23:37:39 pierre
  3513. * function type problem for gdb fix
  3514. Revision 1.76 1998/11/29 21:45:48 florian
  3515. * problem with arrays with init tables fixed
  3516. Revision 1.75 1998/11/29 12:45:59 peter
  3517. * hack for arraydef.size overflow
  3518. Revision 1.74 1998/11/27 14:50:47 peter
  3519. + open strings, $P switch support
  3520. Revision 1.73 1998/11/26 14:47:00 michael
  3521. + Fixed RTTI constants
  3522. Revision 1.72 1998/11/25 14:35:28 florian
  3523. * writting of rtti for properties fixed
  3524. Revision 1.71 1998/11/20 15:35:59 florian
  3525. * problems with rtti fixed, hope it works
  3526. Revision 1.70 1998/11/18 15:44:16 peter
  3527. * VALUEPARA for tp7 compatible value parameters
  3528. Revision 1.69 1998/11/10 17:54:56 peter
  3529. * removed warning
  3530. Revision 1.68 1998/11/05 23:34:36 peter
  3531. * don't dispose staticsymtable (caused crash under tp7 after a fatal
  3532. error)
  3533. Revision 1.67 1998/11/05 12:02:56 peter
  3534. * released useansistring
  3535. * removed -Sv, its now available in fpc modes
  3536. Revision 1.66 1998/10/26 22:58:22 florian
  3537. * new introduded problem with classes fix, the parent class wasn't set
  3538. correct, if the class was defined forward before
  3539. Revision 1.65 1998/10/26 14:19:28 pierre
  3540. + added options -lS and -lT for source and target os output
  3541. (to have a easier way to test OS_SOURCE abd OS_TARGET in makefiles)
  3542. * several problems with rtti data
  3543. (type of sym was not checked)
  3544. assumed to be varsym when they could be procsym or property syms !!
  3545. Revision 1.64 1998/10/22 17:11:21 pierre
  3546. + terminated the include exclude implementation for i386
  3547. * enums inside records fixed
  3548. Revision 1.63 1998/10/20 09:32:56 peter
  3549. * removed some unused vars
  3550. Revision 1.62 1998/10/20 08:06:58 pierre
  3551. * several memory corruptions due to double freemem solved
  3552. => never use p^.loc.location:=p^.left^.loc.location;
  3553. + finally I added now by default
  3554. that ra386dir translates global and unit symbols
  3555. + added a first field in tsymtable and
  3556. a nextsym field in tsym
  3557. (this allows to obtain ordered type info for
  3558. records and objects in gdb !)
  3559. Revision 1.61 1998/10/19 08:55:05 pierre
  3560. * wrong stabs info corrected once again !!
  3561. + variable vmt offset with vmt field only if required
  3562. implemented now !!!
  3563. Revision 1.60 1998/10/16 13:12:53 pierre
  3564. * added vmt_offsets in destructors code also !!!
  3565. * vmt_offset code for m68k
  3566. Revision 1.59 1998/10/16 08:51:51 peter
  3567. + target_os.stackalignment
  3568. + stack can be aligned at 2 or 4 byte boundaries
  3569. Revision 1.58 1998/10/15 15:13:30 pierre
  3570. + added oo_hasconstructor and oo_hasdestructor
  3571. for objects options
  3572. Revision 1.57 1998/10/14 15:54:20 pierre
  3573. * smallsets are not entirely implemented for
  3574. m68k added a ifdef usesmallset
  3575. that is allways defined for i386
  3576. (enables testing for m68k)
  3577. Revision 1.56 1998/10/09 11:47:56 pierre
  3578. * still more memory leaks fixes !!
  3579. Revision 1.55 1998/10/06 17:16:55 pierre
  3580. * some memory leaks fixed (thanks to Peter for heaptrc !)
  3581. Revision 1.54 1998/10/05 21:33:28 peter
  3582. * fixed 161,165,166,167,168
  3583. Revision 1.53 1998/10/05 12:48:39 pierre
  3584. * wrong handling of range check for arrays fixed
  3585. Revision 1.52 1998/10/02 07:20:38 florian
  3586. * range checking in units doesn't work if the units are smartlinked, fixed
  3587. Revision 1.51 1998/09/25 12:01:41 florian
  3588. * tobjectdef.symtable.datasize was set to savesize, this is wrong now
  3589. because the symtable size is read from the ppu file
  3590. Revision 1.50 1998/09/23 15:46:40 florian
  3591. * problem with with and classes fixed
  3592. Revision 1.49 1998/09/23 12:03:55 peter
  3593. * overloading fix for array of const
  3594. Revision 1.48 1998/09/22 15:37:23 peter
  3595. + array of const start
  3596. Revision 1.47 1998/09/21 15:46:01 michael
  3597. Applied florians fix for check_rec_inittable
  3598. Revision 1.46 1998/09/21 08:45:21 pierre
  3599. + added vmt_offset in tobjectdef.write for fututre use
  3600. (first steps to have objects without vmt if no virtual !!)
  3601. + added fpu_used field for tabstractprocdef :
  3602. sets this level to 2 if the functions return with value in FPU
  3603. (is then set to correct value at parsing of implementation)
  3604. THIS MIGHT refuse some code with FPU expression too complex
  3605. that were accepted before and even in some cases
  3606. that don't overflow in fact
  3607. ( like if f : float; is a forward that finally in implementation
  3608. only uses one fpu register !!)
  3609. Nevertheless I think that it will improve security on
  3610. FPU operations !!
  3611. * most other changes only for UseBrowser code
  3612. (added symtable references for record and objects)
  3613. local switch for refs to args and local of each function
  3614. (static symtable still missing)
  3615. UseBrowser still not stable and probably broken by
  3616. the definition hash array !!
  3617. Revision 1.45 1998/09/20 08:31:29 florian
  3618. + bit 6 of tpropinfo.propprocs is set, if the property contains a
  3619. constant index
  3620. Revision 1.44 1998/09/19 15:23:58 florian
  3621. * rtti for ordtypes corrected
  3622. Revision 1.43 1998/09/18 17:12:40 florian
  3623. * problem with writing of class references fixed
  3624. Revision 1.42 1998/09/17 13:41:20 pierre
  3625. sizeof(TPOINT) problem
  3626. Revision 1.40.2.2 1998/09/17 08:42:33 pierre
  3627. TPOINT sizeof fix
  3628. Revision 1.41 1998/09/15 17:39:30 jonas
  3629. + bugfix from bugfix branch
  3630. Revision 1.40.2.1 1998/09/15 17:35:32 jonas
  3631. * chenged string_typ in tstringdef.wideload from ansistring to widestring
  3632. Revision 1.40 1998/09/09 15:34:00 peter
  3633. * removed warnings
  3634. Revision 1.39 1998/09/08 10:23:44 pierre
  3635. * name field of filedef corrected
  3636. Revision 1.38 1998/09/07 23:10:23 florian
  3637. * a lot of stuff fixed regarding rtti and publishing of properties,
  3638. basics should now work
  3639. Revision 1.37 1998/09/07 19:33:24 florian
  3640. + some stuff for property rtti added:
  3641. - NameIndex of the TPropInfo record is now written correctly
  3642. - the DEFAULT/NODEFAULT keyword is supported now
  3643. - the default value and the storedsym/def are now written to
  3644. the PPU fiel
  3645. Revision 1.36 1998/09/07 17:37:01 florian
  3646. * first fixes for published properties
  3647. Revision 1.35 1998/09/06 22:42:02 florian
  3648. + rtti genreation for properties added
  3649. Revision 1.34 1998/09/04 18:15:02 peter
  3650. * filedef updated
  3651. Revision 1.33 1998/09/03 17:08:49 pierre
  3652. * better lines for stabs
  3653. (no scroll back to if before else part
  3654. no return to case line at jump outside case)
  3655. + source lines also if not in order
  3656. Revision 1.32 1998/09/03 16:03:20 florian
  3657. + rtti generation
  3658. * init table generation changed
  3659. Revision 1.31 1998/09/02 15:14:28 peter
  3660. * enum packing changed from len to max
  3661. Revision 1.30 1998/09/01 17:37:29 peter
  3662. * removed debug writeln :(
  3663. Revision 1.29 1998/09/01 12:53:25 peter
  3664. + aktpackenum
  3665. Revision 1.28 1998/09/01 07:54:22 pierre
  3666. * UseBrowser a little updated (might still be buggy !!)
  3667. * bug in psub.pas in function specifier removed
  3668. * stdcall allowed in interface and in implementation
  3669. (FPC will not yet complain if it is missing in either part
  3670. because stdcall is only a dummy !!)
  3671. Revision 1.27 1998/08/28 12:51:43 florian
  3672. + ansistring to pchar type cast fixed
  3673. Revision 1.26 1998/08/25 12:42:44 pierre
  3674. * CDECL changed to CVAR for variables
  3675. specifications are read in structures also
  3676. + started adding GPC compatibility mode ( option -Sp)
  3677. * names changed to lowercase
  3678. Revision 1.25 1998/08/23 21:04:38 florian
  3679. + rtti generation for classes added
  3680. + new/dispose do now also a call to INITIALIZE/FINALIZE, if necessaray
  3681. Revision 1.24 1998/08/20 12:53:26 peter
  3682. * object_options are always written for object syms
  3683. Revision 1.23 1998/08/19 00:42:42 peter
  3684. + subrange types for enums
  3685. + checking for bounds type with ranges
  3686. Revision 1.22 1998/08/17 10:10:10 peter
  3687. - removed OLDPPU
  3688. Revision 1.21 1998/08/10 14:50:28 peter
  3689. + localswitches, moduleswitches, globalswitches splitting
  3690. Revision 1.20 1998/07/18 22:54:30 florian
  3691. * some ansi/wide/longstring support fixed:
  3692. o parameter passing
  3693. o returning as result from functions
  3694. Revision 1.19 1998/07/14 14:47:05 peter
  3695. * released NEWINPUT
  3696. Revision 1.18 1998/07/10 10:51:04 peter
  3697. * m68k updates
  3698. Revision 1.16 1998/07/07 11:20:13 peter
  3699. + NEWINPUT for a better inputfile and scanner object
  3700. Revision 1.15 1998/06/24 14:48:37 peter
  3701. * ifdef newppu -> ifndef oldppu
  3702. Revision 1.14 1998/06/16 08:56:31 peter
  3703. + targetcpu
  3704. * cleaner pmodules for newppu
  3705. Revision 1.13 1998/06/15 15:38:09 pierre
  3706. * small bug in systems.pas corrected
  3707. + operators in different units better hanlded
  3708. Revision 1.12 1998/06/15 14:30:12 daniel
  3709. * Reverted my changes.
  3710. Revision 1.10 1998/06/13 00:10:16 peter
  3711. * working browser and newppu
  3712. * some small fixes against crashes which occured in bp7 (but not in
  3713. fpc?!)
  3714. Revision 1.9 1998/06/12 14:10:37 michael
  3715. * Fixed wrong code for ansistring
  3716. Revision 1.8 1998/06/11 10:11:58 peter
  3717. * -gb works again
  3718. Revision 1.7 1998/06/07 15:30:25 florian
  3719. + first working rtti
  3720. + data init/final. for local variables
  3721. Revision 1.6 1998/06/05 14:37:37 pierre
  3722. * fixes for inline for operators
  3723. * inline procedure more correctly restricted
  3724. Revision 1.5 1998/06/04 23:52:01 peter
  3725. * m68k compiles
  3726. + .def file creation moved to gendef.pas so it could also be used
  3727. for win32
  3728. Revision 1.4 1998/06/04 09:55:45 pierre
  3729. * demangled name of procsym reworked to become independant of the mangling
  3730. scheme
  3731. Revision 1.3 1998/06/03 22:49:03 peter
  3732. + wordbool,longbool
  3733. * rename bis,von -> high,low
  3734. * moved some systemunit loading/creating to psystem.pas
  3735. Revision 1.2 1998/05/31 14:13:37 peter
  3736. * fixed call bugs with assembler readers
  3737. + OPR_SYMBOL to hold a symbol in the asm parser
  3738. * fixed staticsymtable vars which were acessed through %ebp instead of
  3739. name
  3740. Revision 1.1 1998/05/27 19:45:09 peter
  3741. * symtable.pas splitted into includefiles
  3742. * symtable adapted for $ifndef OLDPPU
  3743. }