symtable.pas 88 KB

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