symtable.pas 70 KB

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