symtable.pas 88 KB

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