symsym.pas 86 KB

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