symsym.pas 87 KB

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