symtable.pas 86 KB

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