symtable.pas 88 KB

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