symtable.pas 85 KB

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