symsym.pas 86 KB

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