symtable.pas 89 KB

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