symtable.pas 86 KB

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