symsym.pas 90 KB

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