symtable.pas 86 KB

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