symsym.pas 91 KB

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