symtable.pas 86 KB

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