symtable.pas 88 KB

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