symtable.pas 87 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
  4. This unit handles the symbol tables
  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 symtable;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. { common }
  23. cutils,cclasses,
  24. { global }
  25. cpuinfo,globtype,tokens,
  26. { symtable }
  27. symconst,symbase,symtype,symdef,symsym,
  28. { ppu }
  29. ppu,symppu,
  30. { assembler }
  31. aasmbase,aasmtai,aasmcpu,
  32. { cg }
  33. paramgr
  34. ;
  35. {****************************************************************************
  36. Symtable types
  37. ****************************************************************************}
  38. type
  39. tstoredsymtable = class(tsymtable)
  40. private
  41. b_needs_init_final : boolean;
  42. procedure _needs_init_final(p : tnamedindexitem;arg:pointer);
  43. procedure check_forward(sym : TNamedIndexItem;arg:pointer);
  44. procedure labeldefined(p : TNamedIndexItem;arg:pointer);
  45. procedure unitsymbolused(p : TNamedIndexItem;arg:pointer);
  46. procedure varsymbolused(p : TNamedIndexItem;arg:pointer);
  47. procedure TestPrivate(p : TNamedIndexItem;arg:pointer);
  48. procedure objectprivatesymbolused(p : TNamedIndexItem;arg:pointer);
  49. {$ifdef GDB}
  50. private
  51. procedure concatstab(p : TNamedIndexItem;arg:pointer);
  52. procedure resetstab(p : TNamedIndexItem;arg:pointer);
  53. procedure concattypestab(p : TNamedIndexItem;arg:pointer);
  54. {$endif}
  55. procedure unchain_overloads(p : TNamedIndexItem;arg:pointer);
  56. procedure loaddefs(ppufile:tcompilerppufile);
  57. procedure loadsyms(ppufile:tcompilerppufile);
  58. procedure writedefs(ppufile:tcompilerppufile);
  59. procedure writesyms(ppufile:tcompilerppufile);
  60. public
  61. { load/write }
  62. procedure ppuload(ppufile:tcompilerppufile);virtual;
  63. procedure ppuwrite(ppufile:tcompilerppufile);virtual;
  64. procedure load_references(ppufile:tcompilerppufile;locals:boolean);virtual;
  65. procedure write_references(ppufile:tcompilerppufile;locals:boolean);virtual;
  66. procedure deref;virtual;
  67. procedure derefimpl;virtual;
  68. procedure insert(sym : tsymentry);override;
  69. function speedsearch(const s : stringid;speedvalue : cardinal) : tsymentry;override;
  70. procedure allsymbolsused;
  71. procedure allprivatesused;
  72. procedure allunitsused;
  73. procedure check_forwards;
  74. procedure checklabels;
  75. function needs_init_final : boolean;
  76. procedure unchain_overloaded;
  77. procedure chainoperators;
  78. {$ifdef GDB}
  79. procedure concatstabto(asmlist : taasmoutput);virtual;
  80. function getnewtypecount : word; override;
  81. {$endif GDB}
  82. procedure testfordefaultproperty(p : TNamedIndexItem;arg:pointer);
  83. end;
  84. tabstractrecordsymtable = class(tstoredsymtable)
  85. public
  86. procedure ppuload(ppufile:tcompilerppufile);override;
  87. procedure ppuwrite(ppufile:tcompilerppufile);override;
  88. procedure load_references(ppufile:tcompilerppufile;locals:boolean);override;
  89. procedure write_references(ppufile:tcompilerppufile;locals:boolean);override;
  90. procedure insertvardata(sym : tsymentry);override;
  91. end;
  92. trecordsymtable = class(tabstractrecordsymtable)
  93. public
  94. constructor create;
  95. procedure insert_in(tsymt : tsymtable;offset : longint);
  96. end;
  97. tobjectsymtable = class(tabstractrecordsymtable)
  98. public
  99. constructor create(const n:string);
  100. procedure insert(sym : tsymentry);override;
  101. end;
  102. tabstractlocalsymtable = class(tstoredsymtable)
  103. public
  104. procedure ppuload(ppufile:tcompilerppufile);override;
  105. procedure ppuwrite(ppufile:tcompilerppufile);override;
  106. procedure load_references(ppufile:tcompilerppufile;locals:boolean);override;
  107. procedure write_references(ppufile:tcompilerppufile;locals:boolean);override;
  108. end;
  109. tlocalsymtable = class(tabstractlocalsymtable)
  110. public
  111. constructor create;
  112. procedure insert(sym : tsymentry);override;
  113. procedure insertvardata(sym : tsymentry);override;
  114. procedure insertconstdata(sym : tsymentry);override;
  115. end;
  116. tparasymtable = class(tabstractlocalsymtable)
  117. public
  118. constructor create;
  119. procedure insert(sym : tsymentry);override;
  120. procedure insertvardata(sym : tsymentry);override;
  121. end;
  122. tabstractunitsymtable = class(tstoredsymtable)
  123. public
  124. {$ifdef GDB}
  125. dbx_count : longint;
  126. prev_dbx_counter : plongint;
  127. dbx_count_ok : boolean;
  128. is_stab_written : boolean;
  129. {$endif GDB}
  130. constructor create(const n : string);
  131. {$ifdef GDB}
  132. procedure concattypestabto(asmlist : taasmoutput);
  133. {$endif GDB}
  134. procedure insertvardata(sym : tsymentry);override;
  135. procedure insertconstdata(sym : tsymentry);override;
  136. end;
  137. tglobalsymtable = class(tabstractunitsymtable)
  138. public
  139. unitsym : tunitsym;
  140. unittypecount : word;
  141. constructor create(const n : string);
  142. destructor destroy;override;
  143. procedure ppuload(ppufile:tcompilerppufile);override;
  144. procedure ppuwrite(ppufile:tcompilerppufile);override;
  145. procedure insert(sym : tsymentry);override;
  146. procedure insertvardata(sym : tsymentry);override;
  147. {$ifdef GDB}
  148. function getnewtypecount : word; override;
  149. {$endif}
  150. end;
  151. tstaticsymtable = class(tabstractunitsymtable)
  152. public
  153. constructor create(const n : string);
  154. procedure ppuload(ppufile:tcompilerppufile);override;
  155. procedure ppuwrite(ppufile:tcompilerppufile);override;
  156. procedure load_references(ppufile:tcompilerppufile;locals:boolean);override;
  157. procedure write_references(ppufile:tcompilerppufile;locals:boolean);override;
  158. procedure insert(sym : tsymentry);override;
  159. procedure insertvardata(sym : tsymentry);override;
  160. end;
  161. twithsymtable = class(tsymtable)
  162. direct_with : boolean;
  163. { in fact it is a tnode }
  164. withnode : pointer;
  165. { tnode to load of direct with var }
  166. { already usable before firstwith
  167. needed for firstpass of function parameters PM }
  168. withrefnode : pointer;
  169. use_count : longint;
  170. constructor create(aowner:tdef;asymsearch:TDictionary);
  171. destructor destroy;override;
  172. procedure clear;override;
  173. end;
  174. tstt_exceptsymtable = class(tsymtable)
  175. public
  176. constructor create;
  177. end;
  178. var
  179. constsymtable : tsymtable; { symtable were the constants can be inserted }
  180. systemunit : tglobalsymtable; { pointer to the system unit }
  181. lexlevel : byte; { level of code }
  182. { 1 for main procedure }
  183. { 2 for normal function or proc }
  184. { higher for locals }
  185. {****************************************************************************
  186. Functions
  187. ****************************************************************************}
  188. {*** Misc ***}
  189. procedure globaldef(const s : string;var t:ttype);
  190. function findunitsymtable(st:tsymtable):tsymtable;
  191. procedure duplicatesym(sym:tsym);
  192. {*** Search ***}
  193. function searchsym(const s : stringid;var srsym:tsym;var srsymtable:tsymtable):boolean;
  194. function searchsymonlyin(p : tsymtable;const s : stringid):tsym;
  195. function searchsym_in_class(classh:tobjectdef;const s : stringid):tsym;
  196. function searchsym_in_class_by_msgint(classh:tobjectdef;i:longint):tsym;
  197. function searchsym_in_class_by_msgstr(classh:tobjectdef;const s:string):tsym;
  198. function searchsystype(const s: stringid; var srsym: ttypesym): boolean;
  199. function searchsysvar(const s: stringid; var srsym: tvarsym; var symowner: tsymtable): boolean;
  200. function search_class_member(pd : tobjectdef;const s : string):tsym;
  201. {*** Object Helpers ***}
  202. function search_default_property(pd : tobjectdef) : tpropertysym;
  203. {*** symtable stack ***}
  204. procedure dellexlevel;
  205. procedure RestoreUnitSyms;
  206. {$ifdef DEBUG}
  207. procedure test_symtablestack;
  208. procedure list_symtablestack;
  209. {$endif DEBUG}
  210. {$ifdef UNITALIASES}
  211. type
  212. punit_alias = ^tunit_alias;
  213. tunit_alias = object(TNamedIndexItem)
  214. newname : pstring;
  215. constructor init(const n:string);
  216. destructor done;virtual;
  217. end;
  218. var
  219. unitaliases : pdictionary;
  220. procedure addunitalias(const n:string);
  221. function getunitalias(const n:string):string;
  222. {$endif UNITALIASES}
  223. {*** Init / Done ***}
  224. procedure InitSymtable;
  225. procedure DoneSymtable;
  226. type
  227. toverloaded_operators = array[NOTOKEN..last_overloaded] of tprocsym;
  228. var
  229. overloaded_operators : toverloaded_operators;
  230. { unequal is not equal}
  231. const
  232. overloaded_names : array [NOTOKEN..last_overloaded] of string[16] =
  233. ('error',
  234. 'plus','minus','star','slash','equal',
  235. 'greater','lower','greater_or_equal',
  236. 'lower_or_equal',
  237. 'sym_diff','starstar',
  238. 'as','is','in','or',
  239. 'and','div','mod','not','shl','shr','xor',
  240. 'assign');
  241. implementation
  242. uses
  243. { global }
  244. verbose,globals,
  245. { target }
  246. systems,
  247. { symtable }
  248. symutil,
  249. { module }
  250. fmodule,
  251. {$ifdef GDB}
  252. gdb,
  253. {$endif GDB}
  254. { codegen }
  255. cgbase,tgobj
  256. ;
  257. {*****************************************************************************
  258. TStoredSymtable
  259. *****************************************************************************}
  260. procedure tstoredsymtable.ppuload(ppufile:tcompilerppufile);
  261. begin
  262. { load definitions }
  263. loaddefs(ppufile);
  264. { load symbols }
  265. loadsyms(ppufile);
  266. end;
  267. procedure tstoredsymtable.ppuwrite(ppufile:tcompilerppufile);
  268. begin
  269. { write definitions }
  270. writedefs(ppufile);
  271. { write symbols }
  272. writesyms(ppufile);
  273. end;
  274. procedure tstoredsymtable.loaddefs(ppufile:tcompilerppufile);
  275. var
  276. hp : tdef;
  277. b : byte;
  278. begin
  279. { load start of definition section, which holds the amount of defs }
  280. if ppufile.readentry<>ibstartdefs then
  281. Message(unit_f_ppu_read_error);
  282. ppufile.getlongint;
  283. { read definitions }
  284. repeat
  285. b:=ppufile.readentry;
  286. case b of
  287. ibpointerdef : hp:=tpointerdef.ppuload(ppufile);
  288. ibarraydef : hp:=tarraydef.ppuload(ppufile);
  289. iborddef : hp:=torddef.ppuload(ppufile);
  290. ibfloatdef : hp:=tfloatdef.ppuload(ppufile);
  291. ibprocdef : hp:=tprocdef.ppuload(ppufile);
  292. ibshortstringdef : hp:=tstringdef.loadshort(ppufile);
  293. iblongstringdef : hp:=tstringdef.loadlong(ppufile);
  294. ibansistringdef : hp:=tstringdef.loadansi(ppufile);
  295. ibwidestringdef : hp:=tstringdef.loadwide(ppufile);
  296. ibrecorddef : hp:=trecorddef.ppuload(ppufile);
  297. ibobjectdef : hp:=tobjectdef.ppuload(ppufile);
  298. ibenumdef : hp:=tenumdef.ppuload(ppufile);
  299. ibsetdef : hp:=tsetdef.ppuload(ppufile);
  300. ibprocvardef : hp:=tprocvardef.ppuload(ppufile);
  301. ibfiledef : hp:=tfiledef.ppuload(ppufile);
  302. ibclassrefdef : hp:=tclassrefdef.ppuload(ppufile);
  303. ibformaldef : hp:=tformaldef.ppuload(ppufile);
  304. ibvariantdef : hp:=tvariantdef.ppuload(ppufile);
  305. ibenddefs : break;
  306. ibend : Message(unit_f_ppu_read_error);
  307. else
  308. Message1(unit_f_ppu_invalid_entry,tostr(b));
  309. end;
  310. hp.owner:=self;
  311. defindex.insert(hp);
  312. until false;
  313. end;
  314. procedure tstoredsymtable.loadsyms(ppufile:tcompilerppufile);
  315. var
  316. b : byte;
  317. sym : tsym;
  318. begin
  319. { load start of definition section, which holds the amount of defs }
  320. if ppufile.readentry<>ibstartsyms then
  321. Message(unit_f_ppu_read_error);
  322. { skip amount of symbols, not used currently }
  323. ppufile.getlongint;
  324. { load datasize,dataalignment of this symboltable }
  325. datasize:=ppufile.getlongint;
  326. dataalignment:=byte(ppufile.getlongint);
  327. { now read the symbols }
  328. repeat
  329. b:=ppufile.readentry;
  330. case b of
  331. ibtypesym : sym:=ttypesym.ppuload(ppufile);
  332. ibprocsym : sym:=tprocsym.ppuload(ppufile);
  333. ibconstsym : sym:=tconstsym.ppuload(ppufile);
  334. ibvarsym : sym:=tvarsym.ppuload(ppufile);
  335. ibabsolutesym : sym:=tabsolutesym.ppuload(ppufile);
  336. ibenumsym : sym:=tenumsym.ppuload(ppufile);
  337. ibtypedconstsym : sym:=ttypedconstsym.ppuload(ppufile);
  338. ibpropertysym : sym:=tpropertysym.ppuload(ppufile);
  339. ibunitsym : sym:=tunitsym.ppuload(ppufile);
  340. iblabelsym : sym:=tlabelsym.ppuload(ppufile);
  341. ibsyssym : sym:=tsyssym.ppuload(ppufile);
  342. ibrttisym : sym:=trttisym.ppuload(ppufile);
  343. ibendsyms : break;
  344. ibend : Message(unit_f_ppu_read_error);
  345. else
  346. Message1(unit_f_ppu_invalid_entry,tostr(b));
  347. end;
  348. sym.owner:=self;
  349. symindex.insert(sym);
  350. symsearch.insert(sym);
  351. until false;
  352. end;
  353. procedure tstoredsymtable.writedefs(ppufile:tcompilerppufile);
  354. var
  355. pd : tstoreddef;
  356. begin
  357. { each definition get a number, write then the amount of defs to the
  358. ibstartdef entry }
  359. ppufile.putlongint(defindex.count);
  360. ppufile.writeentry(ibstartdefs);
  361. { now write the definition }
  362. pd:=tstoreddef(defindex.first);
  363. while assigned(pd) do
  364. begin
  365. pd.ppuwrite(ppufile);
  366. pd:=tstoreddef(pd.indexnext);
  367. end;
  368. { write end of definitions }
  369. ppufile.writeentry(ibenddefs);
  370. end;
  371. procedure tstoredsymtable.writesyms(ppufile:tcompilerppufile);
  372. var
  373. pd : tstoredsym;
  374. begin
  375. { each definition get a number, write then the amount of syms and the
  376. datasize to the ibsymdef entry }
  377. ppufile.putlongint(symindex.count);
  378. ppufile.putlongint(datasize);
  379. ppufile.putlongint(dataalignment);
  380. ppufile.writeentry(ibstartsyms);
  381. { foreach is used to write all symbols }
  382. pd:=tstoredsym(symindex.first);
  383. while assigned(pd) do
  384. begin
  385. pd.ppuwrite(ppufile);
  386. pd:=tstoredsym(pd.indexnext);
  387. end;
  388. { end of symbols }
  389. ppufile.writeentry(ibendsyms);
  390. end;
  391. procedure tstoredsymtable.load_references(ppufile:tcompilerppufile;locals:boolean);
  392. var
  393. b : byte;
  394. sym : tstoredsym;
  395. prdef : tstoreddef;
  396. begin
  397. b:=ppufile.readentry;
  398. if b <> ibbeginsymtablebrowser then
  399. Message1(unit_f_ppu_invalid_entry,tostr(b));
  400. repeat
  401. b:=ppufile.readentry;
  402. case b of
  403. ibsymref :
  404. begin
  405. sym:=tstoredsym(ppufile.getderef);
  406. resolvesym(pointer(sym));
  407. if assigned(sym) then
  408. sym.load_references(ppufile,locals);
  409. end;
  410. ibdefref :
  411. begin
  412. prdef:=tstoreddef(ppufile.getderef);
  413. resolvedef(pointer(prdef));
  414. if assigned(prdef) then
  415. begin
  416. if prdef.deftype<>procdef then
  417. Message(unit_f_ppu_read_error);
  418. tprocdef(prdef).load_references(ppufile,locals);
  419. end;
  420. end;
  421. ibendsymtablebrowser :
  422. break;
  423. else
  424. Message1(unit_f_ppu_invalid_entry,tostr(b));
  425. end;
  426. until false;
  427. end;
  428. procedure tstoredsymtable.write_references(ppufile:tcompilerppufile;locals:boolean);
  429. var
  430. pd : tstoredsym;
  431. begin
  432. ppufile.writeentry(ibbeginsymtablebrowser);
  433. { write all symbols }
  434. pd:=tstoredsym(symindex.first);
  435. while assigned(pd) do
  436. begin
  437. pd.write_references(ppufile,locals);
  438. pd:=tstoredsym(pd.indexnext);
  439. end;
  440. ppufile.writeentry(ibendsymtablebrowser);
  441. end;
  442. procedure tstoredsymtable.deref;
  443. var
  444. hp : tdef;
  445. hs : tsym;
  446. begin
  447. { first deref the interface ttype symbols. This is needs
  448. to be done before the interface defs are derefed, because
  449. the interface defs can contain references to the type symbols
  450. which then already need to contain a resolved restype field (PFV) }
  451. hs:=tsym(symindex.first);
  452. while assigned(hs) do
  453. begin
  454. if hs.typ=typesym then
  455. hs.deref;
  456. hs:=tsym(hs.indexnext);
  457. end;
  458. { deref the interface definitions }
  459. hp:=tdef(defindex.first);
  460. while assigned(hp) do
  461. begin
  462. hp.deref;
  463. hp:=tdef(hp.indexnext);
  464. end;
  465. { deref the interface symbols }
  466. hs:=tsym(symindex.first);
  467. while assigned(hs) do
  468. begin
  469. if hs.typ<>typesym then
  470. hs.deref;
  471. hs:=tsym(hs.indexnext);
  472. end;
  473. end;
  474. procedure tstoredsymtable.derefimpl;
  475. var
  476. hp : tdef;
  477. begin
  478. { deref the implementation part of definitions }
  479. hp:=tdef(defindex.first);
  480. while assigned(hp) do
  481. begin
  482. hp.derefimpl;
  483. hp:=tdef(hp.indexnext);
  484. end;
  485. end;
  486. procedure tstoredsymtable.insert(sym:tsymentry);
  487. var
  488. hsym : tsym;
  489. begin
  490. { set owner and sym indexnb }
  491. sym.owner:=self;
  492. { check the current symtable }
  493. hsym:=tsym(search(sym.name));
  494. if assigned(hsym) then
  495. begin
  496. { in TP and Delphi you can have a local with the
  497. same name as the function, the function is then hidden for
  498. the user. (Under delphi it can still be accessed using result),
  499. but don't allow hiding of RESULT }
  500. if (m_duplicate_names in aktmodeswitches) and
  501. (hsym.typ=varsym) and
  502. (vo_is_funcret in tvarsym(hsym).varoptions) and
  503. not((m_result in aktmodeswitches) and
  504. (vo_is_result in tvarsym(hsym).varoptions)) then
  505. hsym.owner.rename(hsym.name,'hidden'+hsym.name)
  506. else
  507. begin
  508. DuplicateSym(hsym);
  509. exit;
  510. end;
  511. end;
  512. { register definition of typesym }
  513. if (sym.typ = typesym) and
  514. assigned(ttypesym(sym).restype.def) then
  515. begin
  516. if not(assigned(ttypesym(sym).restype.def.owner)) and
  517. (ttypesym(sym).restype.def.deftype<>errordef) then
  518. registerdef(ttypesym(sym).restype.def);
  519. {$ifdef GDB}
  520. if (cs_debuginfo in aktmoduleswitches) and assigned(debuglist) and
  521. (symtabletype in [globalsymtable,staticsymtable]) then
  522. begin
  523. ttypesym(sym).isusedinstab := true;
  524. {sym.concatstabto(debuglist);}
  525. end;
  526. {$endif GDB}
  527. end;
  528. { insert in index and search hash }
  529. symindex.insert(sym);
  530. symsearch.insert(sym);
  531. end;
  532. function tstoredsymtable.speedsearch(const s : stringid;speedvalue : cardinal) : tsymentry;
  533. var
  534. hp : tstoredsym;
  535. newref : tref;
  536. begin
  537. hp:=tstoredsym(inherited speedsearch(s,speedvalue));
  538. if assigned(hp) then
  539. begin
  540. { reject non static members in static procedures }
  541. if (symtabletype=objectsymtable) and
  542. not(sp_static in hp.symoptions) and
  543. allow_only_static then
  544. Message(sym_e_only_static_in_static);
  545. { unit uses count }
  546. if (unitid<>0) and
  547. (symtabletype = globalsymtable) and
  548. assigned(tglobalsymtable(self).unitsym) then
  549. inc(tglobalsymtable(self).unitsym.refs);
  550. {$ifdef GDB}
  551. { if it is a type, we need the stabs of this type
  552. this might be the cause of the class debug problems
  553. as TCHILDCLASS.Create did not generate appropriate
  554. stabs debug info if TCHILDCLASS wasn't used anywhere else PM }
  555. if (cs_debuginfo in aktmoduleswitches) and
  556. (hp.typ=typesym) and
  557. make_ref then
  558. begin
  559. if assigned(ttypesym(hp).restype.def) then
  560. tstoreddef(ttypesym(hp).restype.def).numberstring
  561. else
  562. ttypesym(hp).isusedinstab:=true;
  563. end;
  564. {$endif GDB}
  565. { unitsym are only loaded for browsing PM }
  566. { this was buggy anyway because we could use }
  567. { unitsyms from other units in _USES !! }
  568. {if (symtabletype=unitsymtable) and (hp.typ=unitsym) and
  569. assigned(current_module) and (current_module.globalsymtable<>.load) then
  570. hp:=nil;}
  571. if make_ref and (cs_browser in aktmoduleswitches) then
  572. begin
  573. newref:=tref.create(hp.lastref,@akttokenpos);
  574. { for symbols that are in tables without browser info or syssyms }
  575. if hp.refcount=0 then
  576. begin
  577. hp.defref:=newref;
  578. hp.lastref:=newref;
  579. end
  580. else
  581. if resolving_forward and assigned(hp.defref) then
  582. { put it as second reference }
  583. begin
  584. newref.nextref:=hp.defref.nextref;
  585. hp.defref.nextref:=newref;
  586. hp.lastref.nextref:=nil;
  587. end
  588. else
  589. hp.lastref:=newref;
  590. inc(hp.refcount);
  591. end;
  592. if make_ref then
  593. inc(hp.refs);
  594. end; { value was not found }
  595. speedsearch:=hp;
  596. end;
  597. {**************************************
  598. Callbacks
  599. **************************************}
  600. procedure TStoredSymtable.check_forward(sym : TNamedIndexItem;arg:pointer);
  601. begin
  602. if tsym(sym).typ=procsym then
  603. tprocsym(sym).check_forward
  604. { check also object method table }
  605. { we needn't to test the def list }
  606. { because each object has to have a type sym }
  607. else
  608. if (tsym(sym).typ=typesym) and
  609. assigned(ttypesym(sym).restype.def) and
  610. (ttypesym(sym).restype.def.deftype=objectdef) then
  611. tobjectdef(ttypesym(sym).restype.def).check_forwards;
  612. end;
  613. procedure TStoredSymtable.labeldefined(p : TNamedIndexItem;arg:pointer);
  614. begin
  615. if (tsym(p).typ=labelsym) and
  616. not(tlabelsym(p).defined) then
  617. begin
  618. if tlabelsym(p).used then
  619. Message1(sym_e_label_used_and_not_defined,tlabelsym(p).realname)
  620. else
  621. Message1(sym_w_label_not_defined,tlabelsym(p).realname);
  622. end;
  623. end;
  624. procedure TStoredSymtable.unitsymbolused(p : TNamedIndexItem;arg:pointer);
  625. begin
  626. if (tsym(p).typ=unitsym) and
  627. (tunitsym(p).refs=0) and
  628. { do not claim for unit name itself !! }
  629. assigned(tunitsym(p).unitsymtable) and
  630. (tunitsym(p).unitsymtable.symtabletype=globalsymtable) then
  631. MessagePos2(tsym(p).fileinfo,sym_n_unit_not_used,p.name,current_module.modulename^);
  632. end;
  633. procedure TStoredSymtable.varsymbolused(p : TNamedIndexItem;arg:pointer);
  634. begin
  635. if (tsym(p).typ=varsym) and
  636. ((tsym(p).owner.symtabletype in
  637. [parasymtable,localsymtable,objectsymtable,staticsymtable])) then
  638. begin
  639. { unused symbol should be reported only if no }
  640. { error is reported }
  641. { if the symbol is in a register it is used }
  642. { also don't count the value parameters which have local copies }
  643. { also don't claim for high param of open parameters (PM) }
  644. if (Errorcount<>0) or
  645. (copy(p.name,1,3)='val') or
  646. (copy(p.name,1,6)='hidden') or
  647. (copy(p.name,1,4)='high') then
  648. exit;
  649. if (tvarsym(p).refs=0) then
  650. begin
  651. if (tsym(p).owner.symtabletype=parasymtable) or (vo_is_local_copy in tvarsym(p).varoptions) then
  652. MessagePos1(tsym(p).fileinfo,sym_h_para_identifier_not_used,tsym(p).realname)
  653. else if (tsym(p).owner.symtabletype=objectsymtable) then
  654. MessagePos2(tsym(p).fileinfo,sym_n_private_identifier_not_used,tsym(p).owner.realname^,tsym(p).realname)
  655. else if p.name='result' then
  656. MessagePos(tsym(p).fileinfo,sym_w_function_result_not_set)
  657. else
  658. MessagePos1(tsym(p).fileinfo,sym_n_local_identifier_not_used,tsym(p).realname);
  659. end
  660. else if tvarsym(p).varstate=vs_assigned then
  661. begin
  662. if (tsym(p).owner.symtabletype=parasymtable) then
  663. begin
  664. if not(tvarsym(p).varspez in [vs_var,vs_out]) then
  665. MessagePos1(tsym(p).fileinfo,sym_h_para_identifier_only_set,tsym(p).realname)
  666. end
  667. else if (vo_is_local_copy in tvarsym(p).varoptions) then
  668. begin
  669. if not(tvarsym(p).varspez in [vs_var,vs_out]) then
  670. MessagePos1(tsym(p).fileinfo,sym_h_para_identifier_only_set,tsym(p).realname);
  671. end
  672. else if (tsym(p).owner.symtabletype=objectsymtable) then
  673. MessagePos2(tsym(p).fileinfo,sym_n_private_identifier_only_set,tsym(p).owner.realname^,tsym(p).realname)
  674. else if (tsym(p).owner.symtabletype<>parasymtable) then
  675. if not (vo_is_exported in tvarsym(p).varoptions) then
  676. MessagePos1(tsym(p).fileinfo,sym_n_local_identifier_only_set,tsym(p).realname);
  677. end;
  678. end
  679. else if ((tsym(p).owner.symtabletype in
  680. [objectsymtable,parasymtable,localsymtable,staticsymtable])) then
  681. begin
  682. if (Errorcount<>0) or
  683. (copy(p.name,1,3)='def') then
  684. exit;
  685. { do not claim for inherited private fields !! }
  686. if (tstoredsym(p).refs=0) and (tsym(p).owner.symtabletype=objectsymtable) then
  687. MessagePos2(tsym(p).fileinfo,sym_n_private_method_not_used,tsym(p).owner.realname^,tsym(p).realname)
  688. { units references are problematic }
  689. else if (tstoredsym(p).refs=0) and not(tsym(p).typ in [enumsym,unitsym]) then
  690. if (tsym(p).typ<>procsym) or not (tprocsym(p).is_global) or
  691. { all program functions are declared global
  692. but unused should still be signaled PM }
  693. ((tsym(p).owner.symtabletype=staticsymtable) and
  694. not current_module.is_unit) then
  695. MessagePos2(tsym(p).fileinfo,sym_h_local_symbol_not_used,SymTypeName[tsym(p).typ],tsym(p).realname);
  696. end;
  697. end;
  698. procedure TStoredSymtable.TestPrivate(p : TNamedIndexItem;arg:pointer);
  699. begin
  700. if sp_private in tsym(p).symoptions then
  701. varsymbolused(p,arg);
  702. end;
  703. procedure TStoredSymtable.objectprivatesymbolused(p : TNamedIndexItem;arg:pointer);
  704. begin
  705. {
  706. Don't test simple object aliases PM
  707. }
  708. if (tsym(p).typ=typesym) and
  709. (ttypesym(p).restype.def.deftype=objectdef) and
  710. (ttypesym(p).restype.def.typesym=tsym(p)) then
  711. tobjectdef(ttypesym(p).restype.def).symtable.foreach({$ifdef FPCPROCVAR}@{$endif}TestPrivate,nil);
  712. end;
  713. procedure tstoredsymtable.unchain_overloads(p : TNamedIndexItem;arg:pointer);
  714. begin
  715. if tsym(p).typ=procsym then
  716. tprocsym(p).unchain_overload;
  717. end;
  718. {$ifdef GDB}
  719. procedure TStoredSymtable.concatstab(p : TNamedIndexItem;arg:pointer);
  720. begin
  721. if tsym(p).typ <> procsym then
  722. tstoredsym(p).concatstabto(TAAsmOutput(arg));
  723. end;
  724. procedure TStoredSymtable.resetstab(p : TNamedIndexItem;arg:pointer);
  725. begin
  726. if tsym(p).typ <> procsym then
  727. tstoredsym(p).isstabwritten:=false;
  728. end;
  729. procedure TStoredSymtable.concattypestab(p : TNamedIndexItem;arg:pointer);
  730. begin
  731. if tsym(p).typ = typesym then
  732. begin
  733. tstoredsym(p).isstabwritten:=false;
  734. tstoredsym(p).concatstabto(TAAsmOutput(arg));
  735. end;
  736. end;
  737. function tstoredsymtable.getnewtypecount : word;
  738. begin
  739. getnewtypecount:=pglobaltypecount^;
  740. inc(pglobaltypecount^);
  741. end;
  742. {$endif GDB}
  743. procedure tstoredsymtable.chainoperators;
  744. var
  745. t : ttoken;
  746. srsym : tsym;
  747. srsymtable,
  748. storesymtablestack : tsymtable;
  749. begin
  750. storesymtablestack:=symtablestack;
  751. symtablestack:=self;
  752. make_ref:=false;
  753. for t:=first_overloaded to last_overloaded do
  754. begin
  755. overloaded_operators[t]:=nil;
  756. { each operator has a unique lowercased internal name PM }
  757. while assigned(symtablestack) do
  758. begin
  759. searchsym(overloaded_names[t],srsym,srsymtable);
  760. if not assigned(srsym) then
  761. begin
  762. if (t=_STARSTAR) then
  763. begin
  764. symtablestack:=systemunit;
  765. searchsym('POWER',srsym,srsymtable);
  766. end;
  767. end;
  768. if assigned(srsym) then
  769. begin
  770. if (srsym.typ<>procsym) then
  771. internalerror(12344321);
  772. { use this procsym as start ? }
  773. if not assigned(overloaded_operators[t]) then
  774. overloaded_operators[t]:=tprocsym(srsym)
  775. else
  776. { already got a procsym, only add defs of the current procsym }
  777. Tprocsym(srsym).concat_procdefs_to(overloaded_operators[t]);
  778. symtablestack:=srsym.owner.next;
  779. end
  780. else
  781. begin
  782. symtablestack:=nil;
  783. end;
  784. { search for same procsym in other units }
  785. end;
  786. symtablestack:=self;
  787. end;
  788. make_ref:=true;
  789. symtablestack:=storesymtablestack;
  790. end;
  791. {***********************************************
  792. Process all entries
  793. ***********************************************}
  794. { checks, if all procsyms and methods are defined }
  795. procedure tstoredsymtable.check_forwards;
  796. begin
  797. foreach({$ifdef FPCPROCVAR}@{$endif}check_forward,nil);
  798. end;
  799. procedure tstoredsymtable.checklabels;
  800. begin
  801. foreach({$ifdef FPCPROCVAR}@{$endif}labeldefined,nil);
  802. end;
  803. procedure tstoredsymtable.allunitsused;
  804. begin
  805. foreach({$ifdef FPCPROCVAR}@{$endif}unitsymbolused,nil);
  806. end;
  807. procedure tstoredsymtable.allsymbolsused;
  808. begin
  809. foreach({$ifdef FPCPROCVAR}@{$endif}varsymbolused,nil);
  810. end;
  811. procedure tstoredsymtable.allprivatesused;
  812. begin
  813. foreach({$ifdef FPCPROCVAR}@{$endif}objectprivatesymbolused,nil);
  814. end;
  815. procedure tstoredsymtable.unchain_overloaded;
  816. begin
  817. foreach({$ifdef FPCPROCVAR}@{$endif}unchain_overloads,nil);
  818. end;
  819. {$ifdef GDB}
  820. procedure tstoredsymtable.concatstabto(asmlist : taasmoutput);
  821. begin
  822. if symtabletype in [inlineparasymtable,inlinelocalsymtable] then
  823. foreach({$ifdef FPCPROCVAR}@{$endif}resetstab,nil);
  824. foreach({$ifdef FPCPROCVAR}@{$endif}concatstab,asmlist);
  825. end;
  826. {$endif}
  827. procedure TStoredSymtable._needs_init_final(p : tnamedindexitem;arg:pointer);
  828. begin
  829. if b_needs_init_final then
  830. exit;
  831. case tsym(p).typ of
  832. varsym :
  833. begin
  834. if not(is_class(tvarsym(p).vartype.def)) and
  835. tstoreddef(tvarsym(p).vartype.def).needs_inittable then
  836. b_needs_init_final:=true;
  837. end;
  838. typedconstsym :
  839. begin
  840. if ttypedconstsym(p).is_writable and
  841. tstoreddef(ttypedconstsym(p).typedconsttype.def).needs_inittable then
  842. b_needs_init_final:=true;
  843. end;
  844. end;
  845. end;
  846. { returns true, if p contains data which needs init/final code }
  847. function tstoredsymtable.needs_init_final : boolean;
  848. begin
  849. b_needs_init_final:=false;
  850. foreach({$ifdef FPCPROCVAR}@{$endif}_needs_init_final,nil);
  851. needs_init_final:=b_needs_init_final;
  852. end;
  853. {****************************************************************************
  854. TAbstractRecordSymtable
  855. ****************************************************************************}
  856. procedure tabstractrecordsymtable.ppuload(ppufile:tcompilerppufile);
  857. var
  858. storesymtable : tsymtable;
  859. begin
  860. storesymtable:=aktrecordsymtable;
  861. aktrecordsymtable:=self;
  862. inherited ppuload(ppufile);
  863. aktrecordsymtable:=storesymtable;
  864. end;
  865. procedure tabstractrecordsymtable.ppuwrite(ppufile:tcompilerppufile);
  866. var
  867. oldtyp : byte;
  868. storesymtable : tsymtable;
  869. begin
  870. storesymtable:=aktrecordsymtable;
  871. aktrecordsymtable:=self;
  872. oldtyp:=ppufile.entrytyp;
  873. ppufile.entrytyp:=subentryid;
  874. inherited ppuwrite(ppufile);
  875. ppufile.entrytyp:=oldtyp;
  876. aktrecordsymtable:=storesymtable;
  877. end;
  878. procedure tabstractrecordsymtable.load_references(ppufile:tcompilerppufile;locals:boolean);
  879. var
  880. storesymtable : tsymtable;
  881. begin
  882. storesymtable:=aktrecordsymtable;
  883. aktrecordsymtable:=self;
  884. inherited load_references(ppufile,locals);
  885. aktrecordsymtable:=storesymtable;
  886. end;
  887. procedure tabstractrecordsymtable.write_references(ppufile:tcompilerppufile;locals:boolean);
  888. var
  889. storesymtable : tsymtable;
  890. begin
  891. storesymtable:=aktrecordsymtable;
  892. aktrecordsymtable:=self;
  893. inherited write_references(ppufile,locals);
  894. aktrecordsymtable:=storesymtable;
  895. end;
  896. procedure tabstractrecordsymtable.insertvardata(sym : tsymentry);
  897. var
  898. l,varalign : longint;
  899. vardef : tdef;
  900. begin
  901. if sym.typ<>varsym then
  902. internalerror(200208251);
  903. l:=tvarsym(sym).getvaluesize;
  904. vardef:=tvarsym(sym).vartype.def;
  905. { this symbol can't be loaded to a register }
  906. exclude(tvarsym(sym).varoptions,vo_regable);
  907. exclude(tvarsym(sym).varoptions,vo_fpuregable);
  908. { get the alignment size }
  909. if (aktalignment.recordalignmax=-1) then
  910. begin
  911. varalign:=vardef.alignment;
  912. if (varalign>4) and
  913. ((varalign mod 4)<>0) and
  914. (vardef.deftype=arraydef) then
  915. Message1(sym_w_wrong_C_pack,vardef.typename);
  916. if varalign=0 then
  917. varalign:=l;
  918. if (dataalignment<aktalignment.maxCrecordalign) then
  919. begin
  920. if (varalign>16) and (dataalignment<32) then
  921. dataalignment:=32
  922. else if (varalign>12) and (dataalignment<16) then
  923. dataalignment:=16
  924. { 12 is needed for long double }
  925. else if (varalign>8) and (dataalignment<12) then
  926. dataalignment:=12
  927. else if (varalign>4) and (dataalignment<8) then
  928. dataalignment:=8
  929. else if (varalign>2) and (dataalignment<4) then
  930. dataalignment:=4
  931. else if (varalign>1) and (dataalignment<2) then
  932. dataalignment:=2;
  933. end;
  934. dataalignment:=min(dataalignment,aktalignment.maxCrecordalign);
  935. end
  936. else
  937. varalign:=vardef.alignment;
  938. if varalign=0 then
  939. varalign:=size_2_align(l);
  940. varalign:=used_align(varalign,aktalignment.recordalignmin,dataalignment);
  941. tvarsym(sym).address:=align(datasize,varalign);
  942. datasize:=tvarsym(sym).address+l;
  943. end;
  944. {****************************************************************************
  945. TRecordSymtable
  946. ****************************************************************************}
  947. constructor trecordsymtable.create;
  948. begin
  949. inherited create('');
  950. symtabletype:=recordsymtable;
  951. end;
  952. { this procedure is reserved for inserting case variant into
  953. a record symtable }
  954. { the offset is the location of the start of the variant
  955. and datasize and dataalignment corresponds to
  956. the complete size (see code in pdecl unit) PM }
  957. procedure trecordsymtable.insert_in(tsymt : tsymtable;offset : longint);
  958. var
  959. ps,nps : tvarsym;
  960. pd,npd : tdef;
  961. storesize,storealign : longint;
  962. begin
  963. storesize:=tsymt.datasize;
  964. storealign:=tsymt.dataalignment;
  965. tsymt.datasize:=offset;
  966. ps:=tvarsym(symindex.first);
  967. while assigned(ps) do
  968. begin
  969. nps:=tvarsym(ps.indexnext);
  970. { remove from current symtable }
  971. symindex.deleteindex(ps);
  972. ps.left:=nil;
  973. ps.right:=nil;
  974. { add to symt }
  975. ps.owner:=tsymt;
  976. tsymt.datasize:=ps.address+offset;
  977. tsymt.symindex.insert(ps);
  978. tsymt.symsearch.insert(ps);
  979. { update address }
  980. ps.address:=tsymt.datasize;
  981. { next }
  982. ps:=nps;
  983. end;
  984. pd:=tdef(defindex.first);
  985. while assigned(pd) do
  986. begin
  987. npd:=tdef(pd.indexnext);
  988. defindex.deleteindex(pd);
  989. pd.left:=nil;
  990. pd.right:=nil;
  991. tsymt.registerdef(pd);
  992. pd:=npd;
  993. end;
  994. tsymt.datasize:=storesize;
  995. tsymt.dataalignment:=storealign;
  996. end;
  997. {****************************************************************************
  998. TObjectSymtable
  999. ****************************************************************************}
  1000. constructor tobjectsymtable.create(const n:string);
  1001. begin
  1002. inherited create(n);
  1003. symtabletype:=objectsymtable;
  1004. end;
  1005. procedure tobjectsymtable.insert(sym:tsymentry);
  1006. var
  1007. hsym : tsym;
  1008. begin
  1009. { check for duplicate field id in inherited classes }
  1010. if (sym.typ=varsym) and
  1011. assigned(defowner) and
  1012. (
  1013. not(m_delphi in aktmodeswitches) or
  1014. is_object(tdef(defowner))
  1015. ) then
  1016. begin
  1017. { but private ids can be reused }
  1018. hsym:=search_class_member(tobjectdef(defowner),sym.name);
  1019. if assigned(hsym) and
  1020. tstoredsym(hsym).is_visible_for_object(tobjectdef(defowner)) then
  1021. begin
  1022. DuplicateSym(hsym);
  1023. exit;
  1024. end;
  1025. end;
  1026. inherited insert(sym);
  1027. end;
  1028. {****************************************************************************
  1029. TAbstractLocalSymtable
  1030. ****************************************************************************}
  1031. procedure tabstractlocalsymtable.ppuload(ppufile:tcompilerppufile);
  1032. var
  1033. storesymtable : tsymtable;
  1034. begin
  1035. storesymtable:=aktlocalsymtable;
  1036. aktlocalsymtable:=self;
  1037. inherited ppuload(ppufile);
  1038. aktlocalsymtable:=storesymtable;
  1039. end;
  1040. procedure tabstractlocalsymtable.ppuwrite(ppufile:tcompilerppufile);
  1041. var
  1042. oldtyp : byte;
  1043. storesymtable : tsymtable;
  1044. begin
  1045. storesymtable:=aktlocalsymtable;
  1046. aktlocalsymtable:=self;
  1047. oldtyp:=ppufile.entrytyp;
  1048. ppufile.entrytyp:=subentryid;
  1049. { write definitions }
  1050. writedefs(ppufile);
  1051. { write symbols }
  1052. writesyms(ppufile);
  1053. ppufile.entrytyp:=oldtyp;
  1054. aktlocalsymtable:=storesymtable;
  1055. end;
  1056. procedure tabstractlocalsymtable.load_references(ppufile:tcompilerppufile;locals:boolean);
  1057. var
  1058. storesymtable : tsymtable;
  1059. begin
  1060. storesymtable:=aktlocalsymtable;
  1061. aktlocalsymtable:=self;
  1062. inherited load_references(ppufile,locals);
  1063. aktlocalsymtable:=storesymtable;
  1064. end;
  1065. procedure tabstractlocalsymtable.write_references(ppufile:tcompilerppufile;locals:boolean);
  1066. var
  1067. storesymtable : tsymtable;
  1068. begin
  1069. storesymtable:=aktlocalsymtable;
  1070. aktlocalsymtable:=self;
  1071. inherited write_references(ppufile,locals);
  1072. aktlocalsymtable:=storesymtable;
  1073. end;
  1074. {****************************************************************************
  1075. TLocalSymtable
  1076. ****************************************************************************}
  1077. constructor tlocalsymtable.create;
  1078. begin
  1079. inherited create('');
  1080. symtabletype:=localsymtable;
  1081. end;
  1082. procedure tlocalsymtable.insert(sym:tsymentry);
  1083. var
  1084. hsym : tsym;
  1085. begin
  1086. if assigned(next) then
  1087. begin
  1088. if (next.symtabletype=parasymtable) then
  1089. begin
  1090. hsym:=tsym(next.search(sym.name));
  1091. if assigned(hsym) then
  1092. begin
  1093. { a parameter and the function can have the same
  1094. name in TP and Delphi, but RESULT not }
  1095. if (m_duplicate_names in aktmodeswitches) and
  1096. (sym.typ in [absolutesym,varsym]) and
  1097. (vo_is_funcret in tvarsym(sym).varoptions) and
  1098. not((m_result in aktmodeswitches) and
  1099. (vo_is_result in tvarsym(sym).varoptions)) then
  1100. sym.owner.rename(sym.name,'hidden'+sym.name)
  1101. else
  1102. begin
  1103. DuplicateSym(hsym);
  1104. exit;
  1105. end;
  1106. end;
  1107. end;
  1108. { check for duplicate id in local symtable of methods }
  1109. if assigned(next.next) and
  1110. { funcretsym is allowed !! }
  1111. (not is_funcret_sym(sym)) and
  1112. (next.next.symtabletype=objectsymtable) then
  1113. begin
  1114. hsym:=search_class_member(tobjectdef(next.next.defowner),sym.name);
  1115. if assigned(hsym) and
  1116. { private ids can be reused }
  1117. (not(sp_private in hsym.symoptions) or
  1118. (hsym.owner.defowner.owner.symtabletype<>globalsymtable)) then
  1119. begin
  1120. { delphi allows to reuse the names in a class, but not
  1121. in object (tp7 compatible) }
  1122. if not((m_delphi in aktmodeswitches) and
  1123. is_class(tdef(next.next.defowner))) then
  1124. begin
  1125. DuplicateSym(hsym);
  1126. exit;
  1127. end;
  1128. end;
  1129. end;
  1130. end;
  1131. inherited insert(sym);
  1132. end;
  1133. procedure tlocalsymtable.insertvardata(sym : tsymentry);
  1134. var
  1135. l,varalign : longint;
  1136. begin
  1137. if not(sym.typ in [varsym]) then
  1138. internalerror(200208255);
  1139. case sym.typ of
  1140. varsym :
  1141. begin
  1142. tvarsym(sym).varstate:=vs_declared;
  1143. l:=tvarsym(sym).getvaluesize;
  1144. varalign:=size_2_align(l);
  1145. varalign:=used_align(varalign,aktalignment.localalignmin,aktalignment.localalignmax);
  1146. if (tg.direction = 1) then
  1147. begin
  1148. { on the powerpc, the local variables are accessed with a positiv offset }
  1149. tvarsym(sym).address:=align(datasize,varalign);
  1150. datasize:=tvarsym(sym).address+l;
  1151. end
  1152. else
  1153. begin
  1154. tvarsym(sym).address:=align(datasize+l,varalign);
  1155. datasize:=tvarsym(sym).address;
  1156. end;
  1157. end;
  1158. end;
  1159. end;
  1160. procedure tlocalsymtable.insertconstdata(sym : tsymentry);
  1161. { this does not affect the local stack space, since all
  1162. typed constansts and initialized variables are always
  1163. put in the .data / .rodata section
  1164. }
  1165. var
  1166. storefilepos : tfileposinfo;
  1167. curconstsegment : taasmoutput;
  1168. l : longint;
  1169. begin
  1170. { Note: this is the same code as tabstractunitsymtable.insertconstdata }
  1171. if sym.typ<>typedconstsym then
  1172. internalerror(200208254);
  1173. storefilepos:=aktfilepos;
  1174. aktfilepos:=tsym(sym).fileinfo;
  1175. if ttypedconstsym(sym).is_writable then
  1176. curconstsegment:=datasegment
  1177. else
  1178. curconstsegment:=consts;
  1179. l:=ttypedconstsym(sym).getsize;
  1180. { insert cut for smartlinking or alignment }
  1181. if (cs_create_smart in aktmoduleswitches) then
  1182. curconstSegment.concat(Tai_cut.Create);
  1183. curconstSegment.concat(Tai_align.create(const_align(l)));
  1184. {$ifdef GDB}
  1185. if cs_debuginfo in aktmoduleswitches then
  1186. ttypedconstsym(sym).concatstabto(curconstsegment);
  1187. {$endif GDB}
  1188. if (cs_create_smart in aktmoduleswitches) or
  1189. DLLSource then
  1190. begin
  1191. curconstSegment.concat(Tai_symbol.Createdataname_global(
  1192. ttypedconstsym(sym).mangledname,l));
  1193. end
  1194. else
  1195. begin
  1196. curconstSegment.concat(Tai_symbol.Createdataname(
  1197. ttypedconstsym(sym).mangledname,l));
  1198. end;
  1199. aktfilepos:=storefilepos;
  1200. end;
  1201. {****************************************************************************
  1202. TParaSymtable
  1203. ****************************************************************************}
  1204. constructor tparasymtable.create;
  1205. begin
  1206. inherited create('');
  1207. symtabletype:=parasymtable;
  1208. dataalignment:=aktalignment.paraalign;
  1209. end;
  1210. procedure tparasymtable.insert(sym:tsymentry);
  1211. var
  1212. hsym : tsym;
  1213. begin
  1214. { check for duplicate id in para symtable of methods }
  1215. if assigned(procinfo) and
  1216. assigned(procinfo._class) and
  1217. { but not in nested procedures !}
  1218. (not(assigned(procinfo.parent)) or
  1219. (assigned(procinfo.parent) and
  1220. not(assigned(procinfo.parent._class)))
  1221. ) and
  1222. { funcretsym is allowed !! }
  1223. (not is_funcret_sym(sym)) then
  1224. begin
  1225. hsym:=search_class_member(procinfo._class,sym.name);
  1226. { private ids can be reused }
  1227. if assigned(hsym) and
  1228. tstoredsym(hsym).is_visible_for_object(procinfo._class) then
  1229. begin
  1230. { delphi allows to reuse the names in a class, but not
  1231. in object (tp7 compatible) }
  1232. if not((m_delphi in aktmodeswitches) and
  1233. is_class_or_interface(procinfo._class)) then
  1234. begin
  1235. DuplicateSym(hsym);
  1236. exit;
  1237. end;
  1238. end;
  1239. end;
  1240. inherited insert(sym);
  1241. end;
  1242. procedure tparasymtable.insertvardata(sym : tsymentry);
  1243. var
  1244. l,varalign : longint;
  1245. begin
  1246. if sym.typ<>varsym then
  1247. internalerror(200208253);
  1248. { retrieve cdecl status }
  1249. if defowner.deftype<>procdef then
  1250. internalerror(200208256);
  1251. { here we need the size of a push instead of the
  1252. size of the data }
  1253. l:=paramanager.push_size(tvarsym(sym).varspez,tvarsym(sym).vartype.def,tprocdef(defowner).proccalloption);
  1254. varalign:=size_2_align(l);
  1255. tvarsym(sym).varstate:=vs_assigned;
  1256. { we need the new datasize already aligned so we can't
  1257. use the align_address here }
  1258. tvarsym(sym).address:=datasize;
  1259. varalign:=used_align(varalign,dataalignment,dataalignment);
  1260. datasize:=align(tvarsym(sym).address+l,varalign);
  1261. end;
  1262. {****************************************************************************
  1263. TAbstractUnitSymtable
  1264. ****************************************************************************}
  1265. constructor tabstractunitsymtable.create(const n : string);
  1266. begin
  1267. inherited create(n);
  1268. symsearch.usehash;
  1269. {$ifdef GDB}
  1270. { reset GDB things }
  1271. prev_dbx_counter := dbx_counter;
  1272. dbx_counter := nil;
  1273. is_stab_written:=false;
  1274. dbx_count := -1;
  1275. {$endif GDB}
  1276. end;
  1277. procedure tabstractunitsymtable.insertvardata(sym : tsymentry);
  1278. var
  1279. l,varalign : longint;
  1280. storefilepos : tfileposinfo;
  1281. begin
  1282. if sym.typ<>varsym then
  1283. internalerror(200208252);
  1284. storefilepos:=aktfilepos;
  1285. aktfilepos:=tsym(sym).fileinfo;
  1286. l:=tvarsym(sym).getvaluesize;
  1287. if (vo_is_thread_var in tvarsym(sym).varoptions) then
  1288. inc(l,pointer_size);
  1289. varalign:=var_align(l);
  1290. tvarsym(sym).address:=align(datasize,varalign);
  1291. { insert cut for smartlinking or alignment }
  1292. if (cs_create_smart in aktmoduleswitches) then
  1293. bssSegment.concat(Tai_cut.Create);
  1294. bssSegment.concat(Tai_align.create(varalign));
  1295. datasize:=tvarsym(sym).address+l;
  1296. {$ifdef GDB}
  1297. if cs_debuginfo in aktmoduleswitches then
  1298. tvarsym(sym).concatstabto(bsssegment);
  1299. {$endif GDB}
  1300. if (symtabletype=globalsymtable) or
  1301. (cs_create_smart in aktmoduleswitches) or
  1302. DLLSource or
  1303. (vo_is_exported in tvarsym(sym).varoptions) or
  1304. (vo_is_C_var in tvarsym(sym).varoptions) then
  1305. bssSegment.concat(Tai_datablock.Create_global(tvarsym(sym).mangledname,l))
  1306. else
  1307. bssSegment.concat(Tai_datablock.Create(tvarsym(sym).mangledname,l));
  1308. aktfilepos:=storefilepos;
  1309. end;
  1310. procedure tabstractunitsymtable.insertconstdata(sym : tsymentry);
  1311. var
  1312. storefilepos : tfileposinfo;
  1313. curconstsegment : taasmoutput;
  1314. l : longint;
  1315. begin
  1316. if sym.typ<>typedconstsym then
  1317. internalerror(200208254);
  1318. storefilepos:=aktfilepos;
  1319. aktfilepos:=tsym(sym).fileinfo;
  1320. if ttypedconstsym(sym).is_writable then
  1321. curconstsegment:=datasegment
  1322. else
  1323. curconstsegment:=consts;
  1324. l:=ttypedconstsym(sym).getsize;
  1325. { insert cut for smartlinking or alignment }
  1326. if (cs_create_smart in aktmoduleswitches) then
  1327. curconstSegment.concat(Tai_cut.Create);
  1328. curconstSegment.concat(Tai_align.create(const_align(l)));
  1329. {$ifdef GDB}
  1330. if cs_debuginfo in aktmoduleswitches then
  1331. ttypedconstsym(sym).concatstabto(curconstsegment);
  1332. {$endif GDB}
  1333. if (symtabletype=globalsymtable) or
  1334. (cs_create_smart in aktmoduleswitches) or
  1335. DLLSource then
  1336. begin
  1337. curconstSegment.concat(Tai_symbol.Createdataname_global(
  1338. ttypedconstsym(sym).mangledname,l));
  1339. end
  1340. else
  1341. begin
  1342. curconstSegment.concat(Tai_symbol.Createdataname(
  1343. ttypedconstsym(sym).mangledname,l));
  1344. end;
  1345. aktfilepos:=storefilepos;
  1346. end;
  1347. {$ifdef GDB}
  1348. procedure tabstractunitsymtable.concattypestabto(asmlist : taasmoutput);
  1349. var prev_dbx_count : plongint;
  1350. begin
  1351. if is_stab_written then
  1352. exit;
  1353. if not assigned(name) then
  1354. name := stringdup('Main_program');
  1355. if (symtabletype = globalsymtable) and
  1356. (current_module.globalsymtable<>self) then
  1357. begin
  1358. unitid:=current_module.unitcount;
  1359. inc(current_module.unitcount);
  1360. end;
  1361. asmList.concat(tai_comment.Create(strpnew('Begin unit '+name^+' has index '+tostr(unitid))));
  1362. if cs_gdb_dbx in aktglobalswitches then
  1363. begin
  1364. if dbx_count_ok then
  1365. begin
  1366. asmList.concat(tai_comment.Create(strpnew('"repeated" unit '+name^
  1367. +' has index '+tostr(unitid)+' dbx count = '+tostr(dbx_count))));
  1368. asmList.concat(Tai_stabs.Create(strpnew('"'+name^+'",'
  1369. +tostr(N_EXCL)+',0,0,'+tostr(dbx_count))));
  1370. exit;
  1371. end
  1372. else if (current_module.globalsymtable<>self) then
  1373. begin
  1374. prev_dbx_count := dbx_counter;
  1375. dbx_counter := nil;
  1376. do_count_dbx:=false;
  1377. if (symtabletype = globalsymtable) and (unitid<>0) then
  1378. asmList.concat(Tai_stabs.Create(strpnew('"'+name^+'",'+tostr(N_BINCL)+',0,0,0')));
  1379. dbx_counter := @dbx_count;
  1380. dbx_count:=0;
  1381. do_count_dbx:=assigned(dbx_counter);
  1382. end;
  1383. end;
  1384. foreach({$ifdef FPCPROCVAR}@{$endif}concattypestab,asmlist);
  1385. if cs_gdb_dbx in aktglobalswitches then
  1386. begin
  1387. if (current_module.globalsymtable<>self) then
  1388. begin
  1389. dbx_counter := prev_dbx_count;
  1390. do_count_dbx:=false;
  1391. asmList.concat(tai_comment.Create(strpnew('End unit '+name^
  1392. +' has index '+tostr(unitid))));
  1393. asmList.concat(Tai_stabs.Create(strpnew('"'+name^+'",'
  1394. +tostr(N_EINCL)+',0,0,0')));
  1395. do_count_dbx:=assigned(dbx_counter);
  1396. dbx_count_ok := {true}false;
  1397. end;
  1398. end;
  1399. is_stab_written:=true;
  1400. end;
  1401. {$endif GDB}
  1402. {****************************************************************************
  1403. TStaticSymtable
  1404. ****************************************************************************}
  1405. constructor tstaticsymtable.create(const n : string);
  1406. begin
  1407. inherited create(n);
  1408. symtabletype:=staticsymtable;
  1409. end;
  1410. procedure tstaticsymtable.ppuload(ppufile:tcompilerppufile);
  1411. begin
  1412. aktstaticsymtable:=self;
  1413. next:=symtablestack;
  1414. symtablestack:=self;
  1415. inherited ppuload(ppufile);
  1416. { now we can deref the syms and defs }
  1417. deref;
  1418. { restore symtablestack }
  1419. symtablestack:=next;
  1420. end;
  1421. procedure tstaticsymtable.ppuwrite(ppufile:tcompilerppufile);
  1422. begin
  1423. aktstaticsymtable:=self;
  1424. inherited ppuwrite(ppufile);
  1425. end;
  1426. procedure tstaticsymtable.load_references(ppufile:tcompilerppufile;locals:boolean);
  1427. begin
  1428. aktstaticsymtable:=self;
  1429. inherited load_references(ppufile,locals);
  1430. end;
  1431. procedure tstaticsymtable.write_references(ppufile:tcompilerppufile;locals:boolean);
  1432. begin
  1433. aktstaticsymtable:=self;
  1434. inherited write_references(ppufile,locals);
  1435. end;
  1436. procedure tstaticsymtable.insert(sym:tsymentry);
  1437. var
  1438. hsym : tsym;
  1439. begin
  1440. { also check the global symtable }
  1441. if assigned(next) and
  1442. (next.unitid=0) then
  1443. begin
  1444. hsym:=tsym(next.search(sym.name));
  1445. if assigned(hsym) then
  1446. begin
  1447. { Delphi you can have a symbol with the same name as the
  1448. unit, the unit can then not be accessed anymore using
  1449. <unit>.<id>, so we can hide the symbol }
  1450. if (m_duplicate_names in aktmodeswitches) and
  1451. (hsym.typ=symconst.unitsym) then
  1452. hsym.owner.rename(hsym.name,'hidden'+hsym.name)
  1453. else
  1454. begin
  1455. DuplicateSym(hsym);
  1456. exit;
  1457. end;
  1458. end;
  1459. end;
  1460. inherited insert(sym);
  1461. end;
  1462. procedure tstaticsymtable.insertvardata(sym : tsymentry);
  1463. begin
  1464. inherited insertvardata(sym);
  1465. { enable unitialized warning for local symbols }
  1466. if sym.typ=varsym then
  1467. tvarsym(sym).varstate:=vs_declared;
  1468. end;
  1469. {****************************************************************************
  1470. TGlobalSymtable
  1471. ****************************************************************************}
  1472. constructor tglobalsymtable.create(const n : string);
  1473. begin
  1474. inherited create(n);
  1475. symtabletype:=globalsymtable;
  1476. unitid:=0;
  1477. unitsym:=nil;
  1478. {$ifdef GDB}
  1479. if cs_gdb_dbx in aktglobalswitches then
  1480. begin
  1481. dbx_count := 0;
  1482. unittypecount:=1;
  1483. pglobaltypecount := @unittypecount;
  1484. {unitid:=current_module.unitcount;}
  1485. debugList.concat(tai_comment.Create(strpnew('Global '+name^+' has index '+tostr(unitid))));
  1486. debugList.concat(Tai_stabs.Create(strpnew('"'+name^+'",'+tostr(N_BINCL)+',0,0,0')));
  1487. {inc(current_module.unitcount);}
  1488. { we can't use dbx_vcount, because we don't know
  1489. if the object file will be loaded before or afeter PM }
  1490. dbx_count_ok:=false;
  1491. dbx_counter:=@dbx_count;
  1492. do_count_dbx:=true;
  1493. end;
  1494. {$endif GDB}
  1495. end;
  1496. destructor tglobalsymtable.destroy;
  1497. var
  1498. pus : tunitsym;
  1499. begin
  1500. pus:=unitsym;
  1501. while assigned(pus) do
  1502. begin
  1503. unitsym:=pus.prevsym;
  1504. pus.prevsym:=nil;
  1505. pus.unitsymtable:=nil;
  1506. pus:=unitsym;
  1507. end;
  1508. inherited destroy;
  1509. end;
  1510. procedure tglobalsymtable.ppuload(ppufile:tcompilerppufile);
  1511. {$ifdef GDB}
  1512. var
  1513. b : byte;
  1514. {$endif GDB}
  1515. begin
  1516. {$ifdef GDB}
  1517. if cs_gdb_dbx in aktglobalswitches then
  1518. begin
  1519. UnitTypeCount:=1;
  1520. PglobalTypeCount:=@UnitTypeCount;
  1521. end;
  1522. {$endif GDB}
  1523. symtablelevel:=0;
  1524. next:=symtablestack;
  1525. symtablestack:=self;
  1526. inherited ppuload(ppufile);
  1527. { now we can deref the syms and defs }
  1528. deref;
  1529. { restore symtablestack }
  1530. symtablestack:=next;
  1531. { read dbx count }
  1532. {$ifdef GDB}
  1533. if (current_module.flags and uf_has_dbx)<>0 then
  1534. begin
  1535. b:=ppufile.readentry;
  1536. if b<>ibdbxcount then
  1537. Message(unit_f_ppu_dbx_count_problem)
  1538. else
  1539. dbx_count:=ppufile.getlongint;
  1540. {$IfDef EXTDEBUG}
  1541. writeln('Read dbx_count ',dbx_count,' in unit ',name^,'.ppu');
  1542. {$ENDIF EXTDEBUG}
  1543. { we can't use dbx_vcount, because we don't know
  1544. if the object file will be loaded before or afeter PM }
  1545. dbx_count_ok := {true}false;
  1546. end
  1547. else
  1548. begin
  1549. dbx_count:=-1;
  1550. dbx_count_ok:=false;
  1551. end;
  1552. {$endif GDB}
  1553. end;
  1554. procedure tglobalsymtable.ppuwrite(ppufile:tcompilerppufile);
  1555. begin
  1556. { write the symtable entries }
  1557. inherited ppuwrite(ppufile);
  1558. { write dbx count }
  1559. {$ifdef GDB}
  1560. if cs_gdb_dbx in aktglobalswitches then
  1561. begin
  1562. {$IfDef EXTDEBUG}
  1563. writeln('Writing dbx_count ',dbx_count,' in unit ',name^,'.ppu');
  1564. {$ENDIF EXTDEBUG}
  1565. ppufile.do_crc:=false;
  1566. ppufile.putlongint(dbx_count);
  1567. ppufile.writeentry(ibdbxcount);
  1568. ppufile.do_crc:=true;
  1569. end;
  1570. {$endif GDB}
  1571. end;
  1572. procedure tglobalsymtable.insert(sym:tsymentry);
  1573. var
  1574. hsym : tsym;
  1575. begin
  1576. { also check the global symtable }
  1577. if assigned(next) and
  1578. (next.unitid=0) then
  1579. begin
  1580. hsym:=tsym(next.search(sym.name));
  1581. if assigned(hsym) then
  1582. begin
  1583. { Delphi you can have a symbol with the same name as the
  1584. unit, the unit can then not be accessed anymore using
  1585. <unit>.<id>, so we can hide the symbol }
  1586. if (m_duplicate_names in aktmodeswitches) and
  1587. (hsym.typ=symconst.unitsym) then
  1588. hsym.owner.rename(hsym.name,'hidden'+hsym.name)
  1589. else
  1590. begin
  1591. DuplicateSym(hsym);
  1592. exit;
  1593. end;
  1594. end;
  1595. end;
  1596. hsym:=tsym(search(sym.name));
  1597. if assigned(hsym) then
  1598. begin
  1599. { Delphi you can have a symbol with the same name as the
  1600. unit, the unit can then not be accessed anymore using
  1601. <unit>.<id>, so we can hide the symbol }
  1602. if (m_duplicate_names in aktmodeswitches) and
  1603. (hsym.typ=symconst.unitsym) then
  1604. hsym.owner.rename(hsym.name,'hidden'+hsym.name)
  1605. else
  1606. begin
  1607. DuplicateSym(hsym);
  1608. exit;
  1609. end;
  1610. end;
  1611. inherited insert(sym);
  1612. end;
  1613. procedure tglobalsymtable.insertvardata(sym : tsymentry);
  1614. begin
  1615. inherited insertvardata(sym);
  1616. { this symbol can't be loaded to a register }
  1617. if sym.typ=varsym then
  1618. begin
  1619. exclude(tvarsym(sym).varoptions,vo_regable);
  1620. exclude(tvarsym(sym).varoptions,vo_fpuregable);
  1621. end;
  1622. end;
  1623. {$ifdef GDB}
  1624. function tglobalsymtable.getnewtypecount : word;
  1625. begin
  1626. if not (cs_gdb_dbx in aktglobalswitches) then
  1627. getnewtypecount:=inherited getnewtypecount
  1628. else
  1629. begin
  1630. getnewtypecount:=unittypecount;
  1631. inc(unittypecount);
  1632. end;
  1633. end;
  1634. {$endif}
  1635. {****************************************************************************
  1636. TWITHSYMTABLE
  1637. ****************************************************************************}
  1638. constructor twithsymtable.create(aowner:tdef;asymsearch:TDictionary);
  1639. begin
  1640. inherited create('');
  1641. symtabletype:=withsymtable;
  1642. direct_with:=false;
  1643. withnode:=nil;
  1644. withrefnode:=nil;
  1645. use_count:=1;
  1646. { we don't need the symsearch }
  1647. symsearch.free;
  1648. { set the defaults }
  1649. symsearch:=asymsearch;
  1650. defowner:=aowner;
  1651. end;
  1652. destructor twithsymtable.destroy;
  1653. begin
  1654. symsearch:=nil;
  1655. inherited destroy;
  1656. end;
  1657. procedure twithsymtable.clear;
  1658. begin
  1659. { remove no entry from a withsymtable as it is only a pointer to the
  1660. recorddef or objectdef symtable }
  1661. end;
  1662. {****************************************************************************
  1663. TSTT_ExceptionSymtable
  1664. ****************************************************************************}
  1665. constructor tstt_exceptsymtable.create;
  1666. begin
  1667. inherited create('');
  1668. symtabletype:=stt_exceptsymtable;
  1669. end;
  1670. {*****************************************************************************
  1671. Helper Routines
  1672. *****************************************************************************}
  1673. function findunitsymtable(st:tsymtable):tsymtable;
  1674. begin
  1675. findunitsymtable:=nil;
  1676. repeat
  1677. if not assigned(st) then
  1678. internalerror(5566561);
  1679. case st.symtabletype of
  1680. localsymtable,
  1681. parasymtable,
  1682. staticsymtable :
  1683. exit;
  1684. globalsymtable :
  1685. begin
  1686. findunitsymtable:=st;
  1687. exit;
  1688. end;
  1689. objectsymtable :
  1690. st:=st.defowner.owner;
  1691. recordsymtable :
  1692. begin
  1693. { don't continue when the current
  1694. symtable is used for variant records }
  1695. if trecorddef(st.defowner).isunion then
  1696. begin
  1697. findunitsymtable:=nil;
  1698. exit;
  1699. end
  1700. else
  1701. st:=st.defowner.owner;
  1702. end;
  1703. else
  1704. internalerror(5566562);
  1705. end;
  1706. until false;
  1707. end;
  1708. procedure duplicatesym(sym:tsym);
  1709. var
  1710. st : tsymtable;
  1711. begin
  1712. Message1(sym_e_duplicate_id,sym.realname);
  1713. st:=findunitsymtable(sym.owner);
  1714. with sym.fileinfo do
  1715. begin
  1716. if assigned(st) and (st.unitid<>0) then
  1717. Message2(sym_h_duplicate_id_where,'unit '+st.name^,tostr(line))
  1718. else
  1719. Message2(sym_h_duplicate_id_where,current_module.sourcefiles.get_file_name(fileindex),tostr(line));
  1720. end;
  1721. end;
  1722. {*****************************************************************************
  1723. Search
  1724. *****************************************************************************}
  1725. function searchsym(const s : stringid;var srsym:tsym;var srsymtable:tsymtable):boolean;
  1726. var
  1727. speedvalue : cardinal;
  1728. begin
  1729. speedvalue:=getspeedvalue(s);
  1730. srsymtable:=symtablestack;
  1731. while assigned(srsymtable) do
  1732. begin
  1733. srsym:=tsym(srsymtable.speedsearch(s,speedvalue));
  1734. if assigned(srsym) and
  1735. tstoredsym(srsym).is_visible_for_proc(aktprocdef) then
  1736. begin
  1737. searchsym:=true;
  1738. exit;
  1739. end
  1740. else
  1741. srsymtable:=srsymtable.next;
  1742. end;
  1743. searchsym:=false;
  1744. end;
  1745. function searchsymonlyin(p : tsymtable;const s : stringid):tsym;
  1746. var
  1747. srsym : tsym;
  1748. begin
  1749. { the caller have to take care if srsym=nil }
  1750. if assigned(p) then
  1751. begin
  1752. srsym:=tsym(p.search(s));
  1753. if assigned(srsym) then
  1754. begin
  1755. searchsymonlyin:=srsym;
  1756. exit;
  1757. end;
  1758. { also check in the local symtbale if it exists }
  1759. if (p=tsymtable(current_module.globalsymtable)) then
  1760. begin
  1761. srsym:=tsym(current_module.localsymtable.search(s));
  1762. if assigned(srsym) then
  1763. begin
  1764. searchsymonlyin:=srsym;
  1765. exit;
  1766. end;
  1767. end
  1768. end;
  1769. searchsymonlyin:=nil;
  1770. end;
  1771. function searchsym_in_class(classh:tobjectdef;const s : stringid):tsym;
  1772. var
  1773. speedvalue : cardinal;
  1774. topclassh : tobjectdef;
  1775. sym : tsym;
  1776. begin
  1777. speedvalue:=getspeedvalue(s);
  1778. { when the class passed is defined in this unit we
  1779. need to use the scope of that class. This is a trick
  1780. that can be used to access protected members in other
  1781. units. At least kylix supports it this way (PFV) }
  1782. if assigned(classh) and
  1783. (classh.owner.symtabletype in [globalsymtable,staticsymtable]) and
  1784. (classh.owner.unitid=0) then
  1785. topclassh:=classh
  1786. else
  1787. topclassh:=nil;
  1788. sym:=nil;
  1789. while assigned(classh) do
  1790. begin
  1791. sym:=tsym(classh.symtable.speedsearch(s,speedvalue));
  1792. if assigned(sym) then
  1793. begin
  1794. if assigned(topclassh) then
  1795. begin
  1796. if tstoredsym(sym).is_visible_for_object(topclassh) then
  1797. break;
  1798. end
  1799. else
  1800. begin
  1801. if tstoredsym(sym).is_visible_for_proc(aktprocdef) then
  1802. break;
  1803. end;
  1804. end;
  1805. classh:=classh.childof;
  1806. end;
  1807. searchsym_in_class:=sym;
  1808. end;
  1809. function searchsym_in_class_by_msgint(classh:tobjectdef;i:longint):tsym;
  1810. var
  1811. topclassh : tobjectdef;
  1812. def : tdef;
  1813. sym : tsym;
  1814. begin
  1815. { when the class passed is defined in this unit we
  1816. need to use the scope of that class. This is a trick
  1817. that can be used to access protected members in other
  1818. units. At least kylix supports it this way (PFV) }
  1819. if assigned(classh) and
  1820. (classh.owner.symtabletype in [globalsymtable,staticsymtable]) and
  1821. (classh.owner.unitid=0) then
  1822. topclassh:=classh
  1823. else
  1824. topclassh:=nil;
  1825. sym:=nil;
  1826. def:=nil;
  1827. while assigned(classh) do
  1828. begin
  1829. def:=tdef(classh.symtable.defindex.first);
  1830. while assigned(def) do
  1831. begin
  1832. if (def.deftype=procdef) and
  1833. (po_msgint in tprocdef(def).procoptions) and
  1834. (tprocdef(def).messageinf.i=i) then
  1835. begin
  1836. sym:=tprocdef(def).procsym;
  1837. if assigned(topclassh) then
  1838. begin
  1839. if tprocdef(def).is_visible_for_object(topclassh) then
  1840. break;
  1841. end
  1842. else
  1843. begin
  1844. if tprocdef(def).is_visible_for_proc(aktprocdef) then
  1845. break;
  1846. end;
  1847. end;
  1848. def:=tdef(def.indexnext);
  1849. end;
  1850. if assigned(sym) then
  1851. break;
  1852. classh:=classh.childof;
  1853. end;
  1854. searchsym_in_class_by_msgint:=sym;
  1855. end;
  1856. function searchsym_in_class_by_msgstr(classh:tobjectdef;const s:string):tsym;
  1857. var
  1858. topclassh : tobjectdef;
  1859. def : tdef;
  1860. sym : tsym;
  1861. begin
  1862. { when the class passed is defined in this unit we
  1863. need to use the scope of that class. This is a trick
  1864. that can be used to access protected members in other
  1865. units. At least kylix supports it this way (PFV) }
  1866. if assigned(classh) and
  1867. (classh.owner.symtabletype in [globalsymtable,staticsymtable]) and
  1868. (classh.owner.unitid=0) then
  1869. topclassh:=classh
  1870. else
  1871. topclassh:=nil;
  1872. sym:=nil;
  1873. def:=nil;
  1874. while assigned(classh) do
  1875. begin
  1876. def:=tdef(classh.symtable.defindex.first);
  1877. while assigned(def) do
  1878. begin
  1879. if (def.deftype=procdef) and
  1880. (po_msgstr in tprocdef(def).procoptions) and
  1881. (tprocdef(def).messageinf.str=s) then
  1882. begin
  1883. sym:=tprocdef(def).procsym;
  1884. if assigned(topclassh) then
  1885. begin
  1886. if tprocdef(def).is_visible_for_object(topclassh) then
  1887. break;
  1888. end
  1889. else
  1890. begin
  1891. if tprocdef(def).is_visible_for_proc(aktprocdef) then
  1892. break;
  1893. end;
  1894. end;
  1895. def:=tdef(def.indexnext);
  1896. end;
  1897. if assigned(sym) then
  1898. break;
  1899. classh:=classh.childof;
  1900. end;
  1901. searchsym_in_class_by_msgstr:=sym;
  1902. end;
  1903. function searchsystype(const s: stringid; var srsym: ttypesym): boolean;
  1904. var
  1905. symowner: tsymtable;
  1906. begin
  1907. if not(cs_compilesystem in aktmoduleswitches) then
  1908. srsym := ttypesym(searchsymonlyin(systemunit,s))
  1909. else
  1910. searchsym(s,tsym(srsym),symowner);
  1911. searchsystype :=
  1912. assigned(srsym) and
  1913. (srsym.typ = typesym);
  1914. end;
  1915. function searchsysvar(const s: stringid; var srsym: tvarsym; var symowner: tsymtable): boolean;
  1916. begin
  1917. if not(cs_compilesystem in aktmoduleswitches) then
  1918. begin
  1919. srsym := tvarsym(searchsymonlyin(systemunit,s));
  1920. symowner := systemunit;
  1921. end
  1922. else
  1923. searchsym(s,tsym(srsym),symowner);
  1924. searchsysvar :=
  1925. assigned(srsym) and
  1926. (srsym.typ = varsym);
  1927. end;
  1928. function search_class_member(pd : tobjectdef;const s : string):tsym;
  1929. { searches n in symtable of pd and all anchestors }
  1930. var
  1931. speedvalue : cardinal;
  1932. srsym : tsym;
  1933. begin
  1934. speedvalue:=getspeedvalue(s);
  1935. while assigned(pd) do
  1936. begin
  1937. srsym:=tsym(pd.symtable.speedsearch(s,speedvalue));
  1938. if assigned(srsym) then
  1939. begin
  1940. search_class_member:=srsym;
  1941. exit;
  1942. end;
  1943. pd:=pd.childof;
  1944. end;
  1945. search_class_member:=nil;
  1946. end;
  1947. {*****************************************************************************
  1948. Definition Helpers
  1949. *****************************************************************************}
  1950. procedure globaldef(const s : string;var t:ttype);
  1951. var st : string;
  1952. symt : tsymtable;
  1953. srsym : tsym;
  1954. srsymtable : tsymtable;
  1955. begin
  1956. srsym := nil;
  1957. if pos('.',s) > 0 then
  1958. begin
  1959. st := copy(s,1,pos('.',s)-1);
  1960. searchsym(st,srsym,srsymtable);
  1961. st := copy(s,pos('.',s)+1,255);
  1962. if assigned(srsym) then
  1963. begin
  1964. if srsym.typ = unitsym then
  1965. begin
  1966. symt := tunitsym(srsym).unitsymtable;
  1967. srsym := tsym(symt.search(st));
  1968. end else srsym := nil;
  1969. end;
  1970. end else st := s;
  1971. if srsym = nil then
  1972. searchsym(st,srsym,srsymtable);
  1973. if srsym = nil then
  1974. srsym:=searchsymonlyin(systemunit,st);
  1975. if (not assigned(srsym)) or
  1976. (srsym.typ<>typesym) then
  1977. begin
  1978. Message(type_e_type_id_expected);
  1979. t:=generrortype;
  1980. exit;
  1981. end;
  1982. t := ttypesym(srsym).restype;
  1983. end;
  1984. {****************************************************************************
  1985. Object Helpers
  1986. ****************************************************************************}
  1987. var
  1988. _defaultprop : tpropertysym;
  1989. procedure tstoredsymtable.testfordefaultproperty(p : TNamedIndexItem;arg:pointer);
  1990. begin
  1991. if (tsym(p).typ=propertysym) and
  1992. (ppo_defaultproperty in tpropertysym(p).propoptions) then
  1993. _defaultprop:=tpropertysym(p);
  1994. end;
  1995. function search_default_property(pd : tobjectdef) : tpropertysym;
  1996. { returns the default property of a class, searches also anchestors }
  1997. begin
  1998. _defaultprop:=nil;
  1999. while assigned(pd) do
  2000. begin
  2001. pd.symtable.foreach({$ifdef FPCPROCVAR}@{$endif}tstoredsymtable(pd.symtable).testfordefaultproperty,nil);
  2002. if assigned(_defaultprop) then
  2003. break;
  2004. pd:=pd.childof;
  2005. end;
  2006. search_default_property:=_defaultprop;
  2007. end;
  2008. {$ifdef UNITALIASES}
  2009. {****************************************************************************
  2010. TUNIT_ALIAS
  2011. ****************************************************************************}
  2012. constructor tunit_alias.create(const n:string);
  2013. var
  2014. i : longint;
  2015. begin
  2016. i:=pos('=',n);
  2017. if i=0 then
  2018. fail;
  2019. inherited createname(Copy(n,1,i-1));
  2020. newname:=stringdup(Copy(n,i+1,255));
  2021. end;
  2022. destructor tunit_alias.destroy;
  2023. begin
  2024. stringdispose(newname);
  2025. inherited destroy;
  2026. end;
  2027. procedure addunitalias(const n:string);
  2028. begin
  2029. unitaliases^.insert(tunit_alias,init(Upper(n))));
  2030. end;
  2031. function getunitalias(const n:string):string;
  2032. var
  2033. p : punit_alias;
  2034. begin
  2035. p:=punit_alias(unitaliases^.search(Upper(n)));
  2036. if assigned(p) then
  2037. getunitalias:=punit_alias(p).newname^
  2038. else
  2039. getunitalias:=n;
  2040. end;
  2041. {$endif UNITALIASES}
  2042. {****************************************************************************
  2043. Symtable Stack
  2044. ****************************************************************************}
  2045. procedure dellexlevel;
  2046. var
  2047. p : tsymtable;
  2048. begin
  2049. p:=symtablestack;
  2050. symtablestack:=p.next;
  2051. { symbol tables of unit interfaces are never disposed }
  2052. { this is handle by the unit unitm }
  2053. if not(p.symtabletype in [globalsymtable,stt_exceptsymtable]) then
  2054. p.free;
  2055. end;
  2056. procedure RestoreUnitSyms;
  2057. var
  2058. p : tsymtable;
  2059. begin
  2060. p:=symtablestack;
  2061. while assigned(p) do
  2062. begin
  2063. if (p.symtabletype=globalsymtable) and
  2064. assigned(tglobalsymtable(p).unitsym) and
  2065. ((tglobalsymtable(p).unitsym.owner=current_module.globalsymtable) or
  2066. (tglobalsymtable(p).unitsym.owner=current_module.localsymtable)) then
  2067. tglobalsymtable(p).unitsym.restoreunitsym;
  2068. p:=p.next;
  2069. end;
  2070. end;
  2071. {$ifdef DEBUG}
  2072. procedure test_symtablestack;
  2073. var
  2074. p : tsymtable;
  2075. i : longint;
  2076. begin
  2077. p:=symtablestack;
  2078. i:=0;
  2079. while assigned(p) do
  2080. begin
  2081. inc(i);
  2082. p:=p.next;
  2083. if i>500 then
  2084. Message(sym_f_internal_error_in_symtablestack);
  2085. end;
  2086. end;
  2087. procedure list_symtablestack;
  2088. var
  2089. p : tsymtable;
  2090. i : longint;
  2091. begin
  2092. p:=symtablestack;
  2093. i:=0;
  2094. while assigned(p) do
  2095. begin
  2096. inc(i);
  2097. writeln(i,' ',p.name^);
  2098. p:=p.next;
  2099. if i>500 then
  2100. Message(sym_f_internal_error_in_symtablestack);
  2101. end;
  2102. end;
  2103. {$endif DEBUG}
  2104. {****************************************************************************
  2105. Init/Done Symtable
  2106. ****************************************************************************}
  2107. procedure InitSymtable;
  2108. var
  2109. token : ttoken;
  2110. begin
  2111. { Reset symbolstack }
  2112. registerdef:=false;
  2113. symtablestack:=nil;
  2114. systemunit:=nil;
  2115. {$ifdef GDB}
  2116. firstglobaldef:=nil;
  2117. lastglobaldef:=nil;
  2118. globaltypecount:=1;
  2119. pglobaltypecount:=@globaltypecount;
  2120. {$endif GDB}
  2121. { defs for internal use }
  2122. voidprocdef:=tprocdef.create;
  2123. { create error syms and def }
  2124. generrorsym:=terrorsym.create;
  2125. generrortype.setdef(terrordef.create);
  2126. {$ifdef UNITALIASES}
  2127. { unit aliases }
  2128. unitaliases:=tdictionary.create;
  2129. {$endif}
  2130. for token:=first_overloaded to last_overloaded do
  2131. overloaded_operators[token]:=nil;
  2132. end;
  2133. procedure DoneSymtable;
  2134. begin
  2135. voidprocdef.free;
  2136. generrorsym.free;
  2137. generrortype.def.free;
  2138. {$ifdef UNITALIASES}
  2139. unitaliases.free;
  2140. {$endif}
  2141. end;
  2142. end.
  2143. {
  2144. $Log$
  2145. Revision 1.95 2003-04-26 00:33:07 peter
  2146. * vo_is_result flag added for the special RESULT symbol
  2147. Revision 1.94 2003/04/25 20:59:35 peter
  2148. * removed funcretn,funcretsym, function result is now in varsym
  2149. and aliases for result and function name are added using absolutesym
  2150. * vs_hidden parameter for funcret passed in parameter
  2151. * vs_hidden fixes
  2152. * writenode changed to printnode and released from extdebug
  2153. * -vp option added to generate a tree.log with the nodetree
  2154. * nicer printnode for statements, callnode
  2155. Revision 1.93 2003/04/16 07:53:11 jonas
  2156. * calculation of parameter and resultlocation offsets now depends on
  2157. tg.direction instead of if(n)def powerpc
  2158. Revision 1.92 2003/04/05 21:09:32 jonas
  2159. * several ppc/generic result offset related fixes. The "normal" result
  2160. offset seems now to be calculated correctly and a lot of duplicate
  2161. calculations have been removed. Nested functions accessing the parent's
  2162. function result don't work at all though :(
  2163. Revision 1.91 2003/03/17 18:56:49 peter
  2164. * ignore hints for default parameter values
  2165. Revision 1.90 2003/03/17 16:54:41 peter
  2166. * support DefaultHandler and anonymous inheritance fixed
  2167. for message methods
  2168. Revision 1.89 2002/12/29 14:57:50 peter
  2169. * unit loading changed to first register units and load them
  2170. afterwards. This is needed to support uses xxx in yyy correctly
  2171. * unit dependency check fixed
  2172. Revision 1.88 2002/12/27 18:07:45 peter
  2173. * fix crashes when searching symbols
  2174. Revision 1.87 2002/12/25 01:26:56 peter
  2175. * duplicate procsym-unitsym fix
  2176. Revision 1.86 2002/12/21 13:07:34 peter
  2177. * type redefine fix for tb0437
  2178. Revision 1.85 2002/12/07 14:27:10 carl
  2179. * 3% memory optimization
  2180. * changed some types
  2181. + added type checking with different size for call node and for
  2182. parameters
  2183. Revision 1.84 2002/12/06 17:51:11 peter
  2184. * merged cdecl and array fixes
  2185. Revision 1.83 2002/11/30 11:12:48 carl
  2186. + checking for symbols used with hint directives is done mostly in pexpr
  2187. only now
  2188. Revision 1.82 2002/11/29 22:31:20 carl
  2189. + unimplemented hint directive added
  2190. * hint directive parsing implemented
  2191. * warning on these directives
  2192. Revision 1.81 2002/11/27 20:04:09 peter
  2193. * tvarsym.get_push_size replaced by paramanager.push_size
  2194. Revision 1.80 2002/11/22 22:45:49 carl
  2195. + small optimization for speed
  2196. Revision 1.79 2002/11/19 16:26:33 pierre
  2197. * correct a stabs generation problem that lead to use errordef in stabs
  2198. Revision 1.78 2002/11/18 17:32:00 peter
  2199. * pass proccalloption to ret_in_xxx and push_xxx functions
  2200. Revision 1.77 2002/11/15 01:58:54 peter
  2201. * merged changes from 1.0.7 up to 04-11
  2202. - -V option for generating bug report tracing
  2203. - more tracing for option parsing
  2204. - errors for cdecl and high()
  2205. - win32 import stabs
  2206. - win32 records<=8 are returned in eax:edx (turned off by default)
  2207. - heaptrc update
  2208. - more info for temp management in .s file with EXTDEBUG
  2209. Revision 1.76 2002/11/09 15:29:28 carl
  2210. + bss / constant alignment fixes
  2211. * avoid incrementing address/datasize in local symtable for const's
  2212. Revision 1.75 2002/10/14 19:44:43 peter
  2213. * threadvars need 4 bytes extra for storing the threadvar index
  2214. Revision 1.74 2002/10/06 19:41:31 peter
  2215. * Add finalization of typed consts
  2216. * Finalization of globals in the main program
  2217. Revision 1.73 2002/10/05 12:43:29 carl
  2218. * fixes for Delphi 6 compilation
  2219. (warning : Some features do not work under Delphi)
  2220. Revision 1.72 2002/09/09 19:41:46 peter
  2221. * real fix internalerror for dup ids in union sym
  2222. Revision 1.71 2002/09/09 17:34:16 peter
  2223. * tdicationary.replace added to replace and item in a dictionary. This
  2224. is only allowed for the same name
  2225. * varsyms are inserted in symtable before the types are parsed. This
  2226. fixes the long standing "var longint : longint" bug
  2227. - consume_idlist and idstringlist removed. The loops are inserted
  2228. at the callers place and uses the symtable for duplicate id checking
  2229. Revision 1.70 2002/09/05 19:29:45 peter
  2230. * memdebug enhancements
  2231. Revision 1.69 2002/08/25 19:25:21 peter
  2232. * sym.insert_in_data removed
  2233. * symtable.insertvardata/insertconstdata added
  2234. * removed insert_in_data call from symtable.insert, it needs to be
  2235. called separatly. This allows to deref the address calculation
  2236. * procedures now calculate the parast addresses after the procedure
  2237. directives are parsed. This fixes the cdecl parast problem
  2238. * push_addr_param has an extra argument that specifies if cdecl is used
  2239. or not
  2240. Revision 1.68 2002/08/18 20:06:27 peter
  2241. * inlining is now also allowed in interface
  2242. * renamed write/load to ppuwrite/ppuload
  2243. * tnode storing in ppu
  2244. * nld,ncon,nbas are already updated for storing in ppu
  2245. Revision 1.67 2002/08/17 09:23:43 florian
  2246. * first part of procinfo rewrite
  2247. Revision 1.66 2002/08/11 13:24:15 peter
  2248. * saving of asmsymbols in ppu supported
  2249. * asmsymbollist global is removed and moved into a new class
  2250. tasmlibrarydata that will hold the info of a .a file which
  2251. corresponds with a single module. Added librarydata to tmodule
  2252. to keep the library info stored for the module. In the future the
  2253. objectfiles will also be stored to the tasmlibrarydata class
  2254. * all getlabel/newasmsymbol and friends are moved to the new class
  2255. Revision 1.65 2002/07/23 09:51:27 daniel
  2256. * Tried to make Tprocsym.defs protected. I didn't succeed but the cleanups
  2257. are worth comitting.
  2258. Revision 1.64 2002/07/16 15:34:21 florian
  2259. * exit is now a syssym instead of a keyword
  2260. Revision 1.63 2002/07/15 19:44:53 florian
  2261. * fixed crash with default parameters and stdcall calling convention
  2262. Revision 1.62 2002/07/01 18:46:28 peter
  2263. * internal linker
  2264. * reorganized aasm layer
  2265. Revision 1.61 2002/05/18 13:34:19 peter
  2266. * readded missing revisions
  2267. Revision 1.60 2002/05/16 19:46:45 carl
  2268. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  2269. + try to fix temp allocation (still in ifdef)
  2270. + generic constructor calls
  2271. + start of tassembler / tmodulebase class cleanup
  2272. Revision 1.58 2002/05/12 16:53:15 peter
  2273. * moved entry and exitcode to ncgutil and cgobj
  2274. * foreach gets extra argument for passing local data to the
  2275. iterator function
  2276. * -CR checks also class typecasts at runtime by changing them
  2277. into as
  2278. * fixed compiler to cycle with the -CR option
  2279. * fixed stabs with elf writer, finally the global variables can
  2280. be watched
  2281. * removed a lot of routines from cga unit and replaced them by
  2282. calls to cgobj
  2283. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  2284. u32bit then the other is typecasted also to u32bit without giving
  2285. a rangecheck warning/error.
  2286. * fixed pascal calling method with reversing also the high tree in
  2287. the parast, detected by tcalcst3 test
  2288. Revision 1.57 2002/04/04 19:06:05 peter
  2289. * removed unused units
  2290. * use tlocation.size in cg.a_*loc*() routines
  2291. Revision 1.56 2002/03/04 19:10:11 peter
  2292. * removed compiler warnings
  2293. Revision 1.55 2002/02/03 09:30:07 peter
  2294. * more fixes for protected handling
  2295. Revision 1.54 2002/01/29 21:30:25 peter
  2296. * allow also dup id in delphi mode in interfaces
  2297. Revision 1.53 2002/01/29 19:46:00 peter
  2298. * fixed recordsymtable.insert_in() for inserting variant record fields
  2299. to not used symtable.insert() because that also updates alignmentinfo
  2300. which was already set
  2301. Revision 1.52 2002/01/24 18:25:50 peter
  2302. * implicit result variable generation for assembler routines
  2303. * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
  2304. }