symtable.pas 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 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 defines.inc}
  20. interface
  21. uses
  22. { common }
  23. cutils,cclasses,
  24. { global }
  25. globtype,tokens,
  26. { symtable }
  27. symconst,symbase,symtype,symdef,symsym,
  28. { ppu }
  29. ppu,symppu,
  30. { assembler }
  31. aasm
  32. ;
  33. {****************************************************************************
  34. Symtable types
  35. ****************************************************************************}
  36. type
  37. tstoredsymtable = class(tsymtable)
  38. private
  39. b_needs_init_final : boolean;
  40. procedure _needs_init_final(p : tnamedindexitem);
  41. procedure check_forward(sym : TNamedIndexItem);
  42. procedure labeldefined(p : TNamedIndexItem);
  43. procedure unitsymbolused(p : TNamedIndexItem);
  44. procedure varsymbolused(p : TNamedIndexItem);
  45. procedure TestPrivate(p : TNamedIndexItem);
  46. procedure objectprivatesymbolused(p : TNamedIndexItem);
  47. {$ifdef GDB}
  48. private
  49. asmoutput : taasmoutput;
  50. procedure concatstab(p : TNamedIndexItem);
  51. procedure resetstab(p : TNamedIndexItem);
  52. procedure concattypestab(p : TNamedIndexItem);
  53. {$endif}
  54. procedure unchain_overloads(p : TNamedIndexItem);
  55. procedure loaddefs(ppufile:tcompilerppufile);
  56. procedure loadsyms(ppufile:tcompilerppufile);
  57. procedure writedefs(ppufile:tcompilerppufile);
  58. procedure writesyms(ppufile:tcompilerppufile);
  59. public
  60. { load/write }
  61. procedure load(ppufile:tcompilerppufile);virtual;
  62. procedure write(ppufile:tcompilerppufile);virtual;
  63. procedure load_references(ppufile:tcompilerppufile;locals:boolean);virtual;
  64. procedure write_references(ppufile:tcompilerppufile;locals:boolean);virtual;
  65. procedure deref;virtual;
  66. procedure derefimpl;virtual;
  67. procedure insert(sym : tsymentry);override;
  68. function speedsearch(const s : stringid;speedvalue : cardinal) : tsymentry;override;
  69. procedure allsymbolsused;
  70. procedure allprivatesused;
  71. procedure allunitsused;
  72. procedure check_forwards;
  73. procedure checklabels;
  74. function needs_init_final : boolean;
  75. procedure unchain_overloaded;
  76. procedure chainoperators;
  77. {$ifdef GDB}
  78. procedure concatstabto(asmlist : taasmoutput);virtual;
  79. function getnewtypecount : word; override;
  80. {$endif GDB}
  81. procedure testfordefaultproperty(p : TNamedIndexItem);
  82. end;
  83. tabstractrecordsymtable = class(tstoredsymtable)
  84. public
  85. procedure load(ppufile:tcompilerppufile);override;
  86. procedure write(ppufile:tcompilerppufile);override;
  87. procedure load_references(ppufile:tcompilerppufile;locals:boolean);override;
  88. procedure write_references(ppufile:tcompilerppufile;locals:boolean);override;
  89. end;
  90. trecordsymtable = class(tabstractrecordsymtable)
  91. public
  92. constructor create;
  93. procedure insert_in(tsymt : tsymtable;offset : longint);
  94. end;
  95. tobjectsymtable = class(tabstractrecordsymtable)
  96. public
  97. constructor create(const n:string);
  98. procedure insert(sym : tsymentry);override;
  99. end;
  100. tabstractlocalsymtable = class(tstoredsymtable)
  101. public
  102. procedure load(ppufile:tcompilerppufile);override;
  103. procedure write(ppufile:tcompilerppufile);override;
  104. procedure load_references(ppufile:tcompilerppufile;locals:boolean);override;
  105. procedure write_references(ppufile:tcompilerppufile;locals:boolean);override;
  106. end;
  107. tlocalsymtable = class(tabstractlocalsymtable)
  108. public
  109. constructor create;
  110. procedure insert(sym : tsymentry);override;
  111. end;
  112. tparasymtable = class(tabstractlocalsymtable)
  113. public
  114. constructor create;
  115. procedure insert(sym : tsymentry);override;
  116. { change alignment for args only parasymtable }
  117. procedure set_alignment(_alignment : longint);
  118. end;
  119. tabstractunitsymtable = class(tstoredsymtable)
  120. public
  121. {$ifdef GDB}
  122. dbx_count : longint;
  123. prev_dbx_counter : plongint;
  124. dbx_count_ok : boolean;
  125. is_stab_written : boolean;
  126. {$endif GDB}
  127. constructor create(const n : string);
  128. {$ifdef GDB}
  129. procedure concattypestabto(asmlist : taasmoutput);
  130. {$endif GDB}
  131. end;
  132. tglobalsymtable = class(tabstractunitsymtable)
  133. public
  134. unittypecount : word;
  135. unitsym : tunitsym;
  136. constructor create(const n : string);
  137. destructor destroy;override;
  138. procedure load(ppufile:tcompilerppufile);override;
  139. procedure write(ppufile:tcompilerppufile);override;
  140. procedure insert(sym : tsymentry);override;
  141. {$ifdef GDB}
  142. function getnewtypecount : word; override;
  143. {$endif}
  144. end;
  145. tstaticsymtable = class(tabstractunitsymtable)
  146. public
  147. constructor create(const n : string);
  148. procedure load(ppufile:tcompilerppufile);override;
  149. procedure write(ppufile:tcompilerppufile);override;
  150. procedure load_references(ppufile:tcompilerppufile;locals:boolean);override;
  151. procedure write_references(ppufile:tcompilerppufile;locals:boolean);override;
  152. procedure insert(sym : tsymentry);override;
  153. end;
  154. twithsymtable = class(tsymtable)
  155. direct_with : boolean;
  156. { in fact it is a tnode }
  157. withnode : pointer;
  158. { tnode to load of direct with var }
  159. { already usable before firstwith
  160. needed for firstpass of function parameters PM }
  161. withrefnode : pointer;
  162. constructor create(aowner:tdef;asymsearch:TDictionary);
  163. destructor destroy;override;
  164. procedure clear;override;
  165. function speedsearch(const s : stringid;speedvalue : cardinal) : tsymentry;override;
  166. end;
  167. tstt_exceptsymtable = class(tsymtable)
  168. public
  169. constructor create;
  170. end;
  171. var
  172. constsymtable : tsymtable; { symtable were the constants can be inserted }
  173. systemunit : tglobalsymtable; { pointer to the system unit }
  174. read_member : boolean; { reading members of an symtable }
  175. lexlevel : longint; { level of code }
  176. { 1 for main procedure }
  177. { 2 for normal function or proc }
  178. { higher for locals }
  179. {****************************************************************************
  180. Functions
  181. ****************************************************************************}
  182. {*** Misc ***}
  183. procedure globaldef(const s : string;var t:ttype);
  184. function findunitsymtable(st:tsymtable):tsymtable;
  185. procedure duplicatesym(sym:tsym);
  186. {*** Search ***}
  187. function searchsym(const s : stringid;var srsym:tsym;var srsymtable:tsymtable):boolean;
  188. function searchsymonlyin(p : tsymtable;const s : stringid):tsym;
  189. function searchsystype(const s: stringid; var srsym: ttypesym): boolean;
  190. function searchsysvar(const s: stringid; var srsym: tvarsym; var symowner: tsymtable): boolean;
  191. function search_class_member(pd : tobjectdef;const s : string):tsym;
  192. {*** Object Helpers ***}
  193. function search_default_property(pd : tobjectdef) : tpropertysym;
  194. {*** symtable stack ***}
  195. procedure dellexlevel;
  196. procedure RestoreUnitSyms;
  197. {$ifdef DEBUG}
  198. procedure test_symtablestack;
  199. procedure list_symtablestack;
  200. {$endif DEBUG}
  201. {$ifdef UNITALIASES}
  202. type
  203. punit_alias = ^tunit_alias;
  204. tunit_alias = object(TNamedIndexItem)
  205. newname : pstring;
  206. constructor init(const n:string);
  207. destructor done;virtual;
  208. end;
  209. var
  210. unitaliases : pdictionary;
  211. procedure addunitalias(const n:string);
  212. function getunitalias(const n:string):string;
  213. {$endif UNITALIASES}
  214. {*** Init / Done ***}
  215. procedure InitSymtable;
  216. procedure DoneSymtable;
  217. type
  218. toverloaded_operators = array[NOTOKEN..last_overloaded] of tprocsym;
  219. var
  220. overloaded_operators : toverloaded_operators;
  221. { unequal is not equal}
  222. const
  223. overloaded_names : array [NOTOKEN..last_overloaded] of string[16] =
  224. ('error',
  225. 'plus','minus','star','slash','equal',
  226. 'greater','lower','greater_or_equal',
  227. 'lower_or_equal',
  228. 'sym_diff','starstar',
  229. 'as','is','in','or',
  230. 'and','div','mod','not','shl','shr','xor',
  231. 'assign');
  232. implementation
  233. uses
  234. { global }
  235. version,verbose,globals,
  236. { target }
  237. systems,
  238. { module }
  239. finput,fmodule,
  240. {$ifdef GDB}
  241. gdb,
  242. {$endif GDB}
  243. { codegen }
  244. cgbase
  245. ;
  246. var
  247. in_loading : boolean; { remove !!! }
  248. {*****************************************************************************
  249. TStoredSymtable
  250. *****************************************************************************}
  251. procedure tstoredsymtable.load(ppufile:tcompilerppufile);
  252. begin
  253. { load definitions }
  254. loaddefs(ppufile);
  255. { load symbols }
  256. loadsyms(ppufile);
  257. end;
  258. procedure tstoredsymtable.write(ppufile:tcompilerppufile);
  259. begin
  260. { write definitions }
  261. writedefs(ppufile);
  262. { write symbols }
  263. writesyms(ppufile);
  264. end;
  265. procedure tstoredsymtable.loaddefs(ppufile:tcompilerppufile);
  266. var
  267. hp : tdef;
  268. b : byte;
  269. begin
  270. { load start of definition section, which holds the amount of defs }
  271. if ppufile.readentry<>ibstartdefs then
  272. Message(unit_f_ppu_read_error);
  273. ppufile.getlongint;
  274. { read definitions }
  275. repeat
  276. b:=ppufile.readentry;
  277. case b of
  278. ibpointerdef : hp:=tpointerdef.load(ppufile);
  279. ibarraydef : hp:=tarraydef.load(ppufile);
  280. iborddef : hp:=torddef.load(ppufile);
  281. ibfloatdef : hp:=tfloatdef.load(ppufile);
  282. ibprocdef : hp:=tprocdef.load(ppufile);
  283. ibshortstringdef : hp:=tstringdef.loadshort(ppufile);
  284. iblongstringdef : hp:=tstringdef.loadlong(ppufile);
  285. ibansistringdef : hp:=tstringdef.loadansi(ppufile);
  286. ibwidestringdef : hp:=tstringdef.loadwide(ppufile);
  287. ibrecorddef : hp:=trecorddef.load(ppufile);
  288. ibobjectdef : hp:=tobjectdef.load(ppufile);
  289. ibenumdef : hp:=tenumdef.load(ppufile);
  290. ibsetdef : hp:=tsetdef.load(ppufile);
  291. ibprocvardef : hp:=tprocvardef.load(ppufile);
  292. ibfiledef : hp:=tfiledef.load(ppufile);
  293. ibclassrefdef : hp:=tclassrefdef.load(ppufile);
  294. ibformaldef : hp:=tformaldef.load(ppufile);
  295. ibvariantdef : hp:=tvariantdef.load(ppufile);
  296. ibenddefs : break;
  297. ibend : Message(unit_f_ppu_read_error);
  298. else
  299. Message1(unit_f_ppu_invalid_entry,tostr(b));
  300. end;
  301. hp.owner:=self;
  302. defindex.insert(hp);
  303. until false;
  304. end;
  305. procedure tstoredsymtable.loadsyms(ppufile:tcompilerppufile);
  306. var
  307. b : byte;
  308. sym : tsym;
  309. begin
  310. { load start of definition section, which holds the amount of defs }
  311. if ppufile.readentry<>ibstartsyms then
  312. Message(unit_f_ppu_read_error);
  313. { skip amount of symbols, not used currently }
  314. ppufile.getlongint;
  315. { load datasize,dataalignment of this symboltable }
  316. datasize:=ppufile.getlongint;
  317. dataalignment:=ppufile.getlongint;
  318. { now read the symbols }
  319. repeat
  320. b:=ppufile.readentry;
  321. case b of
  322. ibtypesym : sym:=ttypesym.load(ppufile);
  323. ibprocsym : sym:=tprocsym.load(ppufile);
  324. ibconstsym : sym:=tconstsym.load(ppufile);
  325. ibvarsym : sym:=tvarsym.load(ppufile);
  326. ibfuncretsym : sym:=tfuncretsym.load(ppufile);
  327. ibabsolutesym : sym:=tabsolutesym.load(ppufile);
  328. ibenumsym : sym:=tenumsym.load(ppufile);
  329. ibtypedconstsym : sym:=ttypedconstsym.load(ppufile);
  330. ibpropertysym : sym:=tpropertysym.load(ppufile);
  331. ibunitsym : sym:=tunitsym.load(ppufile);
  332. iblabelsym : sym:=tlabelsym.load(ppufile);
  333. ibsyssym : sym:=tsyssym.load(ppufile);
  334. ibrttisym : sym:=trttisym.load(ppufile);
  335. ibendsyms : break;
  336. ibend : Message(unit_f_ppu_read_error);
  337. else
  338. Message1(unit_f_ppu_invalid_entry,tostr(b));
  339. end;
  340. sym.owner:=self;
  341. symindex.insert(sym);
  342. symsearch.insert(sym);
  343. until false;
  344. end;
  345. procedure tstoredsymtable.writedefs(ppufile:tcompilerppufile);
  346. var
  347. pd : tstoreddef;
  348. begin
  349. { each definition get a number, write then the amount of defs to the
  350. ibstartdef entry }
  351. ppufile.putlongint(defindex.count);
  352. ppufile.writeentry(ibstartdefs);
  353. { now write the definition }
  354. pd:=tstoreddef(defindex.first);
  355. while assigned(pd) do
  356. begin
  357. pd.write(ppufile);
  358. pd:=tstoreddef(pd.indexnext);
  359. end;
  360. { write end of definitions }
  361. ppufile.writeentry(ibenddefs);
  362. end;
  363. procedure tstoredsymtable.writesyms(ppufile:tcompilerppufile);
  364. var
  365. pd : tstoredsym;
  366. begin
  367. { each definition get a number, write then the amount of syms and the
  368. datasize to the ibsymdef entry }
  369. ppufile.putlongint(symindex.count);
  370. ppufile.putlongint(datasize);
  371. ppufile.putlongint(dataalignment);
  372. ppufile.writeentry(ibstartsyms);
  373. { foreach is used to write all symbols }
  374. pd:=tstoredsym(symindex.first);
  375. while assigned(pd) do
  376. begin
  377. pd.write(ppufile);
  378. pd:=tstoredsym(pd.indexnext);
  379. end;
  380. { end of symbols }
  381. ppufile.writeentry(ibendsyms);
  382. end;
  383. procedure tstoredsymtable.load_references(ppufile:tcompilerppufile;locals:boolean);
  384. var
  385. b : byte;
  386. sym : tstoredsym;
  387. prdef : tstoreddef;
  388. begin
  389. b:=ppufile.readentry;
  390. if b <> ibbeginsymtablebrowser then
  391. Message1(unit_f_ppu_invalid_entry,tostr(b));
  392. repeat
  393. b:=ppufile.readentry;
  394. case b of
  395. ibsymref :
  396. begin
  397. sym:=tstoredsym(ppufile.getderef);
  398. resolvesym(tsym(sym));
  399. if assigned(sym) then
  400. sym.load_references(ppufile,locals);
  401. end;
  402. ibdefref :
  403. begin
  404. prdef:=tstoreddef(ppufile.getderef);
  405. resolvedef(tdef(prdef));
  406. if assigned(prdef) then
  407. begin
  408. if prdef.deftype<>procdef then
  409. Message(unit_f_ppu_read_error);
  410. tprocdef(prdef).load_references(ppufile,locals);
  411. end;
  412. end;
  413. ibendsymtablebrowser :
  414. break;
  415. else
  416. Message1(unit_f_ppu_invalid_entry,tostr(b));
  417. end;
  418. until false;
  419. end;
  420. procedure tstoredsymtable.write_references(ppufile:tcompilerppufile;locals:boolean);
  421. var
  422. pd : tstoredsym;
  423. begin
  424. ppufile.writeentry(ibbeginsymtablebrowser);
  425. { write all symbols }
  426. pd:=tstoredsym(symindex.first);
  427. while assigned(pd) do
  428. begin
  429. pd.write_references(ppufile,locals);
  430. pd:=tstoredsym(pd.indexnext);
  431. end;
  432. ppufile.writeentry(ibendsymtablebrowser);
  433. end;
  434. procedure tstoredsymtable.deref;
  435. var
  436. hp : tdef;
  437. hs : tsym;
  438. begin
  439. { deref the interface definitions }
  440. hp:=tdef(defindex.first);
  441. while assigned(hp) do
  442. begin
  443. hp.deref;
  444. hp:=tdef(hp.indexnext);
  445. end;
  446. { first deref the interface ttype symbols }
  447. hs:=tsym(symindex.first);
  448. while assigned(hs) do
  449. begin
  450. if hs.typ=typesym then
  451. hs.deref;
  452. hs:=tsym(hs.indexnext);
  453. end;
  454. { deref the interface symbols }
  455. hs:=tsym(symindex.first);
  456. while assigned(hs) do
  457. begin
  458. if hs.typ<>typesym then
  459. hs.deref;
  460. hs:=tsym(hs.indexnext);
  461. end;
  462. end;
  463. procedure tstoredsymtable.derefimpl;
  464. var
  465. hp : tdef;
  466. begin
  467. { deref the implementation part of definitions }
  468. hp:=tdef(defindex.first);
  469. while assigned(hp) do
  470. begin
  471. hp.derefimpl;
  472. hp:=tdef(hp.indexnext);
  473. end;
  474. end;
  475. procedure tstoredsymtable.insert(sym:tsymentry);
  476. var
  477. hsym : tsym;
  478. begin
  479. { set owner and sym indexnb }
  480. sym.owner:=self;
  481. { writes the symbol in data segment if required }
  482. { also sets the datasize of owner }
  483. if not in_loading then
  484. tstoredsym(sym).insert_in_data;
  485. { check the current symtable }
  486. hsym:=tsym(search(sym.name));
  487. if assigned(hsym) then
  488. begin
  489. { in TP and Delphi you can have a local with the
  490. same name as the function, the function is then hidden for
  491. the user. (Under delphi it can still be accessed using result),
  492. but don't allow hiding of RESULT }
  493. if (m_tp in aktmodeswitches) and
  494. (hsym.typ=funcretsym) and
  495. not((m_result in aktmodeswitches) and
  496. (hsym.name='RESULT')) then
  497. hsym.owner.rename(hsym.name,'hidden'+hsym.name)
  498. else
  499. begin
  500. DuplicateSym(hsym);
  501. exit;
  502. end;
  503. end;
  504. { register definition of typesym }
  505. if (sym.typ = typesym) and
  506. assigned(ttypesym(sym).restype.def) then
  507. begin
  508. if not(assigned(ttypesym(sym).restype.def.owner)) and
  509. (ttypesym(sym).restype.def.deftype<>errordef) then
  510. registerdef(ttypesym(sym).restype.def);
  511. {$ifdef GDB}
  512. if (cs_debuginfo in aktmoduleswitches) and assigned(debuglist) and
  513. (symtabletype in [globalsymtable,staticsymtable]) then
  514. begin
  515. ttypesym(sym).isusedinstab := true;
  516. {sym.concatstabto(debuglist);}
  517. end;
  518. {$endif GDB}
  519. end;
  520. { insert in index and search hash }
  521. symindex.insert(sym);
  522. symsearch.insert(sym);
  523. end;
  524. function tstoredsymtable.speedsearch(const s : stringid;speedvalue : cardinal) : tsymentry;
  525. var
  526. hp : tstoredsym;
  527. newref : tref;
  528. begin
  529. hp:=tstoredsym(inherited speedsearch(s,speedvalue));
  530. if assigned(hp) then
  531. begin
  532. { reject non static members in static procedures }
  533. if (symtabletype=objectsymtable) and
  534. not(sp_static in hp.symoptions) and
  535. allow_only_static then
  536. Message(sym_e_only_static_in_static);
  537. { unit uses count }
  538. if (unitid<>0) and
  539. (symtabletype = globalsymtable) and
  540. assigned(tglobalsymtable(self).unitsym) then
  541. inc(tglobalsymtable(self).unitsym.refs);
  542. {$ifdef GDB}
  543. { if it is a type, we need the stabs of this type
  544. this might be the cause of the class debug problems
  545. as TCHILDCLASS.Create did not generate appropriate
  546. stabs debug info if TCHILDCLASS wasn't used anywhere else PM }
  547. if (cs_debuginfo in aktmoduleswitches) and
  548. (hp.typ=typesym) and
  549. make_ref then
  550. begin
  551. if assigned(ttypesym(hp).restype.def) then
  552. tstoreddef(ttypesym(hp).restype.def).numberstring
  553. else
  554. ttypesym(hp).isusedinstab:=true;
  555. end;
  556. {$endif GDB}
  557. { unitsym are only loaded for browsing PM }
  558. { this was buggy anyway because we could use }
  559. { unitsyms from other units in _USES !! }
  560. {if (symtabletype=unitsymtable) and (hp.typ=unitsym) and
  561. assigned(current_module) and (current_module.globalsymtable<>.load) then
  562. hp:=nil;}
  563. if assigned(hp) and
  564. make_ref and
  565. (cs_browser in aktmoduleswitches) then
  566. begin
  567. newref:=tref.create(hp.lastref,@akttokenpos);
  568. { for symbols that are in tables without
  569. browser info or syssyms (PM) }
  570. if hp.refcount=0 then
  571. begin
  572. hp.defref:=newref;
  573. hp.lastref:=newref;
  574. end
  575. else
  576. if resolving_forward and assigned(hp.defref) then
  577. { put it as second reference }
  578. begin
  579. newref.nextref:=hp.defref.nextref;
  580. hp.defref.nextref:=newref;
  581. hp.lastref.nextref:=nil;
  582. end
  583. else
  584. hp.lastref:=newref;
  585. inc(hp.refcount);
  586. end;
  587. if assigned(hp) and make_ref then
  588. begin
  589. inc(hp.refs);
  590. end;
  591. end;
  592. speedsearch:=hp;
  593. end;
  594. {**************************************
  595. Callbacks
  596. **************************************}
  597. procedure TStoredSymtable.check_forward(sym : TNamedIndexItem);
  598. begin
  599. if tsym(sym).typ=procsym then
  600. tprocsym(sym).check_forward
  601. { check also object method table }
  602. { we needn't to test the def list }
  603. { because each object has to have a type sym }
  604. else
  605. if (tsym(sym).typ=typesym) and
  606. assigned(ttypesym(sym).restype.def) and
  607. (ttypesym(sym).restype.def.deftype=objectdef) then
  608. tobjectdef(ttypesym(sym).restype.def).check_forwards;
  609. end;
  610. procedure TStoredSymtable.labeldefined(p : TNamedIndexItem);
  611. begin
  612. if (tsym(p).typ=labelsym) and
  613. not(tlabelsym(p).defined) then
  614. begin
  615. if tlabelsym(p).used then
  616. Message1(sym_e_label_used_and_not_defined,tlabelsym(p).realname)
  617. else
  618. Message1(sym_w_label_not_defined,tlabelsym(p).realname);
  619. end;
  620. end;
  621. procedure TStoredSymtable.unitsymbolused(p : TNamedIndexItem);
  622. begin
  623. if (tsym(p).typ=unitsym) and
  624. (tunitsym(p).refs=0) and
  625. { do not claim for unit name itself !! }
  626. (tunitsym(p).unitsymtable.symtabletype=globalsymtable) then
  627. MessagePos2(tsym(p).fileinfo,sym_n_unit_not_used,
  628. p.name,current_module.modulename^);
  629. end;
  630. procedure TStoredSymtable.varsymbolused(p : TNamedIndexItem);
  631. begin
  632. if (tsym(p).typ=varsym) and
  633. ((tsym(p).owner.symtabletype in
  634. [parasymtable,localsymtable,objectsymtable,staticsymtable])) then
  635. begin
  636. { unused symbol should be reported only if no }
  637. { error is reported }
  638. { if the symbol is in a register it is used }
  639. { also don't count the value parameters which have local copies }
  640. { also don't claim for high param of open parameters (PM) }
  641. if (Errorcount<>0) or
  642. (copy(p.name,1,3)='val') or
  643. (copy(p.name,1,4)='high') then
  644. exit;
  645. if (tvarsym(p).refs=0) then
  646. begin
  647. if (tsym(p).owner.symtabletype=parasymtable) or (vo_is_local_copy in tvarsym(p).varoptions) then
  648. begin
  649. MessagePos1(tsym(p).fileinfo,sym_h_para_identifier_not_used,tsym(p).realname);
  650. end
  651. else if (tsym(p).owner.symtabletype=objectsymtable) then
  652. MessagePos2(tsym(p).fileinfo,sym_n_private_identifier_not_used,tsym(p).owner.realname^,tsym(p).realname)
  653. else
  654. MessagePos1(tsym(p).fileinfo,sym_n_local_identifier_not_used,tsym(p).realname);
  655. end
  656. else if tvarsym(p).varstate=vs_assigned then
  657. begin
  658. if (tsym(p).owner.symtabletype=parasymtable) then
  659. begin
  660. if not(tvarsym(p).varspez in [vs_var,vs_out]) then
  661. MessagePos1(tsym(p).fileinfo,sym_h_para_identifier_only_set,tsym(p).realname)
  662. end
  663. else if (vo_is_local_copy in tvarsym(p).varoptions) then
  664. begin
  665. if not(tvarsym(p).varspez in [vs_var,vs_out]) then
  666. MessagePos1(tsym(p).fileinfo,sym_h_para_identifier_only_set,tsym(p).realname);
  667. end
  668. else if (tsym(p).owner.symtabletype=objectsymtable) then
  669. MessagePos2(tsym(p).fileinfo,sym_n_private_identifier_only_set,tsym(p).owner.realname^,tsym(p).realname)
  670. else if (tsym(p).owner.symtabletype<>parasymtable) then
  671. if not (vo_is_exported in tvarsym(p).varoptions) then
  672. MessagePos1(tsym(p).fileinfo,sym_n_local_identifier_only_set,tsym(p).realname);
  673. end;
  674. end
  675. else if ((tsym(p).owner.symtabletype in
  676. [objectsymtable,parasymtable,localsymtable,staticsymtable])) then
  677. begin
  678. if (Errorcount<>0) then
  679. exit;
  680. { do not claim for inherited private fields !! }
  681. if (tstoredsym(p).refs=0) and (tsym(p).owner.symtabletype=objectsymtable) then
  682. MessagePos2(tsym(p).fileinfo,sym_n_private_method_not_used,tsym(p).owner.realname^,tsym(p).realname)
  683. { units references are problematic }
  684. else if (tstoredsym(p).refs=0) and not(tsym(p).typ in [funcretsym,enumsym,unitsym]) then
  685. if (tsym(p).typ<>procsym) or not (tprocsym(p).is_global) or
  686. { all program functions are declared global
  687. but unused should still be signaled PM }
  688. ((tsym(p).owner.symtabletype=staticsymtable) and
  689. not current_module.is_unit) then
  690. MessagePos2(tsym(p).fileinfo,sym_h_local_symbol_not_used,SymTypeName[tsym(p).typ],tsym(p).realname);
  691. end;
  692. end;
  693. procedure TStoredSymtable.TestPrivate(p : TNamedIndexItem);
  694. begin
  695. if sp_private in tsym(p).symoptions then
  696. varsymbolused(p);
  697. end;
  698. procedure TStoredSymtable.objectprivatesymbolused(p : TNamedIndexItem);
  699. begin
  700. {
  701. Don't test simple object aliases PM
  702. }
  703. if (tsym(p).typ=typesym) and
  704. (ttypesym(p).restype.def.deftype=objectdef) and
  705. (ttypesym(p).restype.def.typesym=tsym(p)) then
  706. tobjectdef(ttypesym(p).restype.def).symtable.foreach({$ifdef FPCPROCVAR}@{$endif}TestPrivate);
  707. end;
  708. procedure tstoredsymtable.unchain_overloads(p : TNamedIndexItem);
  709. begin
  710. if tsym(p).typ=procsym then
  711. tprocsym(p).unchain_overload;
  712. end;
  713. {$ifdef GDB}
  714. procedure TStoredSymtable.concatstab(p : TNamedIndexItem);
  715. begin
  716. if tsym(p).typ <> procsym then
  717. tstoredsym(p).concatstabto(asmoutput);
  718. end;
  719. procedure TStoredSymtable.resetstab(p : TNamedIndexItem);
  720. begin
  721. if tsym(p).typ <> procsym then
  722. tstoredsym(p).isstabwritten:=false;
  723. end;
  724. procedure TStoredSymtable.concattypestab(p : TNamedIndexItem);
  725. begin
  726. if tsym(p).typ = typesym then
  727. begin
  728. tstoredsym(p).isstabwritten:=false;
  729. tstoredsym(p).concatstabto(asmoutput);
  730. end;
  731. end;
  732. function tstoredsymtable.getnewtypecount : word;
  733. begin
  734. getnewtypecount:=pglobaltypecount^;
  735. inc(pglobaltypecount^);
  736. end;
  737. {$endif GDB}
  738. procedure tstoredsymtable.chainoperators;
  739. var
  740. p : tprocsym;
  741. pd : pprocdeflist;
  742. t : ttoken;
  743. def : tprocdef;
  744. srsym : tsym;
  745. srsymtable,
  746. storesymtablestack : tsymtable;
  747. begin
  748. storesymtablestack:=symtablestack;
  749. symtablestack:=self;
  750. make_ref:=false;
  751. for t:=first_overloaded to last_overloaded do
  752. begin
  753. p:=nil;
  754. def:=nil;
  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. begin
  777. { already got a procsym, only add defs of the current procsym }
  778. pd:=tprocsym(srsym).defs;
  779. while assigned(pd) do
  780. begin
  781. overloaded_operators[t].addprocdef(pd^.def);
  782. pd:=pd^.next;
  783. end;
  784. end;
  785. symtablestack:=srsym.owner.next;
  786. end
  787. else
  788. begin
  789. symtablestack:=nil;
  790. end;
  791. { search for same procsym in other units }
  792. end;
  793. symtablestack:=self;
  794. end;
  795. make_ref:=true;
  796. symtablestack:=storesymtablestack;
  797. end;
  798. {***********************************************
  799. Process all entries
  800. ***********************************************}
  801. { checks, if all procsyms and methods are defined }
  802. procedure tstoredsymtable.check_forwards;
  803. begin
  804. foreach({$ifdef FPCPROCVAR}@{$endif}check_forward);
  805. end;
  806. procedure tstoredsymtable.checklabels;
  807. begin
  808. foreach({$ifdef FPCPROCVAR}@{$endif}labeldefined);
  809. end;
  810. procedure tstoredsymtable.allunitsused;
  811. begin
  812. foreach({$ifdef FPCPROCVAR}@{$endif}unitsymbolused);
  813. end;
  814. procedure tstoredsymtable.allsymbolsused;
  815. begin
  816. foreach({$ifdef FPCPROCVAR}@{$endif}varsymbolused);
  817. end;
  818. procedure tstoredsymtable.allprivatesused;
  819. begin
  820. foreach({$ifdef FPCPROCVAR}@{$endif}objectprivatesymbolused);
  821. end;
  822. procedure tstoredsymtable.unchain_overloaded;
  823. begin
  824. foreach({$ifdef FPCPROCVAR}@{$endif}unchain_overloads);
  825. end;
  826. {$ifdef GDB}
  827. procedure tstoredsymtable.concatstabto(asmlist : taasmoutput);
  828. begin
  829. asmoutput:=asmlist;
  830. if symtabletype in [inlineparasymtable,inlinelocalsymtable] then
  831. foreach({$ifdef FPCPROCVAR}@{$endif}resetstab);
  832. foreach({$ifdef FPCPROCVAR}@{$endif}concatstab);
  833. end;
  834. {$endif}
  835. { returns true, if p contains data which needs init/final code }
  836. function tstoredsymtable.needs_init_final : boolean;
  837. begin
  838. b_needs_init_final:=false;
  839. foreach({$ifdef FPCPROCVAR}@{$endif}_needs_init_final);
  840. needs_init_final:=b_needs_init_final;
  841. end;
  842. {****************************************************************************
  843. TAbstractRecordSymtable
  844. ****************************************************************************}
  845. procedure tabstractrecordsymtable.load(ppufile:tcompilerppufile);
  846. var
  847. storesymtable : tsymtable;
  848. begin
  849. storesymtable:=aktrecordsymtable;
  850. aktrecordsymtable:=self;
  851. inherited load(ppufile);
  852. aktrecordsymtable:=storesymtable;
  853. end;
  854. procedure tabstractrecordsymtable.write(ppufile:tcompilerppufile);
  855. var
  856. oldtyp : byte;
  857. storesymtable : tsymtable;
  858. begin
  859. storesymtable:=aktrecordsymtable;
  860. aktrecordsymtable:=self;
  861. oldtyp:=ppufile.entrytyp;
  862. ppufile.entrytyp:=subentryid;
  863. inherited write(ppufile);
  864. ppufile.entrytyp:=oldtyp;
  865. aktrecordsymtable:=storesymtable;
  866. end;
  867. procedure tabstractrecordsymtable.load_references(ppufile:tcompilerppufile;locals:boolean);
  868. var
  869. storesymtable : tsymtable;
  870. begin
  871. storesymtable:=aktrecordsymtable;
  872. aktrecordsymtable:=self;
  873. inherited load_references(ppufile,locals);
  874. aktrecordsymtable:=storesymtable;
  875. end;
  876. procedure tabstractrecordsymtable.write_references(ppufile:tcompilerppufile;locals:boolean);
  877. var
  878. storesymtable : tsymtable;
  879. begin
  880. storesymtable:=aktrecordsymtable;
  881. aktrecordsymtable:=self;
  882. inherited write_references(ppufile,locals);
  883. aktrecordsymtable:=storesymtable;
  884. end;
  885. procedure TStoredSymtable._needs_init_final(p : tnamedindexitem);
  886. begin
  887. if (not b_needs_init_final) and
  888. (tsym(p).typ=varsym) and
  889. assigned(tvarsym(p).vartype.def) and
  890. not is_class(tvarsym(p).vartype.def) and
  891. tstoreddef(tvarsym(p).vartype.def).needs_inittable then
  892. b_needs_init_final:=true;
  893. end;
  894. {****************************************************************************
  895. TRecordSymtable
  896. ****************************************************************************}
  897. constructor trecordsymtable.create;
  898. begin
  899. inherited create('');
  900. symtabletype:=recordsymtable;
  901. end;
  902. { this procedure is reserved for inserting case variant into
  903. a record symtable }
  904. { the offset is the location of the start of the variant
  905. and datasize and dataalignment corresponds to
  906. the complete size (see code in pdecl unit) PM }
  907. procedure trecordsymtable.insert_in(tsymt : tsymtable;offset : longint);
  908. var
  909. ps,nps : tvarsym;
  910. pd,npd : tdef;
  911. storesize,storealign : longint;
  912. begin
  913. storesize:=tsymt.datasize;
  914. storealign:=tsymt.dataalignment;
  915. tsymt.datasize:=offset;
  916. ps:=tvarsym(symindex.first);
  917. while assigned(ps) do
  918. begin
  919. { this is used to insert case variant into the main
  920. record }
  921. tsymt.datasize:=ps.address+offset;
  922. nps:=tvarsym(ps.indexnext);
  923. symindex.deleteindex(ps);
  924. ps.left:=nil;
  925. ps.right:=nil;
  926. tsymt.insert(ps);
  927. ps:=nps;
  928. end;
  929. pd:=tdef(defindex.first);
  930. while assigned(pd) do
  931. begin
  932. npd:=tdef(pd.indexnext);
  933. defindex.deleteindex(pd);
  934. pd.left:=nil;
  935. pd.right:=nil;
  936. tsymt.registerdef(pd);
  937. pd:=npd;
  938. end;
  939. tsymt.datasize:=storesize;
  940. tsymt.dataalignment:=storealign;
  941. end;
  942. {****************************************************************************
  943. TObjectSymtable
  944. ****************************************************************************}
  945. constructor tobjectsymtable.create(const n:string);
  946. begin
  947. inherited create(n);
  948. symtabletype:=objectsymtable;
  949. end;
  950. procedure tobjectsymtable.insert(sym:tsymentry);
  951. var
  952. hsym : tsym;
  953. begin
  954. { check for duplicate field id in inherited classes }
  955. if (sym.typ=varsym) and
  956. assigned(defowner) and
  957. (
  958. not(m_delphi in aktmodeswitches) or
  959. is_object(tdef(defowner))
  960. ) then
  961. begin
  962. { but private ids can be reused }
  963. hsym:=search_class_member(tobjectdef(defowner),sym.name);
  964. if assigned(hsym) and
  965. hsym.check_private then
  966. begin
  967. DuplicateSym(hsym);
  968. exit;
  969. end;
  970. end;
  971. inherited insert(sym);
  972. end;
  973. {****************************************************************************
  974. TAbstractLocalSymtable
  975. ****************************************************************************}
  976. procedure tabstractlocalsymtable.load(ppufile:tcompilerppufile);
  977. var
  978. storesymtable : tsymtable;
  979. begin
  980. storesymtable:=aktlocalsymtable;
  981. aktlocalsymtable:=self;
  982. inherited load(ppufile);
  983. aktlocalsymtable:=storesymtable;
  984. end;
  985. procedure tabstractlocalsymtable.write(ppufile:tcompilerppufile);
  986. var
  987. oldtyp : byte;
  988. storesymtable : tsymtable;
  989. begin
  990. storesymtable:=aktlocalsymtable;
  991. aktlocalsymtable:=self;
  992. oldtyp:=ppufile.entrytyp;
  993. ppufile.entrytyp:=subentryid;
  994. { write definitions }
  995. writedefs(ppufile);
  996. { write symbols }
  997. writesyms(ppufile);
  998. ppufile.entrytyp:=oldtyp;
  999. aktlocalsymtable:=storesymtable;
  1000. end;
  1001. procedure tabstractlocalsymtable.load_references(ppufile:tcompilerppufile;locals:boolean);
  1002. var
  1003. storesymtable : tsymtable;
  1004. begin
  1005. storesymtable:=aktlocalsymtable;
  1006. aktlocalsymtable:=self;
  1007. inherited load_references(ppufile,locals);
  1008. aktlocalsymtable:=storesymtable;
  1009. end;
  1010. procedure tabstractlocalsymtable.write_references(ppufile:tcompilerppufile;locals:boolean);
  1011. var
  1012. storesymtable : tsymtable;
  1013. begin
  1014. storesymtable:=aktlocalsymtable;
  1015. aktlocalsymtable:=self;
  1016. inherited write_references(ppufile,locals);
  1017. aktlocalsymtable:=storesymtable;
  1018. end;
  1019. {****************************************************************************
  1020. TLocalSymtable
  1021. ****************************************************************************}
  1022. constructor tlocalsymtable.create;
  1023. begin
  1024. inherited create('');
  1025. symtabletype:=localsymtable;
  1026. end;
  1027. procedure tlocalsymtable.insert(sym:tsymentry);
  1028. var
  1029. hsym : tsym;
  1030. begin
  1031. if assigned(next) then
  1032. begin
  1033. if (next.symtabletype=parasymtable) then
  1034. begin
  1035. hsym:=tsym(next.search(sym.name));
  1036. if assigned(hsym) then
  1037. begin
  1038. { a parameter and the function can have the same
  1039. name in TP and Delphi, but RESULT not }
  1040. if (m_tp in aktmodeswitches) and
  1041. (sym.typ=funcretsym) and
  1042. not((m_result in aktmodeswitches) and
  1043. (sym.name='RESULT')) then
  1044. sym.name:='hidden'+sym.name
  1045. else
  1046. begin
  1047. DuplicateSym(hsym);
  1048. exit;
  1049. end;
  1050. end;
  1051. end;
  1052. { check for duplicate id in local symtable of methods }
  1053. if assigned(next.next) and
  1054. { funcretsym is allowed !! }
  1055. (sym.typ <> funcretsym) and
  1056. (next.next.symtabletype=objectsymtable) then
  1057. begin
  1058. hsym:=search_class_member(tobjectdef(next.next.defowner),sym.name);
  1059. if assigned(hsym) and
  1060. { private ids can be reused }
  1061. (not(sp_private in hsym.symoptions) or
  1062. (hsym.owner.defowner.owner.symtabletype<>globalsymtable)) then
  1063. begin
  1064. { delphi allows to reuse the names in a class, but not
  1065. in object (tp7 compatible) }
  1066. if not((m_delphi in aktmodeswitches) and
  1067. is_class(tdef(next.next.defowner))) then
  1068. begin
  1069. DuplicateSym(hsym);
  1070. exit;
  1071. end;
  1072. end;
  1073. end;
  1074. end;
  1075. inherited insert(sym);
  1076. end;
  1077. {****************************************************************************
  1078. TParaSymtable
  1079. ****************************************************************************}
  1080. constructor tparasymtable.create;
  1081. begin
  1082. inherited create('');
  1083. symtabletype:=parasymtable;
  1084. dataalignment:=aktalignment.paraalign;
  1085. end;
  1086. procedure tparasymtable.insert(sym:tsymentry);
  1087. var
  1088. hsym : tsym;
  1089. begin
  1090. { check for duplicate id in para symtable of methods }
  1091. if assigned(procinfo^._class) and
  1092. { but not in nested procedures !}
  1093. (not(assigned(procinfo^.parent)) or
  1094. (assigned(procinfo^.parent) and
  1095. not(assigned(procinfo^.parent^._class)))
  1096. ) and
  1097. { funcretsym is allowed !! }
  1098. (sym.typ <> funcretsym) then
  1099. begin
  1100. hsym:=search_class_member(procinfo^._class,sym.name);
  1101. { private ids can be reused }
  1102. if assigned(hsym) and
  1103. hsym.check_private then
  1104. begin
  1105. { delphi allows to reuse the names in a class, but not
  1106. in object (tp7 compatible) }
  1107. if not((m_delphi in aktmodeswitches) and
  1108. is_class(procinfo^._class)) then
  1109. begin
  1110. DuplicateSym(hsym);
  1111. exit;
  1112. end;
  1113. end;
  1114. end;
  1115. inherited insert(sym);
  1116. end;
  1117. procedure tparasymtable.set_alignment(_alignment : longint);
  1118. var
  1119. sym : tvarsym;
  1120. l : longint;
  1121. begin
  1122. dataalignment:=_alignment;
  1123. sym:=tvarsym(symindex.first);
  1124. datasize:=0;
  1125. { there can be only varsyms }
  1126. while assigned(sym) do
  1127. begin
  1128. l:=sym.getpushsize;
  1129. sym.address:=datasize;
  1130. datasize:=align(datasize+l,dataalignment);
  1131. sym:=tvarsym(sym.indexnext);
  1132. end;
  1133. end;
  1134. {****************************************************************************
  1135. TAbstractUnitSymtable
  1136. ****************************************************************************}
  1137. constructor tabstractunitsymtable.create(const n : string);
  1138. begin
  1139. inherited create(n);
  1140. symsearch.usehash;
  1141. {$ifdef GDB}
  1142. { reset GDB things }
  1143. prev_dbx_counter := dbx_counter;
  1144. dbx_counter := nil;
  1145. is_stab_written:=false;
  1146. dbx_count := -1;
  1147. {$endif GDB}
  1148. end;
  1149. {$ifdef GDB}
  1150. procedure tabstractunitsymtable.concattypestabto(asmlist : taasmoutput);
  1151. var prev_dbx_count : plongint;
  1152. begin
  1153. if is_stab_written then
  1154. exit;
  1155. if not assigned(name) then
  1156. name := stringdup('Main_program');
  1157. if (symtabletype = globalsymtable) and
  1158. (current_module.globalsymtable<>self) then
  1159. begin
  1160. unitid:=current_module.unitcount;
  1161. inc(current_module.unitcount);
  1162. end;
  1163. asmList.concat(Tai_asm_comment.Create(strpnew('Begin unit '+name^+' has index '+tostr(unitid))));
  1164. if cs_gdb_dbx in aktglobalswitches then
  1165. begin
  1166. if dbx_count_ok then
  1167. begin
  1168. asmList.concat(Tai_asm_comment.Create(strpnew('"repeated" unit '+name^
  1169. +' has index '+tostr(unitid)+' dbx count = '+tostr(dbx_count))));
  1170. asmList.concat(Tai_stabs.Create(strpnew('"'+name^+'",'
  1171. +tostr(N_EXCL)+',0,0,'+tostr(dbx_count))));
  1172. exit;
  1173. end
  1174. else if (current_module.globalsymtable<>self) then
  1175. begin
  1176. prev_dbx_count := dbx_counter;
  1177. dbx_counter := nil;
  1178. do_count_dbx:=false;
  1179. if (symtabletype = globalsymtable) and (unitid<>0) then
  1180. asmList.concat(Tai_stabs.Create(strpnew('"'+name^+'",'+tostr(N_BINCL)+',0,0,0')));
  1181. dbx_counter := @dbx_count;
  1182. dbx_count:=0;
  1183. do_count_dbx:=assigned(dbx_counter);
  1184. end;
  1185. end;
  1186. asmoutput:=asmlist;
  1187. foreach({$ifdef FPCPROCVAR}@{$endif}concattypestab);
  1188. if cs_gdb_dbx in aktglobalswitches then
  1189. begin
  1190. if (current_module.globalsymtable<>self) then
  1191. begin
  1192. dbx_counter := prev_dbx_count;
  1193. do_count_dbx:=false;
  1194. asmList.concat(Tai_asm_comment.Create(strpnew('End unit '+name^
  1195. +' has index '+tostr(unitid))));
  1196. asmList.concat(Tai_stabs.Create(strpnew('"'+name^+'",'
  1197. +tostr(N_EINCL)+',0,0,0')));
  1198. do_count_dbx:=assigned(dbx_counter);
  1199. dbx_count_ok := {true}false;
  1200. end;
  1201. end;
  1202. is_stab_written:=true;
  1203. end;
  1204. {$endif GDB}
  1205. {****************************************************************************
  1206. TStaticSymtable
  1207. ****************************************************************************}
  1208. constructor tstaticsymtable.create(const n : string);
  1209. begin
  1210. inherited create(n);
  1211. symtabletype:=staticsymtable;
  1212. end;
  1213. procedure tstaticsymtable.load(ppufile:tcompilerppufile);
  1214. begin
  1215. aktstaticsymtable:=self;
  1216. next:=symtablestack;
  1217. symtablestack:=self;
  1218. inherited load(ppufile);
  1219. { now we can deref the syms and defs }
  1220. deref;
  1221. { restore symtablestack }
  1222. symtablestack:=next;
  1223. end;
  1224. procedure tstaticsymtable.write(ppufile:tcompilerppufile);
  1225. begin
  1226. aktstaticsymtable:=self;
  1227. inherited write(ppufile);
  1228. end;
  1229. procedure tstaticsymtable.load_references(ppufile:tcompilerppufile;locals:boolean);
  1230. begin
  1231. aktstaticsymtable:=self;
  1232. inherited load_references(ppufile,locals);
  1233. end;
  1234. procedure tstaticsymtable.write_references(ppufile:tcompilerppufile;locals:boolean);
  1235. begin
  1236. aktstaticsymtable:=self;
  1237. inherited write_references(ppufile,locals);
  1238. end;
  1239. procedure tstaticsymtable.insert(sym:tsymentry);
  1240. var
  1241. hsym : tsym;
  1242. begin
  1243. { also check the global symtable }
  1244. if assigned(next) and
  1245. (next.unitid=0) then
  1246. begin
  1247. hsym:=tsym(next.search(sym.name));
  1248. if assigned(hsym) then
  1249. begin
  1250. DuplicateSym(hsym);
  1251. exit;
  1252. end;
  1253. end;
  1254. inherited insert(sym);
  1255. end;
  1256. {****************************************************************************
  1257. TGlobalSymtable
  1258. ****************************************************************************}
  1259. constructor tglobalsymtable.create(const n : string);
  1260. begin
  1261. inherited create(n);
  1262. symtabletype:=globalsymtable;
  1263. unitid:=0;
  1264. unitsym:=nil;
  1265. {$ifdef GDB}
  1266. if cs_gdb_dbx in aktglobalswitches then
  1267. begin
  1268. dbx_count := 0;
  1269. unittypecount:=1;
  1270. pglobaltypecount := @unittypecount;
  1271. {unitid:=current_module.unitcount;}
  1272. debugList.concat(Tai_asm_comment.Create(strpnew('Global '+name^+' has index '+tostr(unitid))));
  1273. debugList.concat(Tai_stabs.Create(strpnew('"'+name^+'",'+tostr(N_BINCL)+',0,0,0')));
  1274. {inc(current_module.unitcount);}
  1275. dbx_count_ok:=false;
  1276. dbx_counter:=@dbx_count;
  1277. do_count_dbx:=true;
  1278. end;
  1279. {$endif GDB}
  1280. end;
  1281. destructor tglobalsymtable.destroy;
  1282. var
  1283. pus : tunitsym;
  1284. begin
  1285. pus:=unitsym;
  1286. while assigned(pus) do
  1287. begin
  1288. unitsym:=pus.prevsym;
  1289. pus.prevsym:=nil;
  1290. pus.unitsymtable:=nil;
  1291. pus:=unitsym;
  1292. end;
  1293. inherited destroy;
  1294. end;
  1295. procedure tglobalsymtable.load(ppufile:tcompilerppufile);
  1296. {$ifdef GDB}
  1297. var
  1298. storeGlobalTypeCount : pword;
  1299. {$endif GDB}
  1300. begin
  1301. {$ifdef GDB}
  1302. if cs_gdb_dbx in aktglobalswitches then
  1303. begin
  1304. UnitTypeCount:=1;
  1305. storeGlobalTypeCount:=PGlobalTypeCount;
  1306. PglobalTypeCount:=@UnitTypeCount;
  1307. end;
  1308. {$endif GDB}
  1309. symtablelevel:=0;
  1310. {$ifndef NEWMAP}
  1311. current_module.map^[0]:=self;
  1312. {$else NEWMAP}
  1313. current_module.globalsymtable:=self;
  1314. {$endif NEWMAP}
  1315. next:=symtablestack;
  1316. symtablestack:=self;
  1317. inherited load(ppufile);
  1318. { now we can deref the syms and defs }
  1319. deref;
  1320. { restore symtablestack }
  1321. symtablestack:=next;
  1322. {$ifdef NEWMAP}
  1323. { necessary for dependencies }
  1324. current_module.globalsymtable:=nil;
  1325. {$endif NEWMAP}
  1326. end;
  1327. procedure tglobalsymtable.write(ppufile:tcompilerppufile);
  1328. begin
  1329. { write the symtable entries }
  1330. inherited write(ppufile);
  1331. { write dbx count }
  1332. {$ifdef GDB}
  1333. if cs_gdb_dbx in aktglobalswitches then
  1334. begin
  1335. {$IfDef EXTDEBUG}
  1336. writeln('Writing dbx_count ',dbx_count,' in unit ',name^,'.ppu');
  1337. {$ENDIF EXTDEBUG}
  1338. ppufile.do_crc:=false;
  1339. ppufile.putlongint(dbx_count);
  1340. ppufile.writeentry(ibdbxcount);
  1341. ppufile.do_crc:=true;
  1342. end;
  1343. {$endif GDB}
  1344. end;
  1345. procedure tglobalsymtable.insert(sym:tsymentry);
  1346. var
  1347. hsym : tsym;
  1348. begin
  1349. { also check the global symtable }
  1350. if assigned(next) and
  1351. (next.unitid=0) then
  1352. begin
  1353. hsym:=tsym(next.search(sym.name));
  1354. if assigned(hsym) then
  1355. begin
  1356. DuplicateSym(hsym);
  1357. exit;
  1358. end;
  1359. end;
  1360. hsym:=tsym(search(sym.name));
  1361. if assigned(hsym) then
  1362. begin
  1363. { Delphi you can have a symbol with the same name as the
  1364. unit, the unit can then not be accessed anymore using
  1365. <unit>.<id>, so we can hide the symbol }
  1366. if (m_tp in aktmodeswitches) and
  1367. (hsym.typ=symconst.unitsym) then
  1368. hsym.owner.rename(hsym.name,'hidden'+hsym.name)
  1369. else
  1370. begin
  1371. DuplicateSym(hsym);
  1372. exit;
  1373. end;
  1374. end;
  1375. inherited insert(sym);
  1376. end;
  1377. {$ifdef GDB}
  1378. function tglobalsymtable.getnewtypecount : word;
  1379. begin
  1380. if not (cs_gdb_dbx in aktglobalswitches) then
  1381. getnewtypecount:=inherited getnewtypecount
  1382. else
  1383. begin
  1384. getnewtypecount:=unittypecount;
  1385. inc(unittypecount);
  1386. end;
  1387. end;
  1388. {$endif}
  1389. {****************************************************************************
  1390. TWITHSYMTABLE
  1391. ****************************************************************************}
  1392. constructor twithsymtable.create(aowner:tdef;asymsearch:TDictionary);
  1393. begin
  1394. inherited create('');
  1395. symtabletype:=withsymtable;
  1396. direct_with:=false;
  1397. withnode:=nil;
  1398. withrefnode:=nil;
  1399. { we don't need the symsearch }
  1400. symsearch.free;
  1401. { set the defaults }
  1402. symsearch:=asymsearch;
  1403. defowner:=aowner;
  1404. end;
  1405. destructor twithsymtable.destroy;
  1406. begin
  1407. symsearch:=nil;
  1408. inherited destroy;
  1409. end;
  1410. procedure twithsymtable.clear;
  1411. begin
  1412. { remove no entry from a withsymtable as it is only a pointer to the
  1413. recorddef or objectdef symtable }
  1414. end;
  1415. function twithsymtable.speedsearch(const s : stringid;speedvalue : cardinal) : tsymentry;
  1416. var
  1417. hp : tsym;
  1418. begin
  1419. hp:=tsym(inherited speedsearch(s, speedvalue));
  1420. { skip private members that can't be seen }
  1421. if assigned(hp) and
  1422. (sp_private in hp.symoptions) and
  1423. (hp.owner.symtabletype=objectsymtable) and
  1424. (hp.owner.defowner.owner.symtabletype=globalsymtable) and
  1425. (hp.owner.defowner.owner.unitid<>0) then
  1426. hp:=nil;
  1427. speedsearch:=hp;
  1428. end;
  1429. {****************************************************************************
  1430. TSTT_ExceptionSymtable
  1431. ****************************************************************************}
  1432. constructor tstt_exceptsymtable.create;
  1433. begin
  1434. inherited create('');
  1435. symtabletype:=stt_exceptsymtable;
  1436. end;
  1437. {*****************************************************************************
  1438. Helper Routines
  1439. *****************************************************************************}
  1440. function findunitsymtable(st:tsymtable):tsymtable;
  1441. begin
  1442. findunitsymtable:=nil;
  1443. repeat
  1444. if not assigned(st) then
  1445. internalerror(5566561);
  1446. case st.symtabletype of
  1447. localsymtable,
  1448. parasymtable,
  1449. staticsymtable :
  1450. break;
  1451. globalsymtable :
  1452. begin
  1453. findunitsymtable:=st;
  1454. break;
  1455. end;
  1456. objectsymtable,
  1457. recordsymtable :
  1458. st:=st.defowner.owner;
  1459. else
  1460. internalerror(5566562);
  1461. end;
  1462. until false;
  1463. end;
  1464. procedure duplicatesym(sym:tsym);
  1465. var
  1466. st : tsymtable;
  1467. begin
  1468. Message1(sym_e_duplicate_id,sym.realname);
  1469. st:=findunitsymtable(sym.owner);
  1470. with sym.fileinfo do
  1471. begin
  1472. if assigned(st) and (st.unitid<>0) then
  1473. Message2(sym_h_duplicate_id_where,'unit '+st.name^,tostr(line))
  1474. else
  1475. Message2(sym_h_duplicate_id_where,current_module.sourcefiles.get_file_name(fileindex),tostr(line));
  1476. end;
  1477. end;
  1478. {*****************************************************************************
  1479. Search
  1480. *****************************************************************************}
  1481. function searchsym(const s : stringid;var srsym:tsym;var srsymtable:tsymtable):boolean;
  1482. var
  1483. speedvalue : cardinal;
  1484. begin
  1485. speedvalue:=getspeedvalue(s);
  1486. srsymtable:=symtablestack;
  1487. while assigned(srsymtable) do
  1488. begin
  1489. srsym:=tsym(srsymtable.speedsearch(s,speedvalue));
  1490. if assigned(srsym) then
  1491. begin
  1492. searchsym:=true;
  1493. exit;
  1494. end
  1495. else
  1496. srsymtable:=srsymtable.next;
  1497. end;
  1498. searchsym:=false;
  1499. end;
  1500. function searchsymonlyin(p : tsymtable;const s : stringid):tsym;
  1501. var
  1502. srsym : tsym;
  1503. begin
  1504. { the caller have to take care if srsym=nil }
  1505. if assigned(p) then
  1506. begin
  1507. srsym:=tsym(p.search(s));
  1508. if assigned(srsym) then
  1509. begin
  1510. searchsymonlyin:=srsym;
  1511. exit;
  1512. end;
  1513. { also check in the local symtbale if it exists }
  1514. if (p=tsymtable(current_module.globalsymtable)) then
  1515. begin
  1516. srsym:=tsym(current_module.localsymtable.search(s));
  1517. if assigned(srsym) then
  1518. begin
  1519. searchsymonlyin:=srsym;
  1520. exit;
  1521. end;
  1522. end
  1523. end;
  1524. searchsymonlyin:=nil;
  1525. end;
  1526. function searchsystype(const s: stringid; var srsym: ttypesym): boolean;
  1527. var
  1528. symowner: tsymtable;
  1529. begin
  1530. if not(cs_compilesystem in aktmoduleswitches) then
  1531. srsym := ttypesym(searchsymonlyin(systemunit,s))
  1532. else
  1533. searchsym(s,srsym,symowner);
  1534. searchsystype :=
  1535. assigned(srsym) and
  1536. (srsym.typ = typesym);
  1537. end;
  1538. function searchsysvar(const s: stringid; var srsym: tvarsym; var symowner: tsymtable): boolean;
  1539. begin
  1540. if not(cs_compilesystem in aktmoduleswitches) then
  1541. begin
  1542. srsym := tvarsym(searchsymonlyin(systemunit,s));
  1543. symowner := systemunit;
  1544. end
  1545. else
  1546. searchsym(s,srsym,symowner);
  1547. searchsysvar :=
  1548. assigned(srsym) and
  1549. (srsym.typ = varsym);
  1550. end;
  1551. function search_class_member(pd : tobjectdef;const s : string):tsym;
  1552. { searches n in symtable of pd and all anchestors }
  1553. var
  1554. speedvalue : cardinal;
  1555. srsym : tsym;
  1556. begin
  1557. speedvalue:=getspeedvalue(s);
  1558. while assigned(pd) do
  1559. begin
  1560. srsym:=tsym(pd.symtable.speedsearch(s,speedvalue));
  1561. if assigned(srsym) then
  1562. begin
  1563. search_class_member:=srsym;
  1564. exit;
  1565. end;
  1566. pd:=pd.childof;
  1567. end;
  1568. search_class_member:=nil;
  1569. end;
  1570. {*****************************************************************************
  1571. Definition Helpers
  1572. *****************************************************************************}
  1573. procedure globaldef(const s : string;var t:ttype);
  1574. var st : string;
  1575. symt : tsymtable;
  1576. srsym : tsym;
  1577. srsymtable : tsymtable;
  1578. begin
  1579. srsym := nil;
  1580. if pos('.',s) > 0 then
  1581. begin
  1582. st := copy(s,1,pos('.',s)-1);
  1583. searchsym(st,srsym,srsymtable);
  1584. st := copy(s,pos('.',s)+1,255);
  1585. if assigned(srsym) then
  1586. begin
  1587. if srsym.typ = unitsym then
  1588. begin
  1589. symt := tunitsym(srsym).unitsymtable;
  1590. srsym := tsym(symt.search(st));
  1591. end else srsym := nil;
  1592. end;
  1593. end else st := s;
  1594. if srsym = nil then
  1595. searchsym(st,srsym,srsymtable);
  1596. if srsym = nil then
  1597. srsym:=searchsymonlyin(systemunit,st);
  1598. if (not assigned(srsym)) or
  1599. (srsym.typ<>typesym) then
  1600. begin
  1601. Message(type_e_type_id_expected);
  1602. t:=generrortype;
  1603. exit;
  1604. end;
  1605. t := ttypesym(srsym).restype;
  1606. end;
  1607. {****************************************************************************
  1608. Object Helpers
  1609. ****************************************************************************}
  1610. var
  1611. _defaultprop : tpropertysym;
  1612. procedure tstoredsymtable.testfordefaultproperty(p : TNamedIndexItem);
  1613. begin
  1614. if (tsym(p).typ=propertysym) and
  1615. (ppo_defaultproperty in tpropertysym(p).propoptions) then
  1616. _defaultprop:=tpropertysym(p);
  1617. end;
  1618. function search_default_property(pd : tobjectdef) : tpropertysym;
  1619. { returns the default property of a class, searches also anchestors }
  1620. begin
  1621. _defaultprop:=nil;
  1622. while assigned(pd) do
  1623. begin
  1624. pd.symtable.foreach({$ifdef FPCPROCVAR}@{$endif}tstoredsymtable(pd.symtable).testfordefaultproperty);
  1625. if assigned(_defaultprop) then
  1626. break;
  1627. pd:=pd.childof;
  1628. end;
  1629. search_default_property:=_defaultprop;
  1630. end;
  1631. {$ifdef UNITALIASES}
  1632. {****************************************************************************
  1633. TUNIT_ALIAS
  1634. ****************************************************************************}
  1635. constructor tunit_alias.create(const n:string);
  1636. var
  1637. i : longint;
  1638. begin
  1639. i:=pos('=',n);
  1640. if i=0 then
  1641. fail;
  1642. inherited createname(Copy(n,1,i-1));
  1643. newname:=stringdup(Copy(n,i+1,255));
  1644. end;
  1645. destructor tunit_alias.destroy;
  1646. begin
  1647. stringdispose(newname);
  1648. inherited destroy;
  1649. end;
  1650. procedure addunitalias(const n:string);
  1651. begin
  1652. unitaliases^.insert(tunit_alias,init(Upper(n))));
  1653. end;
  1654. function getunitalias(const n:string):string;
  1655. var
  1656. p : punit_alias;
  1657. begin
  1658. p:=punit_alias(unitaliases^.search(Upper(n)));
  1659. if assigned(p) then
  1660. getunitalias:=punit_alias(p).newname^
  1661. else
  1662. getunitalias:=n;
  1663. end;
  1664. {$endif UNITALIASES}
  1665. {****************************************************************************
  1666. Symtable Stack
  1667. ****************************************************************************}
  1668. procedure dellexlevel;
  1669. var
  1670. p : tsymtable;
  1671. begin
  1672. p:=symtablestack;
  1673. symtablestack:=p.next;
  1674. { symbol tables of unit interfaces are never disposed }
  1675. { this is handle by the unit unitm }
  1676. if not(p.symtabletype in [globalsymtable,stt_exceptsymtable]) then
  1677. p.free;
  1678. end;
  1679. procedure RestoreUnitSyms;
  1680. var
  1681. p : tsymtable;
  1682. begin
  1683. p:=symtablestack;
  1684. while assigned(p) do
  1685. begin
  1686. if (p.symtabletype=globalsymtable) and
  1687. assigned(tglobalsymtable(p).unitsym) and
  1688. ((tglobalsymtable(p).unitsym.owner=current_module.globalsymtable) or
  1689. (tglobalsymtable(p).unitsym.owner=current_module.localsymtable)) then
  1690. tglobalsymtable(p).unitsym.restoreunitsym;
  1691. p:=p.next;
  1692. end;
  1693. end;
  1694. {$ifdef DEBUG}
  1695. procedure test_symtablestack;
  1696. var
  1697. p : tsymtable;
  1698. i : longint;
  1699. begin
  1700. p:=symtablestack;
  1701. i:=0;
  1702. while assigned(p) do
  1703. begin
  1704. inc(i);
  1705. p:=p.next;
  1706. if i>500 then
  1707. Message(sym_f_internal_error_in_symtablestack);
  1708. end;
  1709. end;
  1710. procedure list_symtablestack;
  1711. var
  1712. p : tsymtable;
  1713. i : longint;
  1714. begin
  1715. p:=symtablestack;
  1716. i:=0;
  1717. while assigned(p) do
  1718. begin
  1719. inc(i);
  1720. writeln(i,' ',p.name^);
  1721. p:=p.next;
  1722. if i>500 then
  1723. Message(sym_f_internal_error_in_symtablestack);
  1724. end;
  1725. end;
  1726. {$endif DEBUG}
  1727. {****************************************************************************
  1728. Init/Done Symtable
  1729. ****************************************************************************}
  1730. procedure InitSymtable;
  1731. var
  1732. token : ttoken;
  1733. begin
  1734. { Reset symbolstack }
  1735. registerdef:=false;
  1736. read_member:=false;
  1737. symtablestack:=nil;
  1738. systemunit:=nil;
  1739. {$ifdef GDB}
  1740. firstglobaldef:=nil;
  1741. lastglobaldef:=nil;
  1742. globaltypecount:=1;
  1743. pglobaltypecount:=@globaltypecount;
  1744. {$endif GDB}
  1745. { create error syms and def }
  1746. generrorsym:=terrorsym.create;
  1747. generrortype.setdef(terrordef.create);
  1748. {$ifdef UNITALIASES}
  1749. { unit aliases }
  1750. unitaliases:=tdictionary.create;
  1751. {$endif}
  1752. for token:=first_overloaded to last_overloaded do
  1753. overloaded_operators[token]:=nil;
  1754. end;
  1755. procedure DoneSymtable;
  1756. begin
  1757. generrorsym.free;
  1758. generrortype.def.free;
  1759. {$ifdef UNITALIASES}
  1760. unitaliases.free;
  1761. {$endif}
  1762. end;
  1763. end.
  1764. {
  1765. $Log$
  1766. Revision 1.50 2001-11-18 18:43:17 peter
  1767. * overloading supported in child classes
  1768. * fixed parsing of classes with private and virtual and overloaded
  1769. so it is compatible with delphi
  1770. Revision 1.49 2001/11/02 23:16:52 peter
  1771. * removed obsolete chainprocsym and test_procsym code
  1772. Revision 1.48 2001/11/02 22:58:08 peter
  1773. * procsym definition rewrite
  1774. Revision 1.47 2001/10/12 20:27:43 jonas
  1775. * fixed crashing bug in unit reference counting
  1776. Revision 1.46 2001/09/30 21:29:47 peter
  1777. * gdb fixes merged
  1778. Revision 1.45 2001/09/19 11:06:03 michael
  1779. * realname updated for some hints
  1780. * realname used for consts,labels
  1781. Revision 1.44 2001/09/04 11:38:55 jonas
  1782. + searchsystype() and searchsystype() functions in symtable
  1783. * changed ninl and nadd to use these functions
  1784. * i386 set comparison functions now return their results in al instead
  1785. of in the flags so that they can be sued as compilerprocs
  1786. - removed all processor specific code from n386add.pas that has to do
  1787. with set handling, it's now all done in nadd.pas
  1788. * fixed fpc_set_contains_sets in genset.inc
  1789. * fpc_set_in_byte is now coded inline in n386set.pas and doesn't use a
  1790. helper anymore
  1791. * some small fixes in compproc.inc/set.inc regarding the declaration of
  1792. internal helper types (fpc_small_set and fpc_normal_set)
  1793. Revision 1.43 2001/08/30 20:13:56 peter
  1794. * rtti/init table updates
  1795. * rttisym for reusable global rtti/init info
  1796. * support published for interfaces
  1797. Revision 1.42 2001/08/26 13:36:51 florian
  1798. * some cg reorganisation
  1799. * some PPC updates
  1800. Revision 1.41 2001/08/19 09:39:29 peter
  1801. * local browser support fixed
  1802. Revision 1.40 2001/08/06 21:40:49 peter
  1803. * funcret moved from tprocinfo to tprocdef
  1804. Revision 1.39 2001/07/29 22:12:58 peter
  1805. * skip private symbols when found in withsymtable
  1806. Revision 1.38 2001/07/01 20:16:18 peter
  1807. * alignmentinfo record added
  1808. * -Oa argument supports more alignment settings that can be specified
  1809. per type: PROC,LOOP,VARMIN,VARMAX,CONSTMIN,CONSTMAX,RECORDMIN
  1810. RECORDMAX,LOCALMIN,LOCALMAX. It is possible to set the mimimum
  1811. required alignment and the maximum usefull alignment. The final
  1812. alignment will be choosen per variable size dependent on these
  1813. settings
  1814. Revision 1.37 2001/06/04 11:53:14 peter
  1815. + varargs directive
  1816. Revision 1.36 2001/06/03 21:57:38 peter
  1817. + hint directive parsing support
  1818. Revision 1.35 2001/05/06 14:49:18 peter
  1819. * ppu object to class rewrite
  1820. * move ppu read and write stuff to fppu
  1821. Revision 1.34 2001/04/18 22:01:59 peter
  1822. * registration of targets and assemblers
  1823. Revision 1.33 2001/04/13 20:05:15 peter
  1824. * better check for globalsymtable
  1825. Revision 1.32 2001/04/13 18:08:37 peter
  1826. * scanner object to class
  1827. Revision 1.31 2001/04/13 01:22:16 peter
  1828. * symtable change to classes
  1829. * range check generation and errors fixed, make cycle DEBUG=1 works
  1830. * memory leaks fixed
  1831. Revision 1.30 2001/04/02 21:20:35 peter
  1832. * resulttype rewrite
  1833. Revision 1.29 2001/03/22 00:10:58 florian
  1834. + basic variant type support in the compiler
  1835. Revision 1.28 2001/03/13 18:45:07 peter
  1836. * fixed some memory leaks
  1837. Revision 1.27 2001/03/11 22:58:51 peter
  1838. * getsym redesign, removed the globals srsym,srsymtable
  1839. Revision 1.26 2001/02/21 19:37:19 peter
  1840. * moved deref to be done after loading of implementation units. prederef
  1841. is still done directly after loading of symbols and definitions.
  1842. Revision 1.25 2001/02/20 21:41:16 peter
  1843. * new fixfilename, findfile for unix. Look first for lowercase, then
  1844. NormalCase and last for UPPERCASE names.
  1845. Revision 1.24 2001/01/08 21:40:27 peter
  1846. * fixed crash with unsupported token overloading
  1847. Revision 1.23 2000/12/25 00:07:30 peter
  1848. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  1849. tlinkedlist objects)
  1850. Revision 1.22 2000/12/23 19:50:09 peter
  1851. * fixed mem leak with withsymtable
  1852. Revision 1.21 2000/12/10 20:25:32 peter
  1853. * fixed missing typecast
  1854. Revision 1.20 2000/12/10 14:14:51 florian
  1855. * fixed web bug 1203: class fields can be now redefined
  1856. in Delphi mode though I don't like this :/
  1857. Revision 1.19 2000/11/30 22:16:49 florian
  1858. * moved to i386
  1859. Revision 1.18 2000/11/29 00:30:42 florian
  1860. * unused units removed from uses clause
  1861. * some changes for widestrings
  1862. Revision 1.17 2000/11/28 00:28:07 pierre
  1863. * stabs fixing
  1864. Revision 1.1.2.8 2000/11/17 11:14:37 pierre
  1865. * one more class stabs fix
  1866. Revision 1.16 2000/11/12 22:17:47 peter
  1867. * some realname updates for messages
  1868. Revision 1.15 2000/11/06 15:54:15 florian
  1869. * fixed two bugs to get make cycle work, but it's not enough
  1870. Revision 1.14 2000/11/04 14:25:22 florian
  1871. + merged Attila's changes for interfaces, not tested yet
  1872. Revision 1.13 2000/11/01 23:04:38 peter
  1873. * tprocdef.fullprocname added for better casesensitve writing of
  1874. procedures
  1875. Revision 1.12 2000/10/31 22:02:52 peter
  1876. * symtable splitted, no real code changes
  1877. Revision 1.1.2.7 2000/10/16 19:43:04 pierre
  1878. * trying to correct class stabss once more
  1879. Revision 1.11 2000/10/15 07:47:53 peter
  1880. * unit names and procedure names are stored mixed case
  1881. Revision 1.10 2000/10/14 10:14:53 peter
  1882. * moehrendorf oct 2000 rewrite
  1883. Revision 1.9 2000/10/01 19:48:25 peter
  1884. * lot of compile updates for cg11
  1885. Revision 1.8 2000/09/24 15:06:29 peter
  1886. * use defines.inc
  1887. Revision 1.7 2000/08/27 16:11:54 peter
  1888. * moved some util functions from globals,cobjects to cutils
  1889. * splitted files into finput,fmodule
  1890. Revision 1.6 2000/08/21 11:27:45 pierre
  1891. * fix the stabs problems
  1892. Revision 1.5 2000/08/20 14:58:41 peter
  1893. * give fatal if objfpc/delphi mode things are found (merged)
  1894. Revision 1.1.2.6 2000/08/20 14:56:46 peter
  1895. * give fatal if objfpc/delphi mode things are found
  1896. Revision 1.4 2000/08/16 18:33:54 peter
  1897. * splitted namedobjectitem.next into indexnext and listnext so it
  1898. can be used in both lists
  1899. * don't allow "word = word" type definitions (merged)
  1900. Revision 1.3 2000/08/08 19:28:57 peter
  1901. * memdebug/memory patches (merged)
  1902. * only once illegal directive (merged)
  1903. }