symtable.pas 88 KB

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