symsym.pas 88 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
  4. Implementation for the symbols types of the symtable
  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 symsym;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. { common }
  23. cutils,
  24. { target }
  25. cpuinfo,globtype,
  26. { symtable }
  27. symconst,symbase,symtype,symdef,
  28. { ppu }
  29. ppu,symppu,
  30. cclasses,symnot,
  31. { aasm }
  32. aasmbase,aasmtai,cpubase,
  33. globals
  34. ;
  35. type
  36. {************************************************
  37. TSym
  38. ************************************************}
  39. { this object is the base for all symbol objects }
  40. tstoredsym = class(tsym)
  41. protected
  42. _mangledname : pstring;
  43. public
  44. refs : longint;
  45. lastref,
  46. defref,
  47. lastwritten : tref;
  48. refcount : longint;
  49. {$ifdef GDB}
  50. isstabwritten : boolean;
  51. {$endif GDB}
  52. constructor create(const n : string);
  53. constructor loadsym(ppufile:tcompilerppufile);
  54. destructor destroy;override;
  55. procedure ppuwrite(ppufile:tcompilerppufile);virtual;abstract;
  56. procedure writesym(ppufile:tcompilerppufile);
  57. procedure deref;override;
  58. {$ifdef GDB}
  59. function stabstring : pchar;virtual;
  60. procedure concatstabto(asmlist : taasmoutput);virtual;
  61. {$endif GDB}
  62. procedure load_references(ppufile:tcompilerppufile;locals:boolean);virtual;
  63. function write_references(ppufile:tcompilerppufile;locals:boolean):boolean;virtual;
  64. function is_visible_for_proc(currprocdef:tprocdef):boolean;
  65. function is_visible_for_object(currobjdef:tobjectdef):boolean;
  66. function mangledname : string;
  67. procedure generate_mangledname;virtual;abstract;
  68. end;
  69. tlabelsym = class(tstoredsym)
  70. lab : tasmlabel;
  71. used,
  72. defined : boolean;
  73. code : pointer; { should be tnode }
  74. constructor create(const n : string; l : tasmlabel);
  75. destructor destroy;override;
  76. constructor ppuload(ppufile:tcompilerppufile);
  77. procedure generate_mangledname;override;
  78. procedure ppuwrite(ppufile:tcompilerppufile);override;
  79. end;
  80. tunitsym = class(tstoredsym)
  81. unitsymtable : tsymtable;
  82. prevsym : tunitsym;
  83. constructor create(const n : string;ref : tsymtable);
  84. constructor ppuload(ppufile:tcompilerppufile);
  85. destructor destroy;override;
  86. procedure ppuwrite(ppufile:tcompilerppufile);override;
  87. procedure restoreunitsym;
  88. {$ifdef GDB}
  89. procedure concatstabto(asmlist : taasmoutput);override;
  90. {$endif GDB}
  91. end;
  92. terrorsym = class(tstoredsym)
  93. constructor create;
  94. end;
  95. Tprocdefcallback = procedure(p:Tprocdef;arg:pointer);
  96. tprocsym = class(tstoredsym)
  97. protected
  98. pdlistfirst,
  99. pdlistlast : pprocdeflist; { linked list of overloaded procdefs }
  100. function getprocdef(nr:cardinal):Tprocdef;
  101. public
  102. procdef_count : byte;
  103. {$ifdef GDB}
  104. is_global : boolean;
  105. {$endif GDB}
  106. overloadchecked : boolean;
  107. overloadcount : word; { amount of overloaded functions in this module }
  108. property procdef[nr:cardinal]:Tprocdef read getprocdef;
  109. constructor create(const n : string);
  110. constructor ppuload(ppufile:tcompilerppufile);
  111. destructor destroy;override;
  112. { writes all declarations except the specified one }
  113. procedure write_parameter_lists(skipdef:tprocdef);
  114. { tests, if all procedures definitions are defined and not }
  115. { only forward }
  116. procedure check_forward;
  117. procedure unchain_overload;
  118. procedure ppuwrite(ppufile:tcompilerppufile);override;
  119. procedure deref;override;
  120. procedure addprocdef(p:tprocdef);
  121. procedure add_para_match_to(Aprocsym:Tprocsym);
  122. procedure concat_procdefs_to(s:Tprocsym);
  123. procedure foreach_procdef_static(proc2call:Tprocdefcallback;arg:pointer);
  124. function first_procdef:Tprocdef;
  125. function last_procdef:Tprocdef;
  126. function search_procdef_nopara_boolret:Tprocdef;
  127. function search_procdef_bytype(pt:Tproctypeoption):Tprocdef;
  128. function search_procdef_bypara(params:Tlinkedlist;
  129. retdef:tdef;
  130. allowconvert,
  131. allowdefault:boolean):Tprocdef;
  132. function search_procdef_byprocvardef(d:Tprocvardef):Tprocdef;
  133. function search_procdef_unary_operator(firstpara:Tdef):Tprocdef;
  134. function search_procdef_assignment_operator(fromdef,todef:tdef):Tprocdef;
  135. function search_procdef_binary_operator(def1,def2:tdef):Tprocdef;
  136. function write_references(ppufile:tcompilerppufile;locals:boolean):boolean;override;
  137. {$ifdef GDB}
  138. function stabstring : pchar;override;
  139. procedure concatstabto(asmlist : taasmoutput);override;
  140. {$endif GDB}
  141. end;
  142. ttypesym = class(tstoredsym)
  143. restype : ttype;
  144. {$ifdef GDB}
  145. isusedinstab : boolean;
  146. {$endif GDB}
  147. constructor create(const n : string;const tt : ttype);
  148. constructor ppuload(ppufile:tcompilerppufile);
  149. procedure ppuwrite(ppufile:tcompilerppufile);override;
  150. procedure deref;override;
  151. function gettypedef:tdef;override;
  152. procedure load_references(ppufile:tcompilerppufile;locals:boolean);override;
  153. function write_references(ppufile:tcompilerppufile;locals:boolean):boolean;override;
  154. {$ifdef GDB}
  155. function stabstring : pchar;override;
  156. procedure concatstabto(asmlist : taasmoutput);override;
  157. {$endif GDB}
  158. end;
  159. tvarsym = class(tstoredsym)
  160. address : longint;
  161. localvarsym : tvarsym;
  162. highvarsym : tvarsym;
  163. defaultconstsym : tsym;
  164. varoptions : tvaroptions;
  165. reg : tregister; { if reg<>R_NO, then the variable is an register variable }
  166. varspez : tvarspez; { sets the type of access }
  167. varstate : tvarstate;
  168. paraitem : tparaitem;
  169. notifications : Tlinkedlist;
  170. constructor create(const n : string;vsp:tvarspez;const tt : ttype);
  171. constructor create_dll(const n : string;vsp:tvarspez;const tt : ttype);
  172. constructor create_C(const n,mangled : string;vsp:tvarspez;const tt : ttype);
  173. constructor ppuload(ppufile:tcompilerppufile);
  174. destructor destroy;override;
  175. procedure ppuwrite(ppufile:tcompilerppufile);override;
  176. procedure deref;override;
  177. procedure generate_mangledname;override;
  178. procedure set_mangledname(const s:string);
  179. function getsize : longint;
  180. function getvaluesize : longint;
  181. function adjusted_address : longint;
  182. procedure trigger_notifications(what:Tnotification_flag);
  183. function register_notification(flags:Tnotification_flags;
  184. callback:Tnotification_callback):cardinal;
  185. procedure unregister_notification(id:cardinal);
  186. {$ifdef GDB}
  187. function stabstring : pchar;override;
  188. procedure concatstabto(asmlist : taasmoutput);override;
  189. {$endif GDB}
  190. private
  191. procedure setvartype(const newtype: ttype);
  192. _vartype : ttype;
  193. public
  194. property vartype: ttype read _vartype write setvartype;
  195. end;
  196. tpropertysym = class(tstoredsym)
  197. propoptions : tpropertyoptions;
  198. propoverriden : tpropertysym;
  199. proptype,
  200. indextype : ttype;
  201. index,
  202. default : longint;
  203. readaccess,
  204. writeaccess,
  205. storedaccess : tsymlist;
  206. constructor create(const n : string);
  207. destructor destroy;override;
  208. constructor ppuload(ppufile:tcompilerppufile);
  209. function getsize : longint;
  210. procedure ppuwrite(ppufile:tcompilerppufile);override;
  211. function gettypedef:tdef;override;
  212. procedure deref;override;
  213. procedure dooverride(overriden:tpropertysym);
  214. {$ifdef GDB}
  215. function stabstring : pchar;override;
  216. procedure concatstabto(asmlist : taasmoutput);override;
  217. {$endif GDB}
  218. end;
  219. tabsolutesym = class(tvarsym)
  220. abstyp : absolutetyp;
  221. absseg : boolean;
  222. ref : tstoredsym;
  223. asmname : pstring;
  224. constructor create(const n : string;const tt : ttype);
  225. constructor create_ref(const n : string;const tt : ttype;sym:tstoredsym);
  226. constructor ppuload(ppufile:tcompilerppufile);
  227. procedure deref;override;
  228. function mangledname : string;
  229. procedure ppuwrite(ppufile:tcompilerppufile);override;
  230. {$ifdef GDB}
  231. procedure concatstabto(asmlist : taasmoutput);override;
  232. {$endif GDB}
  233. end;
  234. ttypedconstsym = class(tstoredsym)
  235. typedconsttype : ttype;
  236. is_writable : boolean;
  237. constructor create(const n : string;p : tdef;writable : boolean);
  238. constructor createtype(const n : string;const tt : ttype;writable : boolean);
  239. constructor ppuload(ppufile:tcompilerppufile);
  240. destructor destroy;override;
  241. procedure generate_mangledname;override;
  242. procedure ppuwrite(ppufile:tcompilerppufile);override;
  243. procedure deref;override;
  244. function getsize:longint;
  245. {$ifdef GDB}
  246. function stabstring : pchar;override;
  247. {$endif GDB}
  248. end;
  249. tconstvalue = record
  250. case integer of
  251. 0: (valueord : tconstexprint);
  252. 1: (valueordptr : tconstptruint);
  253. 2: (valueptr : pointer; len : longint);
  254. end;
  255. tconstsym = class(tstoredsym)
  256. consttype : ttype;
  257. consttyp : tconsttyp;
  258. value : tconstvalue;
  259. resstrindex : longint; { needed for resource strings }
  260. constructor create_ord(const n : string;t : tconsttyp;v : tconstexprint);
  261. constructor create_ord_typed(const n : string;t : tconsttyp;v : tconstexprint;const tt:ttype);
  262. constructor create_ordptr_typed(const n : string;t : tconsttyp;v : tconstptruint;const tt:ttype);
  263. constructor create_ptr(const n : string;t : tconsttyp;v : pointer);
  264. constructor create_ptr_typed(const n : string;t : tconsttyp;v : pointer;const tt:ttype);
  265. constructor create_string(const n : string;t : tconsttyp;str:pchar;l:longint);
  266. constructor ppuload(ppufile:tcompilerppufile);
  267. destructor destroy;override;
  268. function mangledname : string;
  269. procedure deref;override;
  270. procedure ppuwrite(ppufile:tcompilerppufile);override;
  271. {$ifdef GDB}
  272. function stabstring : pchar;override;
  273. procedure concatstabto(asmlist : taasmoutput);override;
  274. {$endif GDB}
  275. end;
  276. tenumsym = class(tstoredsym)
  277. value : longint;
  278. definition : tenumdef;
  279. nextenum : tenumsym;
  280. constructor create(const n : string;def : tenumdef;v : longint);
  281. constructor ppuload(ppufile:tcompilerppufile);
  282. procedure ppuwrite(ppufile:tcompilerppufile);override;
  283. procedure deref;override;
  284. procedure order;
  285. {$ifdef GDB}
  286. procedure concatstabto(asmlist : taasmoutput);override;
  287. {$endif GDB}
  288. end;
  289. tsyssym = class(tstoredsym)
  290. number : longint;
  291. constructor create(const n : string;l : longint);
  292. constructor ppuload(ppufile:tcompilerppufile);
  293. destructor destroy;override;
  294. procedure ppuwrite(ppufile:tcompilerppufile);override;
  295. {$ifdef GDB}
  296. procedure concatstabto(asmlist : taasmoutput);override;
  297. {$endif GDB}
  298. end;
  299. { compiler generated symbol to point to rtti and init/finalize tables }
  300. trttisym = class(tstoredsym)
  301. lab : tasmsymbol;
  302. rttityp : trttitype;
  303. constructor create(const n:string;rt:trttitype);
  304. constructor ppuload(ppufile:tcompilerppufile);
  305. procedure ppuwrite(ppufile:tcompilerppufile);override;
  306. function mangledname:string;
  307. function get_label:tasmsymbol;
  308. end;
  309. { register variables }
  310. pregvarinfo = ^tregvarinfo;
  311. tregvarinfo = record
  312. regvars : array[1..maxvarregs] of tvarsym;
  313. regvars_para : array[1..maxvarregs] of boolean;
  314. regvars_refs : array[1..maxvarregs] of longint;
  315. fpuregvars : array[1..maxfpuvarregs] of tvarsym;
  316. fpuregvars_para : array[1..maxfpuvarregs] of boolean;
  317. fpuregvars_refs : array[1..maxfpuvarregs] of longint;
  318. end;
  319. var
  320. current_procdef : tprocdef;
  321. aktcallprocdef : tabstractprocdef; { pointer to the definition of the
  322. currently called procedure,
  323. only set/unset in ncal }
  324. generrorsym : tsym;
  325. const
  326. current_object_option : tsymoptions = [sp_public];
  327. { rtti and init/final }
  328. procedure generate_rtti(p:tsym);
  329. procedure generate_inittable(p:tsym);
  330. implementation
  331. uses
  332. {$ifdef Delphi}
  333. sysutils,
  334. {$else Delphi}
  335. strings,
  336. {$endif Delphi}
  337. { global }
  338. verbose,
  339. { target }
  340. systems,
  341. { symtable }
  342. defutil,defcmp,symtable,
  343. {$ifdef GDB}
  344. gdb,
  345. {$endif GDB}
  346. { tree }
  347. node,
  348. { aasm }
  349. aasmcpu,
  350. { module }
  351. fmodule,
  352. { codegen }
  353. tgobj,paramgr,cgbase,cresstr
  354. ;
  355. {****************************************************************************
  356. Helpers
  357. ****************************************************************************}
  358. {****************************************************************************
  359. TSYM (base for all symtypes)
  360. ****************************************************************************}
  361. constructor tstoredsym.create(const n : string);
  362. begin
  363. inherited create(n);
  364. symoptions:=current_object_option;
  365. {$ifdef GDB}
  366. isstabwritten := false;
  367. {$endif GDB}
  368. fileinfo:=akttokenpos;
  369. defref:=nil;
  370. refs:=0;
  371. lastwritten:=nil;
  372. refcount:=0;
  373. if (cs_browser in aktmoduleswitches) and make_ref then
  374. begin
  375. defref:=tref.create(defref,@akttokenpos);
  376. inc(refcount);
  377. end;
  378. lastref:=defref;
  379. _mangledname:=nil;
  380. end;
  381. constructor tstoredsym.loadsym(ppufile:tcompilerppufile);
  382. var
  383. s : string;
  384. nr : word;
  385. begin
  386. nr:=ppufile.getword;
  387. s:=ppufile.getstring;
  388. inherited create(s);
  389. { force the correct indexnr. must be after create! }
  390. indexnr:=nr;
  391. ppufile.getposinfo(fileinfo);
  392. ppufile.getsmallset(symoptions);
  393. lastref:=nil;
  394. defref:=nil;
  395. refs:=0;
  396. lastwritten:=nil;
  397. refcount:=0;
  398. _mangledname:=nil;
  399. {$ifdef GDB}
  400. isstabwritten := false;
  401. {$endif GDB}
  402. end;
  403. procedure tstoredsym.deref;
  404. begin
  405. end;
  406. procedure tstoredsym.load_references(ppufile:tcompilerppufile;locals:boolean);
  407. var
  408. pos : tfileposinfo;
  409. move_last : boolean;
  410. begin
  411. move_last:=lastwritten=lastref;
  412. while (not ppufile.endofentry) do
  413. begin
  414. ppufile.getposinfo(pos);
  415. inc(refcount);
  416. lastref:=tref.create(lastref,@pos);
  417. lastref.is_written:=true;
  418. if refcount=1 then
  419. defref:=lastref;
  420. end;
  421. if move_last then
  422. lastwritten:=lastref;
  423. end;
  424. { big problem here :
  425. wrong refs were written because of
  426. interface parsing of other units PM
  427. moduleindex must be checked !! }
  428. function tstoredsym.write_references(ppufile:tcompilerppufile;locals:boolean):boolean;
  429. var
  430. ref : tref;
  431. symref_written,move_last : boolean;
  432. begin
  433. write_references:=false;
  434. if lastwritten=lastref then
  435. exit;
  436. { should we update lastref }
  437. move_last:=true;
  438. symref_written:=false;
  439. { write symbol refs }
  440. if assigned(lastwritten) then
  441. ref:=lastwritten
  442. else
  443. ref:=defref;
  444. while assigned(ref) do
  445. begin
  446. if ref.moduleindex=current_module.unit_index then
  447. begin
  448. { write address to this symbol }
  449. if not symref_written then
  450. begin
  451. ppufile.putderef(self);
  452. symref_written:=true;
  453. end;
  454. ppufile.putposinfo(ref.posinfo);
  455. ref.is_written:=true;
  456. if move_last then
  457. lastwritten:=ref;
  458. end
  459. else if not ref.is_written then
  460. move_last:=false
  461. else if move_last then
  462. lastwritten:=ref;
  463. ref:=ref.nextref;
  464. end;
  465. if symref_written then
  466. ppufile.writeentry(ibsymref);
  467. write_references:=symref_written;
  468. end;
  469. destructor tstoredsym.destroy;
  470. begin
  471. if assigned(_mangledname) then
  472. begin
  473. {$ifdef MEMDEBUG}
  474. memmanglednames.start;
  475. {$endif MEMDEBUG}
  476. stringdispose(_mangledname);
  477. {$ifdef MEMDEBUG}
  478. memmanglednames.stop;
  479. {$endif MEMDEBUG}
  480. end;
  481. if assigned(defref) then
  482. begin
  483. {$ifdef MEMDEBUG}
  484. membrowser.start;
  485. {$endif MEMDEBUG}
  486. defref.freechain;
  487. defref.free;
  488. {$ifdef MEMDEBUG}
  489. membrowser.stop;
  490. {$endif MEMDEBUG}
  491. end;
  492. inherited destroy;
  493. end;
  494. procedure tstoredsym.writesym(ppufile:tcompilerppufile);
  495. begin
  496. ppufile.putword(indexnr);
  497. ppufile.putstring(_realname^);
  498. ppufile.putposinfo(fileinfo);
  499. ppufile.putsmallset(symoptions);
  500. end;
  501. {$ifdef GDB}
  502. function tstoredsym.stabstring : pchar;
  503. begin
  504. stabstring:=strpnew('"'+name+'",'+tostr(N_LSYM)+',0,'+
  505. tostr(fileinfo.line)+',0');
  506. end;
  507. procedure tstoredsym.concatstabto(asmlist : taasmoutput);
  508. var
  509. stab_str : pchar;
  510. begin
  511. if not isstabwritten then
  512. begin
  513. stab_str := stabstring;
  514. { count_dbx(stab_str); moved to GDB.PAS }
  515. asmList.concat(Tai_stabs.Create(stab_str));
  516. isstabwritten:=true;
  517. end;
  518. end;
  519. {$endif GDB}
  520. function tstoredsym.is_visible_for_proc(currprocdef:tprocdef):boolean;
  521. begin
  522. is_visible_for_proc:=false;
  523. { private symbols are allowed when we are in the same
  524. module as they are defined }
  525. if (sp_private in symoptions) and
  526. assigned(owner.defowner) and
  527. (owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  528. (owner.defowner.owner.unitid<>0) then
  529. exit;
  530. { protected symbols are vissible in the module that defines them and
  531. also visible to related objects }
  532. if (sp_protected in symoptions) and
  533. (
  534. (
  535. (owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  536. (owner.defowner.owner.unitid<>0)
  537. ) and
  538. not(
  539. assigned(currprocdef) and
  540. assigned(currprocdef._class) and
  541. currprocdef._class.is_related(tobjectdef(owner.defowner))
  542. )
  543. ) then
  544. exit;
  545. is_visible_for_proc:=true;
  546. end;
  547. function tstoredsym.is_visible_for_object(currobjdef:tobjectdef):boolean;
  548. begin
  549. is_visible_for_object:=false;
  550. { private symbols are allowed when we are in the same
  551. module as they are defined }
  552. if (sp_private in symoptions) and
  553. (owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  554. (owner.defowner.owner.unitid<>0) then
  555. exit;
  556. { protected symbols are vissible in the module that defines them and
  557. also visible to related objects }
  558. if (sp_protected in symoptions) and
  559. (
  560. (
  561. (owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  562. (owner.defowner.owner.unitid<>0)
  563. ) and
  564. not(
  565. assigned(currobjdef) and
  566. currobjdef.is_related(tobjectdef(owner.defowner))
  567. )
  568. ) then
  569. exit;
  570. is_visible_for_object:=true;
  571. end;
  572. function tstoredsym.mangledname : string;
  573. begin
  574. if not assigned(_mangledname) then
  575. begin
  576. generate_mangledname;
  577. if not assigned(_mangledname) then
  578. internalerror(200204171);
  579. end;
  580. mangledname:=_mangledname^
  581. end;
  582. {****************************************************************************
  583. TLABELSYM
  584. ****************************************************************************}
  585. constructor tlabelsym.create(const n : string; l : tasmlabel);
  586. begin
  587. inherited create(n);
  588. typ:=labelsym;
  589. lab:=l;
  590. used:=false;
  591. defined:=false;
  592. code:=nil;
  593. end;
  594. constructor tlabelsym.ppuload(ppufile:tcompilerppufile);
  595. begin
  596. inherited loadsym(ppufile);
  597. typ:=labelsym;
  598. { this is all dummy
  599. it is only used for local browsing }
  600. lab:=nil;
  601. code:=nil;
  602. used:=false;
  603. defined:=true;
  604. end;
  605. destructor tlabelsym.destroy;
  606. begin
  607. inherited destroy;
  608. end;
  609. procedure tlabelsym.generate_mangledname;
  610. begin
  611. _mangledname:=stringdup(lab.name);
  612. end;
  613. procedure tlabelsym.ppuwrite(ppufile:tcompilerppufile);
  614. begin
  615. if owner.symtabletype=globalsymtable then
  616. Message(sym_e_ill_label_decl)
  617. else
  618. begin
  619. inherited writesym(ppufile);
  620. ppufile.writeentry(iblabelsym);
  621. end;
  622. end;
  623. {****************************************************************************
  624. TUNITSYM
  625. ****************************************************************************}
  626. constructor tunitsym.create(const n : string;ref : tsymtable);
  627. var
  628. old_make_ref : boolean;
  629. begin
  630. old_make_ref:=make_ref;
  631. make_ref:=false;
  632. inherited create(n);
  633. make_ref:=old_make_ref;
  634. typ:=unitsym;
  635. unitsymtable:=ref;
  636. if assigned(ref) and
  637. (ref.symtabletype=globalsymtable) then
  638. begin
  639. prevsym:=tglobalsymtable(ref).unitsym;
  640. tglobalsymtable(ref).unitsym:=self;
  641. end;
  642. end;
  643. constructor tunitsym.ppuload(ppufile:tcompilerppufile);
  644. begin
  645. inherited loadsym(ppufile);
  646. typ:=unitsym;
  647. unitsymtable:=nil;
  648. prevsym:=nil;
  649. refs:=0;
  650. end;
  651. { we need to remove it from the prevsym chain ! }
  652. procedure tunitsym.restoreunitsym;
  653. var pus,ppus : tunitsym;
  654. begin
  655. if assigned(unitsymtable) and
  656. (unitsymtable.symtabletype=globalsymtable) then
  657. begin
  658. ppus:=nil;
  659. pus:=tglobalsymtable(unitsymtable).unitsym;
  660. if pus=self then
  661. tglobalsymtable(unitsymtable).unitsym:=prevsym
  662. else while assigned(pus) do
  663. begin
  664. if pus=self then
  665. begin
  666. ppus.prevsym:=prevsym;
  667. break;
  668. end
  669. else
  670. begin
  671. ppus:=pus;
  672. pus:=ppus.prevsym;
  673. end;
  674. end;
  675. end;
  676. unitsymtable:=nil;
  677. prevsym:=nil;
  678. end;
  679. destructor tunitsym.destroy;
  680. begin
  681. restoreunitsym;
  682. inherited destroy;
  683. end;
  684. procedure tunitsym.ppuwrite(ppufile:tcompilerppufile);
  685. begin
  686. inherited writesym(ppufile);
  687. ppufile.writeentry(ibunitsym);
  688. end;
  689. {$ifdef GDB}
  690. procedure tunitsym.concatstabto(asmlist : taasmoutput);
  691. begin
  692. {Nothing to write to stabs !}
  693. end;
  694. {$endif GDB}
  695. {****************************************************************************
  696. TPROCSYM
  697. ****************************************************************************}
  698. constructor tprocsym.create(const n : string);
  699. begin
  700. inherited create(n);
  701. typ:=procsym;
  702. pdlistfirst:=nil;
  703. pdlistlast:=nil;
  704. owner:=nil;
  705. {$ifdef GDB}
  706. is_global:=false;
  707. {$endif GDB}
  708. overloadchecked:=false;
  709. overloadcount:=0;
  710. procdef_count:=0;
  711. end;
  712. constructor tprocsym.ppuload(ppufile:tcompilerppufile);
  713. var
  714. pd : tprocdef;
  715. begin
  716. inherited loadsym(ppufile);
  717. typ:=procsym;
  718. pdlistfirst:=nil;
  719. pdlistlast:=nil;
  720. procdef_count:=0;
  721. repeat
  722. pd:=tprocdef(ppufile.getderef);
  723. if pd=nil then
  724. break;
  725. addprocdef(pd);
  726. until false;
  727. {$ifdef GDB}
  728. is_global:=false;
  729. {$endif GDB}
  730. overloadchecked:=false;
  731. overloadcount:=$ffff; { invalid, not used anymore }
  732. end;
  733. destructor tprocsym.destroy;
  734. var
  735. hp,p : pprocdeflist;
  736. begin
  737. p:=pdlistfirst;
  738. while assigned(p) do
  739. begin
  740. hp:=p^.next;
  741. dispose(p);
  742. p:=hp;
  743. end;
  744. inherited destroy;
  745. end;
  746. procedure tprocsym.write_parameter_lists(skipdef:tprocdef);
  747. var
  748. p : pprocdeflist;
  749. begin
  750. p:=pdlistfirst;
  751. while assigned(p) do
  752. begin
  753. if p^.def<>skipdef then
  754. MessagePos1(p^.def.fileinfo,sym_h_param_list,p^.def.fullprocname(false));
  755. p:=p^.next;
  756. end;
  757. end;
  758. procedure tprocsym.check_forward;
  759. var
  760. p : pprocdeflist;
  761. begin
  762. p:=pdlistfirst;
  763. while assigned(p) do
  764. begin
  765. if (p^.def.procsym=self) and
  766. (p^.def.forwarddef) then
  767. begin
  768. MessagePos1(p^.def.fileinfo,sym_e_forward_not_resolved,p^.def.fullprocname(false));
  769. { Turn futher error messages off }
  770. p^.def.forwarddef:=false;
  771. end;
  772. p:=p^.next;
  773. end;
  774. end;
  775. procedure tprocsym.deref;
  776. var
  777. p : pprocdeflist;
  778. begin
  779. p:=pdlistfirst;
  780. while assigned(p) do
  781. begin
  782. resolvedef(pointer(p^.def));
  783. p:=p^.next;
  784. end;
  785. end;
  786. procedure tprocsym.addprocdef(p:tprocdef);
  787. var
  788. pd : pprocdeflist;
  789. begin
  790. new(pd);
  791. pd^.def:=p;
  792. pd^.next:=nil;
  793. { Add at end of list to keep always
  794. a correct order, also after loading from ppu }
  795. if assigned(pdlistlast) then
  796. begin
  797. pdlistlast^.next:=pd;
  798. pdlistlast:=pd;
  799. end
  800. else
  801. begin
  802. pdlistfirst:=pd;
  803. pdlistlast:=pd;
  804. end;
  805. inc(procdef_count);
  806. end;
  807. function Tprocsym.getprocdef(nr:cardinal):Tprocdef;
  808. var
  809. i : cardinal;
  810. pd : pprocdeflist;
  811. begin
  812. pd:=pdlistfirst;
  813. for i:=2 to nr do
  814. begin
  815. if not assigned(pd) then
  816. internalerror(200209051);
  817. pd:=pd^.next;
  818. end;
  819. getprocdef:=pd^.def;
  820. end;
  821. procedure Tprocsym.add_para_match_to(Aprocsym:Tprocsym);
  822. var
  823. pd:pprocdeflist;
  824. begin
  825. pd:=pdlistfirst;
  826. while assigned(pd) do
  827. begin
  828. if Aprocsym.search_procdef_bypara(pd^.def.para,nil,false,true)=nil then
  829. Aprocsym.addprocdef(pd^.def);
  830. pd:=pd^.next;
  831. end;
  832. end;
  833. procedure Tprocsym.concat_procdefs_to(s:Tprocsym);
  834. var
  835. pd : pprocdeflist;
  836. begin
  837. pd:=pdlistfirst;
  838. while assigned(pd) do
  839. begin
  840. s.addprocdef(pd^.def);
  841. pd:=pd^.next;
  842. end;
  843. end;
  844. function Tprocsym.first_procdef:Tprocdef;
  845. begin
  846. if assigned(pdlistfirst) then
  847. first_procdef:=pdlistfirst^.def
  848. else
  849. first_procdef:=nil;
  850. end;
  851. function Tprocsym.last_procdef:Tprocdef;
  852. begin
  853. if assigned(pdlistlast) then
  854. last_procdef:=pdlistlast^.def
  855. else
  856. last_procdef:=nil;
  857. end;
  858. procedure Tprocsym.foreach_procdef_static(proc2call:Tprocdefcallback;arg:pointer);
  859. var
  860. p : pprocdeflist;
  861. begin
  862. p:=pdlistfirst;
  863. while assigned(p) do
  864. begin
  865. proc2call(p^.def,arg);
  866. p:=p^.next;
  867. end;
  868. end;
  869. function Tprocsym.search_procdef_nopara_boolret:Tprocdef;
  870. var
  871. p : pprocdeflist;
  872. begin
  873. search_procdef_nopara_boolret:=nil;
  874. p:=pdlistfirst;
  875. while p<>nil do
  876. begin
  877. if (p^.def.maxparacount=0) and
  878. is_boolean(p^.def.rettype.def) then
  879. begin
  880. search_procdef_nopara_boolret:=p^.def;
  881. break;
  882. end;
  883. p:=p^.next;
  884. end;
  885. end;
  886. function Tprocsym.search_procdef_bytype(pt:Tproctypeoption):Tprocdef;
  887. var
  888. p : pprocdeflist;
  889. begin
  890. search_procdef_bytype:=nil;
  891. p:=pdlistfirst;
  892. while p<>nil do
  893. begin
  894. if p^.def.proctypeoption=pt then
  895. begin
  896. search_procdef_bytype:=p^.def;
  897. break;
  898. end;
  899. p:=p^.next;
  900. end;
  901. end;
  902. function Tprocsym.search_procdef_bypara(params:Tlinkedlist;
  903. retdef:tdef;
  904. allowconvert,
  905. allowdefault:boolean):Tprocdef;
  906. var
  907. pd : pprocdeflist;
  908. eq : tequaltype;
  909. begin
  910. search_procdef_bypara:=nil;
  911. pd:=pdlistfirst;
  912. while assigned(pd) do
  913. begin
  914. if assigned(retdef) then
  915. eq:=compare_defs(retdef,pd^.def.rettype.def,nothingn)
  916. else
  917. eq:=te_equal;
  918. if (eq>=te_equal) or
  919. (allowconvert and (eq>te_incompatible)) then
  920. begin
  921. eq:=compare_paras(pd^.def.para,params,cp_value_equal_const,allowdefault);
  922. if (eq>=te_equal) or
  923. (allowconvert and (eq>te_incompatible)) then
  924. begin
  925. search_procdef_bypara:=pd^.def;
  926. break;
  927. end;
  928. end;
  929. pd:=pd^.next;
  930. end;
  931. end;
  932. function Tprocsym.search_procdef_byprocvardef(d:Tprocvardef):Tprocdef;
  933. var
  934. pd : pprocdeflist;
  935. eq,besteq : tequaltype;
  936. bestpd : tprocdef;
  937. begin
  938. { This function will return the pprocdef of pprocsym that
  939. is the best match for procvardef. When there are multiple
  940. matches it returns nil.}
  941. search_procdef_byprocvardef:=nil;
  942. bestpd:=nil;
  943. besteq:=te_incompatible;
  944. pd:=pdlistfirst;
  945. while assigned(pd) do
  946. begin
  947. eq:=proc_to_procvar_equal(pd^.def,d,false);
  948. if eq>=te_equal then
  949. begin
  950. { multiple procvars with the same equal level }
  951. if assigned(bestpd) and
  952. (besteq=eq) then
  953. exit;
  954. if eq>besteq then
  955. begin
  956. besteq:=eq;
  957. bestpd:=pd^.def;
  958. end;
  959. end;
  960. pd:=pd^.next;
  961. end;
  962. search_procdef_byprocvardef:=bestpd;
  963. end;
  964. function Tprocsym.search_procdef_unary_operator(firstpara:Tdef):Tprocdef;
  965. var
  966. pd : pprocdeflist;
  967. currpara : tparaitem;
  968. begin
  969. search_procdef_unary_operator:=nil;
  970. pd:=pdlistfirst;
  971. while assigned(pd) do
  972. begin
  973. currpara:=tparaitem(pd^.def.para.first);
  974. { ignore vs_hidden parameters }
  975. while assigned(currpara) and (currpara.is_hidden) do
  976. currpara:=tparaitem(currpara.next);
  977. if assigned(currpara) then
  978. begin
  979. if (currpara.next=nil) and
  980. equal_defs(currpara.paratype.def,firstpara) then
  981. begin
  982. search_procdef_unary_operator:=pd^.def;
  983. break;
  984. end;
  985. end;
  986. pd:=pd^.next;
  987. end;
  988. end;
  989. function Tprocsym.search_procdef_assignment_operator(fromdef,todef:tdef):Tprocdef;
  990. var
  991. convtyp : tconverttype;
  992. pd : pprocdeflist;
  993. bestpd : tprocdef;
  994. eq,
  995. besteq : tequaltype;
  996. hpd : tprocdef;
  997. currpara : tparaitem;
  998. begin
  999. search_procdef_assignment_operator:=nil;
  1000. bestpd:=nil;
  1001. besteq:=te_incompatible;
  1002. pd:=pdlistfirst;
  1003. while assigned(pd) do
  1004. begin
  1005. if equal_defs(todef,pd^.def.rettype.def) then
  1006. begin
  1007. currpara:=Tparaitem(pd^.def.para.first);
  1008. { ignore vs_hidden parameters }
  1009. while assigned(currpara) and (currpara.is_hidden) do
  1010. currpara:=tparaitem(currpara.next);
  1011. if assigned(currpara) then
  1012. begin
  1013. eq:=compare_defs_ext(fromdef,currpara.paratype.def,
  1014. nothingn,false,false,convtyp,hpd);
  1015. if eq=te_exact then
  1016. begin
  1017. search_procdef_assignment_operator:=pd^.def;
  1018. exit;
  1019. end;
  1020. if eq>besteq then
  1021. begin
  1022. bestpd:=pd^.def;
  1023. besteq:=eq;
  1024. end;
  1025. end;
  1026. end;
  1027. pd:=pd^.next;
  1028. end;
  1029. search_procdef_assignment_operator:=bestpd;
  1030. end;
  1031. function Tprocsym.search_procdef_binary_operator(def1,def2:tdef):Tprocdef;
  1032. var
  1033. convtyp : tconverttype;
  1034. pd : pprocdeflist;
  1035. bestpd : tprocdef;
  1036. eq1,eq2 : tequaltype;
  1037. eqlev,
  1038. bestlev : byte;
  1039. hpd : tprocdef;
  1040. nextpara,
  1041. currpara : tparaitem;
  1042. begin
  1043. search_procdef_binary_operator:=nil;
  1044. bestpd:=nil;
  1045. bestlev:=0;
  1046. pd:=pdlistfirst;
  1047. while assigned(pd) do
  1048. begin
  1049. currpara:=Tparaitem(pd^.def.para.first);
  1050. { ignore vs_hidden parameters }
  1051. while assigned(currpara) and (currpara.is_hidden) do
  1052. currpara:=tparaitem(currpara.next);
  1053. if assigned(currpara) then
  1054. begin
  1055. { Compare def1 with the first para }
  1056. eq1:=compare_defs_ext(def1,currpara.paratype.def,
  1057. nothingn,false,false,convtyp,hpd);
  1058. if eq1<>te_incompatible then
  1059. begin
  1060. { Ignore vs_hidden parameters }
  1061. repeat
  1062. currpara:=tparaitem(currpara.next);
  1063. until (not assigned(currpara)) or (not currpara.is_hidden);
  1064. if assigned(currpara) then
  1065. begin
  1066. { Ignore vs_hidden parameters }
  1067. nextpara:=currpara;
  1068. repeat
  1069. nextpara:=tparaitem(nextpara.next);
  1070. until (not assigned(nextpara)) or (not nextpara.is_hidden);
  1071. { There should be no other parameters left }
  1072. if not assigned(nextpara) then
  1073. begin
  1074. { Compare def2 with the last para }
  1075. eq2:=compare_defs_ext(def2,currpara.paratype.def,
  1076. nothingn,false,false,convtyp,hpd);
  1077. if (eq2<>te_incompatible) then
  1078. begin
  1079. { check level }
  1080. eqlev:=byte(eq1)+byte(eq2);
  1081. if eqlev=(byte(te_exact)+byte(te_exact)) then
  1082. begin
  1083. search_procdef_binary_operator:=pd^.def;
  1084. exit;
  1085. end;
  1086. if eqlev>bestlev then
  1087. begin
  1088. bestpd:=pd^.def;
  1089. bestlev:=eqlev;
  1090. end;
  1091. end;
  1092. end;
  1093. end;
  1094. end;
  1095. end;
  1096. pd:=pd^.next;
  1097. end;
  1098. search_procdef_binary_operator:=bestpd;
  1099. end;
  1100. procedure tprocsym.ppuwrite(ppufile:tcompilerppufile);
  1101. var
  1102. p : pprocdeflist;
  1103. begin
  1104. inherited writesym(ppufile);
  1105. p:=pdlistfirst;
  1106. while assigned(p) do
  1107. begin
  1108. { only write the proc definitions that belong
  1109. to this procsym }
  1110. if (p^.def.procsym=self) then
  1111. ppufile.putderef(p^.def);
  1112. p:=p^.next;
  1113. end;
  1114. ppufile.putderef(nil);
  1115. ppufile.writeentry(ibprocsym);
  1116. end;
  1117. function tprocsym.write_references(ppufile:tcompilerppufile;locals:boolean) : boolean;
  1118. var
  1119. p : pprocdeflist;
  1120. begin
  1121. write_references:=false;
  1122. if not inherited write_references(ppufile,locals) then
  1123. exit;
  1124. write_references:=true;
  1125. p:=pdlistfirst;
  1126. while assigned(p) do
  1127. begin
  1128. if (p^.def.procsym=self) then
  1129. p^.def.write_references(ppufile,locals);
  1130. p:=p^.next;
  1131. end;
  1132. end;
  1133. procedure tprocsym.unchain_overload;
  1134. var
  1135. p,hp : pprocdeflist;
  1136. begin
  1137. { remove all overloaded procdefs from the
  1138. procdeflist that are not in the current symtable }
  1139. p:=pdlistfirst;
  1140. { reset new lists }
  1141. pdlistfirst:=nil;
  1142. pdlistlast:=nil;
  1143. while assigned(p) do
  1144. begin
  1145. hp:=p^.next;
  1146. if (p^.def.procsym=self) then
  1147. begin
  1148. { keep, add to list }
  1149. if assigned(pdlistlast) then
  1150. begin
  1151. pdlistlast^.next:=p;
  1152. pdlistlast:=p;
  1153. end
  1154. else
  1155. begin
  1156. pdlistfirst:=p;
  1157. pdlistlast:=p;
  1158. end;
  1159. p^.next:=nil;
  1160. end
  1161. else
  1162. begin
  1163. { remove }
  1164. dispose(p);
  1165. dec(procdef_count);
  1166. end;
  1167. p:=hp;
  1168. end;
  1169. end;
  1170. {$ifdef GDB}
  1171. function tprocsym.stabstring : pchar;
  1172. begin
  1173. internalerror(200111171);
  1174. stabstring:=nil;
  1175. end;
  1176. procedure tprocsym.concatstabto(asmlist : taasmoutput);
  1177. begin
  1178. internalerror(200111172);
  1179. end;
  1180. {$endif GDB}
  1181. {****************************************************************************
  1182. TERRORSYM
  1183. ****************************************************************************}
  1184. constructor terrorsym.create;
  1185. begin
  1186. inherited create('');
  1187. typ:=errorsym;
  1188. end;
  1189. {****************************************************************************
  1190. TPROPERTYSYM
  1191. ****************************************************************************}
  1192. constructor tpropertysym.create(const n : string);
  1193. begin
  1194. inherited create(n);
  1195. typ:=propertysym;
  1196. propoptions:=[];
  1197. index:=0;
  1198. default:=0;
  1199. proptype.reset;
  1200. indextype.reset;
  1201. readaccess:=tsymlist.create;
  1202. writeaccess:=tsymlist.create;
  1203. storedaccess:=tsymlist.create;
  1204. end;
  1205. constructor tpropertysym.ppuload(ppufile:tcompilerppufile);
  1206. begin
  1207. inherited loadsym(ppufile);
  1208. typ:=propertysym;
  1209. ppufile.getsmallset(propoptions);
  1210. if (ppo_is_override in propoptions) then
  1211. begin
  1212. propoverriden:=tpropertysym(ppufile.getderef);
  1213. { we need to have these objects initialized }
  1214. readaccess:=tsymlist.create;
  1215. writeaccess:=tsymlist.create;
  1216. storedaccess:=tsymlist.create;
  1217. end
  1218. else
  1219. begin
  1220. ppufile.gettype(proptype);
  1221. index:=ppufile.getlongint;
  1222. default:=ppufile.getlongint;
  1223. ppufile.gettype(indextype);
  1224. readaccess:=ppufile.getsymlist;
  1225. writeaccess:=ppufile.getsymlist;
  1226. storedaccess:=ppufile.getsymlist;
  1227. end;
  1228. end;
  1229. destructor tpropertysym.destroy;
  1230. begin
  1231. readaccess.free;
  1232. writeaccess.free;
  1233. storedaccess.free;
  1234. inherited destroy;
  1235. end;
  1236. function tpropertysym.gettypedef:tdef;
  1237. begin
  1238. gettypedef:=proptype.def;
  1239. end;
  1240. procedure tpropertysym.deref;
  1241. begin
  1242. if (ppo_is_override in propoptions) then
  1243. begin
  1244. resolvesym(pointer(propoverriden));
  1245. dooverride(propoverriden);
  1246. end
  1247. else
  1248. begin
  1249. proptype.resolve;
  1250. indextype.resolve;
  1251. readaccess.resolve;
  1252. writeaccess.resolve;
  1253. storedaccess.resolve;
  1254. end;
  1255. end;
  1256. function tpropertysym.getsize : longint;
  1257. begin
  1258. getsize:=0;
  1259. end;
  1260. procedure tpropertysym.ppuwrite(ppufile:tcompilerppufile);
  1261. begin
  1262. inherited writesym(ppufile);
  1263. ppufile.putsmallset(propoptions);
  1264. if (ppo_is_override in propoptions) then
  1265. ppufile.putderef(propoverriden)
  1266. else
  1267. begin
  1268. ppufile.puttype(proptype);
  1269. ppufile.putlongint(index);
  1270. ppufile.putlongint(default);
  1271. ppufile.puttype(indextype);
  1272. ppufile.putsymlist(readaccess);
  1273. ppufile.putsymlist(writeaccess);
  1274. ppufile.putsymlist(storedaccess);
  1275. end;
  1276. ppufile.writeentry(ibpropertysym);
  1277. end;
  1278. procedure tpropertysym.dooverride(overriden:tpropertysym);
  1279. begin
  1280. propoverriden:=overriden;
  1281. proptype:=overriden.proptype;
  1282. propoptions:=overriden.propoptions+[ppo_is_override];
  1283. index:=overriden.index;
  1284. default:=overriden.default;
  1285. indextype:=overriden.indextype;
  1286. readaccess.free;
  1287. readaccess:=overriden.readaccess.getcopy;
  1288. writeaccess.free;
  1289. writeaccess:=overriden.writeaccess.getcopy;
  1290. storedaccess.free;
  1291. storedaccess:=overriden.storedaccess.getcopy;
  1292. end;
  1293. {$ifdef GDB}
  1294. function tpropertysym.stabstring : pchar;
  1295. begin
  1296. { !!!! don't know how to handle }
  1297. stabstring:=strpnew('');
  1298. end;
  1299. procedure tpropertysym.concatstabto(asmlist : taasmoutput);
  1300. begin
  1301. { !!!! don't know how to handle }
  1302. end;
  1303. {$endif GDB}
  1304. {****************************************************************************
  1305. TABSOLUTESYM
  1306. ****************************************************************************}
  1307. constructor tabsolutesym.create(const n : string;const tt : ttype);
  1308. begin
  1309. inherited create(n,vs_value,tt);
  1310. typ:=absolutesym;
  1311. end;
  1312. constructor tabsolutesym.create_ref(const n : string;const tt : ttype;sym:tstoredsym);
  1313. begin
  1314. inherited create(n,vs_value,tt);
  1315. typ:=absolutesym;
  1316. ref:=sym;
  1317. end;
  1318. constructor tabsolutesym.ppuload(ppufile:tcompilerppufile);
  1319. begin
  1320. { Note: This needs to load everything of tvarsym.write }
  1321. inherited ppuload(ppufile);
  1322. { load absolute }
  1323. typ:=absolutesym;
  1324. ref:=nil;
  1325. address:=0;
  1326. asmname:=nil;
  1327. abstyp:=absolutetyp(ppufile.getbyte);
  1328. absseg:=false;
  1329. case abstyp of
  1330. tovar :
  1331. asmname:=stringdup(ppufile.getstring);
  1332. toasm :
  1333. asmname:=stringdup(ppufile.getstring);
  1334. toaddr :
  1335. begin
  1336. address:=ppufile.getlongint;
  1337. absseg:=boolean(ppufile.getbyte);
  1338. end;
  1339. end;
  1340. end;
  1341. procedure tabsolutesym.ppuwrite(ppufile:tcompilerppufile);
  1342. var
  1343. hvo : tvaroptions;
  1344. begin
  1345. { Note: This needs to write everything of tvarsym.write }
  1346. inherited writesym(ppufile);
  1347. ppufile.putbyte(byte(varspez));
  1348. ppufile.putlongint(address);
  1349. { write only definition or definitionsym }
  1350. ppufile.puttype(vartype);
  1351. hvo:=varoptions-[vo_regable,vo_fpuregable];
  1352. ppufile.putsmallset(hvo);
  1353. ppufile.putbyte(byte(abstyp));
  1354. case abstyp of
  1355. tovar :
  1356. ppufile.putstring(ref.name);
  1357. toasm :
  1358. ppufile.putstring(asmname^);
  1359. toaddr :
  1360. begin
  1361. ppufile.putlongint(address);
  1362. ppufile.putbyte(byte(absseg));
  1363. end;
  1364. end;
  1365. ppufile.writeentry(ibabsolutesym);
  1366. end;
  1367. procedure tabsolutesym.deref;
  1368. var
  1369. srsym : tsym;
  1370. srsymtable : tsymtable;
  1371. begin
  1372. { inheritance of varsym.deref ! }
  1373. vartype.resolve;
  1374. { own absolute deref }
  1375. if (abstyp=tovar) and (asmname<>nil) then
  1376. begin
  1377. { search previous loaded symtables }
  1378. searchsym(asmname^,srsym,srsymtable);
  1379. if not assigned(srsym) then
  1380. srsym:=searchsymonlyin(owner,asmname^);
  1381. if not assigned(srsym) then
  1382. srsym:=generrorsym;
  1383. ref:=tstoredsym(srsym);
  1384. stringdispose(asmname);
  1385. end;
  1386. end;
  1387. function tabsolutesym.mangledname : string;
  1388. begin
  1389. case abstyp of
  1390. tovar :
  1391. begin
  1392. case ref.typ of
  1393. varsym :
  1394. mangledname:=tvarsym(ref).mangledname;
  1395. else
  1396. internalerror(200111011);
  1397. end;
  1398. end;
  1399. toasm :
  1400. mangledname:=asmname^;
  1401. toaddr :
  1402. mangledname:='$'+tostr(address);
  1403. else
  1404. internalerror(10002);
  1405. end;
  1406. end;
  1407. {$ifdef GDB}
  1408. procedure tabsolutesym.concatstabto(asmlist : taasmoutput);
  1409. begin
  1410. { I don't know how to handle this !! }
  1411. end;
  1412. {$endif GDB}
  1413. {****************************************************************************
  1414. TVARSYM
  1415. ****************************************************************************}
  1416. constructor tvarsym.create(const n : string;vsp:tvarspez;const tt : ttype);
  1417. begin
  1418. inherited create(n);
  1419. typ:=varsym;
  1420. vartype:=tt;
  1421. _mangledname:=nil;
  1422. varspez:=vsp;
  1423. address:=0;
  1424. localvarsym:=nil;
  1425. highvarsym:=nil;
  1426. defaultconstsym:=nil;
  1427. refs:=0;
  1428. varstate:=vs_used;
  1429. varoptions:=[];
  1430. end;
  1431. constructor tvarsym.create_dll(const n : string;vsp:tvarspez;const tt : ttype);
  1432. begin
  1433. tvarsym(self).create(n,vsp,tt);
  1434. include(varoptions,vo_is_dll_var);
  1435. end;
  1436. constructor tvarsym.create_C(const n,mangled : string;vsp:tvarspez;const tt : ttype);
  1437. begin
  1438. tvarsym(self).create(n,vsp,tt);
  1439. stringdispose(_mangledname);
  1440. _mangledname:=stringdup(mangled);
  1441. end;
  1442. constructor tvarsym.ppuload(ppufile:tcompilerppufile);
  1443. begin
  1444. inherited loadsym(ppufile);
  1445. typ:=varsym;
  1446. reg.enum:=R_NO;
  1447. refs := 0;
  1448. varstate:=vs_used;
  1449. varspez:=tvarspez(ppufile.getbyte);
  1450. address:=ppufile.getlongint;
  1451. localvarsym:=nil;
  1452. highvarsym:=nil;
  1453. defaultconstsym:=nil;
  1454. ppufile.gettype(_vartype);
  1455. ppufile.getsmallset(varoptions);
  1456. if (vo_is_C_var in varoptions) then
  1457. _mangledname:=stringdup(ppufile.getstring);
  1458. end;
  1459. destructor tvarsym.destroy;
  1460. begin
  1461. if assigned(notifications) then
  1462. notifications.destroy;
  1463. inherited destroy;
  1464. end;
  1465. procedure tvarsym.deref;
  1466. begin
  1467. vartype.resolve;
  1468. end;
  1469. procedure tvarsym.ppuwrite(ppufile:tcompilerppufile);
  1470. var
  1471. hvo : tvaroptions;
  1472. begin
  1473. inherited writesym(ppufile);
  1474. ppufile.putbyte(byte(varspez));
  1475. ppufile.putlongint(address);
  1476. ppufile.puttype(vartype);
  1477. { symbols which are load are never candidates for a register,
  1478. turn off the regable }
  1479. hvo:=varoptions-[vo_regable,vo_fpuregable];
  1480. ppufile.putsmallset(hvo);
  1481. if (vo_is_C_var in varoptions) then
  1482. ppufile.putstring(mangledname);
  1483. ppufile.writeentry(ibvarsym);
  1484. end;
  1485. procedure tvarsym.generate_mangledname;
  1486. begin
  1487. _mangledname:=stringdup(mangledname_prefix('U',owner)+name);
  1488. end;
  1489. procedure tvarsym.set_mangledname(const s:string);
  1490. begin
  1491. stringdispose(_mangledname);
  1492. _mangledname:=stringdup(s);
  1493. end;
  1494. function tvarsym.getsize : longint;
  1495. begin
  1496. if assigned(vartype.def) then
  1497. getsize:=vartype.def.size
  1498. else
  1499. getsize:=0;
  1500. end;
  1501. function tvarsym.getvaluesize : longint;
  1502. begin
  1503. if assigned(vartype.def) and
  1504. (varspez=vs_value) and
  1505. ((vartype.def.deftype<>arraydef) or
  1506. tarraydef(vartype.def).isDynamicArray or
  1507. (tarraydef(vartype.def).highrange>=tarraydef(vartype.def).lowrange)) then
  1508. getvaluesize:=vartype.def.size
  1509. else
  1510. getvaluesize:=0;
  1511. end;
  1512. function tvarsym.adjusted_address : longint;
  1513. begin
  1514. result:=address+owner.address_fixup;
  1515. end;
  1516. procedure Tvarsym.trigger_notifications(what:Tnotification_flag);
  1517. var n:Tnotification;
  1518. begin
  1519. if assigned(notifications) then
  1520. begin
  1521. n:=Tnotification(notifications.first);
  1522. while assigned(n) do
  1523. begin
  1524. if what in n.flags then
  1525. n.callback(what,self);
  1526. n:=Tnotification(n.next);
  1527. end;
  1528. end;
  1529. end;
  1530. function Tvarsym.register_notification(flags:Tnotification_flags;callback:
  1531. Tnotification_callback):cardinal;
  1532. var n:Tnotification;
  1533. begin
  1534. if not assigned(notifications) then
  1535. notifications:=Tlinkedlist.create;
  1536. n:=Tnotification.create(flags,callback);
  1537. register_notification:=n.id;
  1538. notifications.concat(n);
  1539. end;
  1540. procedure Tvarsym.unregister_notification(id:cardinal);
  1541. var n:Tnotification;
  1542. begin
  1543. if not assigned(notifications) then
  1544. internalerror(200212311)
  1545. else
  1546. begin
  1547. n:=Tnotification(notifications.first);
  1548. while assigned(n) do
  1549. begin
  1550. if n.id=id then
  1551. begin
  1552. notifications.remove(n);
  1553. n.destroy;
  1554. exit;
  1555. end;
  1556. n:=Tnotification(n.next);
  1557. end;
  1558. internalerror(200212311)
  1559. end;
  1560. end;
  1561. {$ifdef GDB}
  1562. function tvarsym.stabstring : pchar;
  1563. var
  1564. st : string;
  1565. begin
  1566. st:=tstoreddef(vartype.def).numberstring;
  1567. if (owner.symtabletype = objectsymtable) and
  1568. (sp_static in symoptions) then
  1569. begin
  1570. if (cs_gdb_gsym in aktglobalswitches) then st := 'G'+st else st := 'S'+st;
  1571. stabstring := strpnew('"'+owner.name^+'__'+name+':'+st+
  1572. '",'+
  1573. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname);
  1574. end
  1575. else if (owner.symtabletype = globalsymtable) then
  1576. begin
  1577. { Here we used S instead of
  1578. because with G GDB doesn't look at the address field
  1579. but searches the same name or with a leading underscore
  1580. but these names don't exist in pascal !}
  1581. if (cs_gdb_gsym in aktglobalswitches) then st := 'G'+st else st := 'S'+st;
  1582. stabstring := strpnew('"'+name+':'+st+'",'+
  1583. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname);
  1584. end
  1585. else if owner.symtabletype = staticsymtable then
  1586. begin
  1587. stabstring := strpnew('"'+name+':S'+st+'",'+
  1588. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname);
  1589. end
  1590. else if (owner.symtabletype in [parasymtable,inlineparasymtable]) then
  1591. begin
  1592. case varspez of
  1593. vs_out,
  1594. vs_var : st := 'v'+st;
  1595. vs_value,
  1596. vs_const : if paramanager.push_addr_param(vartype.def,tprocdef(owner.defowner).proccalloption) then
  1597. st := 'v'+st { should be 'i' but 'i' doesn't work }
  1598. else
  1599. st := 'p'+st;
  1600. end;
  1601. stabstring := strpnew('"'+name+':'+st+'",'+
  1602. tostr(N_tsym)+',0,'+tostr(fileinfo.line)+','+
  1603. tostr(adjusted_address));
  1604. {offset to ebp => will not work if the framepointer is esp
  1605. so some optimizing will make things harder to debug }
  1606. end
  1607. else if (owner.symtabletype in [localsymtable,inlinelocalsymtable]) then
  1608. if reg.enum<>R_NO then
  1609. begin
  1610. if reg.enum>lastreg then
  1611. internalerror(200201081);
  1612. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1613. { this is the register order for GDB}
  1614. stabstring:=strpnew('"'+name+':r'+st+'",'+
  1615. tostr(N_RSYM)+',0,'+
  1616. tostr(fileinfo.line)+','+tostr(stab_regindex[reg.enum]));
  1617. end
  1618. else
  1619. { I don't know if this will work (PM) }
  1620. if (vo_is_C_var in varoptions) then
  1621. stabstring := strpnew('"'+name+':S'+st+'",'+
  1622. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname)
  1623. else
  1624. stabstring := strpnew('"'+name+':'+st+'",'+
  1625. tostr(N_LSYM)+',0,'+tostr(fileinfo.line)+','+tostr(adjusted_address))
  1626. else
  1627. stabstring := inherited stabstring;
  1628. end;
  1629. procedure tvarsym.concatstabto(asmlist : taasmoutput);
  1630. var
  1631. tempreg: tregister;
  1632. stab_str : pchar;
  1633. c : char;
  1634. begin
  1635. if (owner.symtabletype in [parasymtable,inlineparasymtable]) and
  1636. (copy(name,1,6)='hidden') then
  1637. exit;
  1638. if (vo_is_self in varoptions) then
  1639. begin
  1640. if (po_classmethod in current_procdef.procoptions) or
  1641. (po_staticmethod in current_procdef.procoptions) then
  1642. begin
  1643. asmlist.concat(Tai_stabs.Create(strpnew(
  1644. '"pvmt:p'+tstoreddef(pvmttype.def).numberstring+'",'+
  1645. tostr(N_tsym)+',0,0,'+tostr(adjusted_address))));
  1646. end
  1647. else
  1648. begin
  1649. if not(is_class(current_procdef._class)) then
  1650. c:='v'
  1651. else
  1652. c:='p';
  1653. asmlist.concat(Tai_stabs.Create(strpnew(
  1654. '"$t:'+c+current_procdef._class.numberstring+'",'+
  1655. tostr(N_tsym)+',0,0,'+tostr(adjusted_address))));
  1656. end;
  1657. end
  1658. else
  1659. if (reg.enum<>R_NO) then
  1660. begin
  1661. if reg.enum = R_INTREGISTER then
  1662. begin
  1663. tempreg := reg;
  1664. convert_register_to_enum(tempreg);
  1665. end
  1666. else
  1667. tempreg := reg;
  1668. if tempreg.enum>lastreg then
  1669. internalerror(2003010801);
  1670. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1671. { this is the register order for GDB}
  1672. stab_str:=strpnew('"'+name+':r'
  1673. +tstoreddef(vartype.def).numberstring+'",'+
  1674. tostr(N_RSYM)+',0,'+
  1675. tostr(fileinfo.line)+','+tostr(stab_regindex[tempreg.enum]));
  1676. asmList.concat(Tai_stabs.Create(stab_str));
  1677. end
  1678. else
  1679. inherited concatstabto(asmlist);
  1680. end;
  1681. {$endif GDB}
  1682. procedure tvarsym.setvartype(const newtype: ttype);
  1683. begin
  1684. _vartype := newtype;
  1685. { can we load the value into a register ? }
  1686. if not assigned(owner) or
  1687. (owner.symtabletype in [localsymtable,parasymtable,inlineparasymtable,inlinelocalsymtable]) then
  1688. begin
  1689. if tstoreddef(vartype.def).is_intregable then
  1690. include(varoptions,vo_regable)
  1691. else
  1692. exclude(varoptions,vo_regable);
  1693. if tstoreddef(vartype.def).is_fpuregable then
  1694. include(varoptions,vo_fpuregable)
  1695. else
  1696. exclude(varoptions,vo_fpuregable);
  1697. reg.enum:=R_NO;
  1698. end;
  1699. end;
  1700. {****************************************************************************
  1701. TTYPEDCONSTSYM
  1702. *****************************************************************************}
  1703. constructor ttypedconstsym.create(const n : string;p : tdef;writable : boolean);
  1704. begin
  1705. inherited create(n);
  1706. typ:=typedconstsym;
  1707. typedconsttype.setdef(p);
  1708. is_writable:=writable;
  1709. end;
  1710. constructor ttypedconstsym.createtype(const n : string;const tt : ttype;writable : boolean);
  1711. begin
  1712. inherited create(n);
  1713. typ:=typedconstsym;
  1714. typedconsttype:=tt;
  1715. is_writable:=writable;
  1716. end;
  1717. constructor ttypedconstsym.ppuload(ppufile:tcompilerppufile);
  1718. begin
  1719. inherited loadsym(ppufile);
  1720. typ:=typedconstsym;
  1721. ppufile.gettype(typedconsttype);
  1722. is_writable:=boolean(ppufile.getbyte);
  1723. end;
  1724. destructor ttypedconstsym.destroy;
  1725. begin
  1726. inherited destroy;
  1727. end;
  1728. procedure ttypedconstsym.generate_mangledname;
  1729. begin
  1730. _mangledname:=stringdup(mangledname_prefix('TC',owner)+name);
  1731. end;
  1732. function ttypedconstsym.getsize : longint;
  1733. begin
  1734. if assigned(typedconsttype.def) then
  1735. getsize:=typedconsttype.def.size
  1736. else
  1737. getsize:=0;
  1738. end;
  1739. procedure ttypedconstsym.deref;
  1740. begin
  1741. typedconsttype.resolve;
  1742. end;
  1743. procedure ttypedconstsym.ppuwrite(ppufile:tcompilerppufile);
  1744. begin
  1745. inherited writesym(ppufile);
  1746. ppufile.puttype(typedconsttype);
  1747. ppufile.putbyte(byte(is_writable));
  1748. ppufile.writeentry(ibtypedconstsym);
  1749. end;
  1750. {$ifdef GDB}
  1751. function ttypedconstsym.stabstring : pchar;
  1752. var
  1753. st : char;
  1754. begin
  1755. if (cs_gdb_gsym in aktglobalswitches) and (owner.symtabletype=globalsymtable) then
  1756. st := 'G'
  1757. else
  1758. st := 'S';
  1759. stabstring := strpnew('"'+name+':'+st+
  1760. tstoreddef(typedconsttype.def).numberstring+'",'+tostr(n_STSYM)+',0,'+
  1761. tostr(fileinfo.line)+','+mangledname);
  1762. end;
  1763. {$endif GDB}
  1764. {****************************************************************************
  1765. TCONSTSYM
  1766. ****************************************************************************}
  1767. constructor tconstsym.create_ord(const n : string;t : tconsttyp;v : TConstExprInt);
  1768. begin
  1769. inherited create(n);
  1770. fillchar(value, sizeof(value), #0);
  1771. typ:=constsym;
  1772. consttyp:=t;
  1773. value.valueord:=v;
  1774. ResStrIndex:=0;
  1775. consttype.reset;
  1776. end;
  1777. constructor tconstsym.create_ord_typed(const n : string;t : tconsttyp;v : tconstexprint;const tt:ttype);
  1778. begin
  1779. inherited create(n);
  1780. fillchar(value, sizeof(value), #0);
  1781. typ:=constsym;
  1782. consttyp:=t;
  1783. value.valueord:=v;
  1784. ResStrIndex:=0;
  1785. consttype:=tt;
  1786. end;
  1787. constructor tconstsym.create_ordptr_typed(const n : string;t : tconsttyp;v : tconstptruint;const tt:ttype);
  1788. begin
  1789. inherited create(n);
  1790. fillchar(value, sizeof(value), #0);
  1791. typ:=constsym;
  1792. consttyp:=t;
  1793. value.valueordptr:=v;
  1794. ResStrIndex:=0;
  1795. consttype:=tt;
  1796. end;
  1797. constructor tconstsym.create_ptr(const n : string;t : tconsttyp;v : pointer);
  1798. begin
  1799. inherited create(n);
  1800. fillchar(value, sizeof(value), #0);
  1801. typ:=constsym;
  1802. consttyp:=t;
  1803. value.valueptr:=v;
  1804. ResStrIndex:=0;
  1805. consttype.reset;
  1806. end;
  1807. constructor tconstsym.create_ptr_typed(const n : string;t : tconsttyp;v : pointer;const tt:ttype);
  1808. begin
  1809. inherited create(n);
  1810. fillchar(value, sizeof(value), #0);
  1811. typ:=constsym;
  1812. consttyp:=t;
  1813. value.valueptr:=v;
  1814. ResStrIndex:=0;
  1815. consttype:=tt;
  1816. end;
  1817. constructor tconstsym.create_string(const n : string;t : tconsttyp;str:pchar;l:longint);
  1818. begin
  1819. inherited create(n);
  1820. fillchar(value, sizeof(value), #0);
  1821. typ:=constsym;
  1822. consttyp:=t;
  1823. value.valueptr:=str;
  1824. consttype.reset;
  1825. value.len:=l;
  1826. if t=constresourcestring then
  1827. ResStrIndex:=ResourceStrings.Register(name,pchar(value.valueptr),value.len);
  1828. end;
  1829. constructor tconstsym.ppuload(ppufile:tcompilerppufile);
  1830. var
  1831. pd : pbestreal;
  1832. ps : pnormalset;
  1833. pc : pchar;
  1834. begin
  1835. inherited loadsym(ppufile);
  1836. typ:=constsym;
  1837. consttype.reset;
  1838. consttyp:=tconsttyp(ppufile.getbyte);
  1839. fillchar(value, sizeof(value), #0);
  1840. case consttyp of
  1841. constint:
  1842. value.valueord:=ppufile.getexprint;
  1843. constwchar,
  1844. constbool,
  1845. constchar :
  1846. value.valueord:=ppufile.getlongint;
  1847. constord :
  1848. begin
  1849. ppufile.gettype(consttype);
  1850. value.valueord:=ppufile.getexprint;
  1851. end;
  1852. constpointer :
  1853. begin
  1854. ppufile.gettype(consttype);
  1855. value.valueordptr:=ppufile.getptruint;
  1856. end;
  1857. conststring,
  1858. constresourcestring :
  1859. begin
  1860. value.len:=ppufile.getlongint;
  1861. getmem(pc,value.len+1);
  1862. ppufile.getdata(pc^,value.len);
  1863. if consttyp=constresourcestring then
  1864. ResStrIndex:=ppufile.getlongint;
  1865. value.valueptr:=pc;
  1866. end;
  1867. constreal :
  1868. begin
  1869. new(pd);
  1870. pd^:=ppufile.getreal;
  1871. value.valueptr:=pd;
  1872. end;
  1873. constset :
  1874. begin
  1875. ppufile.gettype(consttype);
  1876. new(ps);
  1877. ppufile.getnormalset(ps^);
  1878. value.valueptr:=ps;
  1879. end;
  1880. constguid :
  1881. begin
  1882. new(pguid(value.valueptr));
  1883. ppufile.getdata(value.valueptr^,sizeof(tguid));
  1884. end;
  1885. constnil : ;
  1886. else
  1887. Message1(unit_f_ppu_invalid_entry,tostr(ord(consttyp)));
  1888. end;
  1889. end;
  1890. destructor tconstsym.destroy;
  1891. begin
  1892. case consttyp of
  1893. conststring,
  1894. constresourcestring :
  1895. freemem(pchar(value.valueptr),value.len+1);
  1896. constreal :
  1897. dispose(pbestreal(value.valueptr));
  1898. constset :
  1899. dispose(pnormalset(value.valueptr));
  1900. constguid :
  1901. dispose(pguid(value.valueptr));
  1902. end;
  1903. inherited destroy;
  1904. end;
  1905. function tconstsym.mangledname : string;
  1906. begin
  1907. mangledname:=name;
  1908. end;
  1909. procedure tconstsym.deref;
  1910. begin
  1911. if consttyp in [constord,constpointer,constset] then
  1912. consttype.resolve;
  1913. end;
  1914. procedure tconstsym.ppuwrite(ppufile:tcompilerppufile);
  1915. begin
  1916. inherited writesym(ppufile);
  1917. ppufile.putbyte(byte(consttyp));
  1918. case consttyp of
  1919. constnil : ;
  1920. constint:
  1921. ppufile.putexprint(value.valueord);
  1922. constbool,
  1923. constchar :
  1924. ppufile.putlongint(value.valueord);
  1925. constord :
  1926. begin
  1927. ppufile.puttype(consttype);
  1928. ppufile.putexprint(value.valueord);
  1929. end;
  1930. constpointer :
  1931. begin
  1932. ppufile.puttype(consttype);
  1933. ppufile.putptruint(value.valueordptr);
  1934. end;
  1935. conststring,
  1936. constresourcestring :
  1937. begin
  1938. ppufile.putlongint(value.len);
  1939. ppufile.putdata(pchar(value.valueptr)^,value.len);
  1940. if consttyp=constresourcestring then
  1941. ppufile.putlongint(ResStrIndex);
  1942. end;
  1943. constreal :
  1944. ppufile.putreal(pbestreal(value.valueptr)^);
  1945. constset :
  1946. begin
  1947. ppufile.puttype(consttype);
  1948. ppufile.putnormalset(value.valueptr^);
  1949. end;
  1950. constguid :
  1951. ppufile.putdata(value.valueptr^,sizeof(tguid));
  1952. else
  1953. internalerror(13);
  1954. end;
  1955. ppufile.writeentry(ibconstsym);
  1956. end;
  1957. {$ifdef GDB}
  1958. function tconstsym.stabstring : pchar;
  1959. var st : string;
  1960. begin
  1961. {even GDB v4.16 only now 'i' 'r' and 'e' !!!}
  1962. case consttyp of
  1963. conststring : begin
  1964. st := 's'''+strpas(pchar(value.valueptr))+'''';
  1965. end;
  1966. constbool,
  1967. constint,
  1968. constord,
  1969. constchar : st := 'i'+int64tostr(value.valueord);
  1970. constpointer :
  1971. st := 'i'+int64tostr(value.valueordptr);
  1972. constreal : begin
  1973. system.str(pbestreal(value.valueptr)^,st);
  1974. st := 'r'+st;
  1975. end;
  1976. { if we don't know just put zero !! }
  1977. else st:='i0';
  1978. {***SETCONST}
  1979. {constset:;} {*** I don't know what to do with a set.}
  1980. { sets are not recognized by GDB}
  1981. {***}
  1982. end;
  1983. stabstring := strpnew('"'+name+':c='+st+'",'+tostr(N_function)+',0,'+
  1984. tostr(fileinfo.line)+',0');
  1985. end;
  1986. procedure tconstsym.concatstabto(asmlist : taasmoutput);
  1987. begin
  1988. if consttyp <> conststring then
  1989. inherited concatstabto(asmlist);
  1990. end;
  1991. {$endif GDB}
  1992. {****************************************************************************
  1993. TENUMSYM
  1994. ****************************************************************************}
  1995. constructor tenumsym.create(const n : string;def : tenumdef;v : longint);
  1996. begin
  1997. inherited create(n);
  1998. typ:=enumsym;
  1999. definition:=def;
  2000. value:=v;
  2001. { check for jumps }
  2002. if v>def.max+1 then
  2003. def.has_jumps:=true;
  2004. { update low and high }
  2005. if def.min>v then
  2006. def.setmin(v);
  2007. if def.max<v then
  2008. def.setmax(v);
  2009. order;
  2010. end;
  2011. constructor tenumsym.ppuload(ppufile:tcompilerppufile);
  2012. begin
  2013. inherited loadsym(ppufile);
  2014. typ:=enumsym;
  2015. definition:=tenumdef(ppufile.getderef);
  2016. value:=ppufile.getlongint;
  2017. nextenum := Nil;
  2018. end;
  2019. procedure tenumsym.deref;
  2020. begin
  2021. resolvedef(pointer(definition));
  2022. order;
  2023. end;
  2024. procedure tenumsym.order;
  2025. var
  2026. sym : tenumsym;
  2027. begin
  2028. sym := tenumsym(definition.firstenum);
  2029. if sym = nil then
  2030. begin
  2031. definition.firstenum := self;
  2032. nextenum := nil;
  2033. exit;
  2034. end;
  2035. { reorder the symbols in increasing value }
  2036. if value < sym.value then
  2037. begin
  2038. nextenum := sym;
  2039. definition.firstenum := self;
  2040. end
  2041. else
  2042. begin
  2043. while (sym.value <= value) and assigned(sym.nextenum) do
  2044. sym := sym.nextenum;
  2045. nextenum := sym.nextenum;
  2046. sym.nextenum := self;
  2047. end;
  2048. end;
  2049. procedure tenumsym.ppuwrite(ppufile:tcompilerppufile);
  2050. begin
  2051. inherited writesym(ppufile);
  2052. ppufile.putderef(definition);
  2053. ppufile.putlongint(value);
  2054. ppufile.writeentry(ibenumsym);
  2055. end;
  2056. {$ifdef GDB}
  2057. procedure tenumsym.concatstabto(asmlist : taasmoutput);
  2058. begin
  2059. {enum elements have no stab !}
  2060. end;
  2061. {$EndIf GDB}
  2062. {****************************************************************************
  2063. TTYPESYM
  2064. ****************************************************************************}
  2065. constructor ttypesym.create(const n : string;const tt : ttype);
  2066. begin
  2067. inherited create(n);
  2068. typ:=typesym;
  2069. restype:=tt;
  2070. {$ifdef GDB}
  2071. isusedinstab := false;
  2072. {$endif GDB}
  2073. { register the typesym for the definition }
  2074. if assigned(restype.def) and
  2075. (restype.def.deftype<>errordef) and
  2076. not(assigned(restype.def.typesym)) then
  2077. restype.def.typesym:=self;
  2078. end;
  2079. constructor ttypesym.ppuload(ppufile:tcompilerppufile);
  2080. begin
  2081. inherited loadsym(ppufile);
  2082. typ:=typesym;
  2083. {$ifdef GDB}
  2084. isusedinstab := false;
  2085. {$endif GDB}
  2086. ppufile.gettype(restype);
  2087. end;
  2088. function ttypesym.gettypedef:tdef;
  2089. begin
  2090. gettypedef:=restype.def;
  2091. end;
  2092. procedure ttypesym.deref;
  2093. begin
  2094. restype.resolve;
  2095. end;
  2096. procedure ttypesym.ppuwrite(ppufile:tcompilerppufile);
  2097. begin
  2098. inherited writesym(ppufile);
  2099. ppufile.puttype(restype);
  2100. ppufile.writeentry(ibtypesym);
  2101. end;
  2102. procedure ttypesym.load_references(ppufile:tcompilerppufile;locals:boolean);
  2103. begin
  2104. inherited load_references(ppufile,locals);
  2105. if (restype.def.deftype=recorddef) then
  2106. tstoredsymtable(trecorddef(restype.def).symtable).load_references(ppufile,locals);
  2107. if (restype.def.deftype=objectdef) then
  2108. tstoredsymtable(tobjectdef(restype.def).symtable).load_references(ppufile,locals);
  2109. end;
  2110. function ttypesym.write_references(ppufile:tcompilerppufile;locals:boolean):boolean;
  2111. begin
  2112. if not inherited write_references(ppufile,locals) then
  2113. begin
  2114. { write address of this symbol if record or object
  2115. even if no real refs are there
  2116. because we need it for the symtable }
  2117. if (restype.def.deftype in [recorddef,objectdef]) then
  2118. begin
  2119. ppufile.putderef(self);
  2120. ppufile.writeentry(ibsymref);
  2121. end;
  2122. end;
  2123. write_references:=true;
  2124. if (restype.def.deftype=recorddef) then
  2125. tstoredsymtable(trecorddef(restype.def).symtable).write_references(ppufile,locals);
  2126. if (restype.def.deftype=objectdef) then
  2127. tstoredsymtable(tobjectdef(restype.def).symtable).write_references(ppufile,locals);
  2128. end;
  2129. {$ifdef GDB}
  2130. function ttypesym.stabstring : pchar;
  2131. var
  2132. stabchar : string[2];
  2133. short : string;
  2134. begin
  2135. if restype.def.deftype in tagtypes then
  2136. stabchar := 'Tt'
  2137. else
  2138. stabchar := 't';
  2139. short := '"'+name+':'+stabchar+tstoreddef(restype.def).numberstring
  2140. +'",'+tostr(N_LSYM)+',0,'+tostr(fileinfo.line)+',0';
  2141. stabstring := strpnew(short);
  2142. end;
  2143. procedure ttypesym.concatstabto(asmlist : taasmoutput);
  2144. begin
  2145. {not stabs for forward defs }
  2146. if assigned(restype.def) then
  2147. if (restype.def.typesym = self) then
  2148. tstoreddef(restype.def).concatstabto(asmlist)
  2149. else
  2150. inherited concatstabto(asmlist);
  2151. end;
  2152. {$endif GDB}
  2153. {****************************************************************************
  2154. TSYSSYM
  2155. ****************************************************************************}
  2156. constructor tsyssym.create(const n : string;l : longint);
  2157. begin
  2158. inherited create(n);
  2159. typ:=syssym;
  2160. number:=l;
  2161. end;
  2162. constructor tsyssym.ppuload(ppufile:tcompilerppufile);
  2163. begin
  2164. inherited loadsym(ppufile);
  2165. typ:=syssym;
  2166. number:=ppufile.getlongint;
  2167. end;
  2168. destructor tsyssym.destroy;
  2169. begin
  2170. inherited destroy;
  2171. end;
  2172. procedure tsyssym.ppuwrite(ppufile:tcompilerppufile);
  2173. begin
  2174. inherited writesym(ppufile);
  2175. ppufile.putlongint(number);
  2176. ppufile.writeentry(ibsyssym);
  2177. end;
  2178. {$ifdef GDB}
  2179. procedure tsyssym.concatstabto(asmlist : taasmoutput);
  2180. begin
  2181. end;
  2182. {$endif GDB}
  2183. {****************************************************************************
  2184. TRTTISYM
  2185. ****************************************************************************}
  2186. constructor trttisym.create(const n:string;rt:trttitype);
  2187. const
  2188. prefix : array[trttitype] of string[5]=('$rtti','$init');
  2189. begin
  2190. inherited create(prefix[rt]+n);
  2191. typ:=rttisym;
  2192. lab:=nil;
  2193. rttityp:=rt;
  2194. end;
  2195. constructor trttisym.ppuload(ppufile:tcompilerppufile);
  2196. begin
  2197. inherited loadsym(ppufile);
  2198. typ:=rttisym;
  2199. lab:=nil;
  2200. rttityp:=trttitype(ppufile.getbyte);
  2201. end;
  2202. procedure trttisym.ppuwrite(ppufile:tcompilerppufile);
  2203. begin
  2204. inherited writesym(ppufile);
  2205. ppufile.putbyte(byte(rttityp));
  2206. ppufile.writeentry(ibrttisym);
  2207. end;
  2208. function trttisym.mangledname : string;
  2209. const
  2210. prefix : array[trttitype] of string[5]=('RTTI_','INIT_');
  2211. var
  2212. s : string;
  2213. p : tsymtable;
  2214. begin
  2215. s:='';
  2216. p:=owner;
  2217. while assigned(p) and (p.symtabletype=localsymtable) do
  2218. begin
  2219. s:=s+'_'+p.defowner.name;
  2220. p:=p.defowner.owner;
  2221. end;
  2222. if not(p.symtabletype in [globalsymtable,staticsymtable]) then
  2223. internalerror(200108265);
  2224. mangledname:=prefix[rttityp]+p.name^+s+'$_'+Copy(name,5,255);
  2225. end;
  2226. function trttisym.get_label:tasmsymbol;
  2227. begin
  2228. { the label is always a global label }
  2229. if not assigned(lab) then
  2230. lab:=objectlibrary.newasmsymboldata(mangledname);
  2231. get_label:=lab;
  2232. end;
  2233. { persistent rtti generation }
  2234. procedure generate_rtti(p:tsym);
  2235. var
  2236. rsym : trttisym;
  2237. def : tstoreddef;
  2238. begin
  2239. { rtti can only be generated for classes that are always typesyms }
  2240. if not(p.typ=typesym) then
  2241. internalerror(200108261);
  2242. def:=tstoreddef(ttypesym(p).restype.def);
  2243. { only create rtti once for each definition }
  2244. if not(df_has_rttitable in def.defoptions) then
  2245. begin
  2246. { definition should be in the same symtable as the symbol }
  2247. if p.owner<>def.owner then
  2248. internalerror(200108262);
  2249. { create rttisym }
  2250. rsym:=trttisym.create(p.name,fullrtti);
  2251. p.owner.insert(rsym);
  2252. { register rttisym in definition }
  2253. include(def.defoptions,df_has_rttitable);
  2254. def.rttitablesym:=rsym;
  2255. { write rtti data }
  2256. def.write_child_rtti_data(fullrtti);
  2257. if (cs_create_smart in aktmoduleswitches) then
  2258. rttiList.concat(Tai_cut.Create);
  2259. rttilist.concat(tai_align.create(const_align(pointer_size)));
  2260. rttiList.concat(Tai_symbol.Create_global(rsym.get_label,0));
  2261. def.write_rtti_data(fullrtti);
  2262. rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
  2263. end;
  2264. end;
  2265. { persistent init table generation }
  2266. procedure generate_inittable(p:tsym);
  2267. var
  2268. rsym : trttisym;
  2269. def : tstoreddef;
  2270. begin
  2271. { anonymous types are also allowed for records that can be varsym }
  2272. case p.typ of
  2273. typesym :
  2274. def:=tstoreddef(ttypesym(p).restype.def);
  2275. varsym :
  2276. def:=tstoreddef(tvarsym(p).vartype.def);
  2277. else
  2278. internalerror(200108263);
  2279. end;
  2280. { only create inittable once for each definition }
  2281. if not(df_has_inittable in def.defoptions) then
  2282. begin
  2283. { definition should be in the same symtable as the symbol }
  2284. if p.owner<>def.owner then
  2285. internalerror(200108264);
  2286. { create rttisym }
  2287. rsym:=trttisym.create(p.name,initrtti);
  2288. p.owner.insert(rsym);
  2289. { register rttisym in definition }
  2290. include(def.defoptions,df_has_inittable);
  2291. def.inittablesym:=rsym;
  2292. { write inittable data }
  2293. def.write_child_rtti_data(initrtti);
  2294. if (cs_create_smart in aktmoduleswitches) then
  2295. rttiList.concat(Tai_cut.Create);
  2296. rttilist.concat(tai_align.create(const_align(pointer_size)));
  2297. rttiList.concat(Tai_symbol.Create_global(rsym.get_label,0));
  2298. def.write_rtti_data(initrtti);
  2299. rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
  2300. end;
  2301. end;
  2302. end.
  2303. {
  2304. $Log$
  2305. Revision 1.108 2003-06-05 17:53:30 peter
  2306. * fix to compile without gdb
  2307. Revision 1.107 2003/06/02 22:59:17 florian
  2308. * absolutesyms aren't fpuregable either
  2309. Revision 1.106 2003/05/30 18:48:17 jonas
  2310. * fixed intregister bug
  2311. * fixed error in my previous commit: vo_(fpu)regable should only be set
  2312. for (inline)localsymtable and (inline)parasymtable entries
  2313. Revision 1.105 2003/05/30 13:35:10 jonas
  2314. * the vartype field of tvarsym is now a property, because is_XXXregable
  2315. must be updated when the vartype is changed
  2316. Revision 1.104 2003/05/15 18:58:53 peter
  2317. * removed selfpointer_offset, vmtpointer_offset
  2318. * tvarsym.adjusted_address
  2319. * address in localsymtable is now in the real direction
  2320. * removed some obsolete globals
  2321. Revision 1.103 2003/05/12 18:13:57 peter
  2322. * create rtti label using newasmsymboldata and update binding
  2323. only when calling tai_symbol.create
  2324. * tai_symbol.create_global added
  2325. Revision 1.102 2003/05/09 17:47:03 peter
  2326. * self moved to hidden parameter
  2327. * removed hdisposen,hnewn,selfn
  2328. Revision 1.101 2003/05/05 14:53:16 peter
  2329. * vs_hidden replaced by is_hidden boolean
  2330. Revision 1.100 2003/04/27 11:21:34 peter
  2331. * aktprocdef renamed to current_procdef
  2332. * procinfo renamed to current_procinfo
  2333. * procinfo will now be stored in current_module so it can be
  2334. cleaned up properly
  2335. * gen_main_procsym changed to create_main_proc and release_main_proc
  2336. to also generate a tprocinfo structure
  2337. * fixed unit implicit initfinal
  2338. Revision 1.99 2003/04/27 10:03:18 jonas
  2339. * fixed stabs generation for local variables on systems where they have
  2340. a positive offset relative to the stack/framepointer
  2341. Revision 1.98 2003/04/27 07:29:51 peter
  2342. * current_procdef cleanup, current_procdef is now always nil when parsing
  2343. a new procdef declaration
  2344. * aktprocsym removed
  2345. * lexlevel removed, use symtable.symtablelevel instead
  2346. * implicit init/final code uses the normal genentry/genexit
  2347. * funcret state checking updated for new funcret handling
  2348. Revision 1.97 2003/04/25 20:59:35 peter
  2349. * removed funcretn,funcretsym, function result is now in varsym
  2350. and aliases for result and function name are added using absolutesym
  2351. * vs_hidden parameter for funcret passed in parameter
  2352. * vs_hidden fixes
  2353. * writenode changed to printnode and released from extdebug
  2354. * -vp option added to generate a tree.log with the nodetree
  2355. * nicer printnode for statements, callnode
  2356. Revision 1.96 2003/04/23 13:13:58 peter
  2357. * fix operator overload search parameter order
  2358. Revision 1.95 2003/04/10 17:57:53 peter
  2359. * vs_hidden released
  2360. Revision 1.94 2003/03/17 15:54:22 peter
  2361. * store symoptions also for procdef
  2362. * check symoptions (private,public) when calculating possible
  2363. overload candidates
  2364. Revision 1.93 2003/01/15 01:44:33 peter
  2365. * merged methodpointer fixes from 1.0.x
  2366. Revision 1.92 2003/01/09 21:52:38 peter
  2367. * merged some verbosity options.
  2368. * V_LineInfo is a verbosity flag to include line info
  2369. Revision 1.91 2003/01/08 18:43:57 daniel
  2370. * Tregister changed into a record
  2371. Revision 1.90 2003/01/03 12:15:56 daniel
  2372. * Removed ifdefs around notifications
  2373. ifdefs around for loop optimizations remain
  2374. Revision 1.89 2003/01/02 11:14:02 michael
  2375. + Patch from peter to support initial values for local variables
  2376. Revision 1.88 2003/01/01 22:51:03 peter
  2377. * high value insertion changed so it works also when 2 parameters
  2378. are passed
  2379. Revision 1.87 2002/12/31 09:55:58 daniel
  2380. + Notification implementation complete
  2381. + Add for loop code optimization using notifications
  2382. results in 1.5-1.9% speed improvement in nestloop benchmark
  2383. Optimization incomplete, compiler does not cycle yet with
  2384. notifications enabled.
  2385. Revision 1.86 2002/12/30 22:44:53 daniel
  2386. * Some work on notifications
  2387. Revision 1.85 2002/12/27 18:07:44 peter
  2388. * fix crashes when searching symbols
  2389. Revision 1.84 2002/12/20 16:02:22 peter
  2390. * fix stupid copy&paste bug in binary operator search
  2391. Revision 1.83 2002/12/16 22:08:31 peter
  2392. * fix order of procdefs in procsym, procdefs are now always appended
  2393. so that loading from a ppu will keep the same order. This is
  2394. important for the generation of VMTs
  2395. Revision 1.82 2002/12/11 22:39:23 peter
  2396. * better error message when no operator is found for equal
  2397. Revision 1.81 2002/12/07 14:27:10 carl
  2398. * 3% memory optimization
  2399. * changed some types
  2400. + added type checking with different size for call node and for
  2401. parameters
  2402. Revision 1.80 2002/12/06 17:51:11 peter
  2403. * merged cdecl and array fixes
  2404. Revision 1.79 2002/11/27 20:04:10 peter
  2405. * tvarsym.get_push_size replaced by paramanager.push_size
  2406. Revision 1.78 2002/11/27 02:34:20 peter
  2407. * only find real equal procvars
  2408. Revision 1.77 2002/11/25 18:43:34 carl
  2409. - removed the invalid if <> checking (Delphi is strange on this)
  2410. + implemented abstract warning on instance creation of class with
  2411. abstract methods.
  2412. * some error message cleanups
  2413. Revision 1.76 2002/11/25 17:43:26 peter
  2414. * splitted defbase in defutil,symutil,defcmp
  2415. * merged isconvertable and is_equal into compare_defs(_ext)
  2416. * made operator search faster by walking the list only once
  2417. Revision 1.75 2002/11/23 22:50:09 carl
  2418. * some small speed optimizations
  2419. + added several new warnings/hints
  2420. Revision 1.74 2002/11/22 22:48:11 carl
  2421. * memory optimization with tconstsym (1.5%)
  2422. Revision 1.73 2002/11/18 17:31:59 peter
  2423. * pass proccalloption to ret_in_xxx and push_xxx functions
  2424. Revision 1.72 2002/11/17 16:31:57 carl
  2425. * memory optimization (3-4%) : cleanup of tai fields,
  2426. cleanup of tdef and tsym fields.
  2427. * make it work for m68k
  2428. Revision 1.71 2002/11/09 15:30:07 carl
  2429. + align RTTI tables
  2430. Revision 1.70 2002/10/13 21:33:37 peter
  2431. * give correct fileposition for undefined forward procs
  2432. Revision 1.69 2002/10/05 12:43:29 carl
  2433. * fixes for Delphi 6 compilation
  2434. (warning : Some features do not work under Delphi)
  2435. Revision 1.68 2002/10/05 00:52:20 peter
  2436. * split boolean check in two lines for easier debugging
  2437. Revision 1.67 2002/09/26 12:04:53 florian
  2438. + constsym with type=constguid can be written to ppu now,
  2439. fixes web bug 1820
  2440. Revision 1.66 2002/09/16 14:11:13 peter
  2441. * add argument to equal_paras() to support default values or not
  2442. Revision 1.65 2002/09/09 17:34:16 peter
  2443. * tdicationary.replace added to replace and item in a dictionary. This
  2444. is only allowed for the same name
  2445. * varsyms are inserted in symtable before the types are parsed. This
  2446. fixes the long standing "var longint : longint" bug
  2447. - consume_idlist and idstringlist removed. The loops are inserted
  2448. at the callers place and uses the symtable for duplicate id checking
  2449. Revision 1.64 2002/09/08 11:10:17 carl
  2450. * bugfix 2109 (bad imho, but only way)
  2451. Revision 1.63 2002/09/07 18:17:41 florian
  2452. + tvarsym.paraitem added
  2453. Revision 1.62 2002/09/07 15:25:10 peter
  2454. * old logs removed and tabs fixed
  2455. Revision 1.61 2002/09/05 19:29:45 peter
  2456. * memdebug enhancements
  2457. Revision 1.60 2002/09/05 14:51:42 peter
  2458. * internalerror instead of crash in getprocdef
  2459. Revision 1.59 2002/09/03 16:26:27 daniel
  2460. * Make Tprocdef.defs protected
  2461. Revision 1.58 2002/09/01 08:01:16 daniel
  2462. * Removed sets from Tcallnode.det_resulttype
  2463. + Added read/write notifications of variables. These will be usefull
  2464. for providing information for several optimizations. For example
  2465. the value of the loop variable of a for loop does matter is the
  2466. variable is read after the for loop, but if it's no longer used
  2467. or written, it doesn't matter and this can be used to optimize
  2468. the loop code generation.
  2469. Revision 1.57 2002/08/25 19:25:21 peter
  2470. * sym.insert_in_data removed
  2471. * symtable.insertvardata/insertconstdata added
  2472. * removed insert_in_data call from symtable.insert, it needs to be
  2473. called separatly. This allows to deref the address calculation
  2474. * procedures now calculate the parast addresses after the procedure
  2475. directives are parsed. This fixes the cdecl parast problem
  2476. * push_addr_param has an extra argument that specifies if cdecl is used
  2477. or not
  2478. Revision 1.56 2002/08/25 09:06:21 peter
  2479. * fixed loop in concat_procdefs
  2480. Revision 1.55 2002/08/20 16:54:40 peter
  2481. * write address of varsym always
  2482. Revision 1.54 2002/08/20 10:31:26 daniel
  2483. * Tcallnode.det_resulttype rewritten
  2484. Revision 1.53 2002/08/18 20:06:27 peter
  2485. * inlining is now also allowed in interface
  2486. * renamed write/load to ppuwrite/ppuload
  2487. * tnode storing in ppu
  2488. * nld,ncon,nbas are already updated for storing in ppu
  2489. Revision 1.52 2002/08/17 09:23:42 florian
  2490. * first part of procinfo rewrite
  2491. Revision 1.51 2002/08/16 14:24:59 carl
  2492. * issameref() to test if two references are the same (then emit no opcodes)
  2493. + ret_in_reg to replace ret_in_acc
  2494. (fix some register allocation bugs at the same time)
  2495. + save_std_register now has an extra parameter which is the
  2496. usedinproc registers
  2497. Revision 1.50 2002/08/13 21:40:57 florian
  2498. * more fixes for ppc calling conventions
  2499. Revision 1.49 2002/08/12 15:08:40 carl
  2500. + stab register indexes for powerpc (moved from gdb to cpubase)
  2501. + tprocessor enumeration moved to cpuinfo
  2502. + linker in target_info is now a class
  2503. * many many updates for m68k (will soon start to compile)
  2504. - removed some ifdef or correct them for correct cpu
  2505. Revision 1.48 2002/08/11 14:32:28 peter
  2506. * renamed current_library to objectlibrary
  2507. Revision 1.47 2002/08/11 13:24:14 peter
  2508. * saving of asmsymbols in ppu supported
  2509. * asmsymbollist global is removed and moved into a new class
  2510. tasmlibrarydata that will hold the info of a .a file which
  2511. corresponds with a single module. Added librarydata to tmodule
  2512. to keep the library info stored for the module. In the future the
  2513. objectfiles will also be stored to the tasmlibrarydata class
  2514. * all getlabel/newasmsymbol and friends are moved to the new class
  2515. Revision 1.46 2002/07/23 10:13:23 daniel
  2516. * Added important comment
  2517. Revision 1.45 2002/07/23 09:51:26 daniel
  2518. * Tried to make Tprocsym.defs protected. I didn't succeed but the cleanups
  2519. are worth comitting.
  2520. Revision 1.44 2002/07/20 17:45:29 daniel
  2521. * Register variables are now possible for global variables too. This is
  2522. important for small programs without procedures.
  2523. Revision 1.43 2002/07/20 11:57:58 florian
  2524. * types.pas renamed to defbase.pas because D6 contains a types
  2525. unit so this would conflicts if D6 programms are compiled
  2526. + Willamette/SSE2 instructions to assembler added
  2527. Revision 1.42 2002/07/11 14:41:31 florian
  2528. * start of the new generic parameter handling
  2529. }