symtable.pas 87 KB

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