symtable.pas 87 KB

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