symtable.pas 88 KB

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