symtable.pas 87 KB

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