symtable.pas 89 KB

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