symsym.pas 93 KB

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