symtable.pas 90 KB

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