symtable.pas 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 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 defines.inc}
  20. interface
  21. uses
  22. { common }
  23. cutils,cclasses,
  24. { global }
  25. globtype,tokens,
  26. { symtable }
  27. symconst,symbase,symtype,symdef,symsym,
  28. { ppu }
  29. ppu,symppu,
  30. { assembler }
  31. aasm
  32. ;
  33. {****************************************************************************
  34. Symtable types
  35. ****************************************************************************}
  36. type
  37. tstoredsymtable = class(tsymtable)
  38. private
  39. b_needs_init_final : boolean;
  40. procedure _needs_init_final(p : tnamedindexitem);
  41. procedure check_forward(sym : TNamedIndexItem);
  42. procedure labeldefined(p : TNamedIndexItem);
  43. procedure unitsymbolused(p : TNamedIndexItem);
  44. procedure varsymbolused(p : TNamedIndexItem);
  45. procedure TestPrivate(p : TNamedIndexItem);
  46. procedure objectprivatesymbolused(p : TNamedIndexItem);
  47. {$ifdef GDB}
  48. private
  49. asmoutput : taasmoutput;
  50. procedure concatstab(p : TNamedIndexItem);
  51. procedure resetstab(p : TNamedIndexItem);
  52. procedure concattypestab(p : TNamedIndexItem);
  53. {$endif}
  54. procedure order_overloads(p : TNamedIndexItem);
  55. procedure loaddefs(ppufile:tcompilerppufile);
  56. procedure loadsyms(ppufile:tcompilerppufile);
  57. procedure writedefs(ppufile:tcompilerppufile);
  58. procedure writesyms(ppufile:tcompilerppufile);
  59. public
  60. { load/write }
  61. procedure load(ppufile:tcompilerppufile);virtual;
  62. procedure write(ppufile:tcompilerppufile);virtual;
  63. procedure load_browser(ppufile:tcompilerppufile);virtual;
  64. procedure write_browser(ppufile:tcompilerppufile);virtual;
  65. procedure deref;virtual;
  66. procedure insert(sym : tsymentry);override;
  67. function speedsearch(const s : stringid;speedvalue : cardinal) : tsymentry;override;
  68. procedure allsymbolsused;
  69. procedure allprivatesused;
  70. procedure allunitsused;
  71. procedure check_forwards;
  72. procedure checklabels;
  73. function needs_init_final : boolean;
  74. {$ifdef CHAINPROCSYMS}
  75. procedure chainprocsyms;
  76. {$endif CHAINPROCSYMS}
  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);
  83. end;
  84. tabstractrecordsymtable = class(tstoredsymtable)
  85. public
  86. procedure load(ppufile:tcompilerppufile);override;
  87. procedure write(ppufile:tcompilerppufile);override;
  88. procedure load_browser(ppufile:tcompilerppufile);override;
  89. procedure write_browser(ppufile:tcompilerppufile);override;
  90. end;
  91. trecordsymtable = class(tabstractrecordsymtable)
  92. public
  93. constructor create;
  94. procedure insert_in(tsymt : tsymtable;offset : longint);
  95. end;
  96. tobjectsymtable = class(tabstractrecordsymtable)
  97. public
  98. constructor create(const n:string);
  99. procedure insert(sym : tsymentry);override;
  100. end;
  101. tabstractlocalsymtable = class(tstoredsymtable)
  102. public
  103. procedure load(ppufile:tcompilerppufile);override;
  104. procedure write(ppufile:tcompilerppufile);override;
  105. procedure load_browser(ppufile:tcompilerppufile);override;
  106. procedure write_browser(ppufile:tcompilerppufile);override;
  107. end;
  108. tlocalsymtable = class(tabstractlocalsymtable)
  109. public
  110. constructor create;
  111. procedure insert(sym : tsymentry);override;
  112. end;
  113. tparasymtable = class(tabstractlocalsymtable)
  114. public
  115. constructor create;
  116. procedure insert(sym : tsymentry);override;
  117. { change alignment for args only parasymtable }
  118. procedure set_alignment(_alignment : longint);
  119. end;
  120. tabstractunitsymtable = class(tstoredsymtable)
  121. public
  122. {$ifdef GDB}
  123. dbx_count : longint;
  124. prev_dbx_counter : plongint;
  125. dbx_count_ok : boolean;
  126. is_stab_written : boolean;
  127. {$endif GDB}
  128. constructor create(const n : string);
  129. {$ifdef GDB}
  130. procedure concattypestabto(asmlist : taasmoutput);
  131. {$endif GDB}
  132. end;
  133. tglobalsymtable = class(tabstractunitsymtable)
  134. public
  135. unittypecount : word;
  136. unitsym : tunitsym;
  137. constructor create(const n : string);
  138. destructor destroy;
  139. procedure load(ppufile:tcompilerppufile);override;
  140. procedure write(ppufile:tcompilerppufile);override;
  141. procedure insert(sym : tsymentry);override;
  142. {$ifdef GDB}
  143. function getnewtypecount : word; override;
  144. {$endif}
  145. end;
  146. tstaticsymtable = class(tabstractunitsymtable)
  147. public
  148. constructor create(const n : string);
  149. procedure load(ppufile:tcompilerppufile);override;
  150. procedure write(ppufile:tcompilerppufile);override;
  151. procedure load_browser(ppufile:tcompilerppufile);override;
  152. procedure write_browser(ppufile:tcompilerppufile);override;
  153. procedure insert(sym : tsymentry);override;
  154. end;
  155. twithsymtable = class(tsymtable)
  156. direct_with : boolean;
  157. { in fact it is a tnode }
  158. withnode : pointer;
  159. { tnode to load of direct with var }
  160. { already usable before firstwith
  161. needed for firstpass of function parameters PM }
  162. withrefnode : pointer;
  163. constructor create(aowner:tdef;asymsearch:TDictionary);
  164. destructor destroy;override;
  165. procedure clear;override;
  166. end;
  167. tstt_exceptsymtable = class(tsymtable)
  168. public
  169. constructor create;
  170. end;
  171. var
  172. constsymtable : tsymtable; { symtable were the constants can be inserted }
  173. systemunit : tglobalsymtable; { pointer to the system unit }
  174. read_member : boolean; { reading members of an symtable }
  175. lexlevel : longint; { level of code }
  176. { 1 for main procedure }
  177. { 2 for normal function or proc }
  178. { higher for locals }
  179. {****************************************************************************
  180. Functions
  181. ****************************************************************************}
  182. {*** Misc ***}
  183. procedure globaldef(const s : string;var t:ttype);
  184. function findunitsymtable(st:tsymtable):tsymtable;
  185. procedure duplicatesym(sym:tsym);
  186. {*** Search ***}
  187. function searchsym(const s : stringid;var srsym:tsym;var srsymtable:tsymtable):boolean;
  188. function searchsymonlyin(p : tsymtable;const s : stringid):tsym;
  189. function search_class_member(pd : tobjectdef;const s : string):tsym;
  190. {*** Object Helpers ***}
  191. function search_default_property(pd : tobjectdef) : tpropertysym;
  192. {*** symtable stack ***}
  193. procedure dellexlevel;
  194. procedure RestoreUnitSyms;
  195. {$ifdef DEBUG}
  196. procedure test_symtablestack;
  197. procedure list_symtablestack;
  198. {$endif DEBUG}
  199. {$ifdef UNITALIASES}
  200. type
  201. punit_alias = ^tunit_alias;
  202. tunit_alias = object(TNamedIndexItem)
  203. newname : pstring;
  204. constructor init(const n:string);
  205. destructor done;virtual;
  206. end;
  207. var
  208. unitaliases : pdictionary;
  209. procedure addunitalias(const n:string);
  210. function getunitalias(const n:string):string;
  211. {$endif UNITALIASES}
  212. {*** Init / Done ***}
  213. procedure InitSymtable;
  214. procedure DoneSymtable;
  215. type
  216. toverloaded_operators = array[NOTOKEN..last_overloaded] of tprocsym;
  217. var
  218. overloaded_operators : toverloaded_operators;
  219. { unequal is not equal}
  220. const
  221. overloaded_names : array [NOTOKEN..last_overloaded] of string[16] =
  222. ('error',
  223. 'plus','minus','star','slash','equal',
  224. 'greater','lower','greater_or_equal',
  225. 'lower_or_equal',
  226. 'sym_diff','starstar',
  227. 'as','is','in','or',
  228. 'and','div','mod','not','shl','shr','xor',
  229. 'assign');
  230. implementation
  231. uses
  232. { global }
  233. version,verbose,globals,
  234. { target }
  235. systems,
  236. { module }
  237. finput,fmodule,
  238. {$ifdef GDB}
  239. gdb,
  240. {$endif GDB}
  241. { codegen }
  242. hcodegen
  243. ;
  244. var
  245. in_loading : boolean; { remove !!! }
  246. {*****************************************************************************
  247. TStoredSymtable
  248. *****************************************************************************}
  249. procedure tstoredsymtable.load(ppufile:tcompilerppufile);
  250. begin
  251. { load definitions }
  252. loaddefs(ppufile);
  253. { load symbols }
  254. loadsyms(ppufile);
  255. end;
  256. procedure tstoredsymtable.write(ppufile:tcompilerppufile);
  257. begin
  258. { write definitions }
  259. writedefs(ppufile);
  260. { write symbols }
  261. writesyms(ppufile);
  262. end;
  263. procedure tstoredsymtable.loaddefs(ppufile:tcompilerppufile);
  264. var
  265. hp : tdef;
  266. b : byte;
  267. begin
  268. { load start of definition section, which holds the amount of defs }
  269. if ppufile.readentry<>ibstartdefs then
  270. Message(unit_f_ppu_read_error);
  271. ppufile.getlongint;
  272. { read definitions }
  273. repeat
  274. b:=ppufile.readentry;
  275. case b of
  276. ibpointerdef : hp:=tpointerdef.load(ppufile);
  277. ibarraydef : hp:=tarraydef.load(ppufile);
  278. iborddef : hp:=torddef.load(ppufile);
  279. ibfloatdef : hp:=tfloatdef.load(ppufile);
  280. ibprocdef : hp:=tprocdef.load(ppufile);
  281. ibshortstringdef : hp:=tstringdef.loadshort(ppufile);
  282. iblongstringdef : hp:=tstringdef.loadlong(ppufile);
  283. ibansistringdef : hp:=tstringdef.loadansi(ppufile);
  284. ibwidestringdef : hp:=tstringdef.loadwide(ppufile);
  285. ibrecorddef : hp:=trecorddef.load(ppufile);
  286. ibobjectdef : hp:=tobjectdef.load(ppufile);
  287. ibenumdef : hp:=tenumdef.load(ppufile);
  288. ibsetdef : hp:=tsetdef.load(ppufile);
  289. ibprocvardef : hp:=tprocvardef.load(ppufile);
  290. ibfiledef : hp:=tfiledef.load(ppufile);
  291. ibclassrefdef : hp:=tclassrefdef.load(ppufile);
  292. ibformaldef : hp:=tformaldef.load(ppufile);
  293. ibvariantdef : hp:=tvariantdef.load(ppufile);
  294. ibenddefs : break;
  295. ibend : Message(unit_f_ppu_read_error);
  296. else
  297. Message1(unit_f_ppu_invalid_entry,tostr(b));
  298. end;
  299. hp.owner:=self;
  300. defindex.insert(hp);
  301. until false;
  302. end;
  303. procedure tstoredsymtable.loadsyms(ppufile:tcompilerppufile);
  304. var
  305. b : byte;
  306. sym : tsym;
  307. begin
  308. { load start of definition section, which holds the amount of defs }
  309. if ppufile.readentry<>ibstartsyms then
  310. Message(unit_f_ppu_read_error);
  311. { skip amount of symbols, not used currently }
  312. ppufile.getlongint;
  313. { load datasize,dataalignment of this symboltable }
  314. datasize:=ppufile.getlongint;
  315. dataalignment:=ppufile.getlongint;
  316. { now read the symbols }
  317. repeat
  318. b:=ppufile.readentry;
  319. case b of
  320. ibtypesym : sym:=ttypesym.load(ppufile);
  321. ibprocsym : sym:=tprocsym.load(ppufile);
  322. ibconstsym : sym:=tconstsym.load(ppufile);
  323. ibvarsym : sym:=tvarsym.load(ppufile);
  324. ibfuncretsym : sym:=tfuncretsym.load(ppufile);
  325. ibabsolutesym : sym:=tabsolutesym.load(ppufile);
  326. ibenumsym : sym:=tenumsym.load(ppufile);
  327. ibtypedconstsym : sym:=ttypedconstsym.load(ppufile);
  328. ibpropertysym : sym:=tpropertysym.load(ppufile);
  329. ibunitsym : sym:=tunitsym.load(ppufile);
  330. iblabelsym : sym:=tlabelsym.load(ppufile);
  331. ibsyssym : sym:=tsyssym.load(ppufile);
  332. ibendsyms : break;
  333. ibend : Message(unit_f_ppu_read_error);
  334. else
  335. Message1(unit_f_ppu_invalid_entry,tostr(b));
  336. end;
  337. sym.owner:=self;
  338. symindex.insert(sym);
  339. symsearch.insert(sym);
  340. until false;
  341. end;
  342. procedure tstoredsymtable.writedefs(ppufile:tcompilerppufile);
  343. var
  344. pd : tstoreddef;
  345. begin
  346. { each definition get a number, write then the amount of defs to the
  347. ibstartdef entry }
  348. ppufile.putlongint(defindex.count);
  349. ppufile.writeentry(ibstartdefs);
  350. { now write the definition }
  351. pd:=tstoreddef(defindex.first);
  352. while assigned(pd) do
  353. begin
  354. pd.write(ppufile);
  355. pd:=tstoreddef(pd.indexnext);
  356. end;
  357. { write end of definitions }
  358. ppufile.writeentry(ibenddefs);
  359. end;
  360. procedure tstoredsymtable.writesyms(ppufile:tcompilerppufile);
  361. var
  362. pd : tstoredsym;
  363. begin
  364. { each definition get a number, write then the amount of syms and the
  365. datasize to the ibsymdef entry }
  366. ppufile.putlongint(symindex.count);
  367. ppufile.putlongint(datasize);
  368. ppufile.putlongint(dataalignment);
  369. ppufile.writeentry(ibstartsyms);
  370. { foreach is used to write all symbols }
  371. pd:=tstoredsym(symindex.first);
  372. while assigned(pd) do
  373. begin
  374. pd.write(ppufile);
  375. pd:=tstoredsym(pd.indexnext);
  376. end;
  377. { end of symbols }
  378. ppufile.writeentry(ibendsyms);
  379. end;
  380. procedure tstoredsymtable.load_browser(ppufile:tcompilerppufile);
  381. var
  382. b : byte;
  383. sym : tstoredsym;
  384. prdef : tstoreddef;
  385. begin
  386. b:=ppufile.readentry;
  387. if b <> ibbeginsymtablebrowser then
  388. Message1(unit_f_ppu_invalid_entry,tostr(b));
  389. repeat
  390. b:=ppufile.readentry;
  391. case b of
  392. ibsymref :
  393. begin
  394. sym:=tstoredsym(ppufile.getderef);
  395. resolvesym(tsym(sym));
  396. if assigned(sym) then
  397. sym.load_references(ppufile);
  398. end;
  399. ibdefref :
  400. begin
  401. prdef:=tstoreddef(ppufile.getderef);
  402. resolvedef(tdef(prdef));
  403. if assigned(prdef) then
  404. begin
  405. if prdef.deftype<>procdef then
  406. Message(unit_f_ppu_read_error);
  407. tprocdef(prdef).load_references(ppufile);
  408. end;
  409. end;
  410. ibendsymtablebrowser :
  411. break;
  412. else
  413. Message1(unit_f_ppu_invalid_entry,tostr(b));
  414. end;
  415. until false;
  416. end;
  417. procedure tstoredsymtable.write_browser(ppufile:tcompilerppufile);
  418. var
  419. pd : tstoredsym;
  420. begin
  421. ppufile.writeentry(ibbeginsymtablebrowser);
  422. { foreach is used to write all symbols }
  423. pd:=tstoredsym(symindex.first);
  424. while assigned(pd) do
  425. begin
  426. pd.write_references(ppufile);
  427. pd:=tstoredsym(pd.indexnext);
  428. end;
  429. ppufile.writeentry(ibendsymtablebrowser);
  430. end;
  431. procedure tstoredsymtable.deref;
  432. var
  433. hp : tdef;
  434. hs : tsym;
  435. begin
  436. { deref the definitions }
  437. hp:=tdef(defindex.first);
  438. while assigned(hp) do
  439. begin
  440. hp.deref;
  441. hp:=tdef(hp.indexnext);
  442. end;
  443. { first deref the ttypesyms }
  444. hs:=tsym(symindex.first);
  445. while assigned(hs) do
  446. begin
  447. hs.prederef;
  448. hs:=tsym(hs.indexnext);
  449. end;
  450. { deref the symbols }
  451. hs:=tsym(symindex.first);
  452. while assigned(hs) do
  453. begin
  454. hs.deref;
  455. hs:=tsym(hs.indexnext);
  456. end;
  457. end;
  458. procedure tstoredsymtable.insert(sym:tsymentry);
  459. var
  460. hsym : tsym;
  461. begin
  462. { set owner and sym indexnb }
  463. sym.owner:=self;
  464. {$ifdef CHAINPROCSYMS}
  465. { set the nextprocsym field }
  466. if sym.typ=procsym then
  467. chainprocsym(sym);
  468. {$endif CHAINPROCSYMS}
  469. { writes the symbol in data segment if required }
  470. { also sets the datasize of owner }
  471. if not in_loading then
  472. tstoredsym(sym).insert_in_data;
  473. { check the current symtable }
  474. hsym:=tsym(search(sym.name));
  475. if assigned(hsym) then
  476. begin
  477. { in TP and Delphi you can have a local with the
  478. same name as the function, the function is then hidden for
  479. the user. (Under delphi it can still be accessed using result),
  480. but don't allow hiding of RESULT }
  481. if (m_tp in aktmodeswitches) and
  482. (hsym.typ=funcretsym) and
  483. not((m_result in aktmodeswitches) and
  484. (hsym.name='RESULT')) then
  485. hsym.owner.rename(hsym.name,'hidden'+hsym.name)
  486. else
  487. begin
  488. DuplicateSym(hsym);
  489. exit;
  490. end;
  491. end;
  492. { register definition of typesym }
  493. if (sym.typ = typesym) and
  494. assigned(ttypesym(sym).restype.def) then
  495. begin
  496. if not(assigned(ttypesym(sym).restype.def.owner)) and
  497. (ttypesym(sym).restype.def.deftype<>errordef) then
  498. registerdef(ttypesym(sym).restype.def);
  499. {$ifdef GDB}
  500. if (cs_debuginfo in aktmoduleswitches) and assigned(debuglist) and
  501. (symtabletype in [globalsymtable,staticsymtable]) then
  502. begin
  503. ttypesym(sym).isusedinstab := true;
  504. {sym.concatstabto(debuglist);}
  505. end;
  506. {$endif GDB}
  507. end;
  508. { insert in index and search hash }
  509. symindex.insert(sym);
  510. symsearch.insert(sym);
  511. end;
  512. function tstoredsymtable.speedsearch(const s : stringid;speedvalue : cardinal) : tsymentry;
  513. var
  514. hp : tstoredsym;
  515. newref : tref;
  516. begin
  517. hp:=tstoredsym(inherited speedsearch(s,speedvalue));
  518. if assigned(hp) then
  519. begin
  520. { reject non static members in static procedures,
  521. be carefull aktprocsym.definition is not allways
  522. loaded already (PFV) }
  523. if (symtabletype=objectsymtable) and
  524. not(sp_static in hp.symoptions) and
  525. allow_only_static
  526. {assigned(aktprocsym) and
  527. assigned(aktprocsym.definition) and
  528. ((aktprocsym.definition.options and postaticmethod)<>0)} then
  529. Message(sym_e_only_static_in_static);
  530. if (unitid<>0) and
  531. assigned(tglobalsymtable(self).unitsym) then
  532. inc(tglobalsymtable(self).unitsym.refs);
  533. {$ifdef GDB}
  534. { if it is a type, we need the stabs of this type
  535. this might be the cause of the class debug problems
  536. as TCHILDCLASS.Create did not generate appropriate
  537. stabs debug info if TCHILDCLASS wasn't used anywhere else PM }
  538. if (hp.typ=typesym) and make_ref then
  539. begin
  540. if assigned(ttypesym(hp).restype.def) then
  541. tstoreddef(ttypesym(hp).restype.def).numberstring
  542. else
  543. ttypesym(hp).isusedinstab:=true;
  544. end;
  545. {$endif GDB}
  546. { unitsym are only loaded for browsing PM }
  547. { this was buggy anyway because we could use }
  548. { unitsyms from other units in _USES !! }
  549. {if (symtabletype=unitsymtable) and (hp.typ=unitsym) and
  550. assigned(current_module) and (current_module.globalsymtable<>.load) then
  551. hp:=nil;}
  552. if assigned(hp) and
  553. (cs_browser in aktmoduleswitches) and make_ref then
  554. begin
  555. newref:=tref.create(hp.lastref,@akttokenpos);
  556. { for symbols that are in tables without
  557. browser info or syssyms (PM) }
  558. if hp.refcount=0 then
  559. begin
  560. hp.defref:=newref;
  561. hp.lastref:=newref;
  562. end
  563. else
  564. if resolving_forward and assigned(hp.defref) then
  565. { put it as second reference }
  566. begin
  567. newref.nextref:=hp.defref.nextref;
  568. hp.defref.nextref:=newref;
  569. hp.lastref.nextref:=nil;
  570. end
  571. else
  572. hp.lastref:=newref;
  573. inc(hp.refcount);
  574. end;
  575. if assigned(hp) and make_ref then
  576. begin
  577. inc(hp.refs);
  578. end;
  579. end;
  580. speedsearch:=hp;
  581. end;
  582. {**************************************
  583. Callbacks
  584. **************************************}
  585. procedure TStoredSymtable.check_forward(sym : TNamedIndexItem);
  586. begin
  587. if tsym(sym).typ=procsym then
  588. tprocsym(sym).check_forward
  589. { check also object method table }
  590. { we needn't to test the def list }
  591. { because each object has to have a type sym }
  592. else
  593. if (tsym(sym).typ=typesym) and
  594. assigned(ttypesym(sym).restype.def) and
  595. (ttypesym(sym).restype.def.deftype=objectdef) then
  596. tobjectdef(ttypesym(sym).restype.def).check_forwards;
  597. end;
  598. procedure TStoredSymtable.labeldefined(p : TNamedIndexItem);
  599. begin
  600. if (tsym(p).typ=labelsym) and
  601. not(tlabelsym(p).defined) then
  602. begin
  603. if tlabelsym(p).used then
  604. Message1(sym_e_label_used_and_not_defined,tlabelsym(p).realname)
  605. else
  606. Message1(sym_w_label_not_defined,tlabelsym(p).realname);
  607. end;
  608. end;
  609. procedure TStoredSymtable.unitsymbolused(p : TNamedIndexItem);
  610. begin
  611. if (tsym(p).typ=unitsym) and
  612. (tunitsym(p).refs=0) and
  613. { do not claim for unit name itself !! }
  614. (tunitsym(p).unitsymtable.symtabletype=globalsymtable) then
  615. MessagePos2(tsym(p).fileinfo,sym_n_unit_not_used,
  616. p.name,current_module.modulename^);
  617. end;
  618. procedure TStoredSymtable.varsymbolused(p : TNamedIndexItem);
  619. begin
  620. if (tsym(p).typ=varsym) and
  621. ((tsym(p).owner.symtabletype in
  622. [parasymtable,localsymtable,objectsymtable,staticsymtable])) then
  623. begin
  624. { unused symbol should be reported only if no }
  625. { error is reported }
  626. { if the symbol is in a register it is used }
  627. { also don't count the value parameters which have local copies }
  628. { also don't claim for high param of open parameters (PM) }
  629. if (Errorcount<>0) or
  630. (copy(p.name,1,3)='val') or
  631. (copy(p.name,1,4)='high') then
  632. exit;
  633. if (tvarsym(p).refs=0) then
  634. begin
  635. if (tsym(p).owner.symtabletype=parasymtable) or (vo_is_local_copy in tvarsym(p).varoptions) then
  636. begin
  637. MessagePos1(tsym(p).fileinfo,sym_h_para_identifier_not_used,tsym(p).realname);
  638. end
  639. else if (tsym(p).owner.symtabletype=objectsymtable) then
  640. MessagePos2(tsym(p).fileinfo,sym_n_private_identifier_not_used,tsym(p).owner.name^,tsym(p).realname)
  641. else
  642. MessagePos1(tsym(p).fileinfo,sym_n_local_identifier_not_used,tsym(p).realname);
  643. end
  644. else if tvarsym(p).varstate=vs_assigned then
  645. begin
  646. if (tsym(p).owner.symtabletype=parasymtable) then
  647. begin
  648. if not(tvarsym(p).varspez in [vs_var,vs_out]) then
  649. MessagePos1(tsym(p).fileinfo,sym_h_para_identifier_only_set,tsym(p).realname)
  650. end
  651. else if (vo_is_local_copy in tvarsym(p).varoptions) then
  652. begin
  653. if not(tvarsym(p).varspez in [vs_var,vs_out]) then
  654. MessagePos1(tsym(p).fileinfo,sym_h_para_identifier_only_set,tsym(p).realname);
  655. end
  656. else if (tsym(p).owner.symtabletype=objectsymtable) then
  657. MessagePos2(tsym(p).fileinfo,sym_n_private_identifier_only_set,tsym(p).owner.name^,tsym(p).realname)
  658. else if (tsym(p).owner.symtabletype<>parasymtable) then
  659. if not (vo_is_exported in tvarsym(p).varoptions) then
  660. MessagePos1(tsym(p).fileinfo,sym_n_local_identifier_only_set,tsym(p).realname);
  661. end;
  662. end
  663. else if ((tsym(p).owner.symtabletype in
  664. [objectsymtable,parasymtable,localsymtable,staticsymtable])) then
  665. begin
  666. if (Errorcount<>0) then
  667. exit;
  668. { do not claim for inherited private fields !! }
  669. if (tstoredsym(p).refs=0) and (tsym(p).owner.symtabletype=objectsymtable) then
  670. MessagePos2(tsym(p).fileinfo,sym_n_private_method_not_used,tsym(p).owner.name^,tsym(p).realname)
  671. { units references are problematic }
  672. else if (tstoredsym(p).refs=0) and not(tsym(p).typ in [funcretsym,enumsym,unitsym]) then
  673. if (tsym(p).typ<>procsym) or not (tprocsym(p).is_global) or
  674. { all program functions are declared global
  675. but unused should still be signaled PM }
  676. ((tsym(p).owner.symtabletype=staticsymtable) and
  677. not current_module.is_unit) then
  678. MessagePos2(tsym(p).fileinfo,sym_h_local_symbol_not_used,SymTypeName[tsym(p).typ],tsym(p).realname);
  679. end;
  680. end;
  681. procedure TStoredSymtable.TestPrivate(p : TNamedIndexItem);
  682. begin
  683. if sp_private in tsym(p).symoptions then
  684. varsymbolused(p);
  685. end;
  686. procedure TStoredSymtable.objectprivatesymbolused(p : TNamedIndexItem);
  687. begin
  688. {
  689. Don't test simple object aliases PM
  690. }
  691. if (tsym(p).typ=typesym) and
  692. (ttypesym(p).restype.def.deftype=objectdef) and
  693. (ttypesym(p).restype.def.typesym=tsym(p)) then
  694. tobjectdef(ttypesym(p).restype.def).symtable.foreach({$ifdef FPCPROCVAR}@{$endif}TestPrivate);
  695. end;
  696. procedure tstoredsymtable.order_overloads(p : TNamedIndexItem);
  697. begin
  698. if tsym(p).typ=procsym then
  699. tprocsym(p).order_overloaded;
  700. end;
  701. {$ifdef GDB}
  702. procedure TStoredSymtable.concatstab(p : TNamedIndexItem);
  703. begin
  704. if tsym(p).typ <> procsym then
  705. tstoredsym(p).concatstabto(asmoutput);
  706. end;
  707. procedure TStoredSymtable.resetstab(p : TNamedIndexItem);
  708. begin
  709. if tsym(p).typ <> procsym then
  710. tstoredsym(p).isstabwritten:=false;
  711. end;
  712. procedure TStoredSymtable.concattypestab(p : TNamedIndexItem);
  713. begin
  714. if tsym(p).typ = typesym then
  715. begin
  716. tstoredsym(p).isstabwritten:=false;
  717. tstoredsym(p).concatstabto(asmoutput);
  718. end;
  719. end;
  720. function tstoredsymtable.getnewtypecount : word;
  721. begin
  722. getnewtypecount:=pglobaltypecount^;
  723. inc(pglobaltypecount^);
  724. end;
  725. {$endif GDB}
  726. {$ifdef CHAINPROCSYMS}
  727. procedure chainprocsym(p : tsym);
  728. var
  729. storesymtablestack : tsymtable;
  730. srsym : tsym;
  731. srsymtable : tsymtable;
  732. begin
  733. if p.typ=procsym then
  734. begin
  735. storesymtablestack:=symtablestack;
  736. symtablestack:=p.owner.next;
  737. while assigned(symtablestack) do
  738. begin
  739. { search for same procsym in other units }
  740. searchsym(p.name,srsym,srsymtable)
  741. if assigned(srsym) and
  742. (srsym.typ=procsym) then
  743. begin
  744. tprocsym(p).nextprocsym:=tprocsym(srsym);
  745. symtablestack:=storesymtablestack;
  746. exit;
  747. end
  748. else if srsym=nil then
  749. symtablestack:=nil
  750. else
  751. symtablestack:=srsymtable.next;
  752. end;
  753. symtablestack:=storesymtablestack;
  754. end;
  755. end;
  756. {$endif}
  757. procedure tstoredsymtable.chainoperators;
  758. var
  759. p : tprocsym;
  760. t : ttoken;
  761. def : tprocdef;
  762. srsym : tsym;
  763. srsymtable,
  764. storesymtablestack : tsymtable;
  765. begin
  766. storesymtablestack:=symtablestack;
  767. symtablestack:=self;
  768. make_ref:=false;
  769. for t:=first_overloaded to last_overloaded do
  770. begin
  771. p:=nil;
  772. def:=nil;
  773. overloaded_operators[t]:=nil;
  774. { each operator has a unique lowercased internal name PM }
  775. while assigned(symtablestack) do
  776. begin
  777. searchsym(overloaded_names[t],srsym,srsymtable);
  778. if not assigned(srsym) then
  779. begin
  780. if (t=_STARSTAR) then
  781. begin
  782. symtablestack:=systemunit;
  783. searchsym('POWER',srsym,srsymtable);
  784. end;
  785. end;
  786. if assigned(srsym) then
  787. begin
  788. if (srsym.typ<>procsym) then
  789. internalerror(12344321);
  790. if assigned(p) then
  791. begin
  792. {$ifdef CHAINPROCSYMS}
  793. p.nextprocsym:=tprocsym(srsym);
  794. {$endif CHAINPROCSYMS}
  795. def.nextoverloaded:=tprocsym(srsym).definition;
  796. end
  797. else
  798. overloaded_operators[t]:=tprocsym(srsym);
  799. p:=tprocsym(srsym);
  800. def:=p.definition;
  801. while assigned(def.nextoverloaded) and
  802. (def.nextoverloaded.owner=p.owner) do
  803. def:=def.nextoverloaded;
  804. def.nextoverloaded:=nil;
  805. symtablestack:=srsym.owner.next;
  806. end
  807. else
  808. begin
  809. symtablestack:=nil;
  810. {$ifdef CHAINPROCSYMS}
  811. if assigned(p) then
  812. p.nextprocsym:=nil;
  813. {$endif CHAINPROCSYMS}
  814. end;
  815. { search for same procsym in other units }
  816. end;
  817. symtablestack:=self;
  818. end;
  819. make_ref:=true;
  820. symtablestack:=storesymtablestack;
  821. end;
  822. {***********************************************
  823. Process all entries
  824. ***********************************************}
  825. { checks, if all procsyms and methods are defined }
  826. procedure tstoredsymtable.check_forwards;
  827. begin
  828. foreach({$ifdef FPCPROCVAR}@{$endif}check_forward);
  829. end;
  830. procedure tstoredsymtable.checklabels;
  831. begin
  832. foreach({$ifdef FPCPROCVAR}@{$endif}labeldefined);
  833. end;
  834. procedure tstoredsymtable.allunitsused;
  835. begin
  836. foreach({$ifdef FPCPROCVAR}@{$endif}unitsymbolused);
  837. end;
  838. procedure tstoredsymtable.allsymbolsused;
  839. begin
  840. foreach({$ifdef FPCPROCVAR}@{$endif}varsymbolused);
  841. end;
  842. procedure tstoredsymtable.allprivatesused;
  843. begin
  844. foreach({$ifdef FPCPROCVAR}@{$endif}objectprivatesymbolused);
  845. end;
  846. {$ifdef CHAINPROCSYMS}
  847. procedure tstoredsymtable.chainprocsyms;
  848. begin
  849. foreach({$ifdef FPCPROCVAR}@{$endif}chainprocsym);
  850. end;
  851. {$endif CHAINPROCSYMS}
  852. {$ifdef GDB}
  853. procedure tstoredsymtable.concatstabto(asmlist : taasmoutput);
  854. begin
  855. asmoutput:=asmlist;
  856. if symtabletype in [inlineparasymtable,inlinelocalsymtable] then
  857. foreach({$ifdef FPCPROCVAR}@{$endif}resetstab);
  858. foreach({$ifdef FPCPROCVAR}@{$endif}concatstab);
  859. end;
  860. {$endif}
  861. {****************************************************************************
  862. TAbstractRecordSymtable
  863. ****************************************************************************}
  864. procedure tabstractrecordsymtable.load(ppufile:tcompilerppufile);
  865. var
  866. storesymtable : tsymtable;
  867. begin
  868. storesymtable:=aktrecordsymtable;
  869. aktrecordsymtable:=self;
  870. inherited load(ppufile);
  871. aktrecordsymtable:=storesymtable;
  872. end;
  873. procedure tabstractrecordsymtable.write(ppufile:tcompilerppufile);
  874. var
  875. oldtyp : byte;
  876. storesymtable : tsymtable;
  877. begin
  878. storesymtable:=aktrecordsymtable;
  879. aktrecordsymtable:=self;
  880. oldtyp:=ppufile.entrytyp;
  881. ppufile.entrytyp:=subentryid;
  882. { order procsym overloads }
  883. foreach({$ifdef FPCPROCVAR}@{$endif}Order_overloads);
  884. inherited write(ppufile);
  885. ppufile.entrytyp:=oldtyp;
  886. aktrecordsymtable:=storesymtable;
  887. end;
  888. procedure tabstractrecordsymtable.load_browser(ppufile:tcompilerppufile);
  889. var
  890. storesymtable : tsymtable;
  891. begin
  892. storesymtable:=aktrecordsymtable;
  893. aktrecordsymtable:=self;
  894. inherited load_browser(ppufile);
  895. aktrecordsymtable:=storesymtable;
  896. end;
  897. procedure tabstractrecordsymtable.write_browser(ppufile:tcompilerppufile);
  898. var
  899. storesymtable : tsymtable;
  900. begin
  901. storesymtable:=aktrecordsymtable;
  902. aktrecordsymtable:=self;
  903. inherited write_browser(ppufile);
  904. aktrecordsymtable:=storesymtable;
  905. end;
  906. procedure TStoredSymtable._needs_init_final(p : tnamedindexitem);
  907. begin
  908. if (not b_needs_init_final) and
  909. (tsym(p).typ=varsym) and
  910. assigned(tvarsym(p).vartype.def) and
  911. not is_class(tvarsym(p).vartype.def) and
  912. tstoreddef(tvarsym(p).vartype.def).needs_inittable then
  913. b_needs_init_final:=true;
  914. end;
  915. { returns true, if p contains data which needs init/final code }
  916. function tstoredsymtable.needs_init_final : boolean;
  917. begin
  918. b_needs_init_final:=false;
  919. foreach({$ifdef FPCPROCVAR}@{$endif}_needs_init_final);
  920. needs_init_final:=b_needs_init_final;
  921. end;
  922. {****************************************************************************
  923. TRecordSymtable
  924. ****************************************************************************}
  925. constructor trecordsymtable.create;
  926. begin
  927. inherited create('');
  928. symtabletype:=recordsymtable;
  929. end;
  930. { this procedure is reserved for inserting case variant into
  931. a record symtable }
  932. { the offset is the location of the start of the variant
  933. and datasize and dataalignment corresponds to
  934. the complete size (see code in pdecl unit) PM }
  935. procedure trecordsymtable.insert_in(tsymt : tsymtable;offset : longint);
  936. var
  937. ps,nps : tvarsym;
  938. pd,npd : tdef;
  939. storesize,storealign : longint;
  940. begin
  941. storesize:=tsymt.datasize;
  942. storealign:=tsymt.dataalignment;
  943. tsymt.datasize:=offset;
  944. ps:=tvarsym(symindex.first);
  945. while assigned(ps) do
  946. begin
  947. { this is used to insert case variant into the main
  948. record }
  949. tsymt.datasize:=ps.address+offset;
  950. nps:=tvarsym(ps.indexnext);
  951. symindex.deleteindex(ps);
  952. ps.left:=nil;
  953. ps.right:=nil;
  954. tsymt.insert(ps);
  955. ps:=nps;
  956. end;
  957. pd:=tdef(defindex.first);
  958. while assigned(pd) do
  959. begin
  960. npd:=tdef(pd.indexnext);
  961. defindex.deleteindex(pd);
  962. pd.left:=nil;
  963. pd.right:=nil;
  964. tsymt.registerdef(pd);
  965. pd:=npd;
  966. end;
  967. tsymt.datasize:=storesize;
  968. tsymt.dataalignment:=storealign;
  969. end;
  970. {****************************************************************************
  971. TObjectSymtable
  972. ****************************************************************************}
  973. constructor tobjectsymtable.create(const n:string);
  974. begin
  975. inherited create(n);
  976. symtabletype:=objectsymtable;
  977. end;
  978. procedure tobjectsymtable.insert(sym:tsymentry);
  979. var
  980. hsym : tsym;
  981. begin
  982. { check for duplicate field id in inherited classes }
  983. if (sym.typ=varsym) and
  984. assigned(defowner) and
  985. (
  986. not(m_delphi in aktmodeswitches) or
  987. is_object(tdef(defowner))
  988. ) then
  989. begin
  990. { but private ids can be reused }
  991. hsym:=search_class_member(tobjectdef(defowner),sym.name);
  992. if assigned(hsym) and
  993. (not(sp_private in hsym.symoptions) or
  994. (hsym.owner.defowner.owner.unitid=0)) then
  995. begin
  996. DuplicateSym(hsym);
  997. exit;
  998. end;
  999. end;
  1000. inherited insert(sym);
  1001. end;
  1002. {****************************************************************************
  1003. TAbstractLocalSymtable
  1004. ****************************************************************************}
  1005. procedure tabstractlocalsymtable.load(ppufile:tcompilerppufile);
  1006. var
  1007. storesymtable : tsymtable;
  1008. begin
  1009. storesymtable:=aktlocalsymtable;
  1010. aktlocalsymtable:=self;
  1011. inherited load(ppufile);
  1012. aktlocalsymtable:=storesymtable;
  1013. end;
  1014. procedure tabstractlocalsymtable.write(ppufile:tcompilerppufile);
  1015. var
  1016. oldtyp : byte;
  1017. storesymtable : tsymtable;
  1018. begin
  1019. storesymtable:=aktlocalsymtable;
  1020. aktlocalsymtable:=self;
  1021. oldtyp:=ppufile.entrytyp;
  1022. ppufile.entrytyp:=subentryid;
  1023. { order procsym overloads }
  1024. foreach({$ifdef FPCPROCVAR}@{$endif}Order_overloads);
  1025. { write definitions }
  1026. writedefs(ppufile);
  1027. { write symbols }
  1028. writesyms(ppufile);
  1029. ppufile.entrytyp:=oldtyp;
  1030. aktlocalsymtable:=storesymtable;
  1031. end;
  1032. procedure tabstractlocalsymtable.load_browser(ppufile:tcompilerppufile);
  1033. var
  1034. storesymtable : tsymtable;
  1035. begin
  1036. storesymtable:=aktlocalsymtable;
  1037. aktlocalsymtable:=self;
  1038. inherited load_browser(ppufile);
  1039. aktlocalsymtable:=storesymtable;
  1040. end;
  1041. procedure tabstractlocalsymtable.write_browser(ppufile:tcompilerppufile);
  1042. var
  1043. storesymtable : tsymtable;
  1044. begin
  1045. storesymtable:=aktlocalsymtable;
  1046. aktlocalsymtable:=self;
  1047. inherited load_browser(ppufile);
  1048. aktlocalsymtable:=storesymtable;
  1049. end;
  1050. {****************************************************************************
  1051. TLocalSymtable
  1052. ****************************************************************************}
  1053. constructor tlocalsymtable.create;
  1054. begin
  1055. inherited create('');
  1056. symtabletype:=localsymtable;
  1057. end;
  1058. procedure tlocalsymtable.insert(sym:tsymentry);
  1059. var
  1060. hsym : tsym;
  1061. begin
  1062. if assigned(next) then
  1063. begin
  1064. if (next.symtabletype=parasymtable) then
  1065. begin
  1066. hsym:=tsym(next.search(sym.name));
  1067. if assigned(hsym) then
  1068. begin
  1069. { a parameter and the function can have the same
  1070. name in TP and Delphi, but RESULT not }
  1071. if (m_tp in aktmodeswitches) and
  1072. (sym.typ=funcretsym) and
  1073. not((m_result in aktmodeswitches) and
  1074. (sym.name='RESULT')) then
  1075. sym.name:='hidden'+sym.name
  1076. else
  1077. begin
  1078. DuplicateSym(hsym);
  1079. exit;
  1080. end;
  1081. end;
  1082. end;
  1083. { check for duplicate id in local symtable of methods }
  1084. if assigned(next.next) and
  1085. { funcretsym is allowed !! }
  1086. (sym.typ <> funcretsym) and
  1087. (next.next.symtabletype=objectsymtable) then
  1088. begin
  1089. hsym:=search_class_member(tobjectdef(next.next.defowner),sym.name);
  1090. if assigned(hsym) and
  1091. { private ids can be reused }
  1092. (not(sp_private in hsym.symoptions) or
  1093. (hsym.owner.defowner.owner.symtabletype<>globalsymtable)) then
  1094. begin
  1095. { delphi allows to reuse the names in a class, but not
  1096. in object (tp7 compatible) }
  1097. if not((m_delphi in aktmodeswitches) and
  1098. is_class(tdef(next.next.defowner))) then
  1099. begin
  1100. DuplicateSym(hsym);
  1101. exit;
  1102. end;
  1103. end;
  1104. end;
  1105. end;
  1106. inherited insert(sym);
  1107. end;
  1108. {****************************************************************************
  1109. TParaSymtable
  1110. ****************************************************************************}
  1111. constructor tparasymtable.create;
  1112. begin
  1113. inherited create('');
  1114. symtabletype:=parasymtable;
  1115. dataalignment:=aktalignment.paraalign;
  1116. end;
  1117. procedure tparasymtable.insert(sym:tsymentry);
  1118. var
  1119. hsym : tsym;
  1120. begin
  1121. { check for duplicate id in para symtable of methods }
  1122. if assigned(procinfo^._class) and
  1123. { but not in nested procedures !}
  1124. (not(assigned(procinfo^.parent)) or
  1125. (assigned(procinfo^.parent) and
  1126. not(assigned(procinfo^.parent^._class)))
  1127. ) and
  1128. { funcretsym is allowed !! }
  1129. (sym.typ <> funcretsym) then
  1130. begin
  1131. hsym:=search_class_member(procinfo^._class,sym.name);
  1132. if assigned(hsym) and
  1133. { private ids can be reused }
  1134. (not(sp_private in hsym.symoptions) or
  1135. (hsym.owner.defowner.owner.unitid=0)) then
  1136. begin
  1137. { delphi allows to reuse the names in a class, but not
  1138. in object (tp7 compatible) }
  1139. if not((m_delphi in aktmodeswitches) and
  1140. is_class(procinfo^._class)) then
  1141. begin
  1142. DuplicateSym(hsym);
  1143. exit;
  1144. end;
  1145. end;
  1146. end;
  1147. inherited insert(sym);
  1148. end;
  1149. procedure tparasymtable.set_alignment(_alignment : longint);
  1150. var
  1151. sym : tvarsym;
  1152. l : longint;
  1153. begin
  1154. dataalignment:=_alignment;
  1155. sym:=tvarsym(symindex.first);
  1156. datasize:=0;
  1157. { there can be only varsyms }
  1158. while assigned(sym) do
  1159. begin
  1160. l:=sym.getpushsize;
  1161. sym.address:=datasize;
  1162. datasize:=align(datasize+l,dataalignment);
  1163. sym:=tvarsym(sym.indexnext);
  1164. end;
  1165. end;
  1166. {****************************************************************************
  1167. TAbstractUnitSymtable
  1168. ****************************************************************************}
  1169. constructor tabstractunitsymtable.create(const n : string);
  1170. begin
  1171. inherited create(n);
  1172. symsearch.usehash;
  1173. {$ifdef GDB}
  1174. { reset GDB things }
  1175. prev_dbx_counter := dbx_counter;
  1176. dbx_counter := nil;
  1177. is_stab_written:=false;
  1178. dbx_count := -1;
  1179. {$endif GDB}
  1180. end;
  1181. {$ifdef GDB}
  1182. procedure tabstractunitsymtable.concattypestabto(asmlist : taasmoutput);
  1183. var prev_dbx_count : plongint;
  1184. begin
  1185. if is_stab_written then
  1186. exit;
  1187. if not assigned(name) then
  1188. name := stringdup('Main_program');
  1189. if (symtabletype = globalsymtable) and
  1190. (current_module.globalsymtable<>self) then
  1191. begin
  1192. unitid:=current_module.unitcount;
  1193. inc(current_module.unitcount);
  1194. end;
  1195. asmList.concat(Tai_asm_comment.Create(strpnew('Begin unit '+name^+' has index '+tostr(unitid))));
  1196. if cs_gdb_dbx in aktglobalswitches then
  1197. begin
  1198. if dbx_count_ok then
  1199. begin
  1200. asmList.concat(Tai_asm_comment.Create(strpnew('"repeated" unit '+name^
  1201. +' has index '+tostr(unitid)+' dbx count = '+tostr(dbx_count))));
  1202. asmList.concat(Tai_stabs.Create(strpnew('"'+name^+'",'
  1203. +tostr(N_EXCL)+',0,0,'+tostr(dbx_count))));
  1204. exit;
  1205. end
  1206. else if (current_module.globalsymtable<>self) then
  1207. begin
  1208. prev_dbx_count := dbx_counter;
  1209. dbx_counter := nil;
  1210. do_count_dbx:=false;
  1211. if (symtabletype = globalsymtable) and (unitid<>0) then
  1212. asmList.concat(Tai_stabs.Create(strpnew('"'+name^+'",'+tostr(N_BINCL)+',0,0,0')));
  1213. dbx_counter := @dbx_count;
  1214. dbx_count:=0;
  1215. do_count_dbx:=assigned(dbx_counter);
  1216. end;
  1217. end;
  1218. asmoutput:=asmlist;
  1219. foreach({$ifdef FPCPROCVAR}@{$endif}concattypestab);
  1220. if cs_gdb_dbx in aktglobalswitches then
  1221. begin
  1222. if (current_module.globalsymtable<>self) then
  1223. begin
  1224. dbx_counter := prev_dbx_count;
  1225. do_count_dbx:=false;
  1226. asmList.concat(Tai_asm_comment.Create(strpnew('End unit '+name^
  1227. +' has index '+tostr(unitid))));
  1228. asmList.concat(Tai_stabs.Create(strpnew('"'+name^+'",'
  1229. +tostr(N_EINCL)+',0,0,0')));
  1230. do_count_dbx:=assigned(dbx_counter);
  1231. dbx_count_ok := {true}false;
  1232. end;
  1233. end;
  1234. is_stab_written:=true;
  1235. end;
  1236. {$endif GDB}
  1237. {****************************************************************************
  1238. TStaticSymtable
  1239. ****************************************************************************}
  1240. constructor tstaticsymtable.create(const n : string);
  1241. begin
  1242. inherited create(n);
  1243. symtabletype:=staticsymtable;
  1244. end;
  1245. procedure tstaticsymtable.load(ppufile:tcompilerppufile);
  1246. begin
  1247. aktstaticsymtable:=self;
  1248. next:=symtablestack;
  1249. symtablestack:=self;
  1250. inherited load(ppufile);
  1251. { now we can deref the syms and defs }
  1252. deref;
  1253. { restore symtablestack }
  1254. symtablestack:=next;
  1255. end;
  1256. procedure tstaticsymtable.write(ppufile:tcompilerppufile);
  1257. begin
  1258. aktstaticsymtable:=self;
  1259. { order procsym overloads }
  1260. foreach({$ifdef FPCPROCVAR}@{$endif}Order_overloads);
  1261. inherited write(ppufile);
  1262. end;
  1263. procedure tstaticsymtable.load_browser(ppufile:tcompilerppufile);
  1264. begin
  1265. aktstaticsymtable:=self;
  1266. inherited load_browser(ppufile);
  1267. end;
  1268. procedure tstaticsymtable.write_browser(ppufile:tcompilerppufile);
  1269. begin
  1270. aktstaticsymtable:=self;
  1271. inherited write_browser(ppufile);
  1272. end;
  1273. procedure tstaticsymtable.insert(sym:tsymentry);
  1274. var
  1275. hsym : tsym;
  1276. begin
  1277. { also check the global symtable }
  1278. if assigned(next) and
  1279. (next.unitid=0) then
  1280. begin
  1281. hsym:=tsym(next.search(sym.name));
  1282. if assigned(hsym) then
  1283. begin
  1284. DuplicateSym(hsym);
  1285. exit;
  1286. end;
  1287. end;
  1288. inherited insert(sym);
  1289. end;
  1290. {****************************************************************************
  1291. TGlobalSymtable
  1292. ****************************************************************************}
  1293. constructor tglobalsymtable.create(const n : string);
  1294. begin
  1295. inherited create(n);
  1296. symtabletype:=globalsymtable;
  1297. unitid:=0;
  1298. unitsym:=nil;
  1299. {$ifdef GDB}
  1300. if cs_gdb_dbx in aktglobalswitches then
  1301. begin
  1302. dbx_count := 0;
  1303. unittypecount:=1;
  1304. pglobaltypecount := @unittypecount;
  1305. unitid:=current_module.unitcount;
  1306. debugList.concat(Tai_asm_comment.Create(strpnew('Global '+name^+' has index '+tostr(unitid))));
  1307. debugList.concat(Tai_stabs.Create(strpnew('"'+name^+'",'+tostr(N_BINCL)+',0,0,0')));
  1308. inc(current_module.unitcount);
  1309. dbx_count_ok:=false;
  1310. dbx_counter:=@dbx_count;
  1311. do_count_dbx:=true;
  1312. end;
  1313. {$endif GDB}
  1314. end;
  1315. destructor tglobalsymtable.destroy;
  1316. var
  1317. pus : tunitsym;
  1318. begin
  1319. pus:=unitsym;
  1320. while assigned(pus) do
  1321. begin
  1322. unitsym:=pus.prevsym;
  1323. pus.prevsym:=nil;
  1324. pus.unitsymtable:=nil;
  1325. pus:=unitsym;
  1326. end;
  1327. inherited destroy;
  1328. end;
  1329. procedure tglobalsymtable.load(ppufile:tcompilerppufile);
  1330. {$ifdef GDB}
  1331. var
  1332. storeGlobalTypeCount : pword;
  1333. {$endif GDB}
  1334. begin
  1335. {$ifdef GDB}
  1336. if cs_gdb_dbx in aktglobalswitches then
  1337. begin
  1338. UnitTypeCount:=1;
  1339. storeGlobalTypeCount:=PGlobalTypeCount;
  1340. PglobalTypeCount:=@UnitTypeCount;
  1341. end;
  1342. {$endif GDB}
  1343. symtablelevel:=0;
  1344. {$ifndef NEWMAP}
  1345. current_module.map^[0]:=self;
  1346. {$else NEWMAP}
  1347. current_module.globalsymtable:=self;
  1348. {$endif NEWMAP}
  1349. next:=symtablestack;
  1350. symtablestack:=self;
  1351. inherited load(ppufile);
  1352. { now we can deref the syms and defs }
  1353. deref;
  1354. { restore symtablestack }
  1355. symtablestack:=next;
  1356. {$ifdef NEWMAP}
  1357. { necessary for dependencies }
  1358. current_module.globalsymtable:=nil;
  1359. {$endif NEWMAP}
  1360. end;
  1361. procedure tglobalsymtable.write(ppufile:tcompilerppufile);
  1362. begin
  1363. { order procsym overloads }
  1364. foreach({$ifdef FPCPROCVAR}@{$endif}Order_overloads);
  1365. { write the symtable entries }
  1366. inherited write(ppufile);
  1367. { write dbx count }
  1368. {$ifdef GDB}
  1369. if cs_gdb_dbx in aktglobalswitches then
  1370. begin
  1371. {$IfDef EXTDEBUG}
  1372. writeln('Writing dbx_count ',dbx_count,' in unit ',name^,'.ppu');
  1373. {$ENDIF EXTDEBUG}
  1374. ppufile.do_crc:=false;
  1375. ppufile.putlongint(dbx_count);
  1376. ppufile.writeentry(ibdbxcount);
  1377. ppufile.do_crc:=true;
  1378. end;
  1379. {$endif GDB}
  1380. end;
  1381. procedure tglobalsymtable.insert(sym:tsymentry);
  1382. var
  1383. hsym : tsym;
  1384. begin
  1385. { also check the global symtable }
  1386. if assigned(next) and
  1387. (next.unitid=0) then
  1388. begin
  1389. hsym:=tsym(next.search(sym.name));
  1390. if assigned(hsym) then
  1391. begin
  1392. DuplicateSym(hsym);
  1393. exit;
  1394. end;
  1395. end;
  1396. hsym:=tsym(search(sym.name));
  1397. if assigned(hsym) then
  1398. begin
  1399. { Delphi you can have a symbol with the same name as the
  1400. unit, the unit can then not be accessed anymore using
  1401. <unit>.<id>, so we can hide the symbol }
  1402. if (m_tp in aktmodeswitches) and
  1403. (hsym.typ=symconst.unitsym) then
  1404. hsym.owner.rename(hsym.name,'hidden'+hsym.name)
  1405. else
  1406. begin
  1407. DuplicateSym(hsym);
  1408. exit;
  1409. end;
  1410. end;
  1411. inherited insert(sym);
  1412. end;
  1413. {$ifdef GDB}
  1414. function tglobalsymtable.getnewtypecount : word;
  1415. begin
  1416. if not (cs_gdb_dbx in aktglobalswitches) then
  1417. getnewtypecount:=inherited getnewtypecount
  1418. else
  1419. begin
  1420. getnewtypecount:=unittypecount;
  1421. inc(unittypecount);
  1422. end;
  1423. end;
  1424. {$endif}
  1425. {****************************************************************************
  1426. TWITHSYMTABLE
  1427. ****************************************************************************}
  1428. constructor twithsymtable.create(aowner:tdef;asymsearch:TDictionary);
  1429. begin
  1430. inherited create('');
  1431. symtabletype:=withsymtable;
  1432. direct_with:=false;
  1433. withnode:=nil;
  1434. withrefnode:=nil;
  1435. { we don't need the symsearch }
  1436. symsearch.free;
  1437. { set the defaults }
  1438. symsearch:=asymsearch;
  1439. defowner:=aowner;
  1440. end;
  1441. destructor twithsymtable.destroy;
  1442. begin
  1443. symsearch:=nil;
  1444. inherited destroy;
  1445. end;
  1446. procedure twithsymtable.clear;
  1447. begin
  1448. { remove no entry from a withsymtable as it is only a pointer to the
  1449. recorddef or objectdef symtable }
  1450. end;
  1451. {****************************************************************************
  1452. TSTT_ExceptionSymtable
  1453. ****************************************************************************}
  1454. constructor tstt_exceptsymtable.create;
  1455. begin
  1456. inherited create('');
  1457. symtabletype:=stt_exceptsymtable;
  1458. end;
  1459. {*****************************************************************************
  1460. Helper Routines
  1461. *****************************************************************************}
  1462. function findunitsymtable(st:tsymtable):tsymtable;
  1463. begin
  1464. findunitsymtable:=nil;
  1465. repeat
  1466. if not assigned(st) then
  1467. internalerror(5566561);
  1468. case st.symtabletype of
  1469. localsymtable,
  1470. parasymtable,
  1471. staticsymtable :
  1472. break;
  1473. globalsymtable :
  1474. begin
  1475. findunitsymtable:=st;
  1476. break;
  1477. end;
  1478. objectsymtable,
  1479. recordsymtable :
  1480. st:=st.defowner.owner;
  1481. else
  1482. internalerror(5566562);
  1483. end;
  1484. until false;
  1485. end;
  1486. procedure duplicatesym(sym:tsym);
  1487. var
  1488. st : tsymtable;
  1489. begin
  1490. Message1(sym_e_duplicate_id,sym.realname);
  1491. st:=findunitsymtable(sym.owner);
  1492. with sym.fileinfo do
  1493. begin
  1494. if assigned(st) and (st.unitid<>0) then
  1495. Message2(sym_h_duplicate_id_where,'unit '+st.name^,tostr(line))
  1496. else
  1497. Message2(sym_h_duplicate_id_where,current_module.sourcefiles.get_file_name(fileindex),tostr(line));
  1498. end;
  1499. end;
  1500. {*****************************************************************************
  1501. Search
  1502. *****************************************************************************}
  1503. function searchsym(const s : stringid;var srsym:tsym;var srsymtable:tsymtable):boolean;
  1504. var
  1505. speedvalue : cardinal;
  1506. begin
  1507. speedvalue:=getspeedvalue(s);
  1508. srsymtable:=symtablestack;
  1509. while assigned(srsymtable) do
  1510. begin
  1511. srsym:=tsym(srsymtable.speedsearch(s,speedvalue));
  1512. if assigned(srsym) then
  1513. begin
  1514. searchsym:=true;
  1515. exit;
  1516. end
  1517. else
  1518. srsymtable:=srsymtable.next;
  1519. end;
  1520. searchsym:=false;
  1521. end;
  1522. function searchsymonlyin(p : tsymtable;const s : stringid):tsym;
  1523. var
  1524. srsym : tsym;
  1525. begin
  1526. { the caller have to take care if srsym=nil }
  1527. if assigned(p) then
  1528. begin
  1529. srsym:=tsym(p.search(s));
  1530. if assigned(srsym) then
  1531. begin
  1532. searchsymonlyin:=srsym;
  1533. exit;
  1534. end;
  1535. { also check in the local symtbale if it exists }
  1536. if (p=tsymtable(current_module.globalsymtable)) then
  1537. begin
  1538. srsym:=tsym(current_module.localsymtable.search(s));
  1539. if assigned(srsym) then
  1540. begin
  1541. searchsymonlyin:=srsym;
  1542. exit;
  1543. end;
  1544. end
  1545. end;
  1546. searchsymonlyin:=nil;
  1547. end;
  1548. function search_class_member(pd : tobjectdef;const s : string):tsym;
  1549. { searches n in symtable of pd and all anchestors }
  1550. var
  1551. speedvalue : cardinal;
  1552. srsym : tsym;
  1553. begin
  1554. speedvalue:=getspeedvalue(s);
  1555. while assigned(pd) do
  1556. begin
  1557. srsym:=tsym(pd.symtable.speedsearch(s,speedvalue));
  1558. if assigned(srsym) then
  1559. begin
  1560. search_class_member:=srsym;
  1561. exit;
  1562. end;
  1563. pd:=pd.childof;
  1564. end;
  1565. search_class_member:=nil;
  1566. end;
  1567. {*****************************************************************************
  1568. Definition Helpers
  1569. *****************************************************************************}
  1570. procedure globaldef(const s : string;var t:ttype);
  1571. var st : string;
  1572. symt : tsymtable;
  1573. srsym : tsym;
  1574. srsymtable : tsymtable;
  1575. begin
  1576. srsym := nil;
  1577. if pos('.',s) > 0 then
  1578. begin
  1579. st := copy(s,1,pos('.',s)-1);
  1580. searchsym(st,srsym,srsymtable);
  1581. st := copy(s,pos('.',s)+1,255);
  1582. if assigned(srsym) then
  1583. begin
  1584. if srsym.typ = unitsym then
  1585. begin
  1586. symt := tunitsym(srsym).unitsymtable;
  1587. srsym := tsym(symt.search(st));
  1588. end else srsym := nil;
  1589. end;
  1590. end else st := s;
  1591. if srsym = nil then
  1592. searchsym(st,srsym,srsymtable);
  1593. if srsym = nil then
  1594. srsym:=searchsymonlyin(systemunit,st);
  1595. if (not assigned(srsym)) or
  1596. (srsym.typ<>typesym) then
  1597. begin
  1598. Message(type_e_type_id_expected);
  1599. t:=generrortype;
  1600. exit;
  1601. end;
  1602. t := ttypesym(srsym).restype;
  1603. end;
  1604. {****************************************************************************
  1605. Object Helpers
  1606. ****************************************************************************}
  1607. var
  1608. _defaultprop : tpropertysym;
  1609. procedure tstoredsymtable.testfordefaultproperty(p : TNamedIndexItem);
  1610. begin
  1611. if (tsym(p).typ=propertysym) and
  1612. (ppo_defaultproperty in tpropertysym(p).propoptions) then
  1613. _defaultprop:=tpropertysym(p);
  1614. end;
  1615. function search_default_property(pd : tobjectdef) : tpropertysym;
  1616. { returns the default property of a class, searches also anchestors }
  1617. begin
  1618. _defaultprop:=nil;
  1619. while assigned(pd) do
  1620. begin
  1621. pd.symtable.foreach({$ifdef FPCPROCVAR}@{$endif}tstoredsymtable(pd.symtable).testfordefaultproperty);
  1622. if assigned(_defaultprop) then
  1623. break;
  1624. pd:=pd.childof;
  1625. end;
  1626. search_default_property:=_defaultprop;
  1627. end;
  1628. {$ifdef UNITALIASES}
  1629. {****************************************************************************
  1630. TUNIT_ALIAS
  1631. ****************************************************************************}
  1632. constructor tunit_alias.create(const n:string);
  1633. var
  1634. i : longint;
  1635. begin
  1636. i:=pos('=',n);
  1637. if i=0 then
  1638. fail;
  1639. inherited createname(Copy(n,1,i-1));
  1640. newname:=stringdup(Copy(n,i+1,255));
  1641. end;
  1642. destructor tunit_alias.destroy;
  1643. begin
  1644. stringdispose(newname);
  1645. inherited destroy;
  1646. end;
  1647. procedure addunitalias(const n:string);
  1648. begin
  1649. unitaliases^.insert(tunit_alias,init(Upper(n))));
  1650. end;
  1651. function getunitalias(const n:string):string;
  1652. var
  1653. p : punit_alias;
  1654. begin
  1655. p:=punit_alias(unitaliases^.search(Upper(n)));
  1656. if assigned(p) then
  1657. getunitalias:=punit_alias(p).newname^
  1658. else
  1659. getunitalias:=n;
  1660. end;
  1661. {$endif UNITALIASES}
  1662. {****************************************************************************
  1663. Symtable Stack
  1664. ****************************************************************************}
  1665. procedure dellexlevel;
  1666. var
  1667. p : tsymtable;
  1668. begin
  1669. p:=symtablestack;
  1670. symtablestack:=p.next;
  1671. { symbol tables of unit interfaces are never disposed }
  1672. { this is handle by the unit unitm }
  1673. if not(p.symtabletype in [globalsymtable,stt_exceptsymtable]) then
  1674. p.free;
  1675. end;
  1676. procedure RestoreUnitSyms;
  1677. var
  1678. p : tsymtable;
  1679. begin
  1680. p:=symtablestack;
  1681. while assigned(p) do
  1682. begin
  1683. if (p.symtabletype=globalsymtable) and
  1684. assigned(tglobalsymtable(p).unitsym) and
  1685. ((tglobalsymtable(p).unitsym.owner=current_module.globalsymtable) or
  1686. (tglobalsymtable(p).unitsym.owner=current_module.localsymtable)) then
  1687. tglobalsymtable(p).unitsym.restoreunitsym;
  1688. p:=p.next;
  1689. end;
  1690. end;
  1691. {$ifdef DEBUG}
  1692. procedure test_symtablestack;
  1693. var
  1694. p : tsymtable;
  1695. i : longint;
  1696. begin
  1697. p:=symtablestack;
  1698. i:=0;
  1699. while assigned(p) do
  1700. begin
  1701. inc(i);
  1702. p:=p.next;
  1703. if i>500 then
  1704. Message(sym_f_internal_error_in_symtablestack);
  1705. end;
  1706. end;
  1707. procedure list_symtablestack;
  1708. var
  1709. p : tsymtable;
  1710. i : longint;
  1711. begin
  1712. p:=symtablestack;
  1713. i:=0;
  1714. while assigned(p) do
  1715. begin
  1716. inc(i);
  1717. writeln(i,' ',p.name^);
  1718. p:=p.next;
  1719. if i>500 then
  1720. Message(sym_f_internal_error_in_symtablestack);
  1721. end;
  1722. end;
  1723. {$endif DEBUG}
  1724. {****************************************************************************
  1725. Init/Done Symtable
  1726. ****************************************************************************}
  1727. procedure InitSymtable;
  1728. var
  1729. token : ttoken;
  1730. begin
  1731. { Reset symbolstack }
  1732. registerdef:=false;
  1733. read_member:=false;
  1734. symtablestack:=nil;
  1735. systemunit:=nil;
  1736. {$ifdef GDB}
  1737. firstglobaldef:=nil;
  1738. lastglobaldef:=nil;
  1739. globaltypecount:=1;
  1740. pglobaltypecount:=@globaltypecount;
  1741. {$endif GDB}
  1742. { create error syms and def }
  1743. generrorsym:=terrorsym.create;
  1744. generrortype.setdef(terrordef.create);
  1745. {$ifdef UNITALIASES}
  1746. { unit aliases }
  1747. unitaliases:=tdictionary.create;
  1748. {$endif}
  1749. for token:=first_overloaded to last_overloaded do
  1750. overloaded_operators[token]:=nil;
  1751. end;
  1752. procedure DoneSymtable;
  1753. begin
  1754. generrorsym.free;
  1755. generrortype.def.free;
  1756. {$ifdef UNITALIASES}
  1757. unitaliases.free;
  1758. {$endif}
  1759. end;
  1760. end.
  1761. {
  1762. $Log$
  1763. Revision 1.38 2001-07-01 20:16:18 peter
  1764. * alignmentinfo record added
  1765. * -Oa argument supports more alignment settings that can be specified
  1766. per type: PROC,LOOP,VARMIN,VARMAX,CONSTMIN,CONSTMAX,RECORDMIN
  1767. RECORDMAX,LOCALMIN,LOCALMAX. It is possible to set the mimimum
  1768. required alignment and the maximum usefull alignment. The final
  1769. alignment will be choosen per variable size dependent on these
  1770. settings
  1771. Revision 1.37 2001/06/04 11:53:14 peter
  1772. + varargs directive
  1773. Revision 1.36 2001/06/03 21:57:38 peter
  1774. + hint directive parsing support
  1775. Revision 1.35 2001/05/06 14:49:18 peter
  1776. * ppu object to class rewrite
  1777. * move ppu read and write stuff to fppu
  1778. Revision 1.34 2001/04/18 22:01:59 peter
  1779. * registration of targets and assemblers
  1780. Revision 1.33 2001/04/13 20:05:15 peter
  1781. * better check for globalsymtable
  1782. Revision 1.32 2001/04/13 18:08:37 peter
  1783. * scanner object to class
  1784. Revision 1.31 2001/04/13 01:22:16 peter
  1785. * symtable change to classes
  1786. * range check generation and errors fixed, make cycle DEBUG=1 works
  1787. * memory leaks fixed
  1788. Revision 1.30 2001/04/02 21:20:35 peter
  1789. * resulttype rewrite
  1790. Revision 1.29 2001/03/22 00:10:58 florian
  1791. + basic variant type support in the compiler
  1792. Revision 1.28 2001/03/13 18:45:07 peter
  1793. * fixed some memory leaks
  1794. Revision 1.27 2001/03/11 22:58:51 peter
  1795. * getsym redesign, removed the globals srsym,srsymtable
  1796. Revision 1.26 2001/02/21 19:37:19 peter
  1797. * moved deref to be done after loading of implementation units. prederef
  1798. is still done directly after loading of symbols and definitions.
  1799. Revision 1.25 2001/02/20 21:41:16 peter
  1800. * new fixfilename, findfile for unix. Look first for lowercase, then
  1801. NormalCase and last for UPPERCASE names.
  1802. Revision 1.24 2001/01/08 21:40:27 peter
  1803. * fixed crash with unsupported token overloading
  1804. Revision 1.23 2000/12/25 00:07:30 peter
  1805. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  1806. tlinkedlist objects)
  1807. Revision 1.22 2000/12/23 19:50:09 peter
  1808. * fixed mem leak with withsymtable
  1809. Revision 1.21 2000/12/10 20:25:32 peter
  1810. * fixed missing typecast
  1811. Revision 1.20 2000/12/10 14:14:51 florian
  1812. * fixed web bug 1203: class fields can be now redefined
  1813. in Delphi mode though I don't like this :/
  1814. Revision 1.19 2000/11/30 22:16:49 florian
  1815. * moved to i386
  1816. Revision 1.18 2000/11/29 00:30:42 florian
  1817. * unused units removed from uses clause
  1818. * some changes for widestrings
  1819. Revision 1.17 2000/11/28 00:28:07 pierre
  1820. * stabs fixing
  1821. Revision 1.1.2.8 2000/11/17 11:14:37 pierre
  1822. * one more class stabs fix
  1823. Revision 1.16 2000/11/12 22:17:47 peter
  1824. * some realname updates for messages
  1825. Revision 1.15 2000/11/06 15:54:15 florian
  1826. * fixed two bugs to get make cycle work, but it's not enough
  1827. Revision 1.14 2000/11/04 14:25:22 florian
  1828. + merged Attila's changes for interfaces, not tested yet
  1829. Revision 1.13 2000/11/01 23:04:38 peter
  1830. * tprocdef.fullprocname added for better casesensitve writing of
  1831. procedures
  1832. Revision 1.12 2000/10/31 22:02:52 peter
  1833. * symtable splitted, no real code changes
  1834. Revision 1.1.2.7 2000/10/16 19:43:04 pierre
  1835. * trying to correct class stabss once more
  1836. Revision 1.11 2000/10/15 07:47:53 peter
  1837. * unit names and procedure names are stored mixed case
  1838. Revision 1.10 2000/10/14 10:14:53 peter
  1839. * moehrendorf oct 2000 rewrite
  1840. Revision 1.9 2000/10/01 19:48:25 peter
  1841. * lot of compile updates for cg11
  1842. Revision 1.8 2000/09/24 15:06:29 peter
  1843. * use defines.inc
  1844. Revision 1.7 2000/08/27 16:11:54 peter
  1845. * moved some util functions from globals,cobjects to cutils
  1846. * splitted files into finput,fmodule
  1847. Revision 1.6 2000/08/21 11:27:45 pierre
  1848. * fix the stabs problems
  1849. Revision 1.5 2000/08/20 14:58:41 peter
  1850. * give fatal if objfpc/delphi mode things are found (merged)
  1851. Revision 1.1.2.6 2000/08/20 14:56:46 peter
  1852. * give fatal if objfpc/delphi mode things are found
  1853. Revision 1.4 2000/08/16 18:33:54 peter
  1854. * splitted namedobjectitem.next into indexnext and listnext so it
  1855. can be used in both lists
  1856. * don't allow "word = word" type definitions (merged)
  1857. Revision 1.3 2000/08/08 19:28:57 peter
  1858. * memdebug/memory patches (merged)
  1859. * only once illegal directive (merged)
  1860. }