symtable.pas 70 KB

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