symsym.pas 93 KB

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