symsym.pas 90 KB

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