symtable.pas 87 KB

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