symsym.pas 92 KB

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