symsym.pas 90 KB

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