symsym.pas 88 KB

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