symtable.pas 87 KB

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