symsym.pas 90 KB

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