symtable.pas 90 KB

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