symsym.pas 93 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
  4. Implementation for the symbols types of the symtable
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit symsym;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. { common }
  23. cutils,
  24. { target }
  25. globtype,globals,
  26. { symtable }
  27. symconst,symbase,symtype,symdef,
  28. { ppu }
  29. ppu,symppu,
  30. cclasses,symnot,
  31. { aasm }
  32. aasmbase,aasmtai,
  33. cpuinfo,cpubase,cgbase
  34. ;
  35. type
  36. {************************************************
  37. TSym
  38. ************************************************}
  39. { this object is the base for all symbol objects }
  40. tstoredsym = class(tsym)
  41. protected
  42. _mangledname : pstring;
  43. public
  44. refs : longint;
  45. lastref,
  46. defref,
  47. lastwritten : tref;
  48. refcount : longint;
  49. {$ifdef GDB}
  50. isstabwritten : boolean;
  51. {$endif GDB}
  52. constructor create(const n : string);
  53. constructor loadsym(ppufile:tcompilerppufile);
  54. destructor destroy;override;
  55. procedure ppuwrite(ppufile:tcompilerppufile);virtual;abstract;
  56. procedure writesym(ppufile:tcompilerppufile);
  57. procedure deref;override;
  58. {$ifdef GDB}
  59. function stabstring : pchar;virtual;
  60. procedure concatstabto(asmlist : taasmoutput);virtual;
  61. {$endif GDB}
  62. procedure load_references(ppufile:tcompilerppufile;locals:boolean);virtual;
  63. function write_references(ppufile:tcompilerppufile;locals:boolean):boolean;virtual;
  64. function is_visible_for_proc(currprocdef:tprocdef):boolean;
  65. function is_visible_for_object(currobjdef:tobjectdef):boolean;
  66. function mangledname : string;
  67. procedure generate_mangledname;virtual;abstract;
  68. end;
  69. tlabelsym = class(tstoredsym)
  70. lab : tasmlabel;
  71. used,
  72. defined : boolean;
  73. code : pointer; { should be tnode }
  74. constructor create(const n : string; l : tasmlabel);
  75. destructor destroy;override;
  76. constructor ppuload(ppufile:tcompilerppufile);
  77. procedure generate_mangledname;override;
  78. procedure ppuwrite(ppufile:tcompilerppufile);override;
  79. end;
  80. tunitsym = class(tstoredsym)
  81. unitsymtable : tsymtable;
  82. prevsym : tunitsym;
  83. constructor create(const n : string;ref : tsymtable);
  84. constructor ppuload(ppufile:tcompilerppufile);
  85. destructor destroy;override;
  86. procedure ppuwrite(ppufile:tcompilerppufile);override;
  87. procedure restoreunitsym;
  88. {$ifdef GDB}
  89. procedure concatstabto(asmlist : taasmoutput);override;
  90. {$endif GDB}
  91. end;
  92. terrorsym = class(tstoredsym)
  93. constructor create;
  94. end;
  95. Tprocdefcallback = procedure(p:Tprocdef;arg:pointer);
  96. tprocsym = class(tstoredsym)
  97. protected
  98. pdlistfirst,
  99. pdlistlast : pprocdeflist; { linked list of overloaded procdefs }
  100. function getprocdef(nr:cardinal):Tprocdef;
  101. public
  102. procdef_count : byte;
  103. {$ifdef GDB}
  104. is_global : boolean;
  105. {$endif GDB}
  106. overloadchecked : boolean;
  107. overloadcount : word; { amount of overloaded functions in this module }
  108. property procdef[nr:cardinal]:Tprocdef read getprocdef;
  109. constructor create(const n : string);
  110. constructor ppuload(ppufile:tcompilerppufile);
  111. destructor destroy;override;
  112. { writes all declarations except the specified one }
  113. procedure write_parameter_lists(skipdef:tprocdef);
  114. { tests, if all procedures definitions are defined and not }
  115. { only forward }
  116. procedure check_forward;
  117. procedure unchain_overload;
  118. procedure ppuwrite(ppufile:tcompilerppufile);override;
  119. procedure deref;override;
  120. procedure addprocdef(p:tprocdef);
  121. procedure addprocdef_deref(const d:tderef);
  122. procedure add_para_match_to(Aprocsym:Tprocsym);
  123. procedure concat_procdefs_to(s:Tprocsym);
  124. procedure foreach_procdef_static(proc2call:Tprocdefcallback;arg:pointer);
  125. function first_procdef:Tprocdef;
  126. function last_procdef:Tprocdef;
  127. function search_procdef_nopara_boolret:Tprocdef;
  128. function search_procdef_bytype(pt:Tproctypeoption):Tprocdef;
  129. function search_procdef_bypara(params:Tlinkedlist;
  130. retdef:tdef;
  131. allowconvert,
  132. allowdefault:boolean):Tprocdef;
  133. function search_procdef_byprocvardef(d:Tprocvardef):Tprocdef;
  134. function search_procdef_unary_operator(firstpara:Tdef):Tprocdef;
  135. function search_procdef_assignment_operator(fromdef,todef:tdef):Tprocdef;
  136. function search_procdef_binary_operator(def1,def2:tdef):Tprocdef;
  137. function write_references(ppufile:tcompilerppufile;locals:boolean):boolean;override;
  138. {$ifdef GDB}
  139. function stabstring : pchar;override;
  140. procedure concatstabto(asmlist : taasmoutput);override;
  141. {$endif GDB}
  142. end;
  143. ttypesym = class(tstoredsym)
  144. restype : ttype;
  145. {$ifdef GDB}
  146. isusedinstab : boolean;
  147. {$endif GDB}
  148. constructor create(const n : string;const tt : ttype);
  149. constructor ppuload(ppufile:tcompilerppufile);
  150. procedure ppuwrite(ppufile:tcompilerppufile);override;
  151. procedure deref;override;
  152. function gettypedef:tdef;override;
  153. procedure load_references(ppufile:tcompilerppufile;locals:boolean);override;
  154. function write_references(ppufile:tcompilerppufile;locals:boolean):boolean;override;
  155. {$ifdef GDB}
  156. function stabstring : pchar;override;
  157. procedure concatstabto(asmlist : taasmoutput);override;
  158. {$endif GDB}
  159. end;
  160. tvarsym = class(tstoredsym)
  161. highvarsym : tvarsym;
  162. defaultconstsym : tsym;
  163. varoptions : tvaroptions;
  164. varspez : tvarspez; { sets the type of access }
  165. varstate : tvarstate;
  166. localloc : tparalocation; { register/reference for local var }
  167. fieldoffset : longint; { offset in record/object }
  168. paraitem : tparaitem;
  169. notifications : Tlinkedlist;
  170. constructor create(const n : string;vsp:tvarspez;const tt : ttype);
  171. constructor create_dll(const n : string;vsp:tvarspez;const tt : ttype);
  172. constructor create_C(const n,mangled : string;vsp:tvarspez;const tt : ttype);
  173. constructor ppuload(ppufile:tcompilerppufile);
  174. destructor destroy;override;
  175. procedure ppuwrite(ppufile:tcompilerppufile);override;
  176. procedure deref;override;
  177. procedure generate_mangledname;override;
  178. procedure set_mangledname(const s:string);
  179. function getsize : longint;
  180. function getvaluesize : longint;
  181. procedure trigger_notifications(what:Tnotification_flag);
  182. function register_notification(flags:Tnotification_flags;
  183. callback:Tnotification_callback):cardinal;
  184. procedure unregister_notification(id:cardinal);
  185. {$ifdef GDB}
  186. function stabstring : pchar;override;
  187. procedure concatstabto(asmlist : taasmoutput);override;
  188. {$endif GDB}
  189. private
  190. procedure setvartype(const newtype: ttype);
  191. _vartype : ttype;
  192. public
  193. property vartype: ttype read _vartype write setvartype;
  194. end;
  195. tpropertysym = class(tstoredsym)
  196. propoptions : tpropertyoptions;
  197. propoverriden : tpropertysym;
  198. propoverridenderef : tderef;
  199. proptype,
  200. indextype : ttype;
  201. index,
  202. default : longint;
  203. readaccess,
  204. writeaccess,
  205. storedaccess : tsymlist;
  206. constructor create(const n : string);
  207. destructor destroy;override;
  208. constructor ppuload(ppufile:tcompilerppufile);
  209. function getsize : longint;
  210. procedure ppuwrite(ppufile:tcompilerppufile);override;
  211. function gettypedef:tdef;override;
  212. procedure deref;override;
  213. procedure dooverride(overriden:tpropertysym);
  214. {$ifdef GDB}
  215. function stabstring : pchar;override;
  216. procedure concatstabto(asmlist : taasmoutput);override;
  217. {$endif GDB}
  218. end;
  219. tabsolutesym = class(tvarsym)
  220. abstyp : absolutetyp;
  221. absseg : boolean;
  222. ref : tstoredsym;
  223. asmname : pstring;
  224. constructor create(const n : string;const tt : ttype);
  225. constructor create_ref(const n : string;const tt : ttype;sym:tstoredsym);
  226. constructor ppuload(ppufile:tcompilerppufile);
  227. procedure deref;override;
  228. function mangledname : string;
  229. procedure ppuwrite(ppufile:tcompilerppufile);override;
  230. {$ifdef GDB}
  231. procedure concatstabto(asmlist : taasmoutput);override;
  232. {$endif GDB}
  233. end;
  234. ttypedconstsym = class(tstoredsym)
  235. typedconsttype : ttype;
  236. is_writable : boolean;
  237. constructor create(const n : string;p : tdef;writable : boolean);
  238. constructor createtype(const n : string;const tt : ttype;writable : boolean);
  239. constructor ppuload(ppufile:tcompilerppufile);
  240. destructor destroy;override;
  241. procedure generate_mangledname;override;
  242. procedure ppuwrite(ppufile:tcompilerppufile);override;
  243. procedure deref;override;
  244. function getsize:longint;
  245. {$ifdef GDB}
  246. function stabstring : pchar;override;
  247. {$endif GDB}
  248. end;
  249. tconstvalue = record
  250. case integer of
  251. 0: (valueord : tconstexprint);
  252. 1: (valueordptr : tconstptruint);
  253. 2: (valueptr : pointer; len : longint);
  254. end;
  255. tconstsym = class(tstoredsym)
  256. consttype : ttype;
  257. consttyp : tconsttyp;
  258. value : tconstvalue;
  259. resstrindex : longint; { needed for resource strings }
  260. constructor create_ord(const n : string;t : tconsttyp;v : tconstexprint);
  261. constructor create_ord_typed(const n : string;t : tconsttyp;v : tconstexprint;const tt:ttype);
  262. constructor create_ordptr_typed(const n : string;t : tconsttyp;v : tconstptruint;const tt:ttype);
  263. constructor create_ptr(const n : string;t : tconsttyp;v : pointer);
  264. constructor create_ptr_typed(const n : string;t : tconsttyp;v : pointer;const tt:ttype);
  265. constructor create_string(const n : string;t : tconsttyp;str:pchar;l:longint);
  266. constructor ppuload(ppufile:tcompilerppufile);
  267. destructor destroy;override;
  268. function mangledname : string;
  269. procedure deref;override;
  270. procedure ppuwrite(ppufile:tcompilerppufile);override;
  271. {$ifdef GDB}
  272. function stabstring : pchar;override;
  273. procedure concatstabto(asmlist : taasmoutput);override;
  274. {$endif GDB}
  275. end;
  276. tenumsym = class(tstoredsym)
  277. value : longint;
  278. definition : tenumdef;
  279. definitionderef : tderef;
  280. nextenum : tenumsym;
  281. constructor create(const n : string;def : tenumdef;v : longint);
  282. constructor ppuload(ppufile:tcompilerppufile);
  283. procedure ppuwrite(ppufile:tcompilerppufile);override;
  284. procedure deref;override;
  285. procedure order;
  286. {$ifdef GDB}
  287. procedure concatstabto(asmlist : taasmoutput);override;
  288. {$endif GDB}
  289. end;
  290. tsyssym = class(tstoredsym)
  291. number : longint;
  292. constructor create(const n : string;l : longint);
  293. constructor ppuload(ppufile:tcompilerppufile);
  294. destructor destroy;override;
  295. procedure ppuwrite(ppufile:tcompilerppufile);override;
  296. {$ifdef GDB}
  297. procedure concatstabto(asmlist : taasmoutput);override;
  298. {$endif GDB}
  299. end;
  300. { compiler generated symbol to point to rtti and init/finalize tables }
  301. trttisym = class(tstoredsym)
  302. lab : tasmsymbol;
  303. rttityp : trttitype;
  304. constructor create(const n:string;rt:trttitype);
  305. constructor ppuload(ppufile:tcompilerppufile);
  306. procedure ppuwrite(ppufile:tcompilerppufile);override;
  307. function mangledname:string;
  308. function get_label:tasmsymbol;
  309. end;
  310. { register variables }
  311. pregvarinfo = ^tregvarinfo;
  312. tregvarinfo = record
  313. regvars : array[1..maxvarregs] of tvarsym;
  314. regvars_para : array[1..maxvarregs] of boolean;
  315. regvars_refs : array[1..maxvarregs] of longint;
  316. fpuregvars : array[1..maxfpuvarregs] of tvarsym;
  317. fpuregvars_para : array[1..maxfpuvarregs] of boolean;
  318. fpuregvars_refs : array[1..maxfpuvarregs] of longint;
  319. end;
  320. var
  321. generrorsym : tsym;
  322. const
  323. current_object_option : tsymoptions = [sp_public];
  324. { rtti and init/final }
  325. procedure generate_rtti(p:tsym);
  326. procedure generate_inittable(p:tsym);
  327. implementation
  328. uses
  329. {$ifdef Delphi}
  330. sysutils,
  331. {$else Delphi}
  332. strings,
  333. {$endif Delphi}
  334. { global }
  335. verbose,
  336. { target }
  337. systems,
  338. { symtable }
  339. defutil,defcmp,symtable,
  340. {$ifdef GDB}
  341. gdb,
  342. {$endif GDB}
  343. { tree }
  344. node,
  345. { aasm }
  346. aasmcpu,
  347. { module }
  348. fmodule,
  349. { codegen }
  350. paramgr,cresstr,
  351. procinfo
  352. ;
  353. {****************************************************************************
  354. Helpers
  355. ****************************************************************************}
  356. {****************************************************************************
  357. TSYM (base for all symtypes)
  358. ****************************************************************************}
  359. constructor tstoredsym.create(const n : string);
  360. begin
  361. inherited create(n);
  362. symoptions:=current_object_option;
  363. {$ifdef GDB}
  364. isstabwritten := false;
  365. {$endif GDB}
  366. fileinfo:=akttokenpos;
  367. defref:=nil;
  368. refs:=0;
  369. lastwritten:=nil;
  370. refcount:=0;
  371. if (cs_browser in aktmoduleswitches) and make_ref then
  372. begin
  373. defref:=tref.create(defref,@akttokenpos);
  374. inc(refcount);
  375. end;
  376. lastref:=defref;
  377. _mangledname:=nil;
  378. end;
  379. constructor tstoredsym.loadsym(ppufile:tcompilerppufile);
  380. var
  381. s : string;
  382. nr : word;
  383. begin
  384. nr:=ppufile.getword;
  385. s:=ppufile.getstring;
  386. inherited create(s);
  387. { force the correct indexnr. must be after create! }
  388. indexnr:=nr;
  389. ppufile.getposinfo(fileinfo);
  390. ppufile.getsmallset(symoptions);
  391. lastref:=nil;
  392. defref:=nil;
  393. refs:=0;
  394. lastwritten:=nil;
  395. refcount:=0;
  396. _mangledname:=nil;
  397. {$ifdef GDB}
  398. isstabwritten := false;
  399. {$endif GDB}
  400. end;
  401. procedure tstoredsym.deref;
  402. begin
  403. end;
  404. procedure tstoredsym.load_references(ppufile:tcompilerppufile;locals:boolean);
  405. var
  406. pos : tfileposinfo;
  407. move_last : boolean;
  408. begin
  409. move_last:=lastwritten=lastref;
  410. while (not ppufile.endofentry) do
  411. begin
  412. ppufile.getposinfo(pos);
  413. inc(refcount);
  414. lastref:=tref.create(lastref,@pos);
  415. lastref.is_written:=true;
  416. if refcount=1 then
  417. defref:=lastref;
  418. end;
  419. if move_last then
  420. lastwritten:=lastref;
  421. end;
  422. { big problem here :
  423. wrong refs were written because of
  424. interface parsing of other units PM
  425. moduleindex must be checked !! }
  426. function tstoredsym.write_references(ppufile:tcompilerppufile;locals:boolean):boolean;
  427. var
  428. d : tderef;
  429. ref : tref;
  430. symref_written,move_last : boolean;
  431. begin
  432. write_references:=false;
  433. if lastwritten=lastref then
  434. exit;
  435. { should we update lastref }
  436. move_last:=true;
  437. symref_written:=false;
  438. { write symbol refs }
  439. d.reset;
  440. if assigned(lastwritten) then
  441. ref:=lastwritten
  442. else
  443. ref:=defref;
  444. while assigned(ref) do
  445. begin
  446. if ref.moduleindex=current_module.unit_index then
  447. begin
  448. { write address to this symbol }
  449. if not symref_written then
  450. begin
  451. ppufile.putderef(self,d);
  452. symref_written:=true;
  453. end;
  454. ppufile.putposinfo(ref.posinfo);
  455. ref.is_written:=true;
  456. if move_last then
  457. lastwritten:=ref;
  458. end
  459. else if not ref.is_written then
  460. move_last:=false
  461. else if move_last then
  462. lastwritten:=ref;
  463. ref:=ref.nextref;
  464. end;
  465. if symref_written then
  466. ppufile.writeentry(ibsymref);
  467. write_references:=symref_written;
  468. end;
  469. destructor tstoredsym.destroy;
  470. begin
  471. if assigned(_mangledname) then
  472. begin
  473. {$ifdef MEMDEBUG}
  474. memmanglednames.start;
  475. {$endif MEMDEBUG}
  476. stringdispose(_mangledname);
  477. {$ifdef MEMDEBUG}
  478. memmanglednames.stop;
  479. {$endif MEMDEBUG}
  480. end;
  481. if assigned(defref) then
  482. begin
  483. {$ifdef MEMDEBUG}
  484. membrowser.start;
  485. {$endif MEMDEBUG}
  486. defref.freechain;
  487. defref.free;
  488. {$ifdef MEMDEBUG}
  489. membrowser.stop;
  490. {$endif MEMDEBUG}
  491. end;
  492. inherited destroy;
  493. end;
  494. procedure tstoredsym.writesym(ppufile:tcompilerppufile);
  495. begin
  496. ppufile.putword(indexnr);
  497. ppufile.putstring(_realname^);
  498. ppufile.putposinfo(fileinfo);
  499. ppufile.putsmallset(symoptions);
  500. end;
  501. {$ifdef GDB}
  502. function tstoredsym.stabstring : pchar;
  503. begin
  504. stabstring:=strpnew('"'+name+'",'+tostr(N_LSYM)+',0,'+
  505. tostr(fileinfo.line)+',0');
  506. end;
  507. procedure tstoredsym.concatstabto(asmlist : taasmoutput);
  508. var
  509. stab_str : pchar;
  510. begin
  511. if not isstabwritten then
  512. begin
  513. stab_str := stabstring;
  514. if assigned(stab_str) then
  515. asmList.concat(Tai_stabs.Create(stab_str));
  516. isstabwritten:=true;
  517. end;
  518. end;
  519. {$endif GDB}
  520. function tstoredsym.is_visible_for_proc(currprocdef:tprocdef):boolean;
  521. begin
  522. is_visible_for_proc:=false;
  523. { private symbols are allowed when we are in the same
  524. module as they are defined }
  525. if (sp_private in symoptions) and
  526. assigned(owner.defowner) and
  527. (owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  528. (owner.defowner.owner.unitid<>0) then
  529. exit;
  530. { protected symbols are vissible in the module that defines them and
  531. also visible to related objects }
  532. if (sp_protected in symoptions) and
  533. (
  534. (
  535. assigned(owner.defowner) and
  536. (owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  537. (owner.defowner.owner.unitid<>0)
  538. ) and
  539. not(
  540. assigned(currprocdef) and
  541. assigned(currprocdef._class) and
  542. currprocdef._class.is_related(tobjectdef(owner.defowner))
  543. )
  544. ) then
  545. exit;
  546. is_visible_for_proc:=true;
  547. end;
  548. function tstoredsym.is_visible_for_object(currobjdef:tobjectdef):boolean;
  549. begin
  550. is_visible_for_object:=false;
  551. { private symbols are allowed when we are in the same
  552. module as they are defined }
  553. if (sp_private in symoptions) and
  554. assigned(owner.defowner) and
  555. (owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  556. (owner.defowner.owner.unitid<>0) then
  557. exit;
  558. { protected symbols are vissible in the module that defines them and
  559. also visible to related objects }
  560. if (sp_protected in symoptions) and
  561. (
  562. (
  563. assigned(owner.defowner) and
  564. (owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  565. (owner.defowner.owner.unitid<>0)
  566. ) and
  567. not(
  568. assigned(currobjdef) and
  569. currobjdef.is_related(tobjectdef(owner.defowner))
  570. )
  571. ) then
  572. exit;
  573. is_visible_for_object:=true;
  574. end;
  575. function tstoredsym.mangledname : string;
  576. begin
  577. if not assigned(_mangledname) then
  578. begin
  579. generate_mangledname;
  580. if not assigned(_mangledname) then
  581. internalerror(200204171);
  582. end;
  583. mangledname:=_mangledname^
  584. end;
  585. {****************************************************************************
  586. TLABELSYM
  587. ****************************************************************************}
  588. constructor tlabelsym.create(const n : string; l : tasmlabel);
  589. begin
  590. inherited create(n);
  591. typ:=labelsym;
  592. lab:=l;
  593. used:=false;
  594. defined:=false;
  595. code:=nil;
  596. end;
  597. constructor tlabelsym.ppuload(ppufile:tcompilerppufile);
  598. begin
  599. inherited loadsym(ppufile);
  600. typ:=labelsym;
  601. { this is all dummy
  602. it is only used for local browsing }
  603. lab:=nil;
  604. code:=nil;
  605. used:=false;
  606. defined:=true;
  607. end;
  608. destructor tlabelsym.destroy;
  609. begin
  610. inherited destroy;
  611. end;
  612. procedure tlabelsym.generate_mangledname;
  613. begin
  614. _mangledname:=stringdup(lab.name);
  615. end;
  616. procedure tlabelsym.ppuwrite(ppufile:tcompilerppufile);
  617. begin
  618. if owner.symtabletype=globalsymtable then
  619. Message(sym_e_ill_label_decl)
  620. else
  621. begin
  622. inherited writesym(ppufile);
  623. ppufile.writeentry(iblabelsym);
  624. end;
  625. end;
  626. {****************************************************************************
  627. TUNITSYM
  628. ****************************************************************************}
  629. constructor tunitsym.create(const n : string;ref : tsymtable);
  630. var
  631. old_make_ref : boolean;
  632. begin
  633. old_make_ref:=make_ref;
  634. make_ref:=false;
  635. inherited create(n);
  636. make_ref:=old_make_ref;
  637. typ:=unitsym;
  638. unitsymtable:=ref;
  639. if assigned(ref) and
  640. (ref.symtabletype=globalsymtable) then
  641. begin
  642. prevsym:=tglobalsymtable(ref).unitsym;
  643. tglobalsymtable(ref).unitsym:=self;
  644. end;
  645. end;
  646. constructor tunitsym.ppuload(ppufile:tcompilerppufile);
  647. begin
  648. inherited loadsym(ppufile);
  649. typ:=unitsym;
  650. unitsymtable:=nil;
  651. prevsym:=nil;
  652. refs:=0;
  653. end;
  654. { we need to remove it from the prevsym chain ! }
  655. procedure tunitsym.restoreunitsym;
  656. var pus,ppus : tunitsym;
  657. begin
  658. if assigned(unitsymtable) and
  659. (unitsymtable.symtabletype=globalsymtable) then
  660. begin
  661. ppus:=nil;
  662. pus:=tglobalsymtable(unitsymtable).unitsym;
  663. if pus=self then
  664. tglobalsymtable(unitsymtable).unitsym:=prevsym
  665. else while assigned(pus) do
  666. begin
  667. if pus=self then
  668. begin
  669. ppus.prevsym:=prevsym;
  670. break;
  671. end
  672. else
  673. begin
  674. ppus:=pus;
  675. pus:=ppus.prevsym;
  676. end;
  677. end;
  678. end;
  679. unitsymtable:=nil;
  680. prevsym:=nil;
  681. end;
  682. destructor tunitsym.destroy;
  683. begin
  684. restoreunitsym;
  685. inherited destroy;
  686. end;
  687. procedure tunitsym.ppuwrite(ppufile:tcompilerppufile);
  688. begin
  689. inherited writesym(ppufile);
  690. ppufile.writeentry(ibunitsym);
  691. end;
  692. {$ifdef GDB}
  693. procedure tunitsym.concatstabto(asmlist : taasmoutput);
  694. begin
  695. {Nothing to write to stabs !}
  696. end;
  697. {$endif GDB}
  698. {****************************************************************************
  699. TPROCSYM
  700. ****************************************************************************}
  701. constructor tprocsym.create(const n : string);
  702. begin
  703. inherited create(n);
  704. typ:=procsym;
  705. pdlistfirst:=nil;
  706. pdlistlast:=nil;
  707. owner:=nil;
  708. {$ifdef GDB}
  709. is_global:=false;
  710. {$endif GDB}
  711. overloadchecked:=false;
  712. overloadcount:=0;
  713. procdef_count:=0;
  714. end;
  715. constructor tprocsym.ppuload(ppufile:tcompilerppufile);
  716. var
  717. pdderef : tderef;
  718. i,n : longint;
  719. begin
  720. inherited loadsym(ppufile);
  721. typ:=procsym;
  722. pdlistfirst:=nil;
  723. pdlistlast:=nil;
  724. procdef_count:=0;
  725. n:=ppufile.getword;
  726. for i:=1to n do
  727. begin
  728. ppufile.getderef(pdderef);
  729. addprocdef_deref(pdderef);
  730. end;
  731. {$ifdef GDB}
  732. is_global:=false;
  733. {$endif GDB}
  734. overloadchecked:=false;
  735. overloadcount:=$ffff; { invalid, not used anymore }
  736. end;
  737. destructor tprocsym.destroy;
  738. var
  739. hp,p : pprocdeflist;
  740. begin
  741. p:=pdlistfirst;
  742. while assigned(p) do
  743. begin
  744. hp:=p^.next;
  745. dispose(p);
  746. p:=hp;
  747. end;
  748. inherited destroy;
  749. end;
  750. procedure tprocsym.ppuwrite(ppufile:tcompilerppufile);
  751. var
  752. p : pprocdeflist;
  753. n : word;
  754. begin
  755. inherited writesym(ppufile);
  756. { count procdefs }
  757. n:=0;
  758. p:=pdlistfirst;
  759. while assigned(p) do
  760. begin
  761. { only write the proc definitions that belong
  762. to this procsym and are in the global symtable }
  763. if (p^.def.procsym=self) and
  764. (p^.def.owner.symtabletype in [globalsymtable,objectsymtable]) then
  765. inc(n);
  766. p:=p^.next;
  767. end;
  768. ppufile.putword(n);
  769. { write procdefs }
  770. p:=pdlistfirst;
  771. while assigned(p) do
  772. begin
  773. { only write the proc definitions that belong
  774. to this procsym and are in the global symtable }
  775. if (p^.def.procsym=self) and
  776. (p^.def.owner.symtabletype in [globalsymtable,objectsymtable]) then
  777. ppufile.putderef(p^.def,p^.defderef);
  778. p:=p^.next;
  779. end;
  780. ppufile.writeentry(ibprocsym);
  781. end;
  782. procedure tprocsym.write_parameter_lists(skipdef:tprocdef);
  783. var
  784. p : pprocdeflist;
  785. begin
  786. p:=pdlistfirst;
  787. while assigned(p) do
  788. begin
  789. if p^.def<>skipdef then
  790. MessagePos1(p^.def.fileinfo,sym_h_param_list,p^.def.fullprocname(false));
  791. p:=p^.next;
  792. end;
  793. end;
  794. procedure tprocsym.check_forward;
  795. var
  796. p : pprocdeflist;
  797. begin
  798. p:=pdlistfirst;
  799. while assigned(p) do
  800. begin
  801. if (p^.def.procsym=self) and
  802. (p^.def.forwarddef) then
  803. begin
  804. MessagePos1(p^.def.fileinfo,sym_e_forward_not_resolved,p^.def.fullprocname(false));
  805. { Turn futher error messages off }
  806. p^.def.forwarddef:=false;
  807. end;
  808. p:=p^.next;
  809. end;
  810. end;
  811. procedure tprocsym.deref;
  812. var
  813. p : pprocdeflist;
  814. begin
  815. p:=pdlistfirst;
  816. while assigned(p) do
  817. begin
  818. p^.def:=tprocdef(p^.defderef.resolve);
  819. p:=p^.next;
  820. end;
  821. end;
  822. procedure tprocsym.addprocdef(p:tprocdef);
  823. var
  824. pd : pprocdeflist;
  825. begin
  826. new(pd);
  827. pd^.def:=p;
  828. pd^.defderef.reset;
  829. pd^.next:=nil;
  830. { Add at end of list to keep always
  831. a correct order, also after loading from ppu }
  832. if assigned(pdlistlast) then
  833. begin
  834. pdlistlast^.next:=pd;
  835. pdlistlast:=pd;
  836. end
  837. else
  838. begin
  839. pdlistfirst:=pd;
  840. pdlistlast:=pd;
  841. end;
  842. inc(procdef_count);
  843. end;
  844. procedure tprocsym.addprocdef_deref(const d:tderef);
  845. var
  846. pd : pprocdeflist;
  847. begin
  848. new(pd);
  849. pd^.def:=nil;
  850. pd^.defderef:=d;
  851. pd^.next:=nil;
  852. { Add at end of list to keep always
  853. a correct order, also after loading from ppu }
  854. if assigned(pdlistlast) then
  855. begin
  856. pdlistlast^.next:=pd;
  857. pdlistlast:=pd;
  858. end
  859. else
  860. begin
  861. pdlistfirst:=pd;
  862. pdlistlast:=pd;
  863. end;
  864. inc(procdef_count);
  865. end;
  866. function Tprocsym.getprocdef(nr:cardinal):Tprocdef;
  867. var
  868. i : cardinal;
  869. pd : pprocdeflist;
  870. begin
  871. pd:=pdlistfirst;
  872. for i:=2 to nr do
  873. begin
  874. if not assigned(pd) then
  875. internalerror(200209051);
  876. pd:=pd^.next;
  877. end;
  878. getprocdef:=pd^.def;
  879. end;
  880. procedure Tprocsym.add_para_match_to(Aprocsym:Tprocsym);
  881. var
  882. pd:pprocdeflist;
  883. begin
  884. pd:=pdlistfirst;
  885. while assigned(pd) do
  886. begin
  887. if Aprocsym.search_procdef_bypara(pd^.def.para,nil,false,true)=nil then
  888. Aprocsym.addprocdef(pd^.def);
  889. pd:=pd^.next;
  890. end;
  891. end;
  892. procedure Tprocsym.concat_procdefs_to(s:Tprocsym);
  893. var
  894. pd : pprocdeflist;
  895. begin
  896. pd:=pdlistfirst;
  897. while assigned(pd) do
  898. begin
  899. s.addprocdef(pd^.def);
  900. pd:=pd^.next;
  901. end;
  902. end;
  903. function Tprocsym.first_procdef:Tprocdef;
  904. begin
  905. if assigned(pdlistfirst) then
  906. first_procdef:=pdlistfirst^.def
  907. else
  908. first_procdef:=nil;
  909. end;
  910. function Tprocsym.last_procdef:Tprocdef;
  911. begin
  912. if assigned(pdlistlast) then
  913. last_procdef:=pdlistlast^.def
  914. else
  915. last_procdef:=nil;
  916. end;
  917. procedure Tprocsym.foreach_procdef_static(proc2call:Tprocdefcallback;arg:pointer);
  918. var
  919. p : pprocdeflist;
  920. begin
  921. p:=pdlistfirst;
  922. while assigned(p) do
  923. begin
  924. proc2call(p^.def,arg);
  925. p:=p^.next;
  926. end;
  927. end;
  928. function Tprocsym.search_procdef_nopara_boolret:Tprocdef;
  929. var
  930. p : pprocdeflist;
  931. begin
  932. search_procdef_nopara_boolret:=nil;
  933. p:=pdlistfirst;
  934. while p<>nil do
  935. begin
  936. if (p^.def.maxparacount=0) and
  937. is_boolean(p^.def.rettype.def) then
  938. begin
  939. search_procdef_nopara_boolret:=p^.def;
  940. break;
  941. end;
  942. p:=p^.next;
  943. end;
  944. end;
  945. function Tprocsym.search_procdef_bytype(pt:Tproctypeoption):Tprocdef;
  946. var
  947. p : pprocdeflist;
  948. begin
  949. search_procdef_bytype:=nil;
  950. p:=pdlistfirst;
  951. while p<>nil do
  952. begin
  953. if p^.def.proctypeoption=pt then
  954. begin
  955. search_procdef_bytype:=p^.def;
  956. break;
  957. end;
  958. p:=p^.next;
  959. end;
  960. end;
  961. function Tprocsym.search_procdef_bypara(params:Tlinkedlist;
  962. retdef:tdef;
  963. allowconvert,
  964. allowdefault:boolean):Tprocdef;
  965. var
  966. pd : pprocdeflist;
  967. eq : tequaltype;
  968. begin
  969. search_procdef_bypara:=nil;
  970. pd:=pdlistfirst;
  971. while assigned(pd) do
  972. begin
  973. if assigned(retdef) then
  974. eq:=compare_defs(retdef,pd^.def.rettype.def,nothingn)
  975. else
  976. eq:=te_equal;
  977. if (eq>=te_equal) or
  978. (allowconvert and (eq>te_incompatible)) then
  979. begin
  980. eq:=compare_paras(pd^.def.para,params,cp_value_equal_const,allowdefault,false);
  981. if (eq>=te_equal) or
  982. (allowconvert and (eq>te_incompatible)) then
  983. begin
  984. search_procdef_bypara:=pd^.def;
  985. break;
  986. end;
  987. end;
  988. pd:=pd^.next;
  989. end;
  990. end;
  991. function Tprocsym.search_procdef_byprocvardef(d:Tprocvardef):Tprocdef;
  992. var
  993. pd : pprocdeflist;
  994. eq,besteq : tequaltype;
  995. bestpd : tprocdef;
  996. begin
  997. { This function will return the pprocdef of pprocsym that
  998. is the best match for procvardef. When there are multiple
  999. matches it returns nil.}
  1000. search_procdef_byprocvardef:=nil;
  1001. bestpd:=nil;
  1002. besteq:=te_incompatible;
  1003. pd:=pdlistfirst;
  1004. while assigned(pd) do
  1005. begin
  1006. eq:=proc_to_procvar_equal(pd^.def,d,false);
  1007. if eq>=te_equal then
  1008. begin
  1009. { multiple procvars with the same equal level }
  1010. if assigned(bestpd) and
  1011. (besteq=eq) then
  1012. exit;
  1013. if eq>besteq then
  1014. begin
  1015. besteq:=eq;
  1016. bestpd:=pd^.def;
  1017. end;
  1018. end;
  1019. pd:=pd^.next;
  1020. end;
  1021. search_procdef_byprocvardef:=bestpd;
  1022. end;
  1023. function Tprocsym.search_procdef_unary_operator(firstpara:Tdef):Tprocdef;
  1024. var
  1025. pd : pprocdeflist;
  1026. currpara : tparaitem;
  1027. begin
  1028. search_procdef_unary_operator:=nil;
  1029. pd:=pdlistfirst;
  1030. while assigned(pd) do
  1031. begin
  1032. currpara:=tparaitem(pd^.def.para.first);
  1033. { ignore vs_hidden parameters }
  1034. while assigned(currpara) and (currpara.is_hidden) do
  1035. currpara:=tparaitem(currpara.next);
  1036. if assigned(currpara) then
  1037. begin
  1038. if (currpara.next=nil) and
  1039. equal_defs(currpara.paratype.def,firstpara) then
  1040. begin
  1041. search_procdef_unary_operator:=pd^.def;
  1042. break;
  1043. end;
  1044. end;
  1045. pd:=pd^.next;
  1046. end;
  1047. end;
  1048. function Tprocsym.search_procdef_assignment_operator(fromdef,todef:tdef):Tprocdef;
  1049. var
  1050. convtyp : tconverttype;
  1051. pd : pprocdeflist;
  1052. bestpd : tprocdef;
  1053. eq,
  1054. besteq : tequaltype;
  1055. hpd : tprocdef;
  1056. currpara : tparaitem;
  1057. begin
  1058. search_procdef_assignment_operator:=nil;
  1059. bestpd:=nil;
  1060. besteq:=te_incompatible;
  1061. pd:=pdlistfirst;
  1062. while assigned(pd) do
  1063. begin
  1064. if equal_defs(todef,pd^.def.rettype.def) then
  1065. begin
  1066. currpara:=Tparaitem(pd^.def.para.first);
  1067. { ignore vs_hidden parameters }
  1068. while assigned(currpara) and (currpara.is_hidden) do
  1069. currpara:=tparaitem(currpara.next);
  1070. if assigned(currpara) then
  1071. begin
  1072. eq:=compare_defs_ext(fromdef,currpara.paratype.def,
  1073. nothingn,false,false,convtyp,hpd);
  1074. if eq=te_exact then
  1075. begin
  1076. search_procdef_assignment_operator:=pd^.def;
  1077. exit;
  1078. end;
  1079. if eq>besteq then
  1080. begin
  1081. bestpd:=pd^.def;
  1082. besteq:=eq;
  1083. end;
  1084. end;
  1085. end;
  1086. pd:=pd^.next;
  1087. end;
  1088. search_procdef_assignment_operator:=bestpd;
  1089. end;
  1090. function Tprocsym.search_procdef_binary_operator(def1,def2:tdef):Tprocdef;
  1091. var
  1092. convtyp : tconverttype;
  1093. pd : pprocdeflist;
  1094. bestpd : tprocdef;
  1095. eq1,eq2 : tequaltype;
  1096. eqlev,
  1097. bestlev : byte;
  1098. hpd : tprocdef;
  1099. nextpara,
  1100. currpara : tparaitem;
  1101. begin
  1102. search_procdef_binary_operator:=nil;
  1103. bestpd:=nil;
  1104. bestlev:=0;
  1105. pd:=pdlistfirst;
  1106. while assigned(pd) do
  1107. begin
  1108. currpara:=Tparaitem(pd^.def.para.first);
  1109. { ignore vs_hidden parameters }
  1110. while assigned(currpara) and (currpara.is_hidden) do
  1111. currpara:=tparaitem(currpara.next);
  1112. if assigned(currpara) then
  1113. begin
  1114. { Compare def1 with the first para }
  1115. eq1:=compare_defs_ext(def1,currpara.paratype.def,
  1116. nothingn,false,false,convtyp,hpd);
  1117. if eq1<>te_incompatible then
  1118. begin
  1119. { Ignore vs_hidden parameters }
  1120. repeat
  1121. currpara:=tparaitem(currpara.next);
  1122. until (not assigned(currpara)) or (not currpara.is_hidden);
  1123. if assigned(currpara) then
  1124. begin
  1125. { Ignore vs_hidden parameters }
  1126. nextpara:=currpara;
  1127. repeat
  1128. nextpara:=tparaitem(nextpara.next);
  1129. until (not assigned(nextpara)) or (not nextpara.is_hidden);
  1130. { There should be no other parameters left }
  1131. if not assigned(nextpara) then
  1132. begin
  1133. { Compare def2 with the last para }
  1134. eq2:=compare_defs_ext(def2,currpara.paratype.def,
  1135. nothingn,false,false,convtyp,hpd);
  1136. if (eq2<>te_incompatible) then
  1137. begin
  1138. { check level }
  1139. eqlev:=byte(eq1)+byte(eq2);
  1140. if eqlev=(byte(te_exact)+byte(te_exact)) then
  1141. begin
  1142. search_procdef_binary_operator:=pd^.def;
  1143. exit;
  1144. end;
  1145. if eqlev>bestlev then
  1146. begin
  1147. bestpd:=pd^.def;
  1148. bestlev:=eqlev;
  1149. end;
  1150. end;
  1151. end;
  1152. end;
  1153. end;
  1154. end;
  1155. pd:=pd^.next;
  1156. end;
  1157. search_procdef_binary_operator:=bestpd;
  1158. end;
  1159. function tprocsym.write_references(ppufile:tcompilerppufile;locals:boolean) : boolean;
  1160. var
  1161. p : pprocdeflist;
  1162. begin
  1163. write_references:=false;
  1164. if not inherited write_references(ppufile,locals) then
  1165. exit;
  1166. write_references:=true;
  1167. p:=pdlistfirst;
  1168. while assigned(p) do
  1169. begin
  1170. if (p^.def.procsym=self) then
  1171. p^.def.write_references(ppufile,locals);
  1172. p:=p^.next;
  1173. end;
  1174. end;
  1175. procedure tprocsym.unchain_overload;
  1176. var
  1177. p,hp : pprocdeflist;
  1178. begin
  1179. { remove all overloaded procdefs from the
  1180. procdeflist that are not in the current symtable }
  1181. p:=pdlistfirst;
  1182. { reset new lists }
  1183. pdlistfirst:=nil;
  1184. pdlistlast:=nil;
  1185. while assigned(p) do
  1186. begin
  1187. hp:=p^.next;
  1188. if (p^.def.procsym=self) then
  1189. begin
  1190. { keep, add to list }
  1191. if assigned(pdlistlast) then
  1192. begin
  1193. pdlistlast^.next:=p;
  1194. pdlistlast:=p;
  1195. end
  1196. else
  1197. begin
  1198. pdlistfirst:=p;
  1199. pdlistlast:=p;
  1200. end;
  1201. p^.next:=nil;
  1202. end
  1203. else
  1204. begin
  1205. { remove }
  1206. dispose(p);
  1207. dec(procdef_count);
  1208. end;
  1209. p:=hp;
  1210. end;
  1211. end;
  1212. {$ifdef GDB}
  1213. function tprocsym.stabstring : pchar;
  1214. begin
  1215. internalerror(200111171);
  1216. stabstring:=nil;
  1217. end;
  1218. procedure tprocsym.concatstabto(asmlist : taasmoutput);
  1219. begin
  1220. internalerror(200111172);
  1221. end;
  1222. {$endif GDB}
  1223. {****************************************************************************
  1224. TERRORSYM
  1225. ****************************************************************************}
  1226. constructor terrorsym.create;
  1227. begin
  1228. inherited create('');
  1229. typ:=errorsym;
  1230. end;
  1231. {****************************************************************************
  1232. TPROPERTYSYM
  1233. ****************************************************************************}
  1234. constructor tpropertysym.create(const n : string);
  1235. begin
  1236. inherited create(n);
  1237. typ:=propertysym;
  1238. propoptions:=[];
  1239. index:=0;
  1240. default:=0;
  1241. proptype.reset;
  1242. indextype.reset;
  1243. readaccess:=tsymlist.create;
  1244. writeaccess:=tsymlist.create;
  1245. storedaccess:=tsymlist.create;
  1246. end;
  1247. constructor tpropertysym.ppuload(ppufile:tcompilerppufile);
  1248. begin
  1249. inherited loadsym(ppufile);
  1250. typ:=propertysym;
  1251. ppufile.getsmallset(propoptions);
  1252. if (ppo_is_override in propoptions) then
  1253. begin
  1254. ppufile.getderef(propoverridenderef);
  1255. { we need to have these objects initialized }
  1256. readaccess:=tsymlist.create;
  1257. writeaccess:=tsymlist.create;
  1258. storedaccess:=tsymlist.create;
  1259. end
  1260. else
  1261. begin
  1262. ppufile.gettype(proptype);
  1263. index:=ppufile.getlongint;
  1264. default:=ppufile.getlongint;
  1265. ppufile.gettype(indextype);
  1266. readaccess:=ppufile.getsymlist;
  1267. writeaccess:=ppufile.getsymlist;
  1268. storedaccess:=ppufile.getsymlist;
  1269. end;
  1270. end;
  1271. destructor tpropertysym.destroy;
  1272. begin
  1273. readaccess.free;
  1274. writeaccess.free;
  1275. storedaccess.free;
  1276. inherited destroy;
  1277. end;
  1278. function tpropertysym.gettypedef:tdef;
  1279. begin
  1280. gettypedef:=proptype.def;
  1281. end;
  1282. procedure tpropertysym.deref;
  1283. begin
  1284. if (ppo_is_override in propoptions) then
  1285. begin
  1286. propoverriden:=tpropertysym(propoverridenderef.resolve);
  1287. dooverride(propoverriden);
  1288. end
  1289. else
  1290. begin
  1291. proptype.resolve;
  1292. indextype.resolve;
  1293. readaccess.resolve;
  1294. writeaccess.resolve;
  1295. storedaccess.resolve;
  1296. end;
  1297. end;
  1298. function tpropertysym.getsize : longint;
  1299. begin
  1300. getsize:=0;
  1301. end;
  1302. procedure tpropertysym.ppuwrite(ppufile:tcompilerppufile);
  1303. begin
  1304. inherited writesym(ppufile);
  1305. ppufile.putsmallset(propoptions);
  1306. if (ppo_is_override in propoptions) then
  1307. ppufile.putderef(propoverriden,propoverridenderef)
  1308. else
  1309. begin
  1310. ppufile.puttype(proptype);
  1311. ppufile.putlongint(index);
  1312. ppufile.putlongint(default);
  1313. ppufile.puttype(indextype);
  1314. ppufile.putsymlist(readaccess);
  1315. ppufile.putsymlist(writeaccess);
  1316. ppufile.putsymlist(storedaccess);
  1317. end;
  1318. ppufile.writeentry(ibpropertysym);
  1319. end;
  1320. procedure tpropertysym.dooverride(overriden:tpropertysym);
  1321. begin
  1322. propoverriden:=overriden;
  1323. proptype:=overriden.proptype;
  1324. propoptions:=overriden.propoptions+[ppo_is_override];
  1325. index:=overriden.index;
  1326. default:=overriden.default;
  1327. indextype:=overriden.indextype;
  1328. readaccess.free;
  1329. readaccess:=overriden.readaccess.getcopy;
  1330. writeaccess.free;
  1331. writeaccess:=overriden.writeaccess.getcopy;
  1332. storedaccess.free;
  1333. storedaccess:=overriden.storedaccess.getcopy;
  1334. end;
  1335. {$ifdef GDB}
  1336. function tpropertysym.stabstring : pchar;
  1337. begin
  1338. { !!!! don't know how to handle }
  1339. stabstring:=nil;
  1340. end;
  1341. procedure tpropertysym.concatstabto(asmlist : taasmoutput);
  1342. begin
  1343. { !!!! don't know how to handle }
  1344. end;
  1345. {$endif GDB}
  1346. {****************************************************************************
  1347. TABSOLUTESYM
  1348. ****************************************************************************}
  1349. constructor tabsolutesym.create(const n : string;const tt : ttype);
  1350. begin
  1351. inherited create(n,vs_value,tt);
  1352. typ:=absolutesym;
  1353. end;
  1354. constructor tabsolutesym.create_ref(const n : string;const tt : ttype;sym:tstoredsym);
  1355. begin
  1356. inherited create(n,vs_value,tt);
  1357. typ:=absolutesym;
  1358. ref:=sym;
  1359. end;
  1360. constructor tabsolutesym.ppuload(ppufile:tcompilerppufile);
  1361. begin
  1362. { Note: This needs to load everything of tvarsym.write }
  1363. inherited ppuload(ppufile);
  1364. { load absolute }
  1365. typ:=absolutesym;
  1366. ref:=nil;
  1367. fieldoffset:=0;
  1368. asmname:=nil;
  1369. abstyp:=absolutetyp(ppufile.getbyte);
  1370. absseg:=false;
  1371. case abstyp of
  1372. tovar :
  1373. asmname:=stringdup(ppufile.getstring);
  1374. toasm :
  1375. asmname:=stringdup(ppufile.getstring);
  1376. toaddr :
  1377. begin
  1378. fieldoffset:=ppufile.getlongint;
  1379. absseg:=boolean(ppufile.getbyte);
  1380. end;
  1381. end;
  1382. end;
  1383. procedure tabsolutesym.ppuwrite(ppufile:tcompilerppufile);
  1384. var
  1385. hvo : tvaroptions;
  1386. begin
  1387. { Note: This needs to write everything of tvarsym.write }
  1388. inherited writesym(ppufile);
  1389. ppufile.putbyte(byte(varspez));
  1390. ppufile.putlongint(fieldoffset);
  1391. { write only definition or definitionsym }
  1392. ppufile.puttype(vartype);
  1393. hvo:=varoptions-[vo_regable,vo_fpuregable];
  1394. ppufile.putsmallset(hvo);
  1395. ppufile.putbyte(byte(abstyp));
  1396. case abstyp of
  1397. tovar :
  1398. ppufile.putstring(ref.name);
  1399. toasm :
  1400. ppufile.putstring(asmname^);
  1401. toaddr :
  1402. begin
  1403. ppufile.putlongint(fieldoffset);
  1404. ppufile.putbyte(byte(absseg));
  1405. end;
  1406. end;
  1407. ppufile.writeentry(ibabsolutesym);
  1408. end;
  1409. procedure tabsolutesym.deref;
  1410. var
  1411. srsym : tsym;
  1412. srsymtable : tsymtable;
  1413. begin
  1414. { inheritance of varsym.deref ! }
  1415. vartype.resolve;
  1416. { own absolute deref }
  1417. if (abstyp=tovar) and (asmname<>nil) then
  1418. begin
  1419. { search previous loaded symtables }
  1420. searchsym(asmname^,srsym,srsymtable);
  1421. if not assigned(srsym) then
  1422. srsym:=searchsymonlyin(owner,asmname^);
  1423. if not assigned(srsym) then
  1424. srsym:=generrorsym;
  1425. ref:=tstoredsym(srsym);
  1426. stringdispose(asmname);
  1427. end;
  1428. end;
  1429. function tabsolutesym.mangledname : string;
  1430. begin
  1431. case abstyp of
  1432. tovar :
  1433. begin
  1434. case ref.typ of
  1435. varsym :
  1436. mangledname:=tvarsym(ref).mangledname;
  1437. else
  1438. internalerror(200111011);
  1439. end;
  1440. end;
  1441. toasm :
  1442. mangledname:=asmname^;
  1443. toaddr :
  1444. mangledname:='$'+tostr(fieldoffset);
  1445. else
  1446. internalerror(10002);
  1447. end;
  1448. end;
  1449. {$ifdef GDB}
  1450. procedure tabsolutesym.concatstabto(asmlist : taasmoutput);
  1451. begin
  1452. { I don't know how to handle this !! }
  1453. end;
  1454. {$endif GDB}
  1455. {****************************************************************************
  1456. TVARSYM
  1457. ****************************************************************************}
  1458. constructor tvarsym.create(const n : string;vsp:tvarspez;const tt : ttype);
  1459. begin
  1460. inherited create(n);
  1461. typ:=varsym;
  1462. vartype:=tt;
  1463. _mangledname:=nil;
  1464. varspez:=vsp;
  1465. fieldoffset:=0;
  1466. fillchar(localloc,sizeof(localloc),0);
  1467. highvarsym:=nil;
  1468. defaultconstsym:=nil;
  1469. refs:=0;
  1470. varstate:=vs_declared;
  1471. varoptions:=[];
  1472. end;
  1473. constructor tvarsym.create_dll(const n : string;vsp:tvarspez;const tt : ttype);
  1474. begin
  1475. tvarsym(self).create(n,vsp,tt);
  1476. include(varoptions,vo_is_dll_var);
  1477. end;
  1478. constructor tvarsym.create_C(const n,mangled : string;vsp:tvarspez;const tt : ttype);
  1479. begin
  1480. tvarsym(self).create(n,vsp,tt);
  1481. stringdispose(_mangledname);
  1482. _mangledname:=stringdup(mangled);
  1483. end;
  1484. constructor tvarsym.ppuload(ppufile:tcompilerppufile);
  1485. begin
  1486. inherited loadsym(ppufile);
  1487. typ:=varsym;
  1488. fillchar(localloc,sizeof(localloc),0);
  1489. refs := 0;
  1490. varstate:=vs_used;
  1491. varspez:=tvarspez(ppufile.getbyte);
  1492. fieldoffset:=ppufile.getlongint;
  1493. highvarsym:=nil;
  1494. defaultconstsym:=nil;
  1495. ppufile.gettype(_vartype);
  1496. ppufile.getsmallset(varoptions);
  1497. if (vo_is_C_var in varoptions) then
  1498. _mangledname:=stringdup(ppufile.getstring);
  1499. end;
  1500. destructor tvarsym.destroy;
  1501. begin
  1502. if assigned(notifications) then
  1503. notifications.destroy;
  1504. inherited destroy;
  1505. end;
  1506. procedure tvarsym.deref;
  1507. begin
  1508. vartype.resolve;
  1509. end;
  1510. procedure tvarsym.ppuwrite(ppufile:tcompilerppufile);
  1511. var
  1512. hvo : tvaroptions;
  1513. begin
  1514. inherited writesym(ppufile);
  1515. ppufile.putbyte(byte(varspez));
  1516. ppufile.putlongint(fieldoffset);
  1517. ppufile.puttype(vartype);
  1518. { symbols which are load are never candidates for a register,
  1519. turn off the regable }
  1520. hvo:=varoptions-[vo_regable,vo_fpuregable];
  1521. ppufile.putsmallset(hvo);
  1522. if (vo_is_C_var in varoptions) then
  1523. ppufile.putstring(mangledname);
  1524. ppufile.writeentry(ibvarsym);
  1525. end;
  1526. procedure tvarsym.generate_mangledname;
  1527. begin
  1528. _mangledname:=stringdup(mangledname_prefix('U',owner)+name);
  1529. end;
  1530. procedure tvarsym.set_mangledname(const s:string);
  1531. begin
  1532. stringdispose(_mangledname);
  1533. _mangledname:=stringdup(s);
  1534. end;
  1535. function tvarsym.getsize : longint;
  1536. begin
  1537. if assigned(vartype.def) then
  1538. getsize:=vartype.def.size
  1539. else
  1540. getsize:=0;
  1541. end;
  1542. function tvarsym.getvaluesize : longint;
  1543. begin
  1544. if assigned(vartype.def) and
  1545. (varspez=vs_value) and
  1546. ((vartype.def.deftype<>arraydef) or
  1547. tarraydef(vartype.def).isDynamicArray or
  1548. (tarraydef(vartype.def).highrange>=tarraydef(vartype.def).lowrange)) then
  1549. getvaluesize:=vartype.def.size
  1550. else
  1551. getvaluesize:=0;
  1552. end;
  1553. procedure Tvarsym.trigger_notifications(what:Tnotification_flag);
  1554. var n:Tnotification;
  1555. begin
  1556. if assigned(notifications) then
  1557. begin
  1558. n:=Tnotification(notifications.first);
  1559. while assigned(n) do
  1560. begin
  1561. if what in n.flags then
  1562. n.callback(what,self);
  1563. n:=Tnotification(n.next);
  1564. end;
  1565. end;
  1566. end;
  1567. function Tvarsym.register_notification(flags:Tnotification_flags;callback:
  1568. Tnotification_callback):cardinal;
  1569. var n:Tnotification;
  1570. begin
  1571. if not assigned(notifications) then
  1572. notifications:=Tlinkedlist.create;
  1573. n:=Tnotification.create(flags,callback);
  1574. register_notification:=n.id;
  1575. notifications.concat(n);
  1576. end;
  1577. procedure Tvarsym.unregister_notification(id:cardinal);
  1578. var n:Tnotification;
  1579. begin
  1580. if not assigned(notifications) then
  1581. internalerror(200212311)
  1582. else
  1583. begin
  1584. n:=Tnotification(notifications.first);
  1585. while assigned(n) do
  1586. begin
  1587. if n.id=id then
  1588. begin
  1589. notifications.remove(n);
  1590. n.destroy;
  1591. exit;
  1592. end;
  1593. n:=Tnotification(n.next);
  1594. end;
  1595. internalerror(200212311)
  1596. end;
  1597. end;
  1598. {$ifdef GDB}
  1599. function tvarsym.stabstring : pchar;
  1600. var
  1601. st : string;
  1602. threadvaroffset : string;
  1603. regidx : tregisterindex;
  1604. begin
  1605. stabstring:=nil;
  1606. st:=tstoreddef(vartype.def).numberstring;
  1607. if (vo_is_thread_var in varoptions) then
  1608. threadvaroffset:='+'+tostr(pointer_size)
  1609. else
  1610. threadvaroffset:='';
  1611. case owner.symtabletype of
  1612. objectsymtable :
  1613. begin
  1614. if (sp_static in symoptions) then
  1615. begin
  1616. if (cs_gdb_gsym in aktglobalswitches) then
  1617. st := 'G'+st
  1618. else
  1619. st := 'S'+st;
  1620. stabstring := strpnew('"'+owner.name^+'__'+name+':'+st+
  1621. '",'+
  1622. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)
  1623. +','+mangledname+threadvaroffset);
  1624. end;
  1625. end;
  1626. globalsymtable :
  1627. begin
  1628. { Here we used S instead of
  1629. because with G GDB doesn't look at the address field
  1630. but searches the same name or with a leading underscore
  1631. but these names don't exist in pascal !}
  1632. if (cs_gdb_gsym in aktglobalswitches) then
  1633. st := 'G'+st
  1634. else
  1635. st := 'S'+st;
  1636. stabstring := strpnew('"'+name+':'+st+'",'+
  1637. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+
  1638. ','+mangledname+threadvaroffset);
  1639. end;
  1640. staticsymtable :
  1641. begin
  1642. stabstring := strpnew('"'+name+':S'+st+'",'+
  1643. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+
  1644. ','+mangledname+threadvaroffset);
  1645. end;
  1646. parasymtable,
  1647. localsymtable :
  1648. begin
  1649. { There is no space allocated for not referenced locals }
  1650. if (owner.symtabletype=localsymtable) and
  1651. (refs=0) then
  1652. begin
  1653. exit;
  1654. end;
  1655. if (vo_is_C_var in varoptions) then
  1656. begin
  1657. stabstring := strpnew('"'+name+':S'+st+'",'+
  1658. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname);
  1659. exit;
  1660. end;
  1661. if (owner.symtabletype=parasymtable) and
  1662. paramanager.push_addr_param(varspez,vartype.def,tprocdef(owner.defowner).proccalloption) and
  1663. not(vo_has_local_copy in varoptions) then
  1664. st := 'v'+st { should be 'i' but 'i' doesn't work }
  1665. else
  1666. st := 'p'+st;
  1667. case localloc.loc of
  1668. LOC_REGISTER :
  1669. begin
  1670. regidx:=findreg_by_number(localloc.register);
  1671. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1672. { this is the register order for GDB}
  1673. stabstring:=strpnew('"'+name+':r'+st+'",'+
  1674. tostr(N_RSYM)+',0,'+
  1675. tostr(fileinfo.line)+','+tostr(regstabs_table[regidx]));
  1676. end;
  1677. LOC_REFERENCE :
  1678. begin
  1679. { offset to ebp => will not work if the framepointer is esp
  1680. so some optimizing will make things harder to debug }
  1681. stabstring := strpnew('"'+name+':'+st+'",'+
  1682. tostr(N_tsym)+',0,'+tostr(fileinfo.line)+','+
  1683. tostr(localloc.reference.offset));
  1684. end;
  1685. else
  1686. internalerror(2003091814);
  1687. end;
  1688. end;
  1689. else
  1690. stabstring := inherited stabstring;
  1691. end;
  1692. end;
  1693. procedure tvarsym.concatstabto(asmlist : taasmoutput);
  1694. var
  1695. regidx : tregisterindex;
  1696. stab_str : pchar;
  1697. c : char;
  1698. begin
  1699. if (owner.symtabletype=parasymtable) and
  1700. (copy(name,1,6)='hidden') then
  1701. exit;
  1702. if (vo_is_self in varoptions) then
  1703. begin
  1704. if localloc.loc<>LOC_REFERENCE then
  1705. internalerror(2003091815);
  1706. if (po_classmethod in current_procinfo.procdef.procoptions) or
  1707. (po_staticmethod in current_procinfo.procdef.procoptions) then
  1708. begin
  1709. asmlist.concat(Tai_stabs.Create(strpnew(
  1710. '"pvmt:p'+tstoreddef(pvmttype.def).numberstring+'",'+
  1711. tostr(N_tsym)+',0,0,'+tostr(localloc.reference.offset))));
  1712. end
  1713. else
  1714. begin
  1715. if not(is_class(current_procinfo.procdef._class)) then
  1716. c:='v'
  1717. else
  1718. c:='p';
  1719. asmlist.concat(Tai_stabs.Create(strpnew(
  1720. '"$t:'+c+current_procinfo.procdef._class.numberstring+'",'+
  1721. tostr(N_tsym)+',0,0,'+tostr(localloc.reference.offset))));
  1722. end;
  1723. end
  1724. else
  1725. if (localloc.loc=LOC_REGISTER) then
  1726. begin
  1727. regidx:=findreg_by_number(localloc.register);
  1728. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1729. { this is the register order for GDB}
  1730. stab_str:=strpnew('"'+name+':r'
  1731. +tstoreddef(vartype.def).numberstring+'",'+
  1732. tostr(N_RSYM)+',0,'+
  1733. tostr(fileinfo.line)+','+tostr(regstabs_table[regidx]));
  1734. asmList.concat(Tai_stabs.Create(stab_str));
  1735. end
  1736. else
  1737. inherited concatstabto(asmlist);
  1738. end;
  1739. {$endif GDB}
  1740. procedure tvarsym.setvartype(const newtype: ttype);
  1741. begin
  1742. _vartype := newtype;
  1743. { can we load the value into a register ? }
  1744. if not assigned(owner) or
  1745. (owner.symtabletype in [localsymtable,parasymtable]) then
  1746. begin
  1747. if tstoreddef(vartype.def).is_intregable then
  1748. include(varoptions,vo_regable)
  1749. else
  1750. exclude(varoptions,vo_regable);
  1751. if tstoreddef(vartype.def).is_fpuregable then
  1752. include(varoptions,vo_fpuregable)
  1753. else
  1754. exclude(varoptions,vo_fpuregable);
  1755. end;
  1756. end;
  1757. {****************************************************************************
  1758. TTYPEDCONSTSYM
  1759. *****************************************************************************}
  1760. constructor ttypedconstsym.create(const n : string;p : tdef;writable : boolean);
  1761. begin
  1762. inherited create(n);
  1763. typ:=typedconstsym;
  1764. typedconsttype.setdef(p);
  1765. is_writable:=writable;
  1766. end;
  1767. constructor ttypedconstsym.createtype(const n : string;const tt : ttype;writable : boolean);
  1768. begin
  1769. inherited create(n);
  1770. typ:=typedconstsym;
  1771. typedconsttype:=tt;
  1772. is_writable:=writable;
  1773. end;
  1774. constructor ttypedconstsym.ppuload(ppufile:tcompilerppufile);
  1775. begin
  1776. inherited loadsym(ppufile);
  1777. typ:=typedconstsym;
  1778. ppufile.gettype(typedconsttype);
  1779. is_writable:=boolean(ppufile.getbyte);
  1780. end;
  1781. destructor ttypedconstsym.destroy;
  1782. begin
  1783. inherited destroy;
  1784. end;
  1785. procedure ttypedconstsym.generate_mangledname;
  1786. begin
  1787. _mangledname:=stringdup(mangledname_prefix('TC',owner)+name);
  1788. end;
  1789. function ttypedconstsym.getsize : longint;
  1790. begin
  1791. if assigned(typedconsttype.def) then
  1792. getsize:=typedconsttype.def.size
  1793. else
  1794. getsize:=0;
  1795. end;
  1796. procedure ttypedconstsym.deref;
  1797. begin
  1798. typedconsttype.resolve;
  1799. end;
  1800. procedure ttypedconstsym.ppuwrite(ppufile:tcompilerppufile);
  1801. begin
  1802. inherited writesym(ppufile);
  1803. ppufile.puttype(typedconsttype);
  1804. ppufile.putbyte(byte(is_writable));
  1805. ppufile.writeentry(ibtypedconstsym);
  1806. end;
  1807. {$ifdef GDB}
  1808. function ttypedconstsym.stabstring : pchar;
  1809. var
  1810. st : char;
  1811. begin
  1812. if (cs_gdb_gsym in aktglobalswitches) and (owner.symtabletype=globalsymtable) then
  1813. st := 'G'
  1814. else
  1815. st := 'S';
  1816. stabstring := strpnew('"'+name+':'+st+
  1817. tstoreddef(typedconsttype.def).numberstring+'",'+tostr(n_STSYM)+',0,'+
  1818. tostr(fileinfo.line)+','+mangledname);
  1819. end;
  1820. {$endif GDB}
  1821. {****************************************************************************
  1822. TCONSTSYM
  1823. ****************************************************************************}
  1824. constructor tconstsym.create_ord(const n : string;t : tconsttyp;v : TConstExprInt);
  1825. begin
  1826. inherited create(n);
  1827. fillchar(value, sizeof(value), #0);
  1828. typ:=constsym;
  1829. consttyp:=t;
  1830. value.valueord:=v;
  1831. ResStrIndex:=0;
  1832. consttype.reset;
  1833. end;
  1834. constructor tconstsym.create_ord_typed(const n : string;t : tconsttyp;v : tconstexprint;const tt:ttype);
  1835. begin
  1836. inherited create(n);
  1837. fillchar(value, sizeof(value), #0);
  1838. typ:=constsym;
  1839. consttyp:=t;
  1840. value.valueord:=v;
  1841. ResStrIndex:=0;
  1842. consttype:=tt;
  1843. end;
  1844. constructor tconstsym.create_ordptr_typed(const n : string;t : tconsttyp;v : tconstptruint;const tt:ttype);
  1845. begin
  1846. inherited create(n);
  1847. fillchar(value, sizeof(value), #0);
  1848. typ:=constsym;
  1849. consttyp:=t;
  1850. value.valueordptr:=v;
  1851. ResStrIndex:=0;
  1852. consttype:=tt;
  1853. end;
  1854. constructor tconstsym.create_ptr(const n : string;t : tconsttyp;v : pointer);
  1855. begin
  1856. inherited create(n);
  1857. fillchar(value, sizeof(value), #0);
  1858. typ:=constsym;
  1859. consttyp:=t;
  1860. value.valueptr:=v;
  1861. ResStrIndex:=0;
  1862. consttype.reset;
  1863. end;
  1864. constructor tconstsym.create_ptr_typed(const n : string;t : tconsttyp;v : pointer;const tt:ttype);
  1865. begin
  1866. inherited create(n);
  1867. fillchar(value, sizeof(value), #0);
  1868. typ:=constsym;
  1869. consttyp:=t;
  1870. value.valueptr:=v;
  1871. ResStrIndex:=0;
  1872. consttype:=tt;
  1873. end;
  1874. constructor tconstsym.create_string(const n : string;t : tconsttyp;str:pchar;l:longint);
  1875. begin
  1876. inherited create(n);
  1877. fillchar(value, sizeof(value), #0);
  1878. typ:=constsym;
  1879. consttyp:=t;
  1880. value.valueptr:=str;
  1881. consttype.reset;
  1882. value.len:=l;
  1883. if t=constresourcestring then
  1884. ResStrIndex:=ResourceStrings.Register(name,pchar(value.valueptr),value.len);
  1885. end;
  1886. constructor tconstsym.ppuload(ppufile:tcompilerppufile);
  1887. var
  1888. pd : pbestreal;
  1889. ps : pnormalset;
  1890. pc : pchar;
  1891. begin
  1892. inherited loadsym(ppufile);
  1893. typ:=constsym;
  1894. consttype.reset;
  1895. consttyp:=tconsttyp(ppufile.getbyte);
  1896. fillchar(value, sizeof(value), #0);
  1897. case consttyp of
  1898. constint:
  1899. value.valueord:=ppufile.getexprint;
  1900. constwchar,
  1901. constbool,
  1902. constchar :
  1903. value.valueord:=ppufile.getlongint;
  1904. constord :
  1905. begin
  1906. ppufile.gettype(consttype);
  1907. value.valueord:=ppufile.getexprint;
  1908. end;
  1909. constpointer :
  1910. begin
  1911. ppufile.gettype(consttype);
  1912. value.valueordptr:=ppufile.getptruint;
  1913. end;
  1914. conststring,
  1915. constresourcestring :
  1916. begin
  1917. value.len:=ppufile.getlongint;
  1918. getmem(pc,value.len+1);
  1919. ppufile.getdata(pc^,value.len);
  1920. if consttyp=constresourcestring then
  1921. ResStrIndex:=ppufile.getlongint;
  1922. value.valueptr:=pc;
  1923. end;
  1924. constreal :
  1925. begin
  1926. new(pd);
  1927. pd^:=ppufile.getreal;
  1928. value.valueptr:=pd;
  1929. end;
  1930. constset :
  1931. begin
  1932. ppufile.gettype(consttype);
  1933. new(ps);
  1934. ppufile.getnormalset(ps^);
  1935. value.valueptr:=ps;
  1936. end;
  1937. constguid :
  1938. begin
  1939. new(pguid(value.valueptr));
  1940. ppufile.getdata(value.valueptr^,sizeof(tguid));
  1941. end;
  1942. constnil : ;
  1943. else
  1944. Message1(unit_f_ppu_invalid_entry,tostr(ord(consttyp)));
  1945. end;
  1946. end;
  1947. destructor tconstsym.destroy;
  1948. begin
  1949. case consttyp of
  1950. conststring,
  1951. constresourcestring :
  1952. freemem(pchar(value.valueptr),value.len+1);
  1953. constreal :
  1954. dispose(pbestreal(value.valueptr));
  1955. constset :
  1956. dispose(pnormalset(value.valueptr));
  1957. constguid :
  1958. dispose(pguid(value.valueptr));
  1959. end;
  1960. inherited destroy;
  1961. end;
  1962. function tconstsym.mangledname : string;
  1963. begin
  1964. mangledname:=name;
  1965. end;
  1966. procedure tconstsym.deref;
  1967. begin
  1968. if consttyp in [constord,constpointer,constset] then
  1969. consttype.resolve;
  1970. end;
  1971. procedure tconstsym.ppuwrite(ppufile:tcompilerppufile);
  1972. begin
  1973. inherited writesym(ppufile);
  1974. ppufile.putbyte(byte(consttyp));
  1975. case consttyp of
  1976. constnil : ;
  1977. constint:
  1978. ppufile.putexprint(value.valueord);
  1979. constbool,
  1980. constchar :
  1981. ppufile.putlongint(value.valueord);
  1982. constord :
  1983. begin
  1984. ppufile.puttype(consttype);
  1985. ppufile.putexprint(value.valueord);
  1986. end;
  1987. constpointer :
  1988. begin
  1989. ppufile.puttype(consttype);
  1990. ppufile.putptruint(value.valueordptr);
  1991. end;
  1992. conststring,
  1993. constresourcestring :
  1994. begin
  1995. ppufile.putlongint(value.len);
  1996. ppufile.putdata(pchar(value.valueptr)^,value.len);
  1997. if consttyp=constresourcestring then
  1998. ppufile.putlongint(ResStrIndex);
  1999. end;
  2000. constreal :
  2001. ppufile.putreal(pbestreal(value.valueptr)^);
  2002. constset :
  2003. begin
  2004. ppufile.puttype(consttype);
  2005. ppufile.putnormalset(value.valueptr^);
  2006. end;
  2007. constguid :
  2008. ppufile.putdata(value.valueptr^,sizeof(tguid));
  2009. else
  2010. internalerror(13);
  2011. end;
  2012. ppufile.writeentry(ibconstsym);
  2013. end;
  2014. {$ifdef GDB}
  2015. function tconstsym.stabstring : pchar;
  2016. var st : string;
  2017. begin
  2018. {even GDB v4.16 only now 'i' 'r' and 'e' !!!}
  2019. case consttyp of
  2020. conststring : begin
  2021. st := 's'''+strpas(pchar(value.valueptr))+'''';
  2022. end;
  2023. constbool,
  2024. constint,
  2025. constord,
  2026. constchar : st := 'i'+int64tostr(value.valueord);
  2027. constpointer :
  2028. st := 'i'+int64tostr(value.valueordptr);
  2029. constreal : begin
  2030. system.str(pbestreal(value.valueptr)^,st);
  2031. st := 'r'+st;
  2032. end;
  2033. { if we don't know just put zero !! }
  2034. else st:='i0';
  2035. {***SETCONST}
  2036. {constset:;} {*** I don't know what to do with a set.}
  2037. { sets are not recognized by GDB}
  2038. {***}
  2039. end;
  2040. stabstring := strpnew('"'+name+':c='+st+'",'+tostr(N_function)+',0,'+
  2041. tostr(fileinfo.line)+',0');
  2042. end;
  2043. procedure tconstsym.concatstabto(asmlist : taasmoutput);
  2044. begin
  2045. if consttyp <> conststring then
  2046. inherited concatstabto(asmlist);
  2047. end;
  2048. {$endif GDB}
  2049. {****************************************************************************
  2050. TENUMSYM
  2051. ****************************************************************************}
  2052. constructor tenumsym.create(const n : string;def : tenumdef;v : longint);
  2053. begin
  2054. inherited create(n);
  2055. typ:=enumsym;
  2056. definition:=def;
  2057. value:=v;
  2058. { check for jumps }
  2059. if v>def.max+1 then
  2060. def.has_jumps:=true;
  2061. { update low and high }
  2062. if def.min>v then
  2063. def.setmin(v);
  2064. if def.max<v then
  2065. def.setmax(v);
  2066. order;
  2067. end;
  2068. constructor tenumsym.ppuload(ppufile:tcompilerppufile);
  2069. begin
  2070. inherited loadsym(ppufile);
  2071. typ:=enumsym;
  2072. ppufile.getderef(definitionderef);
  2073. value:=ppufile.getlongint;
  2074. nextenum := Nil;
  2075. end;
  2076. procedure tenumsym.deref;
  2077. begin
  2078. definition:=tenumdef(definitionderef.resolve);
  2079. order;
  2080. end;
  2081. procedure tenumsym.order;
  2082. var
  2083. sym : tenumsym;
  2084. begin
  2085. sym := tenumsym(definition.firstenum);
  2086. if sym = nil then
  2087. begin
  2088. definition.firstenum := self;
  2089. nextenum := nil;
  2090. exit;
  2091. end;
  2092. { reorder the symbols in increasing value }
  2093. if value < sym.value then
  2094. begin
  2095. nextenum := sym;
  2096. definition.firstenum := self;
  2097. end
  2098. else
  2099. begin
  2100. while (sym.value <= value) and assigned(sym.nextenum) do
  2101. sym := sym.nextenum;
  2102. nextenum := sym.nextenum;
  2103. sym.nextenum := self;
  2104. end;
  2105. end;
  2106. procedure tenumsym.ppuwrite(ppufile:tcompilerppufile);
  2107. begin
  2108. inherited writesym(ppufile);
  2109. ppufile.putderef(definition,definitionderef);
  2110. ppufile.putlongint(value);
  2111. ppufile.writeentry(ibenumsym);
  2112. end;
  2113. {$ifdef GDB}
  2114. procedure tenumsym.concatstabto(asmlist : taasmoutput);
  2115. begin
  2116. {enum elements have no stab !}
  2117. end;
  2118. {$EndIf GDB}
  2119. {****************************************************************************
  2120. TTYPESYM
  2121. ****************************************************************************}
  2122. constructor ttypesym.create(const n : string;const tt : ttype);
  2123. begin
  2124. inherited create(n);
  2125. typ:=typesym;
  2126. restype:=tt;
  2127. {$ifdef GDB}
  2128. isusedinstab := false;
  2129. {$endif GDB}
  2130. { register the typesym for the definition }
  2131. if assigned(restype.def) and
  2132. (restype.def.deftype<>errordef) and
  2133. not(assigned(restype.def.typesym)) then
  2134. restype.def.typesym:=self;
  2135. end;
  2136. constructor ttypesym.ppuload(ppufile:tcompilerppufile);
  2137. begin
  2138. inherited loadsym(ppufile);
  2139. typ:=typesym;
  2140. {$ifdef GDB}
  2141. isusedinstab := false;
  2142. {$endif GDB}
  2143. ppufile.gettype(restype);
  2144. end;
  2145. function ttypesym.gettypedef:tdef;
  2146. begin
  2147. gettypedef:=restype.def;
  2148. end;
  2149. procedure ttypesym.deref;
  2150. begin
  2151. restype.resolve;
  2152. end;
  2153. procedure ttypesym.ppuwrite(ppufile:tcompilerppufile);
  2154. begin
  2155. inherited writesym(ppufile);
  2156. ppufile.puttype(restype);
  2157. ppufile.writeentry(ibtypesym);
  2158. end;
  2159. procedure ttypesym.load_references(ppufile:tcompilerppufile;locals:boolean);
  2160. begin
  2161. inherited load_references(ppufile,locals);
  2162. if (restype.def.deftype=recorddef) then
  2163. tstoredsymtable(trecorddef(restype.def).symtable).load_references(ppufile,locals);
  2164. if (restype.def.deftype=objectdef) then
  2165. tstoredsymtable(tobjectdef(restype.def).symtable).load_references(ppufile,locals);
  2166. end;
  2167. function ttypesym.write_references(ppufile:tcompilerppufile;locals:boolean):boolean;
  2168. var
  2169. d : tderef;
  2170. begin
  2171. d.reset;
  2172. if not inherited write_references(ppufile,locals) then
  2173. begin
  2174. { write address of this symbol if record or object
  2175. even if no real refs are there
  2176. because we need it for the symtable }
  2177. if (restype.def.deftype in [recorddef,objectdef]) then
  2178. begin
  2179. ppufile.putderef(self,d);
  2180. ppufile.writeentry(ibsymref);
  2181. end;
  2182. end;
  2183. write_references:=true;
  2184. if (restype.def.deftype=recorddef) then
  2185. tstoredsymtable(trecorddef(restype.def).symtable).write_references(ppufile,locals);
  2186. if (restype.def.deftype=objectdef) then
  2187. tstoredsymtable(tobjectdef(restype.def).symtable).write_references(ppufile,locals);
  2188. end;
  2189. {$ifdef GDB}
  2190. function ttypesym.stabstring : pchar;
  2191. var
  2192. stabchar : string[2];
  2193. short : string;
  2194. begin
  2195. if restype.def.deftype in tagtypes then
  2196. stabchar := 'Tt'
  2197. else
  2198. stabchar := 't';
  2199. short := '"'+name+':'+stabchar+tstoreddef(restype.def).numberstring
  2200. +'",'+tostr(N_LSYM)+',0,'+tostr(fileinfo.line)+',0';
  2201. stabstring := strpnew(short);
  2202. end;
  2203. procedure ttypesym.concatstabto(asmlist : taasmoutput);
  2204. begin
  2205. {not stabs for forward defs }
  2206. if assigned(restype.def) then
  2207. if (restype.def.typesym = self) then
  2208. tstoreddef(restype.def).concatstabto(asmlist)
  2209. else
  2210. inherited concatstabto(asmlist);
  2211. end;
  2212. {$endif GDB}
  2213. {****************************************************************************
  2214. TSYSSYM
  2215. ****************************************************************************}
  2216. constructor tsyssym.create(const n : string;l : longint);
  2217. begin
  2218. inherited create(n);
  2219. typ:=syssym;
  2220. number:=l;
  2221. end;
  2222. constructor tsyssym.ppuload(ppufile:tcompilerppufile);
  2223. begin
  2224. inherited loadsym(ppufile);
  2225. typ:=syssym;
  2226. number:=ppufile.getlongint;
  2227. end;
  2228. destructor tsyssym.destroy;
  2229. begin
  2230. inherited destroy;
  2231. end;
  2232. procedure tsyssym.ppuwrite(ppufile:tcompilerppufile);
  2233. begin
  2234. inherited writesym(ppufile);
  2235. ppufile.putlongint(number);
  2236. ppufile.writeentry(ibsyssym);
  2237. end;
  2238. {$ifdef GDB}
  2239. procedure tsyssym.concatstabto(asmlist : taasmoutput);
  2240. begin
  2241. end;
  2242. {$endif GDB}
  2243. {****************************************************************************
  2244. TRTTISYM
  2245. ****************************************************************************}
  2246. constructor trttisym.create(const n:string;rt:trttitype);
  2247. const
  2248. prefix : array[trttitype] of string[5]=('$rtti','$init');
  2249. begin
  2250. inherited create(prefix[rt]+n);
  2251. typ:=rttisym;
  2252. lab:=nil;
  2253. rttityp:=rt;
  2254. end;
  2255. constructor trttisym.ppuload(ppufile:tcompilerppufile);
  2256. begin
  2257. inherited loadsym(ppufile);
  2258. typ:=rttisym;
  2259. lab:=nil;
  2260. rttityp:=trttitype(ppufile.getbyte);
  2261. end;
  2262. procedure trttisym.ppuwrite(ppufile:tcompilerppufile);
  2263. begin
  2264. inherited writesym(ppufile);
  2265. ppufile.putbyte(byte(rttityp));
  2266. ppufile.writeentry(ibrttisym);
  2267. end;
  2268. function trttisym.mangledname : string;
  2269. const
  2270. prefix : array[trttitype] of string[5]=('RTTI_','INIT_');
  2271. var
  2272. s : string;
  2273. p : tsymtable;
  2274. begin
  2275. s:='';
  2276. p:=owner;
  2277. while assigned(p) and (p.symtabletype=localsymtable) do
  2278. begin
  2279. s:=s+'_'+p.defowner.name;
  2280. p:=p.defowner.owner;
  2281. end;
  2282. if not(p.symtabletype in [globalsymtable,staticsymtable]) then
  2283. internalerror(200108265);
  2284. mangledname:=prefix[rttityp]+p.name^+s+'$_'+Copy(name,5,255);
  2285. end;
  2286. function trttisym.get_label:tasmsymbol;
  2287. begin
  2288. { the label is always a global label }
  2289. if not assigned(lab) then
  2290. lab:=objectlibrary.newasmsymboldata(mangledname);
  2291. get_label:=lab;
  2292. end;
  2293. { persistent rtti generation }
  2294. procedure generate_rtti(p:tsym);
  2295. var
  2296. rsym : trttisym;
  2297. def : tstoreddef;
  2298. begin
  2299. { rtti can only be generated for classes that are always typesyms }
  2300. if not(p.typ=typesym) then
  2301. internalerror(200108261);
  2302. def:=tstoreddef(ttypesym(p).restype.def);
  2303. { only create rtti once for each definition }
  2304. if not(df_has_rttitable in def.defoptions) then
  2305. begin
  2306. { definition should be in the same symtable as the symbol }
  2307. if p.owner<>def.owner then
  2308. internalerror(200108262);
  2309. { create rttisym }
  2310. rsym:=trttisym.create(p.name,fullrtti);
  2311. p.owner.insert(rsym);
  2312. { register rttisym in definition }
  2313. include(def.defoptions,df_has_rttitable);
  2314. def.rttitablesym:=rsym;
  2315. { write rtti data }
  2316. def.write_child_rtti_data(fullrtti);
  2317. if (cs_create_smart in aktmoduleswitches) then
  2318. rttiList.concat(Tai_cut.Create);
  2319. rttilist.concat(tai_align.create(const_align(pointer_size)));
  2320. rttiList.concat(Tai_symbol.Create_global(rsym.get_label,0));
  2321. def.write_rtti_data(fullrtti);
  2322. rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
  2323. end;
  2324. end;
  2325. { persistent init table generation }
  2326. procedure generate_inittable(p:tsym);
  2327. var
  2328. rsym : trttisym;
  2329. def : tstoreddef;
  2330. begin
  2331. { anonymous types are also allowed for records that can be varsym }
  2332. case p.typ of
  2333. typesym :
  2334. def:=tstoreddef(ttypesym(p).restype.def);
  2335. varsym :
  2336. def:=tstoreddef(tvarsym(p).vartype.def);
  2337. else
  2338. internalerror(200108263);
  2339. end;
  2340. { only create inittable once for each definition }
  2341. if not(df_has_inittable in def.defoptions) then
  2342. begin
  2343. { definition should be in the same symtable as the symbol }
  2344. if p.owner<>def.owner then
  2345. internalerror(200108264);
  2346. { create rttisym }
  2347. rsym:=trttisym.create(p.name,initrtti);
  2348. p.owner.insert(rsym);
  2349. { register rttisym in definition }
  2350. include(def.defoptions,df_has_inittable);
  2351. def.inittablesym:=rsym;
  2352. { write inittable data }
  2353. def.write_child_rtti_data(initrtti);
  2354. if (cs_create_smart in aktmoduleswitches) then
  2355. rttiList.concat(Tai_cut.Create);
  2356. rttilist.concat(tai_align.create(const_align(pointer_size)));
  2357. rttiList.concat(Tai_symbol.Create_global(rsym.get_label,0));
  2358. def.write_rtti_data(initrtti);
  2359. rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
  2360. end;
  2361. end;
  2362. end.
  2363. {
  2364. $Log$
  2365. Revision 1.125 2003-10-08 19:19:45 peter
  2366. * set_varstate cleanup
  2367. Revision 1.124 2003/10/07 21:14:33 peter
  2368. * compare_paras() has a parameter to ignore hidden parameters
  2369. * cross unit overload searching ignores hidden parameters when
  2370. comparing parameter lists. Now function(string):string is
  2371. not overriden with procedure(string) which has the same visible
  2372. parameter list
  2373. Revision 1.123 2003/10/07 15:17:07 peter
  2374. * inline supported again, LOC_REFERENCEs are used to pass the
  2375. parameters
  2376. * inlineparasymtable,inlinelocalsymtable removed
  2377. * exitlabel inserting fixed
  2378. Revision 1.122 2003/10/01 20:34:49 peter
  2379. * procinfo unit contains tprocinfo
  2380. * cginfo renamed to cgbase
  2381. * moved cgmessage to verbose
  2382. * fixed ppc and sparc compiles
  2383. Revision 1.121 2003/09/25 21:25:37 peter
  2384. * has_local_copy gdb fix
  2385. Revision 1.120 2003/09/25 16:18:54 peter
  2386. * fixed stabs for globals,static
  2387. Revision 1.119 2003/09/23 17:56:06 peter
  2388. * locals and paras are allocated in the code generation
  2389. * tvarsym.localloc contains the location of para/local when
  2390. generating code for the current procedure
  2391. Revision 1.118 2003/09/16 16:17:01 peter
  2392. * varspez in calls to push_addr_param
  2393. Revision 1.117 2003/09/14 13:20:12 peter
  2394. * fix previous commit, also include objectsymtable
  2395. Revision 1.116 2003/09/14 12:58:00 peter
  2396. * support mulitple overloads in implementation, this is delphi
  2397. compatible
  2398. * procsym only stores the overloads available in the interface
  2399. Revision 1.115 2003/09/03 15:55:01 peter
  2400. * NEWRA branch merged
  2401. Revision 1.114 2003/09/03 11:18:37 florian
  2402. * fixed arm concatcopy
  2403. + arm support in the common compiler sources added
  2404. * moved some generic cg code around
  2405. + tfputype added
  2406. * ...
  2407. Revision 1.113.2.2 2003/08/29 17:28:59 peter
  2408. * next batch of updates
  2409. Revision 1.113.2.1 2003/08/27 19:55:54 peter
  2410. * first tregister patch
  2411. Revision 1.113 2003/08/20 20:29:06 daniel
  2412. * Some more R_NO changes
  2413. * Preventive code to loadref added
  2414. Revision 1.112 2003/07/05 22:41:59 peter
  2415. * check if owner.defowner is valid when checking private/protected
  2416. Revision 1.111 2003/07/04 22:41:41 pierre
  2417. * single threadvar debugging support
  2418. Revision 1.110 2003/06/13 21:19:31 peter
  2419. * current_procdef removed, use current_procinfo.procdef instead
  2420. Revision 1.109 2003/06/07 20:26:32 peter
  2421. * re-resolving added instead of reloading from ppu
  2422. * tderef object added to store deref info for resolving
  2423. Revision 1.108 2003/06/05 17:53:30 peter
  2424. * fix to compile without gdb
  2425. Revision 1.107 2003/06/02 22:59:17 florian
  2426. * absolutesyms aren't fpuregable either
  2427. Revision 1.106 2003/05/30 18:48:17 jonas
  2428. * fixed intregister bug
  2429. * fixed error in my previous commit: vo_(fpu)regable should only be set
  2430. for (inline)localsymtable and (inline)parasymtable entries
  2431. Revision 1.105 2003/05/30 13:35:10 jonas
  2432. * the vartype field of tvarsym is now a property, because is_XXXregable
  2433. must be updated when the vartype is changed
  2434. Revision 1.104 2003/05/15 18:58:53 peter
  2435. * removed selfpointer_offset, vmtpointer_offset
  2436. * tvarsym.adjusted_address
  2437. * address in localsymtable is now in the real direction
  2438. * removed some obsolete globals
  2439. Revision 1.103 2003/05/12 18:13:57 peter
  2440. * create rtti label using newasmsymboldata and update binding
  2441. only when calling tai_symbol.create
  2442. * tai_symbol.create_global added
  2443. Revision 1.102 2003/05/09 17:47:03 peter
  2444. * self moved to hidden parameter
  2445. * removed hdisposen,hnewn,selfn
  2446. Revision 1.101 2003/05/05 14:53:16 peter
  2447. * vs_hidden replaced by is_hidden boolean
  2448. Revision 1.100 2003/04/27 11:21:34 peter
  2449. * aktprocdef renamed to current_procinfo.procdef
  2450. * procinfo renamed to current_procinfo
  2451. * procinfo will now be stored in current_module so it can be
  2452. cleaned up properly
  2453. * gen_main_procsym changed to create_main_proc and release_main_proc
  2454. to also generate a tprocinfo structure
  2455. * fixed unit implicit initfinal
  2456. Revision 1.99 2003/04/27 10:03:18 jonas
  2457. * fixed stabs generation for local variables on systems where they have
  2458. a positive offset relative to the stack/framepointer
  2459. Revision 1.98 2003/04/27 07:29:51 peter
  2460. * current_procinfo.procdef cleanup, current_procdef is now always nil when parsing
  2461. a new procdef declaration
  2462. * aktprocsym removed
  2463. * lexlevel removed, use symtable.symtablelevel instead
  2464. * implicit init/final code uses the normal genentry/genexit
  2465. * funcret state checking updated for new funcret handling
  2466. Revision 1.97 2003/04/25 20:59:35 peter
  2467. * removed funcretn,funcretsym, function result is now in varsym
  2468. and aliases for result and function name are added using absolutesym
  2469. * vs_hidden parameter for funcret passed in parameter
  2470. * vs_hidden fixes
  2471. * writenode changed to printnode and released from extdebug
  2472. * -vp option added to generate a tree.log with the nodetree
  2473. * nicer printnode for statements, callnode
  2474. Revision 1.96 2003/04/23 13:13:58 peter
  2475. * fix operator overload search parameter order
  2476. Revision 1.95 2003/04/10 17:57:53 peter
  2477. * vs_hidden released
  2478. Revision 1.94 2003/03/17 15:54:22 peter
  2479. * store symoptions also for procdef
  2480. * check symoptions (private,public) when calculating possible
  2481. overload candidates
  2482. Revision 1.93 2003/01/15 01:44:33 peter
  2483. * merged methodpointer fixes from 1.0.x
  2484. Revision 1.92 2003/01/09 21:52:38 peter
  2485. * merged some verbosity options.
  2486. * V_LineInfo is a verbosity flag to include line info
  2487. Revision 1.91 2003/01/08 18:43:57 daniel
  2488. * Tregister changed into a record
  2489. Revision 1.90 2003/01/03 12:15:56 daniel
  2490. * Removed ifdefs around notifications
  2491. ifdefs around for loop optimizations remain
  2492. Revision 1.89 2003/01/02 11:14:02 michael
  2493. + Patch from peter to support initial values for local variables
  2494. Revision 1.88 2003/01/01 22:51:03 peter
  2495. * high value insertion changed so it works also when 2 parameters
  2496. are passed
  2497. Revision 1.87 2002/12/31 09:55:58 daniel
  2498. + Notification implementation complete
  2499. + Add for loop code optimization using notifications
  2500. results in 1.5-1.9% speed improvement in nestloop benchmark
  2501. Optimization incomplete, compiler does not cycle yet with
  2502. notifications enabled.
  2503. Revision 1.86 2002/12/30 22:44:53 daniel
  2504. * Some work on notifications
  2505. Revision 1.85 2002/12/27 18:07:44 peter
  2506. * fix crashes when searching symbols
  2507. Revision 1.84 2002/12/20 16:02:22 peter
  2508. * fix stupid copy&paste bug in binary operator search
  2509. Revision 1.83 2002/12/16 22:08:31 peter
  2510. * fix order of procdefs in procsym, procdefs are now always appended
  2511. so that loading from a ppu will keep the same order. This is
  2512. important for the generation of VMTs
  2513. Revision 1.82 2002/12/11 22:39:23 peter
  2514. * better error message when no operator is found for equal
  2515. Revision 1.81 2002/12/07 14:27:10 carl
  2516. * 3% memory optimization
  2517. * changed some types
  2518. + added type checking with different size for call node and for
  2519. parameters
  2520. Revision 1.80 2002/12/06 17:51:11 peter
  2521. * merged cdecl and array fixes
  2522. Revision 1.79 2002/11/27 20:04:10 peter
  2523. * tvarsym.get_push_size replaced by paramanager.push_size
  2524. Revision 1.78 2002/11/27 02:34:20 peter
  2525. * only find real equal procvars
  2526. Revision 1.77 2002/11/25 18:43:34 carl
  2527. - removed the invalid if <> checking (Delphi is strange on this)
  2528. + implemented abstract warning on instance creation of class with
  2529. abstract methods.
  2530. * some error message cleanups
  2531. Revision 1.76 2002/11/25 17:43:26 peter
  2532. * splitted defbase in defutil,symutil,defcmp
  2533. * merged isconvertable and is_equal into compare_defs(_ext)
  2534. * made operator search faster by walking the list only once
  2535. Revision 1.75 2002/11/23 22:50:09 carl
  2536. * some small speed optimizations
  2537. + added several new warnings/hints
  2538. Revision 1.74 2002/11/22 22:48:11 carl
  2539. * memory optimization with tconstsym (1.5%)
  2540. Revision 1.73 2002/11/18 17:31:59 peter
  2541. * pass proccalloption to ret_in_xxx and push_xxx functions
  2542. Revision 1.72 2002/11/17 16:31:57 carl
  2543. * memory optimization (3-4%) : cleanup of tai fields,
  2544. cleanup of tdef and tsym fields.
  2545. * make it work for m68k
  2546. Revision 1.71 2002/11/09 15:30:07 carl
  2547. + align RTTI tables
  2548. Revision 1.70 2002/10/13 21:33:37 peter
  2549. * give correct fileposition for undefined forward procs
  2550. Revision 1.69 2002/10/05 12:43:29 carl
  2551. * fixes for Delphi 6 compilation
  2552. (warning : Some features do not work under Delphi)
  2553. Revision 1.68 2002/10/05 00:52:20 peter
  2554. * split boolean check in two lines for easier debugging
  2555. Revision 1.67 2002/09/26 12:04:53 florian
  2556. + constsym with type=constguid can be written to ppu now,
  2557. fixes web bug 1820
  2558. Revision 1.66 2002/09/16 14:11:13 peter
  2559. * add argument to equal_paras() to support default values or not
  2560. Revision 1.65 2002/09/09 17:34:16 peter
  2561. * tdicationary.replace added to replace and item in a dictionary. This
  2562. is only allowed for the same name
  2563. * varsyms are inserted in symtable before the types are parsed. This
  2564. fixes the long standing "var longint : longint" bug
  2565. - consume_idlist and idstringlist removed. The loops are inserted
  2566. at the callers place and uses the symtable for duplicate id checking
  2567. Revision 1.64 2002/09/08 11:10:17 carl
  2568. * bugfix 2109 (bad imho, but only way)
  2569. Revision 1.63 2002/09/07 18:17:41 florian
  2570. + tvarsym.paraitem added
  2571. Revision 1.62 2002/09/07 15:25:10 peter
  2572. * old logs removed and tabs fixed
  2573. Revision 1.61 2002/09/05 19:29:45 peter
  2574. * memdebug enhancements
  2575. Revision 1.60 2002/09/05 14:51:42 peter
  2576. * internalerror instead of crash in getprocdef
  2577. Revision 1.59 2002/09/03 16:26:27 daniel
  2578. * Make Tprocdef.defs protected
  2579. Revision 1.58 2002/09/01 08:01:16 daniel
  2580. * Removed sets from Tcallnode.det_resulttype
  2581. + Added read/write notifications of variables. These will be usefull
  2582. for providing information for several optimizations. For example
  2583. the value of the loop variable of a for loop does matter is the
  2584. variable is read after the for loop, but if it's no longer used
  2585. or written, it doesn't matter and this can be used to optimize
  2586. the loop code generation.
  2587. Revision 1.57 2002/08/25 19:25:21 peter
  2588. * sym.insert_in_data removed
  2589. * symtable.insertvardata/insertconstdata added
  2590. * removed insert_in_data call from symtable.insert, it needs to be
  2591. called separatly. This allows to deref the address calculation
  2592. * procedures now calculate the parast addresses after the procedure
  2593. directives are parsed. This fixes the cdecl parast problem
  2594. * push_addr_param has an extra argument that specifies if cdecl is used
  2595. or not
  2596. Revision 1.56 2002/08/25 09:06:21 peter
  2597. * fixed loop in concat_procdefs
  2598. Revision 1.55 2002/08/20 16:54:40 peter
  2599. * write address of varsym always
  2600. Revision 1.54 2002/08/20 10:31:26 daniel
  2601. * Tcallnode.det_resulttype rewritten
  2602. Revision 1.53 2002/08/18 20:06:27 peter
  2603. * inlining is now also allowed in interface
  2604. * renamed write/load to ppuwrite/ppuload
  2605. * tnode storing in ppu
  2606. * nld,ncon,nbas are already updated for storing in ppu
  2607. Revision 1.52 2002/08/17 09:23:42 florian
  2608. * first part of procinfo rewrite
  2609. Revision 1.51 2002/08/16 14:24:59 carl
  2610. * issameref() to test if two references are the same (then emit no opcodes)
  2611. + ret_in_reg to replace ret_in_acc
  2612. (fix some register allocation bugs at the same time)
  2613. + save_std_register now has an extra parameter which is the
  2614. usedinproc registers
  2615. Revision 1.50 2002/08/13 21:40:57 florian
  2616. * more fixes for ppc calling conventions
  2617. Revision 1.49 2002/08/12 15:08:40 carl
  2618. + stab register indexes for powerpc (moved from gdb to cpubase)
  2619. + tprocessor enumeration moved to cpuinfo
  2620. + linker in target_info is now a class
  2621. * many many updates for m68k (will soon start to compile)
  2622. - removed some ifdef or correct them for correct cpu
  2623. Revision 1.48 2002/08/11 14:32:28 peter
  2624. * renamed current_library to objectlibrary
  2625. Revision 1.47 2002/08/11 13:24:14 peter
  2626. * saving of asmsymbols in ppu supported
  2627. * asmsymbollist global is removed and moved into a new class
  2628. tasmlibrarydata that will hold the info of a .a file which
  2629. corresponds with a single module. Added librarydata to tmodule
  2630. to keep the library info stored for the module. In the future the
  2631. objectfiles will also be stored to the tasmlibrarydata class
  2632. * all getlabel/newasmsymbol and friends are moved to the new class
  2633. Revision 1.46 2002/07/23 10:13:23 daniel
  2634. * Added important comment
  2635. Revision 1.45 2002/07/23 09:51:26 daniel
  2636. * Tried to make Tprocsym.defs protected. I didn't succeed but the cleanups
  2637. are worth comitting.
  2638. Revision 1.44 2002/07/20 17:45:29 daniel
  2639. * Register variables are now possible for global variables too. This is
  2640. important for small programs without procedures.
  2641. Revision 1.43 2002/07/20 11:57:58 florian
  2642. * types.pas renamed to defbase.pas because D6 contains a types
  2643. unit so this would conflicts if D6 programms are compiled
  2644. + Willamette/SSE2 instructions to assembler added
  2645. Revision 1.42 2002/07/11 14:41:31 florian
  2646. * start of the new generic parameter handling
  2647. }