symsym.pas 104 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
  3. Implementation for the symbols types of the symtable
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit symsym;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. { common }
  22. cutils,compinnr,
  23. { target }
  24. globtype,globals,widestr,constexp,
  25. { symtable }
  26. symconst,symbase,symtype,symdef,defcmp,
  27. cclasses,
  28. { aasm }
  29. aasmbase,
  30. cpuinfo,cgbase,cgutils,parabase
  31. ;
  32. type
  33. { this class is the base for all symbol objects }
  34. tstoredsym = class(tsym)
  35. private
  36. procedure writeentry(ppufile: tcompilerppufile; ibnr: byte);
  37. protected
  38. procedure ppuwrite_platform(ppufile: tcompilerppufile);virtual;
  39. procedure ppuload_platform(ppufile: tcompilerppufile);virtual;
  40. public
  41. { this is Nil if the symbol has no RTTI attributes }
  42. rtti_attribute_list : trtti_attribute_list;
  43. constructor create(st:tsymtyp;const n : TSymStr);
  44. constructor ppuload(st:tsymtyp;ppufile:tcompilerppufile);
  45. destructor destroy;override;
  46. procedure ppuwrite(ppufile:tcompilerppufile);virtual;
  47. { this is called directly after ppuload }
  48. procedure ppuload_subentries(ppufile:tcompilerppufile);virtual;
  49. { this is called directly after ppuwrite }
  50. procedure ppuwrite_subentries(ppufile:tcompilerppufile);virtual;
  51. procedure deref; override;
  52. procedure buildderef; override;
  53. procedure register_sym; override;
  54. end;
  55. tlabelsym = class(tstoredsym)
  56. used,
  57. defined,
  58. nonlocal : boolean;
  59. { points to the matching node, only valid resultdef pass is run and
  60. the goto<->label relation in the node tree is created, should
  61. be a tnode }
  62. code : pointer;
  63. { points to the jump buffer }
  64. jumpbuf : tstoredsym;
  65. { when the label is defined in an asm block, this points to the
  66. generated asmlabel }
  67. asmblocklabel : tasmlabel;
  68. constructor create(const n : TSymStr);virtual;
  69. constructor ppuload(ppufile:tcompilerppufile);
  70. { do not override this routine in platform-specific subclasses,
  71. override ppuwrite_platform instead }
  72. procedure ppuwrite(ppufile:tcompilerppufile);override;final;
  73. function mangledname:TSymStr;override;
  74. end;
  75. tlabelsymclass = class of tlabelsym;
  76. tunitsym = class(Tstoredsym)
  77. module : tobject; { tmodule }
  78. constructor create(const n : TSymStr;amodule : tobject);virtual;
  79. constructor ppuload(ppufile:tcompilerppufile);
  80. destructor destroy;override;
  81. { do not override this routine in platform-specific subclasses,
  82. override ppuwrite_platform instead }
  83. procedure ppuwrite(ppufile:tcompilerppufile);override;final;
  84. end;
  85. tunitsymclass = class of tunitsym;
  86. tprogramparasym = class(Tstoredsym)
  87. isoindex : dword;
  88. constructor create(const n : TSymStr;i : dword);virtual;
  89. constructor ppuload(ppufile:tcompilerppufile);
  90. destructor destroy;override;
  91. { do not override this routine in platform-specific subclasses,
  92. override ppuwrite_platform instead }
  93. procedure ppuwrite(ppufile:tcompilerppufile);override;final;
  94. end;
  95. tprogramparasymclass = class of tprogramparasym;
  96. tnamespacesym = class(Tstoredsym)
  97. unitsym:tsym;
  98. unitsymderef:tderef;
  99. constructor create(const n : TSymStr);virtual;
  100. constructor ppuload(ppufile:tcompilerppufile);
  101. { do not override this routine in platform-specific subclasses,
  102. override ppuwrite_platform instead }
  103. procedure ppuwrite(ppufile:tcompilerppufile);override;final;
  104. procedure buildderef;override;
  105. procedure deref;override;
  106. end;
  107. tnamespacesymclass = class of tnamespacesym;
  108. terrorsym = class(Tsym)
  109. constructor create;
  110. procedure register_sym; override;
  111. end;
  112. { tprocsym }
  113. tprocsym = class(tstoredsym)
  114. protected type
  115. tprocdefcomparer = function(pd:tprocdef;arg:tobject):tequaltype;
  116. protected
  117. FProcdefList : TFPObjectList;
  118. FProcdefDerefList : TFPList;
  119. fgenprocsymovlds : tfpobjectlist;
  120. fgenprocsymovldsderefs : tfplist;
  121. function find_procdef_with_comparer(comparer:tprocdefcomparer;arg:tobject):tprocdef;
  122. class function compare_procvardef(pd:tprocdef;arg:tobject):tequaltype;static;
  123. class function compare_funcrefdef(pd:tprocdef;arg:tobject):tequaltype;static;
  124. public
  125. constructor create(const n : TSymStr);virtual;
  126. constructor ppuload(ppufile:tcompilerppufile);
  127. destructor destroy;override;
  128. { writes all declarations except the specified one }
  129. procedure write_parameter_lists(skipdef:tprocdef);
  130. { tests, if all procedures definitions are defined and not }
  131. { only forward }
  132. procedure check_forward; virtual;
  133. { do not override this routine in platform-specific subclasses,
  134. override ppuwrite_platform instead }
  135. procedure ppuwrite(ppufile:tcompilerppufile);override;final;
  136. procedure buildderef;override;
  137. procedure deref;override;
  138. function find_procdef_bytype(pt:Tproctypeoption):Tprocdef;
  139. function find_bytype_parameterless(pt:Tproctypeoption):Tprocdef;
  140. function find_procdef_bypara(para:TFPObjectList;retdef:tdef;cpoptions:tcompare_paras_options):Tprocdef;
  141. function find_procdef_bytype_and_para(pt:Tproctypeoption;para:TFPObjectList;retdef:tdef;cpoptions:tcompare_paras_options):Tprocdef;
  142. function find_procdef_byoptions(ops:tprocoptions): Tprocdef;
  143. function find_procdef_byprocvardef(d:Tprocvardef):Tprocdef;
  144. function find_procdef_byfuncrefdef(d:tobjectdef):tprocdef;
  145. function find_procdef_assignment_operator(fromdef,todef:tdef;var besteq:tequaltype;isexplicit:boolean):Tprocdef;
  146. function find_procdef_enumerator_operator(fromdef,todef:tdef;var besteq:tequaltype):Tprocdef;
  147. procedure add_generic_overload(sym:tprocsym);
  148. function could_be_implicitly_specialized:boolean;inline;
  149. property ProcdefList:TFPObjectList read FProcdefList;
  150. { only valid if sp_generic_dummy is set and either an overload was
  151. added using add_generic_overload or this was loaded from a ppu }
  152. property genprocsymovlds:tfpobjectlist read fgenprocsymovlds;
  153. end;
  154. tprocsymclass = class of tprocsym;
  155. ttypesym = class(Tstoredsym)
  156. public
  157. typedef : tdef;
  158. typedefderef : tderef;
  159. fprettyname : ansistring;
  160. constructor create(const n : TSymStr;def:tdef);virtual;
  161. destructor destroy;override;
  162. constructor ppuload(ppufile:tcompilerppufile);
  163. { do not override this routine in platform-specific subclasses,
  164. override ppuwrite_platform instead }
  165. procedure ppuwrite(ppufile:tcompilerppufile);override;final;
  166. procedure buildderef;override;
  167. procedure deref;override;
  168. function prettyname : string;override;
  169. end;
  170. ttypesymclass = class of ttypesym;
  171. tabstractvarsym = class(tstoredsym)
  172. varoptions : tvaroptions;
  173. varspez : tvarspez; { sets the type of access }
  174. varregable : tvarregable;
  175. varstate : tvarstate;
  176. {could also be part of tabstractnormalvarsym, but there's
  177. one byte left here till the next 4 byte alignment }
  178. varsymaccess : tvarsymaccessflags;
  179. constructor create(st:tsymtyp;const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);
  180. constructor ppuload(st:tsymtyp;ppufile:tcompilerppufile);
  181. procedure ppuwrite(ppufile:tcompilerppufile);override;
  182. procedure buildderef;override;
  183. procedure deref;override;
  184. function getsize : asizeint;
  185. function getpackedbitsize : longint;
  186. function is_regvar(refpara: boolean):boolean;
  187. private
  188. _vardef : tdef;
  189. vardefderef : tderef;
  190. function get_addr_taken: boolean;
  191. function get_different_scope: boolean;
  192. procedure setregable;
  193. procedure setvardef(const def: tdef);
  194. procedure setvardef_and_regable(def:tdef);
  195. procedure set_addr_taken(AValue: boolean);
  196. procedure set_different_scope(AValue: boolean);
  197. public
  198. property vardef: tdef read _vardef write setvardef_and_regable;
  199. property addr_taken: boolean read get_addr_taken write set_addr_taken;
  200. property different_scope: boolean read get_different_scope write set_different_scope;
  201. end;
  202. tfieldvarsym = class(tabstractvarsym)
  203. { offset in record/object, for bitpacked fields the offset is
  204. given in bit, else in bytes }
  205. fieldoffset : asizeint;
  206. {$ifdef llvm}
  207. { the llvm version of the record does not support variants, }
  208. { so the llvm equivalent field may not be at the exact same }
  209. { offset -> store the difference (bits for bitpacked records, }
  210. { bytes otherwise) }
  211. offsetfromllvmfield : aint;
  212. { number of the closest field in the llvm definition }
  213. llvmfieldnr : longint;
  214. {$endif llvm}
  215. externalname : pshortstring;
  216. {$ifdef symansistr}
  217. cachedmangledname: TSymStr; { mangled name for ObjC or Java }
  218. {$else symansistr}
  219. cachedmangledname: pshortstring; { mangled name for ObjC or Java }
  220. {$endif symansistr}
  221. constructor create(const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);virtual;
  222. constructor ppuload(ppufile:tcompilerppufile);
  223. { do not override this routine in platform-specific subclasses,
  224. override ppuwrite_platform instead }
  225. procedure ppuwrite(ppufile:tcompilerppufile);override;final;
  226. procedure set_externalname(const s:string);virtual;
  227. function bitoffset: asizeuint;
  228. function mangledname:TSymStr;override;
  229. destructor destroy;override;
  230. {$ifdef DEBUG_NODE_XML}
  231. public
  232. procedure XMLPrintFieldData(var T: Text);
  233. {$endif DEBUG_NODE_XML}
  234. end;
  235. tfieldvarsymclass = class of tfieldvarsym;
  236. tabstractnormalvarsym = class(tabstractvarsym)
  237. defaultconstsym : tsym;
  238. defaultconstsymderef : tderef;
  239. { register/reference for local var }
  240. localloc : TLocation;
  241. { initial location so it can still be initialized later after the location was changed by SSA }
  242. initialloc : TLocation;
  243. { migrated to a parentfpstruct because of nested access (not written to ppu, because not important and would change interface crc) }
  244. inparentfpstruct : boolean;
  245. { the variable is not living at entry of the scope, so it does not need to be initialized if it is a reg. var
  246. (not written to ppu, because not important and would change interface crc) }
  247. noregvarinitneeded : boolean;
  248. { not stored in PPU! }
  249. capture_sym : tsym;
  250. constructor create(st:tsymtyp;const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);
  251. constructor ppuload(st:tsymtyp;ppufile:tcompilerppufile);
  252. function globalasmsym: boolean;
  253. procedure ppuwrite(ppufile:tcompilerppufile);override;
  254. procedure buildderef;override;
  255. procedure deref;override;
  256. function is_captured:boolean;
  257. end;
  258. tlocalvarsym = class(tabstractnormalvarsym)
  259. constructor create(const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);virtual;
  260. constructor ppuload(ppufile:tcompilerppufile);
  261. { do not override this routine in platform-specific subclasses,
  262. override ppuwrite_platform instead }
  263. procedure ppuwrite(ppufile:tcompilerppufile);override;final;
  264. end;
  265. tlocalvarsymclass = class of tlocalvarsym;
  266. tparavarsym = class(tabstractnormalvarsym)
  267. paraloc : array[callerside..calleeside] of TCGPara;
  268. paranr : word; { position of this parameter }
  269. { in MacPas mode, "univ" parameters mean that type checking should
  270. be disabled, except that the size of the passed parameter must
  271. match the size of the formal parameter }
  272. univpara : boolean;
  273. {$ifdef EXTDEBUG}
  274. eqval : tequaltype;
  275. {$endif EXTDEBUG}
  276. constructor create(const n : TSymStr;nr:word;vsp:tvarspez;def:tdef;vopts:tvaroptions);virtual;
  277. constructor ppuload(ppufile:tcompilerppufile);
  278. destructor destroy;override;
  279. { do not override this routine in platform-specific subclasses,
  280. override ppuwrite_platform instead }
  281. procedure ppuwrite(ppufile:tcompilerppufile);override;final;
  282. function needs_finalization: boolean;
  283. function is_used: boolean;
  284. end;
  285. tparavarsymclass = class of tparavarsym;
  286. tstaticvarsym = class(tabstractnormalvarsym)
  287. protected
  288. {$ifdef symansistr}
  289. _mangledbasename,
  290. _mangledname : TSymStr;
  291. {$else symansistr}
  292. _mangledbasename,
  293. _mangledname : pshortstring;
  294. {$endif symansistr}
  295. public
  296. section : ansistring;
  297. { if a text buffer has been defined as being initialized from command line
  298. parameters as it is done by iso pascal with the program symbols,
  299. isoindex contains the parameter number }
  300. isoindex : dword;
  301. { if this static variable was created based on a class field variable then this is set
  302. to the symbol of the corresponding class field }
  303. fieldvarsym : tfieldvarsym;
  304. fieldvarsymderef : tderef;
  305. constructor create(const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);virtual;
  306. constructor create_dll(const n : TSymStr;vsp:tvarspez;def:tdef);virtual;
  307. constructor create_C(const n: TSymStr; const mangled : TSymStr;vsp:tvarspez;def:tdef);virtual;
  308. constructor create_from_fieldvar(const n: TSymStr;fieldvar:tfieldvarsym);virtual;
  309. constructor ppuload(ppufile:tcompilerppufile);
  310. destructor destroy;override;
  311. { do not override this routine in platform-specific subclasses,
  312. override ppuwrite_platform instead }
  313. procedure ppuwrite(ppufile:tcompilerppufile);override;final;
  314. procedure buildderef;override;
  315. procedure deref;override;
  316. function mangledname:TSymStr;override;
  317. procedure set_mangledbasename(const s: TSymStr);
  318. function mangledbasename: TSymStr;
  319. procedure set_mangledname(const s:TSymStr);virtual;
  320. procedure set_raw_mangledname(const s:TSymStr);
  321. end;
  322. tstaticvarsymclass = class of tstaticvarsym;
  323. tabsolutevarsym = class(tabstractvarsym)
  324. public
  325. abstyp : absolutetyp;
  326. asmname : pshortstring;
  327. addroffset : PUint;
  328. ref : tpropaccesslist;
  329. constructor create(const n : TSymStr;def:tdef);virtual;
  330. constructor create_ref(const n : TSymStr;def:tdef;_ref:tpropaccesslist);virtual;
  331. destructor destroy;override;
  332. constructor ppuload(ppufile:tcompilerppufile);
  333. procedure buildderef;override;
  334. procedure deref;override;
  335. function mangledname : TSymStr;override;
  336. { do not override this routine in platform-specific subclasses,
  337. override ppuwrite_platform instead }
  338. procedure ppuwrite(ppufile:tcompilerppufile);override;final;
  339. end;
  340. tabsolutevarsymclass = class of tabsolutevarsym;
  341. tpropaccesslisttypes=(palt_none,palt_read,palt_write,palt_stored);
  342. tpropertysym = class(Tstoredsym)
  343. protected
  344. procedure finalize_getter_or_setter_for_sym(getset: tpropaccesslisttypes; sym: tsym; fielddef: tdef; accessordef: tprocdef); virtual;
  345. public
  346. propoptions : tpropertyoptions;
  347. overriddenpropsym : tpropertysym;
  348. overriddenpropsymderef : tderef;
  349. propdef : tdef;
  350. propdefderef : tderef;
  351. indexdef : tdef;
  352. indexdefderef : tderef;
  353. index,
  354. default : longint;
  355. dispid : longint;
  356. propaccesslist: array[tpropaccesslisttypes] of tpropaccesslist;
  357. parast : tsymtable;
  358. constructor create(const n : TSymStr);virtual;
  359. destructor destroy;override;
  360. constructor ppuload(ppufile:tcompilerppufile);
  361. function getsize : asizeint;
  362. { do not override this routine in platform-specific subclasses,
  363. override ppuwrite_platform instead }
  364. procedure ppuwrite(ppufile:tcompilerppufile);override;final;
  365. procedure buildderef;override;
  366. procedure deref;override;
  367. function getpropaccesslist(pap:tpropaccesslisttypes;out plist:tpropaccesslist):boolean;
  368. { copies the settings of the current propertysym to p; a bit like
  369. a form of getcopy, but without the name }
  370. procedure makeduplicate(p: tpropertysym; readprocdef, writeprocdef: tprocdef; out paranr: word);
  371. procedure add_accessor_parameters(readprocdef, writeprocdef: tprocdef);
  372. procedure add_index_parameter(var paranr: word; readprocdef, writeprocdef: tprocdef);
  373. { set up the accessors for this property }
  374. procedure add_getter_or_setter_for_sym(getset: tpropaccesslisttypes; sym: tsym; fielddef: tdef; accessordef: tprocdef);
  375. procedure register_override(overriddenprop: tpropertysym);
  376. { inherit the read/write property }
  377. procedure inherit_accessor(getset: tpropaccesslisttypes); virtual;
  378. end;
  379. tpropertysymclass = class of tpropertysym;
  380. tconstvalue = record
  381. case integer of
  382. 0: (valueord : tconstexprint);
  383. 1: (valueordptr : tconstptruint);
  384. 2: (valueptr : pointer; len : longint);
  385. end;
  386. tconstsym = class(tstoredsym)
  387. constdef : tdef;
  388. constdefderef : tderef;
  389. consttyp : tconsttyp;
  390. value : tconstvalue;
  391. constructor create_ord(const n : TSymStr;t : tconsttyp;v : tconstexprint;def:tdef);virtual;
  392. constructor create_ordptr(const n : TSymStr;t : tconsttyp;v : tconstptruint;def:tdef);virtual;
  393. constructor create_ptr(const n : TSymStr;t : tconsttyp;v : pointer;def:tdef);virtual;
  394. constructor create_string(const n : TSymStr;t : tconsttyp;str:pchar;l:longint;def:tdef);virtual;
  395. constructor create_wstring(const n : TSymStr;t : tconsttyp;pw:pcompilerwidestring);virtual;
  396. constructor create_undefined(const n : TSymStr;def:tdef);virtual;
  397. constructor ppuload(ppufile:tcompilerppufile);
  398. destructor destroy;override;
  399. procedure buildderef;override;
  400. procedure deref;override;
  401. { do not override this routine in platform-specific subclasses,
  402. override ppuwrite_platform instead }
  403. procedure ppuwrite(ppufile:tcompilerppufile);override;final;
  404. {$ifdef DEBUG_NODE_XML}
  405. public
  406. procedure XMLPrintConstData(var T: Text);
  407. {$endif DEBUG_NODE_XML}
  408. end;
  409. tconstsymclass = class of tconstsym;
  410. tenumsym = class(Tstoredsym)
  411. value : longint;
  412. definition : tenumdef;
  413. definitionderef : tderef;
  414. constructor create(const n : TSymStr;def : tenumdef;v : longint);virtual;
  415. constructor ppuload(ppufile:tcompilerppufile);
  416. { do not override this routine in platform-specific subclasses,
  417. override ppuwrite_platform instead }
  418. procedure ppuwrite(ppufile:tcompilerppufile);override;final;
  419. procedure buildderef;override;
  420. procedure deref;override;
  421. end;
  422. tenumsymclass = class of tenumsym;
  423. tsyssym = class(Tstoredsym)
  424. number : tinlinenumber;
  425. constructor create(const n : TSymStr;l : tinlinenumber);virtual;
  426. constructor ppuload(ppufile:tcompilerppufile);
  427. destructor destroy;override;
  428. { do not override this routine in platform-specific subclasses,
  429. override ppuwrite_platform instead }
  430. procedure ppuwrite(ppufile:tcompilerppufile);override;final;
  431. class function find_by_number(l:longint):tsyssym;
  432. end;
  433. tsyssymclass = class of tsyssym;
  434. const
  435. maxmacrolen=16*1024;
  436. type
  437. pmacrobuffer = ^tmacrobuffer;
  438. tmacrobuffer = array[0..maxmacrolen-1] of char;
  439. tmacro = class(tstoredsym)
  440. {Normally true, but false when a previously defined macro is undef-ed}
  441. defined : boolean;
  442. {True if this is a mac style compiler variable, in which case no macro
  443. substitutions shall be done.}
  444. is_compiler_var : boolean;
  445. {Whether the macro was used. NOTE: A use of a macro which was never defined}
  446. {e. g. an IFDEF which returns false, will not be registered as used,}
  447. {since there is no place to register its use. }
  448. is_used : boolean;
  449. buftext : pchar;
  450. buflen : longint;
  451. constructor create(const n : TSymStr);
  452. constructor ppuload(ppufile:tcompilerppufile);
  453. { do not override this routine in platform-specific subclasses,
  454. override ppuwrite_platform instead }
  455. procedure ppuwrite(ppufile:tcompilerppufile);override;final;
  456. destructor destroy;override;
  457. function GetCopy:tmacro;
  458. end;
  459. var
  460. generrorsym : tsym;
  461. clabelsym: tlabelsymclass;
  462. cunitsym: tunitsymclass;
  463. cprogramparasym: tprogramparasymclass;
  464. cnamespacesym: tnamespacesymclass;
  465. cprocsym: tprocsymclass;
  466. ctypesym: ttypesymclass;
  467. cfieldvarsym: tfieldvarsymclass;
  468. clocalvarsym: tlocalvarsymclass;
  469. cparavarsym: tparavarsymclass;
  470. cstaticvarsym: tstaticvarsymclass;
  471. cabsolutevarsym: tabsolutevarsymclass;
  472. cpropertysym: tpropertysymclass;
  473. cconstsym: tconstsymclass;
  474. cenumsym: tenumsymclass;
  475. csyssym: tsyssymclass;
  476. { generate internal static field name based on regular field name }
  477. function internal_static_field_name(const fieldname: TSymStr): TSymStr;
  478. function get_high_value_sym(vs: tparavarsym):tabstractvarsym; { marking it as inline causes IE 200311075 during loading from ppu file }
  479. procedure check_hints(const srsym: tsym; const symoptions: tsymoptions; const deprecatedmsg : pshortstring);inline;
  480. procedure check_hints(const srsym: tsym; const symoptions: tsymoptions; const deprecatedmsg : pshortstring;filepos:tfileposinfo);
  481. function same_constvalue(consttyp:tconsttyp;const value1,value2:tconstvalue):boolean;
  482. implementation
  483. uses
  484. { global }
  485. verbose,
  486. { target }
  487. systems,
  488. { symtable }
  489. defutil,symtable,
  490. fmodule,
  491. { tree }
  492. node,
  493. { aasm }
  494. aasmdata,
  495. { codegen }
  496. paramgr,
  497. procinfo,
  498. { ppu }
  499. entfile,ppu
  500. ;
  501. {****************************************************************************
  502. Helpers
  503. ****************************************************************************}
  504. function internal_static_field_name(const fieldname: TSymStr): TSymStr;
  505. begin
  506. result:='$_static_'+fieldname;
  507. end;
  508. function get_high_value_sym(vs: tparavarsym):tabstractvarsym;
  509. begin
  510. result := tabstractvarsym(vs.owner.Find('high'+vs.name));
  511. end;
  512. function same_constvalue(consttyp:tconsttyp;const value1,value2:tconstvalue):boolean;
  513. begin
  514. result:=false;
  515. case consttyp of
  516. constnone,
  517. constnil:
  518. result:=true;
  519. constord:
  520. result:=value1.valueord=value2.valueord;
  521. constpointer:
  522. result:=value1.valueordptr=value2.valueordptr;
  523. conststring,
  524. constreal,
  525. constset,
  526. constresourcestring,
  527. constwstring,
  528. constguid: begin
  529. if value1.len<>value2.len then
  530. exit(false);
  531. result:=CompareByte(value1.valueptr^,value2.valueptr^,value1.len)=0;
  532. end;
  533. end;
  534. end;
  535. procedure check_hints(const srsym: tsym; const symoptions: tsymoptions; const deprecatedmsg : pshortstring);
  536. begin
  537. check_hints(srsym,symoptions,deprecatedmsg,current_filepos);
  538. end;
  539. procedure check_hints(const srsym: tsym; const symoptions: tsymoptions; const deprecatedmsg : pshortstring;filepos:tfileposinfo);
  540. begin
  541. if not assigned(srsym) then
  542. internalerror(200602051);
  543. if sp_hint_deprecated in symoptions then
  544. if (sp_has_deprecated_msg in symoptions) and (deprecatedmsg <> nil) then
  545. MessagePos2(filepos,sym_w_deprecated_symbol_with_msg,srsym.realname,deprecatedmsg^)
  546. else
  547. MessagePos1(filepos,sym_w_deprecated_symbol,srsym.realname);
  548. if sp_hint_experimental in symoptions then
  549. MessagePos1(filepos,sym_w_experimental_symbol,srsym.realname);
  550. if sp_hint_platform in symoptions then
  551. MessagePos1(filepos,sym_w_non_portable_symbol,srsym.realname);
  552. if sp_hint_library in symoptions then
  553. MessagePos1(filepos,sym_w_library_symbol,srsym.realname);
  554. if sp_hint_unimplemented in symoptions then
  555. MessagePos1(filepos,sym_w_non_implemented_symbol,srsym.realname);
  556. end;
  557. {****************************************************************************
  558. TSYM (base for all symtypes)
  559. ****************************************************************************}
  560. constructor tstoredsym.create(st:tsymtyp;const n : TSymStr);
  561. begin
  562. inherited create(st,n);
  563. end;
  564. constructor tstoredsym.ppuload(st:tsymtyp;ppufile:tcompilerppufile);
  565. begin
  566. {$ifdef symansistr}
  567. inherited Create(st,ppufile.getansistring);
  568. {$else symansistr}
  569. inherited Create(st,ppufile.getstring);
  570. {$endif symansistr}
  571. SymId:=ppufile.getlongint;
  572. current_module.symlist[SymId]:=self;
  573. ppufile.getposinfo(fileinfo);
  574. visibility:=tvisibility(ppufile.getbyte);
  575. ppufile.getset(tppuset2(symoptions));
  576. if sp_has_deprecated_msg in symoptions then
  577. deprecatedmsg:=ppufile.getpshortstring
  578. else
  579. deprecatedmsg:=nil;
  580. rtti_attribute_list:=trtti_attribute_list.ppuload(ppufile);
  581. end;
  582. procedure tstoredsym.ppuwrite(ppufile:tcompilerppufile);
  583. var
  584. oldintfcrc : boolean;
  585. begin
  586. {$ifdef symansistr}
  587. ppufile.putansistring(realname);
  588. {$else}
  589. ppufile.putstring(realname);
  590. {$endif}
  591. ppufile.putlongint(SymId);
  592. ppufile.putposinfo(fileinfo);
  593. ppufile.putbyte(byte(visibility));
  594. { symoptions can differ between interface and implementation, except
  595. for overload (this is checked in pdecsub.proc_add_definition() )
  596. These differences can lead to compiler crashes, so ignore them.
  597. This does mean that changing e.g. the "deprecated" state of a symbol
  598. by itself will not trigger a recompilation of dependent units.
  599. }
  600. oldintfcrc:=ppufile.do_interface_crc;
  601. ppufile.do_interface_crc:=false;
  602. ppufile.putset(tppuset2(symoptions));
  603. if sp_has_deprecated_msg in symoptions then
  604. ppufile.putstring(deprecatedmsg^);
  605. ppufile.do_interface_crc:=oldintfcrc;
  606. trtti_attribute_list.ppuwrite(rtti_attribute_list,ppufile);
  607. end;
  608. procedure tstoredsym.ppuload_subentries(ppufile: tcompilerppufile);
  609. begin
  610. trtti_attribute_list.ppuload_subentries(rtti_attribute_list,ppufile);
  611. end;
  612. procedure tstoredsym.ppuwrite_subentries(ppufile: tcompilerppufile);
  613. begin
  614. trtti_attribute_list.ppuwrite_subentries(rtti_attribute_list,ppufile);
  615. end;
  616. procedure tstoredsym.deref;
  617. begin
  618. inherited;
  619. if assigned(rtti_attribute_list) then
  620. rtti_attribute_list.deref;
  621. end;
  622. procedure tstoredsym.buildderef;
  623. begin
  624. inherited;
  625. if not registered then
  626. register_sym;
  627. if assigned(rtti_attribute_list) then
  628. rtti_attribute_list.buildderef;
  629. end;
  630. procedure tstoredsym.writeentry(ppufile: tcompilerppufile; ibnr: byte);
  631. begin
  632. ppuwrite_platform(ppufile);
  633. ppufile.writeentry(ibnr);
  634. end;
  635. procedure tstoredsym.ppuwrite_platform(ppufile: tcompilerppufile);
  636. begin
  637. { by default: do nothing }
  638. end;
  639. procedure tstoredsym.ppuload_platform(ppufile: tcompilerppufile);
  640. begin
  641. { by default: do nothing }
  642. end;
  643. destructor tstoredsym.destroy;
  644. begin
  645. rtti_attribute_list.free;
  646. inherited destroy;
  647. end;
  648. procedure tstoredsym.register_sym;
  649. begin
  650. if registered then
  651. exit;
  652. { Register in current_module }
  653. if assigned(current_module) then
  654. begin
  655. current_module.symlist.Add(self);
  656. SymId:=current_module.symlist.Count-1;
  657. end
  658. else
  659. SymId:=symid_registered_nost;
  660. end;
  661. {****************************************************************************
  662. TLABELSYM
  663. ****************************************************************************}
  664. constructor tlabelsym.create(const n : TSymStr);
  665. begin
  666. inherited create(labelsym,n);
  667. used:=false;
  668. defined:=false;
  669. nonlocal:=false;
  670. code:=nil;
  671. end;
  672. constructor tlabelsym.ppuload(ppufile:tcompilerppufile);
  673. begin
  674. inherited ppuload(labelsym,ppufile);
  675. code:=nil;
  676. used:=false;
  677. nonlocal:=false;
  678. defined:=true;
  679. ppuload_platform(ppufile);
  680. end;
  681. procedure tlabelsym.ppuwrite(ppufile:tcompilerppufile);
  682. begin
  683. if owner.symtabletype=globalsymtable then
  684. Message(sym_e_ill_label_decl)
  685. else
  686. begin
  687. inherited ppuwrite(ppufile);
  688. writeentry(ppufile,iblabelsym);
  689. end;
  690. end;
  691. function tlabelsym.mangledname:TSymStr;
  692. begin
  693. if (asmblocklabel=nil) then
  694. begin
  695. if nonlocal then
  696. current_asmdata.getglobaljumplabel(asmblocklabel)
  697. else
  698. current_asmdata.getjumplabel(asmblocklabel);
  699. end;
  700. result:=asmblocklabel.name;
  701. end;
  702. {****************************************************************************
  703. TUNITSYM
  704. ****************************************************************************}
  705. constructor tunitsym.create(const n : TSymStr;amodule : tobject);
  706. begin
  707. inherited create(unitsym,n);
  708. module:=amodule;
  709. end;
  710. constructor tunitsym.ppuload(ppufile:tcompilerppufile);
  711. begin
  712. inherited ppuload(unitsym,ppufile);
  713. module:=nil;
  714. ppuload_platform(ppufile);
  715. end;
  716. destructor tunitsym.destroy;
  717. begin
  718. inherited destroy;
  719. end;
  720. procedure tunitsym.ppuwrite(ppufile:tcompilerppufile);
  721. begin
  722. inherited ppuwrite(ppufile);
  723. writeentry(ppufile,ibunitsym);
  724. end;
  725. {****************************************************************************
  726. TPROGRAMPARASYM
  727. ****************************************************************************}
  728. constructor tprogramparasym.create(const n : TSymStr; i : dword);
  729. begin
  730. inherited create(programparasym,n);
  731. isoindex:=i;
  732. end;
  733. constructor tprogramparasym.ppuload(ppufile : tcompilerppufile);
  734. begin
  735. { program parameter syms (iso pascal style) might be never written to a ppu }
  736. internalerror(2015050102);
  737. end;
  738. destructor tprogramparasym.destroy;
  739. begin
  740. inherited destroy;
  741. end;
  742. procedure tprogramparasym.ppuwrite(ppufile : tcompilerppufile);
  743. begin
  744. { program parameter syms (iso pascal style) might be never written to a ppu }
  745. internalerror(2015050101);
  746. end;
  747. {****************************************************************************
  748. TNAMESPACESYM
  749. ****************************************************************************}
  750. constructor tnamespacesym.create(const n : TSymStr);
  751. begin
  752. inherited create(namespacesym,n);
  753. unitsym:=nil;
  754. unitsymderef.reset;
  755. end;
  756. constructor tnamespacesym.ppuload(ppufile:tcompilerppufile);
  757. begin
  758. inherited ppuload(namespacesym,ppufile);
  759. ppufile.getderef(unitsymderef);
  760. ppuload_platform(ppufile);
  761. end;
  762. procedure tnamespacesym.ppuwrite(ppufile:tcompilerppufile);
  763. begin
  764. inherited ppuwrite(ppufile);
  765. ppufile.putderef(unitsymderef);
  766. writeentry(ppufile,ibnamespacesym);
  767. end;
  768. procedure tnamespacesym.buildderef;
  769. begin
  770. inherited buildderef;
  771. unitsymderef.build(unitsym);
  772. end;
  773. procedure tnamespacesym.deref;
  774. begin
  775. inherited deref;
  776. unitsym:=tsym(unitsymderef.resolve);
  777. end;
  778. {****************************************************************************
  779. TPROCSYM
  780. ****************************************************************************}
  781. constructor tprocsym.create(const n : TSymStr);
  782. var
  783. i: longint;
  784. begin
  785. if not(ts_lowercase_proc_start in current_settings.targetswitches) or
  786. (n='') then
  787. inherited create(procsym,n)
  788. else
  789. begin
  790. { YToX -> yToX
  791. RC64Encode -> rc64Encode
  792. Test -> test
  793. }
  794. i:=2;
  795. while i<=length(n) do
  796. begin
  797. if not(n[i] in ['A'..'Z']) then
  798. begin
  799. if (i>2) and
  800. (n[i] in ['a'..'z']) then
  801. dec(i);
  802. break;
  803. end;
  804. inc(i);
  805. end;
  806. inherited create(procsym,lower(copy(n,1,i-1))+copy(n,i,length(n)));
  807. end;
  808. FProcdefList:=TFPObjectList.Create(false);
  809. FProcdefderefList:=nil;
  810. { the tprocdef have their own symoptions, make the procsym
  811. always visible }
  812. visibility:=vis_public;
  813. end;
  814. constructor tprocsym.ppuload(ppufile:tcompilerppufile);
  815. var
  816. symderef,
  817. pdderef : tderef;
  818. i,
  819. symcnt,
  820. pdcnt : longint;
  821. begin
  822. inherited ppuload(procsym,ppufile);
  823. FProcdefList:=TFPObjectList.Create(false);
  824. FProcdefDerefList:=TFPList.Create;
  825. pdcnt:=ppufile.getword;
  826. for i:=1 to pdcnt do
  827. begin
  828. ppufile.getderef(pdderef);
  829. FProcdefDerefList.Add(Pointer(PtrInt(pdderef.dataidx)));
  830. end;
  831. if sp_generic_dummy in symoptions then
  832. begin
  833. fgenprocsymovlds:=tfpobjectlist.create(false);
  834. fgenprocsymovldsderefs:=tfplist.create;
  835. symcnt:=ppufile.getword;
  836. for i:=1 to symcnt do
  837. begin
  838. ppufile.getderef(symderef);
  839. fgenprocsymovldsderefs.add(pointer(ptrint(symderef.dataidx)));
  840. end;
  841. end;
  842. ppuload_platform(ppufile);
  843. end;
  844. destructor tprocsym.destroy;
  845. begin
  846. FProcdefList.Free;
  847. if assigned(FProcdefDerefList) then
  848. FProcdefDerefList.Free;
  849. fgenprocsymovlds.free;
  850. fgenprocsymovldsderefs.free;
  851. inherited destroy;
  852. end;
  853. procedure tprocsym.ppuwrite(ppufile:tcompilerppufile);
  854. var
  855. i : longint;
  856. d : tderef;
  857. begin
  858. inherited ppuwrite(ppufile);
  859. if fprocdefdereflist=nil then
  860. internalerror(2013121801);
  861. ppufile.putword(FProcdefDerefList.Count);
  862. for i:=0 to FProcdefDerefList.Count-1 do
  863. begin
  864. d.dataidx:=PtrInt(FProcdefDerefList[i]);
  865. ppufile.putderef(d);
  866. end;
  867. if sp_generic_dummy in symoptions then
  868. begin
  869. if not assigned(fgenprocsymovldsderefs) then
  870. internalerror(2021010301);
  871. ppufile.putword(fgenprocsymovldsderefs.count);
  872. for i:=0 to fgenprocsymovldsderefs.count-1 do
  873. begin
  874. d.dataidx:=ptrint(fgenprocsymovldsderefs[i]);
  875. ppufile.putderef(d);
  876. end;
  877. end;
  878. writeentry(ppufile,ibprocsym);
  879. end;
  880. procedure tprocsym.write_parameter_lists(skipdef:tprocdef);
  881. var
  882. i : longint;
  883. pd : tprocdef;
  884. begin
  885. for i:=0 to ProcdefList.Count-1 do
  886. begin
  887. pd:=tprocdef(ProcdefList[i]);
  888. if pd<>skipdef then
  889. MessagePos1(pd.fileinfo,sym_e_param_list,pd.fullprocname(false));
  890. end;
  891. end;
  892. procedure tprocsym.check_forward;
  893. var
  894. i : longint;
  895. pd : tprocdef;
  896. begin
  897. for i:=0 to ProcdefList.Count-1 do
  898. begin
  899. pd:=tprocdef(ProcdefList[i]);
  900. if (pd.owner=owner) and (pd.forwarddef) then
  901. begin
  902. { For mode macpas. Make implicit externals (procedures declared in the interface
  903. section which do not have a counterpart in the implementation)
  904. to be an imported procedure }
  905. if (m_mac in current_settings.modeswitches) and
  906. (pd.interfacedef) then
  907. begin
  908. pd.setmangledname(target_info.CPrefix+tprocdef(pd).procsym.realname);
  909. if (not current_module.interface_only) then
  910. MessagePos1(pd.fileinfo,sym_w_forward_not_resolved,pd.fullprocname(false));
  911. end
  912. else
  913. begin
  914. MessagePos1(pd.fileinfo,sym_e_forward_not_resolved,pd.fullprocname(false));
  915. end;
  916. { Turn further error messages off }
  917. pd.forwarddef:=false;
  918. end;
  919. end;
  920. end;
  921. procedure tprocsym.buildderef;
  922. var
  923. i : longint;
  924. pd : tprocdef;
  925. d : tderef;
  926. sym : tprocsym;
  927. begin
  928. inherited;
  929. if not assigned(FProcdefDerefList) then
  930. FProcdefDerefList:=TFPList.Create
  931. else
  932. FProcdefDerefList.Clear;
  933. for i:=0 to ProcdefList.Count-1 do
  934. begin
  935. pd:=tprocdef(ProcdefList[i]);
  936. { only write the proc definitions that belong
  937. to this procsym and are in the global symtable }
  938. if pd.owner=owner then
  939. begin
  940. d.build(pd);
  941. FProcdefDerefList.Add(Pointer(PtrInt(d.dataidx)));
  942. end;
  943. end;
  944. if sp_generic_dummy in symoptions then
  945. begin
  946. if not assigned(fgenprocsymovlds) then
  947. internalerror(2021010602);
  948. if not assigned(fgenprocsymovldsderefs) then
  949. fgenprocsymovldsderefs:=tfplist.create
  950. else
  951. fgenprocsymovldsderefs.clear;
  952. for i:=0 to fgenprocsymovlds.count-1 do
  953. begin
  954. sym:=tprocsym(fgenprocsymovlds[i]);
  955. d.build(sym);
  956. fgenprocsymovldsderefs.add(pointer(ptrint(d.dataidx)));
  957. end;
  958. end;
  959. end;
  960. procedure tprocsym.deref;
  961. var
  962. i : longint;
  963. pd : tprocdef;
  964. d : tderef;
  965. sym : tsym;
  966. begin
  967. { Clear all procdefs }
  968. ProcdefList.Clear;
  969. if not assigned(FProcdefDerefList) then
  970. internalerror(200611031);
  971. for i:=0 to FProcdefDerefList.Count-1 do
  972. begin
  973. d.dataidx:=PtrInt(FProcdefDerefList[i]);
  974. pd:=tprocdef(d.resolve);
  975. ProcdefList.Add(pd);
  976. end;
  977. if sp_generic_dummy in symoptions then
  978. begin
  979. if not assigned(fgenprocsymovlds) then
  980. internalerror(2021010603);
  981. if not assigned(fgenprocsymovldsderefs) then
  982. internalerror(2021010302);
  983. fgenprocsymovlds.clear;
  984. for i:= 0 to fgenprocsymovldsderefs.count-1 do
  985. begin
  986. d.dataidx:=ptrint(fgenprocsymovldsderefs[i]);
  987. sym:=tprocsym(d.resolve);
  988. fgenprocsymovlds.add(sym);
  989. end;
  990. end;
  991. end;
  992. function Tprocsym.Find_procdef_bytype(pt:Tproctypeoption):Tprocdef;
  993. var
  994. i : longint;
  995. pd : tprocdef;
  996. begin
  997. result:=nil;
  998. for i:=0 to ProcdefList.Count-1 do
  999. begin
  1000. pd:=tprocdef(ProcdefList[i]);
  1001. if pd.proctypeoption=pt then
  1002. begin
  1003. result:=pd;
  1004. exit;
  1005. end;
  1006. end;
  1007. end;
  1008. function tprocsym.find_bytype_parameterless(pt: Tproctypeoption): Tprocdef;
  1009. var
  1010. i,j : longint;
  1011. pd : tprocdef;
  1012. found : boolean;
  1013. begin
  1014. result:=nil;
  1015. for i:=0 to ProcdefList.Count-1 do
  1016. begin
  1017. pd:=tprocdef(ProcdefList[i]);
  1018. if (pd.proctypeoption=pt) then
  1019. begin
  1020. found:=true;
  1021. for j:=0 to pd.paras.count-1 do
  1022. begin
  1023. if not(vo_is_hidden_para in tparavarsym(pd.paras[j]).varoptions) then
  1024. begin
  1025. found:=false;
  1026. break;
  1027. end;
  1028. end;
  1029. if found then
  1030. begin
  1031. result:=pd;
  1032. exit;
  1033. end;
  1034. end;
  1035. end;
  1036. end;
  1037. function check_procdef_paras(pd:tprocdef;para:TFPObjectList;retdef:tdef;
  1038. cpoptions:tcompare_paras_options): tprocdef;
  1039. var
  1040. eq: tequaltype;
  1041. begin
  1042. result:=nil;
  1043. if assigned(retdef) then
  1044. eq:=compare_defs(retdef,pd.returndef,nothingn)
  1045. else
  1046. eq:=te_equal;
  1047. if (eq>=te_equal) or
  1048. ((cpo_allowconvert in cpoptions) and (eq>te_incompatible)) then
  1049. begin
  1050. eq:=compare_paras(para,pd.paras,cp_value_equal_const,cpoptions);
  1051. if (eq>=te_equal) or
  1052. ((cpo_allowconvert in cpoptions) and (eq>te_incompatible)) then
  1053. begin
  1054. result:=pd;
  1055. exit;
  1056. end;
  1057. end;
  1058. end;
  1059. function Tprocsym.Find_procdef_bypara(para:TFPObjectList;retdef:tdef;
  1060. cpoptions:tcompare_paras_options):Tprocdef;
  1061. var
  1062. i : longint;
  1063. pd : tprocdef;
  1064. begin
  1065. result:=nil;
  1066. for i:=0 to ProcdefList.Count-1 do
  1067. begin
  1068. pd:=tprocdef(ProcdefList[i]);
  1069. result:=check_procdef_paras(pd,para,retdef,cpoptions);
  1070. if assigned(result) then
  1071. exit;
  1072. end;
  1073. end;
  1074. function Tprocsym.find_procdef_bytype_and_para(pt:Tproctypeoption;
  1075. para:TFPObjectList;retdef:tdef;cpoptions:tcompare_paras_options):Tprocdef;
  1076. var
  1077. i : longint;
  1078. pd : tprocdef;
  1079. begin
  1080. result:=nil;
  1081. for i:=0 to ProcdefList.Count-1 do
  1082. begin
  1083. pd:=tprocdef(ProcdefList[i]);
  1084. if pd.proctypeoption=pt then
  1085. begin
  1086. result:=check_procdef_paras(pd,para,retdef,cpoptions);
  1087. if assigned(result) then
  1088. exit;
  1089. end;
  1090. end;
  1091. end;
  1092. function tprocsym.find_procdef_byoptions(ops: tprocoptions): Tprocdef;
  1093. var
  1094. i : longint;
  1095. pd : tprocdef;
  1096. begin
  1097. result:=nil;
  1098. for i:=0 to ProcdefList.Count-1 do
  1099. begin
  1100. pd:=tprocdef(ProcdefList[i]);
  1101. if ops * pd.procoptions = ops then
  1102. begin
  1103. result:=pd;
  1104. exit;
  1105. end;
  1106. end;
  1107. end;
  1108. function Tprocsym.find_procdef_with_comparer(comparer:tprocdefcomparer;arg:tobject):tprocdef;
  1109. var
  1110. i : longint;
  1111. bestpd,
  1112. pd : tprocdef;
  1113. eq,besteq : tequaltype;
  1114. sym: tsym;
  1115. ps: tprocsym;
  1116. begin
  1117. { This function will return the pprocdef of pprocsym that
  1118. is the best match for procvardef. When there are multiple
  1119. matches it returns nil.}
  1120. result:=nil;
  1121. bestpd:=nil;
  1122. besteq:=te_incompatible;
  1123. ps:=self;
  1124. repeat
  1125. for i:=0 to ps.ProcdefList.Count-1 do
  1126. begin
  1127. pd:=tprocdef(ps.ProcdefList[i]);
  1128. eq:=comparer(pd,arg);
  1129. if eq>=te_convert_l1 then
  1130. begin
  1131. { multiple procvars with the same equal level }
  1132. if assigned(bestpd) and
  1133. (besteq=eq) then
  1134. exit;
  1135. if eq>besteq then
  1136. begin
  1137. besteq:=eq;
  1138. bestpd:=pd;
  1139. end;
  1140. end;
  1141. end;
  1142. { maybe TODO: also search class helpers? -- this code is similar to
  1143. what happens in htypechk in
  1144. tcallcandidates.collect_overloads_in_struct: keep searching in
  1145. parent types in case the currently found procdef is marked as
  1146. "overload" and we haven't found a proper match yet }
  1147. if assigned(ps.owner.defowner) and
  1148. (ps.owner.defowner.typ=objectdef) and
  1149. assigned(tobjectdef(ps.owner.defowner).childof) and
  1150. (not assigned(bestpd) or
  1151. (po_overload in bestpd.procoptions)) then
  1152. begin
  1153. sym:=tsym(tobjectdef(ps.owner.defowner).childof.symtable.find(ps.name));
  1154. if assigned(sym) and
  1155. (sym.typ=procsym) then
  1156. ps:=tprocsym(sym)
  1157. else
  1158. ps:=nil;
  1159. end
  1160. else
  1161. ps:=nil;
  1162. until (besteq>=te_equal) or
  1163. not assigned(ps);
  1164. result:=bestpd;
  1165. end;
  1166. class function Tprocsym.compare_procvardef(pd:tprocdef;arg:tobject):tequaltype;
  1167. begin
  1168. result:=proc_to_procvar_equal(pd,tprocvardef(arg),false);
  1169. end;
  1170. class function Tprocsym.compare_funcrefdef(pd:tprocdef;arg:tobject):tequaltype;
  1171. begin
  1172. result:=proc_to_funcref_equal(pd,tobjectdef(arg));
  1173. end;
  1174. function Tprocsym.Find_procdef_byprocvardef(d:Tprocvardef):Tprocdef;
  1175. begin
  1176. result:=find_procdef_with_comparer(@compare_procvardef,d);
  1177. end;
  1178. function Tprocsym.Find_procdef_byfuncrefdef(d:tobjectdef):Tprocdef;
  1179. begin
  1180. if not is_invokable(d) then
  1181. internalerror(2022033001);
  1182. result:=find_procdef_with_comparer(@compare_funcrefdef,d);
  1183. end;
  1184. function Tprocsym.Find_procdef_assignment_operator(fromdef,todef:tdef;var besteq:tequaltype;isexplicit:boolean):Tprocdef;
  1185. var
  1186. paraidx, realparamcount,
  1187. i, j : longint;
  1188. bestpd,
  1189. hpd,
  1190. pd : tprocdef;
  1191. convtyp : tconverttype;
  1192. eq : tequaltype;
  1193. shortstringcount : longint;
  1194. checkshortstring,
  1195. isgenshortstring : boolean;
  1196. begin
  1197. { This function will return the pprocdef of pprocsym that
  1198. is the best match for fromdef and todef. }
  1199. result:=nil;
  1200. bestpd:=nil;
  1201. besteq:=te_incompatible;
  1202. { special handling for assignment operators overloads to shortstring:
  1203. for implicit assignment we pick the ShortString one if available and
  1204. only pick one with specific length if it is the *only* one }
  1205. shortstringcount:=0;
  1206. checkshortstring:=not isexplicit and
  1207. is_shortstring(todef) and
  1208. (tstringdef(todef).len<>255);
  1209. for i:=0 to ProcdefList.Count-1 do
  1210. begin
  1211. pd:=tprocdef(ProcdefList[i]);
  1212. if (pd.owner.symtabletype=staticsymtable) and not pd.owner.iscurrentunit then
  1213. continue;
  1214. if (equal_defs(todef,pd.returndef) or
  1215. { shortstrings of different lengths are ok as result }
  1216. (not isexplicit and is_shortstring(todef) and is_shortstring(pd.returndef))) and
  1217. { the result type must be always really equal and not an alias,
  1218. if you mess with this code, check tw4093 }
  1219. ((todef=pd.returndef) or
  1220. (
  1221. not(df_unique in todef.defoptions) and
  1222. not(df_unique in pd.returndef.defoptions)
  1223. )
  1224. ) then
  1225. begin
  1226. paraidx:=0;
  1227. { ignore vs_hidden parameters }
  1228. while (paraidx<pd.paras.count) and
  1229. assigned(pd.paras[paraidx]) and
  1230. (vo_is_hidden_para in tparavarsym(pd.paras[paraidx]).varoptions) do
  1231. inc(paraidx);
  1232. realparamcount:=0;
  1233. for j := 0 to pd.paras.Count-1 do
  1234. if assigned(pd.paras[j]) and not (vo_is_hidden_para in tparavarsym(pd.paras[j]).varoptions) then
  1235. inc(realparamcount);
  1236. if (paraidx<pd.paras.count) and
  1237. assigned(pd.paras[paraidx]) and
  1238. (realparamcount = 1) then
  1239. begin
  1240. eq:=compare_defs_ext(fromdef,tparavarsym(pd.paras[paraidx]).vardef,nothingn,convtyp,hpd,[]);
  1241. { alias? if yes, only l1 choice,
  1242. if you mess with this code, check tw4093 }
  1243. if (eq=te_exact) and
  1244. (fromdef<>tparavarsym(pd.paras[paraidx]).vardef) and
  1245. ((df_unique in fromdef.defoptions) or
  1246. (df_unique in tparavarsym(pd.paras[paraidx]).vardef.defoptions)) then
  1247. eq:=te_convert_l1;
  1248. isgenshortstring:=false;
  1249. if checkshortstring and is_shortstring(pd.returndef) then
  1250. if tstringdef(pd.returndef).len<>255 then
  1251. inc(shortstringcount)
  1252. else
  1253. isgenshortstring:=true;
  1254. if (eq=te_exact) and (not checkshortstring or isgenshortstring) then
  1255. begin
  1256. besteq:=eq;
  1257. result:=pd;
  1258. exit;
  1259. end;
  1260. if eq>besteq then
  1261. begin
  1262. bestpd:=pd;
  1263. besteq:=eq;
  1264. end;
  1265. end;
  1266. end;
  1267. end;
  1268. if checkshortstring and (shortstringcount>1) then
  1269. begin
  1270. besteq:=te_incompatible;
  1271. bestpd:=nil;
  1272. end;
  1273. result:=bestpd;
  1274. end;
  1275. function Tprocsym.find_procdef_enumerator_operator(fromdef,todef:tdef;var besteq:tequaltype):Tprocdef;
  1276. var
  1277. paraidx, realparamcount,
  1278. i, j : longint;
  1279. bestpd,
  1280. hpd,
  1281. pd : tprocdef;
  1282. current : tpropertysym;
  1283. convtyp : tconverttype;
  1284. eq : tequaltype;
  1285. begin
  1286. { This function will return the pprocdef of pprocsym that
  1287. is the best match for fromdef and todef. }
  1288. result:=nil;
  1289. bestpd:=nil;
  1290. besteq:=te_incompatible;
  1291. for i:=0 to ProcdefList.Count-1 do
  1292. begin
  1293. pd:=tprocdef(ProcdefList[i]);
  1294. if (pd.owner.symtabletype=staticsymtable) and not pd.owner.iscurrentunit then
  1295. continue;
  1296. if not (is_class_or_interface_or_object(pd.returndef) or is_record(pd.returndef)) then
  1297. continue;
  1298. current := tpropertysym(tabstractrecorddef(pd.returndef).search_enumerator_current);
  1299. if (current = nil) then
  1300. continue;
  1301. // compare current result def with the todef
  1302. if (equal_defs(todef, current.propdef) or
  1303. { shortstrings of different lengths are ok as result }
  1304. (is_shortstring(todef) and is_shortstring(current.propdef))) and
  1305. { the result type must be always really equal and not an alias,
  1306. if you mess with this code, check tw4093 }
  1307. ((todef=current.propdef) or
  1308. (
  1309. not(df_unique in todef.defoptions) and
  1310. not(df_unique in current.propdef.defoptions)
  1311. )
  1312. ) then
  1313. begin
  1314. paraidx:=0;
  1315. { ignore vs_hidden parameters }
  1316. while (paraidx<pd.paras.count) and
  1317. assigned(pd.paras[paraidx]) and
  1318. (vo_is_hidden_para in tparavarsym(pd.paras[paraidx]).varoptions) do
  1319. inc(paraidx);
  1320. realparamcount:=0;
  1321. for j := 0 to pd.paras.Count-1 do
  1322. if assigned(pd.paras[j]) and not (vo_is_hidden_para in tparavarsym(pd.paras[j]).varoptions) then
  1323. inc(realparamcount);
  1324. if (paraidx<pd.paras.count) and
  1325. assigned(pd.paras[paraidx]) and
  1326. (realparamcount = 1) then
  1327. begin
  1328. eq:=compare_defs_ext(fromdef,tparavarsym(pd.paras[paraidx]).vardef,nothingn,convtyp,hpd,[]);
  1329. { alias? if yes, only l1 choice,
  1330. if you mess with this code, check tw4093 }
  1331. if (eq=te_exact) and
  1332. (fromdef<>tparavarsym(pd.paras[paraidx]).vardef) and
  1333. ((df_unique in fromdef.defoptions) or
  1334. (df_unique in tparavarsym(pd.paras[paraidx]).vardef.defoptions)) then
  1335. eq:=te_convert_l1;
  1336. if eq=te_exact then
  1337. begin
  1338. besteq:=eq;
  1339. result:=pd;
  1340. exit;
  1341. end;
  1342. if eq>besteq then
  1343. begin
  1344. bestpd:=pd;
  1345. besteq:=eq;
  1346. end;
  1347. end;
  1348. end;
  1349. end;
  1350. result:=bestpd;
  1351. end;
  1352. procedure tprocsym.add_generic_overload(sym:tprocsym);
  1353. var
  1354. i : longint;
  1355. begin
  1356. if not (sp_generic_dummy in symoptions) then
  1357. internalerror(2021010601);
  1358. if not assigned(fgenprocsymovlds) then
  1359. fgenprocsymovlds:=tfpobjectlist.create(false);
  1360. for i:=0 to genprocsymovlds.count-1 do
  1361. if tprocsym(genprocsymovlds[i])=sym then
  1362. exit;
  1363. genprocsymovlds.add(sym);
  1364. end;
  1365. function tprocsym.could_be_implicitly_specialized:boolean;
  1366. begin
  1367. result:=(m_implicit_function_specialization in current_settings.modeswitches) and
  1368. (sp_generic_dummy in symoptions) and
  1369. assigned(genprocsymovlds);
  1370. end;
  1371. {****************************************************************************
  1372. TERRORSYM
  1373. ****************************************************************************}
  1374. constructor terrorsym.create;
  1375. begin
  1376. inherited create(errorsym,'');
  1377. end;
  1378. procedure terrorsym.register_sym;
  1379. begin
  1380. { these should never be written to a ppu file, since they don't
  1381. derive from tstoredsym }
  1382. Internalerror(2015101801);
  1383. end;
  1384. {****************************************************************************
  1385. TPROPERTYSYM
  1386. ****************************************************************************}
  1387. procedure tpropertysym.finalize_getter_or_setter_for_sym(getset: tpropaccesslisttypes; sym: tsym; fielddef: tdef; accessordef: tprocdef);
  1388. begin
  1389. { do nothing by default }
  1390. end;
  1391. constructor tpropertysym.create(const n : TSymStr);
  1392. var
  1393. pap : tpropaccesslisttypes;
  1394. begin
  1395. inherited create(propertysym,n);
  1396. propoptions:=[];
  1397. index:=0;
  1398. default:=0;
  1399. propdef:=nil;
  1400. propdefderef.reset;
  1401. indexdef:=nil;
  1402. indexdefderef.reset;
  1403. parast:=nil;
  1404. for pap:=low(tpropaccesslisttypes) to high(tpropaccesslisttypes) do
  1405. propaccesslist[pap]:=tpropaccesslist.create;
  1406. end;
  1407. constructor tpropertysym.ppuload(ppufile:tcompilerppufile);
  1408. var
  1409. pap : tpropaccesslisttypes;
  1410. begin
  1411. inherited ppuload(propertysym,ppufile);
  1412. ppufile.getset(tppuset2(propoptions));
  1413. if ppo_overrides in propoptions then
  1414. ppufile.getderef(overriddenpropsymderef);
  1415. ppufile.getderef(propdefderef);
  1416. index:=ppufile.getlongint;
  1417. default:=ppufile.getlongint;
  1418. ppufile.getderef(indexdefderef);
  1419. for pap:=low(tpropaccesslisttypes) to high(tpropaccesslisttypes) do
  1420. propaccesslist[pap]:=ppufile.getpropaccesslist;
  1421. ppuload_platform(ppufile);
  1422. if [ppo_hasparameters,ppo_overrides]*propoptions=[ppo_hasparameters] then
  1423. begin
  1424. parast:=tparasymtable.create(nil,0);
  1425. tparasymtable(parast).ppuload(ppufile);
  1426. end
  1427. else
  1428. parast:=nil;
  1429. end;
  1430. destructor tpropertysym.destroy;
  1431. var
  1432. pap : tpropaccesslisttypes;
  1433. begin
  1434. for pap:=low(tpropaccesslisttypes) to high(tpropaccesslisttypes) do
  1435. propaccesslist[pap].free;
  1436. parast.free;
  1437. inherited destroy;
  1438. end;
  1439. procedure tpropertysym.buildderef;
  1440. var
  1441. pap : tpropaccesslisttypes;
  1442. begin
  1443. inherited;
  1444. propdefderef.build(propdef);
  1445. indexdefderef.build(indexdef);
  1446. for pap:=low(tpropaccesslisttypes) to high(tpropaccesslisttypes) do
  1447. propaccesslist[pap].buildderef;
  1448. if ppo_overrides in propoptions then
  1449. overriddenpropsymderef.build(overriddenpropsym)
  1450. else
  1451. if ppo_hasparameters in propoptions then
  1452. tparasymtable(parast).buildderef;
  1453. end;
  1454. procedure tpropertysym.deref;
  1455. var
  1456. pap : tpropaccesslisttypes;
  1457. begin
  1458. indexdef:=tdef(indexdefderef.resolve);
  1459. propdef:=tdef(propdefderef.resolve);
  1460. for pap:=low(tpropaccesslisttypes) to high(tpropaccesslisttypes) do
  1461. propaccesslist[pap].resolve;
  1462. if ppo_overrides in propoptions then
  1463. begin
  1464. overriddenpropsym:=tpropertysym(overriddenpropsymderef.resolve);
  1465. if ppo_hasparameters in propoptions then
  1466. parast:=overriddenpropsym.parast.getcopy;
  1467. end
  1468. else
  1469. if ppo_hasparameters in propoptions then
  1470. tparasymtable(parast).deref(false)
  1471. end;
  1472. function tpropertysym.getpropaccesslist(pap:tpropaccesslisttypes;out plist:tpropaccesslist):boolean;
  1473. var
  1474. hpropsym : tpropertysym;
  1475. begin
  1476. result:=false;
  1477. { find property in the overridden list }
  1478. hpropsym:=self;
  1479. repeat
  1480. plist:=hpropsym.propaccesslist[pap];
  1481. if not plist.empty then
  1482. begin
  1483. result:=true;
  1484. exit;
  1485. end;
  1486. hpropsym:=hpropsym.overriddenpropsym;
  1487. until not assigned(hpropsym);
  1488. end;
  1489. procedure tpropertysym.add_accessor_parameters(readprocdef, writeprocdef: tprocdef);
  1490. var
  1491. i: integer;
  1492. orig, hparavs: tparavarsym;
  1493. begin
  1494. for i := 0 to parast.SymList.Count - 1 do
  1495. begin
  1496. orig:=tparavarsym(parast.SymList[i]);
  1497. if assigned(readprocdef) then
  1498. begin
  1499. hparavs:=cparavarsym.create(orig.RealName,orig.paranr,orig.varspez,orig.vardef,[]);
  1500. readprocdef.parast.insertsym(hparavs);
  1501. end;
  1502. if assigned(writeprocdef) then
  1503. begin
  1504. hparavs:=cparavarsym.create(orig.RealName,orig.paranr,orig.varspez,orig.vardef,[]);
  1505. writeprocdef.parast.insertsym(hparavs);
  1506. end;
  1507. end;
  1508. end;
  1509. procedure tpropertysym.add_index_parameter(var paranr: word; readprocdef, writeprocdef: tprocdef);
  1510. var
  1511. hparavs: tparavarsym;
  1512. begin
  1513. inc(paranr);
  1514. if assigned(readprocdef) then
  1515. begin
  1516. hparavs:=cparavarsym.create('$index',10*paranr,vs_value,indexdef,[]);
  1517. readprocdef.parast.insertsym(hparavs);
  1518. end;
  1519. if assigned(writeprocdef) then
  1520. begin
  1521. hparavs:=cparavarsym.create('$index',10*paranr,vs_value,indexdef,[]);
  1522. writeprocdef.parast.insertsym(hparavs);
  1523. end;
  1524. end;
  1525. procedure tpropertysym.add_getter_or_setter_for_sym(getset: tpropaccesslisttypes; sym: tsym; fielddef: tdef; accessordef: tprocdef);
  1526. var
  1527. cpo: tcompare_paras_options;
  1528. begin
  1529. case sym.typ of
  1530. procsym :
  1531. begin
  1532. { search procdefs matching accessordef }
  1533. { we ignore hidden stuff here because the property access symbol might have
  1534. non default calling conventions which might change the hidden stuff;
  1535. see tw3216.pp (FK) }
  1536. cpo:=[cpo_allowdefaults,cpo_ignorehidden];
  1537. { allow var-parameters for setters in case of VARPROPSETTER+ }
  1538. if (getset=palt_write) and
  1539. (cs_varpropsetter in current_settings.localswitches) then
  1540. include(cpo,cpo_ignorevarspez);
  1541. propaccesslist[getset].procdef:=tprocsym(sym).find_procdef_bypara(accessordef.paras,accessordef.returndef,cpo);
  1542. if not assigned(propaccesslist[getset].procdef) or
  1543. { because of cpo_ignorehidden we need to compare if it is a static class method and we have a class property }
  1544. ((sp_static in symoptions)<>tprocdef(propaccesslist[getset].procdef).no_self_node) then
  1545. Message(parser_e_ill_property_access_sym)
  1546. else
  1547. finalize_getter_or_setter_for_sym(getset,sym,fielddef,accessordef);
  1548. end;
  1549. fieldvarsym :
  1550. begin
  1551. if not assigned(fielddef) then
  1552. internalerror(200310071);
  1553. if compare_defs(fielddef,propdef,nothingn)>=te_equal then
  1554. begin
  1555. { property parameters are allowed if this is
  1556. an indexed property, because the index is then
  1557. the parameter.
  1558. Note: In the help of Kylix it is written
  1559. that it isn't allowed, but the compiler accepts it (PFV) }
  1560. if (ppo_hasparameters in propoptions) or
  1561. ((sp_static in symoptions) <> (sp_static in sym.symoptions)) then
  1562. Message(parser_e_ill_property_access_sym)
  1563. else
  1564. finalize_getter_or_setter_for_sym(getset,sym,fielddef,accessordef);
  1565. end
  1566. else
  1567. IncompatibleTypes(fielddef,propdef);
  1568. end;
  1569. else
  1570. Message(parser_e_ill_property_access_sym);
  1571. end;
  1572. end;
  1573. procedure tpropertysym.register_override(overriddenprop: tpropertysym);
  1574. begin
  1575. overriddenpropsym:=tpropertysym(overriddenprop);
  1576. include(propoptions,ppo_overrides);
  1577. end;
  1578. procedure tpropertysym.inherit_accessor(getset: tpropaccesslisttypes);
  1579. begin
  1580. { nothing to do by default }
  1581. end;
  1582. procedure tpropertysym.makeduplicate(p: tpropertysym; readprocdef, writeprocdef: tprocdef; out paranr: word);
  1583. begin
  1584. { inherit all type related entries }
  1585. p.indexdef:=indexdef;
  1586. p.propdef:=propdef;
  1587. p.index:=index;
  1588. p.default:=default;
  1589. p.propoptions:=propoptions;
  1590. paranr:=0;
  1591. if ppo_hasparameters in propoptions then
  1592. begin
  1593. p.parast:=parast.getcopy;
  1594. p.add_accessor_parameters(readprocdef,writeprocdef);
  1595. paranr:=p.parast.SymList.Count;
  1596. end;
  1597. if ppo_indexed in p.propoptions then
  1598. p.add_index_parameter(paranr,readprocdef,writeprocdef);
  1599. end;
  1600. function tpropertysym.getsize : asizeint;
  1601. begin
  1602. getsize:=0;
  1603. end;
  1604. procedure tpropertysym.ppuwrite(ppufile:tcompilerppufile);
  1605. var
  1606. pap : tpropaccesslisttypes;
  1607. begin
  1608. inherited ppuwrite(ppufile);
  1609. ppufile.putset(tppuset2(propoptions));
  1610. if ppo_overrides in propoptions then
  1611. ppufile.putderef(overriddenpropsymderef);
  1612. ppufile.putderef(propdefderef);
  1613. ppufile.putlongint(index);
  1614. ppufile.putlongint(default);
  1615. ppufile.putderef(indexdefderef);
  1616. for pap:=low(tpropaccesslisttypes) to high(tpropaccesslisttypes) do
  1617. ppufile.putpropaccesslist(propaccesslist[pap]);
  1618. writeentry(ppufile,ibpropertysym);
  1619. if [ppo_hasparameters,ppo_overrides]*propoptions=[ppo_hasparameters] then
  1620. tparasymtable(parast).ppuwrite(ppufile);
  1621. end;
  1622. {****************************************************************************
  1623. TABSTRACTVARSYM
  1624. ****************************************************************************}
  1625. constructor tabstractvarsym.create(st:tsymtyp;const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);
  1626. begin
  1627. inherited create(st,n);
  1628. vardef:=def;
  1629. vardefderef.reset;
  1630. varspez:=vsp;
  1631. varstate:=vs_declared;
  1632. varoptions:=vopts;
  1633. end;
  1634. constructor tabstractvarsym.ppuload(st:tsymtyp;ppufile:tcompilerppufile);
  1635. begin
  1636. inherited ppuload(st,ppufile);
  1637. varstate:=vs_readwritten;
  1638. varspez:=tvarspez(ppufile.getbyte);
  1639. varregable:=tvarregable(ppufile.getbyte);
  1640. ppufile.getset(tppuset1(varsymaccess));
  1641. ppufile.getderef(vardefderef);
  1642. ppufile.getset(tppuset4(varoptions));
  1643. end;
  1644. procedure tabstractvarsym.buildderef;
  1645. begin
  1646. inherited;
  1647. vardefderef.build(vardef);
  1648. end;
  1649. procedure tabstractvarsym.deref;
  1650. begin
  1651. { assigning vardef also updates varregable. We just loaded this }
  1652. { value from a ppu, so it must not be changed (e.g. tw7817a.pp/ }
  1653. { tw7817b.pp: the address is taken of a local variable in an }
  1654. { inlined procedure -> must remain non-regable when inlining) }
  1655. setvardef(tdef(vardefderef.resolve));
  1656. end;
  1657. procedure tabstractvarsym.ppuwrite(ppufile:tcompilerppufile);
  1658. var
  1659. oldintfcrc : boolean;
  1660. begin
  1661. inherited ppuwrite(ppufile);
  1662. ppufile.putbyte(byte(varspez));
  1663. oldintfcrc:=ppufile.do_crc;
  1664. ppufile.do_crc:=false;
  1665. ppufile.putbyte(byte(varregable));
  1666. ppufile.putset(tppuset1(varsymaccess));
  1667. ppufile.do_crc:=oldintfcrc;
  1668. ppufile.putderef(vardefderef);
  1669. ppufile.putset(tppuset4(varoptions));
  1670. end;
  1671. function tabstractvarsym.getsize : asizeint;
  1672. begin
  1673. if assigned(vardef) and
  1674. ((vardef.typ<>arraydef) or
  1675. is_dynamic_array(vardef) or
  1676. (tarraydef(vardef).highrange>=tarraydef(vardef).lowrange)) then
  1677. result:=vardef.size
  1678. else
  1679. result:=0;
  1680. end;
  1681. function tabstractvarsym.getpackedbitsize : longint;
  1682. begin
  1683. { bitpacking is only done for ordinals }
  1684. if not is_ordinal(vardef) then
  1685. internalerror(2006082010);
  1686. result:=vardef.packedbitsize;
  1687. end;
  1688. function tabstractvarsym.is_regvar(refpara: boolean):boolean;
  1689. var
  1690. tempdef : tdef;
  1691. begin
  1692. { Register variables are not allowed in the following cases:
  1693. - regvars are disabled
  1694. - exceptions are used (after an exception is raised the contents of the
  1695. registers is not valid anymore)
  1696. - it has a local copy
  1697. - the value needs to be in memory (i.e. reference counted) }
  1698. result:=(cs_opt_regvar in current_settings.optimizerswitches) and
  1699. not(pi_has_assembler_block in current_procinfo.flags) and
  1700. not(pi_uses_exceptions in current_procinfo.flags) and
  1701. not(pi_has_interproclabel in current_procinfo.flags) and
  1702. ((refpara and
  1703. (varregable <> vr_none)) or
  1704. (not refpara and
  1705. not(varregable in [vr_none,vr_addr])))
  1706. {$if not defined(powerpc) and not defined(powerpc64)}
  1707. and ((vardef.typ <> recorddef) or
  1708. (varregable = vr_addr) or
  1709. tabstractrecordsymtable(tabstractrecorddef(vardef).symtable).has_single_field(tempdef) or
  1710. not(varstate in [vs_written,vs_readwritten]));
  1711. {$endif}
  1712. end;
  1713. procedure tabstractvarsym.setvardef_and_regable(def:tdef);
  1714. begin
  1715. setvardef(def);
  1716. setregable;
  1717. end;
  1718. procedure tabstractvarsym.set_addr_taken(AValue: boolean);
  1719. begin
  1720. if AValue then
  1721. include(varsymaccess, vsa_addr_taken)
  1722. else
  1723. exclude(varsymaccess, vsa_addr_taken);
  1724. end;
  1725. procedure tabstractvarsym.set_different_scope(AValue: boolean);
  1726. begin
  1727. if AValue then
  1728. include(varsymaccess, vsa_different_scope)
  1729. else
  1730. exclude(varsymaccess, vsa_different_scope);
  1731. end;
  1732. procedure tabstractvarsym.setregable;
  1733. begin
  1734. if vo_volatile in varoptions then
  1735. exit;
  1736. { can we load the value into a register ? }
  1737. if not assigned(owner) or
  1738. (owner.symtabletype in [localsymtable, parasymtable]) or
  1739. (
  1740. (owner.symtabletype=staticsymtable) and
  1741. not(cs_create_pic in current_settings.moduleswitches)
  1742. ) then
  1743. begin
  1744. if (tstoreddef(vardef).is_intregable and
  1745. { we could keep all aint*2 records in registers, but this causes
  1746. too much spilling for CPUs with 8-16 registers so keep only
  1747. parameters and function results of this type in register because they are normally
  1748. passed by register anyways
  1749. This can be changed, as soon as we have full ssa (FK) }
  1750. ((typ=paravarsym) or
  1751. (vo_is_funcret in varoptions) or
  1752. (tstoreddef(vardef).typ<>recorddef) or
  1753. (tstoreddef(vardef).size<=sizeof(aint)))) or
  1754. { const parameters can be put into registers if the def fits into a register }
  1755. (tstoreddef(vardef).is_const_intregable and
  1756. (typ=paravarsym) and
  1757. (varspez=vs_const)) then
  1758. varregable:=vr_intreg
  1759. else if tstoreddef(vardef).is_fpuregable then
  1760. begin
  1761. if use_vectorfpu(vardef) then
  1762. varregable:=vr_mmreg
  1763. else
  1764. varregable:=vr_fpureg;
  1765. end
  1766. else if is_vector(vardef) and
  1767. fits_in_mm_register(vardef) then
  1768. begin
  1769. varregable:=vr_mmreg;
  1770. end;
  1771. end;
  1772. end;
  1773. function tabstractvarsym.get_addr_taken: boolean;
  1774. begin
  1775. result:=vsa_addr_taken in varsymaccess;
  1776. end;
  1777. function tabstractvarsym.get_different_scope: boolean;
  1778. begin
  1779. result:=vsa_different_scope in varsymaccess;
  1780. end;
  1781. procedure tabstractvarsym.setvardef(const def: tdef);
  1782. begin
  1783. _vardef := def;
  1784. end;
  1785. {****************************************************************************
  1786. TFIELDVARSYM
  1787. ****************************************************************************}
  1788. constructor tfieldvarsym.create(const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);
  1789. begin
  1790. inherited create(fieldvarsym,n,vsp,def,vopts);
  1791. fieldoffset:=-1;
  1792. end;
  1793. constructor tfieldvarsym.ppuload(ppufile:tcompilerppufile);
  1794. begin
  1795. inherited ppuload(fieldvarsym,ppufile);
  1796. fieldoffset:=ppufile.getasizeint;
  1797. if (vo_has_mangledname in varoptions) then
  1798. externalname:=ppufile.getpshortstring
  1799. else
  1800. externalname:=nil;
  1801. ppuload_platform(ppufile);
  1802. end;
  1803. procedure tfieldvarsym.ppuwrite(ppufile:tcompilerppufile);
  1804. begin
  1805. inherited ppuwrite(ppufile);
  1806. ppufile.putasizeint(fieldoffset);
  1807. if (vo_has_mangledname in varoptions) then
  1808. ppufile.putstring(externalname^);
  1809. writeentry(ppufile,ibfieldvarsym);
  1810. end;
  1811. procedure tfieldvarsym.set_externalname(const s: string);
  1812. begin
  1813. internalerror(2014033001);
  1814. end;
  1815. function tfieldvarsym.bitoffset: asizeuint;
  1816. begin
  1817. result:=fieldoffset;
  1818. if tabstractrecordsymtable(owner).fieldalignment<>bit_alignment then
  1819. result:=result*8;
  1820. end;
  1821. function tfieldvarsym.mangledname:TSymStr;
  1822. var
  1823. srsym : tsym;
  1824. srsymtable : tsymtable;
  1825. begin
  1826. if sp_static in symoptions then
  1827. begin
  1828. if searchsym(lower(owner.name^)+'_'+name,srsym,srsymtable) then
  1829. result:=srsym.mangledname
  1830. { when generating the debug info for the module in which the }
  1831. { symbol is defined, the localsymtable of that module is }
  1832. { already popped from the symtablestack }
  1833. else if searchsym_in_module(current_module,lower(owner.name^)+'_'+name,srsym,srsymtable) then
  1834. result:=srsym.mangledname
  1835. else
  1836. internalerror(2007012501);
  1837. end
  1838. else if is_objcclass(tdef(owner.defowner)) then
  1839. begin
  1840. {$ifdef symansistr}
  1841. if cachedmangledname<>'' then
  1842. result:=cachedmangledname
  1843. {$else symansistr}
  1844. if assigned(cachedmangledname) then
  1845. result:=cachedmangledname^
  1846. {$endif symansistr}
  1847. else
  1848. begin
  1849. result:=target_info.cprefix+'OBJC_IVAR_$_'+tobjectdef(owner.defowner).objextname^+'.'+RealName;
  1850. {$ifdef symansistr}
  1851. cachedmangledname:=result;
  1852. {$else symansistr}
  1853. cachedmangledname:=stringdup(result);
  1854. {$endif symansistr}
  1855. end;
  1856. end
  1857. else
  1858. result:=inherited mangledname;
  1859. end;
  1860. destructor tfieldvarsym.destroy;
  1861. begin
  1862. {$ifndef symansistr}
  1863. stringdispose(cachedmangledname);
  1864. {$endif symansistr}
  1865. stringdispose(externalname);
  1866. inherited destroy;
  1867. end;
  1868. {$ifdef DEBUG_NODE_XML}
  1869. procedure TFieldVarSym.XMLPrintFieldData(var T: Text);
  1870. begin
  1871. WriteLn(T, PrintNodeIndention, '<type>', SanitiseXMLString(vardef.GetTypeName), '</type>');
  1872. WriteLn(T, PrintNodeIndention, '<visibility>', visibility, '</visibility>');
  1873. WriteLn(T, PrintNodeIndention, '<offset>', fieldoffset, '</offset>');
  1874. WriteLn(T, PrintNodeIndention, '<size>', vardef.size, '</size>');
  1875. end;
  1876. {$endif DEBUG_NODE_XML}
  1877. {****************************************************************************
  1878. TABSTRACTNORMALVARSYM
  1879. ****************************************************************************}
  1880. constructor tabstractnormalvarsym.create(st:tsymtyp;const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);
  1881. begin
  1882. inherited create(st,n,vsp,def,vopts);
  1883. fillchar(localloc,sizeof(localloc),0);
  1884. fillchar(initialloc,sizeof(initialloc),0);
  1885. defaultconstsym:=nil;
  1886. defaultconstsymderef.reset;
  1887. end;
  1888. constructor tabstractnormalvarsym.ppuload(st:tsymtyp;ppufile:tcompilerppufile);
  1889. begin
  1890. inherited ppuload(st,ppufile);
  1891. fillchar(localloc,sizeof(localloc),0);
  1892. fillchar(initialloc,sizeof(initialloc),0);
  1893. ppufile.getderef(defaultconstsymderef);
  1894. end;
  1895. function tabstractnormalvarsym.globalasmsym: boolean;
  1896. begin
  1897. result:=
  1898. (owner.symtabletype=globalsymtable) or
  1899. (create_smartlink and
  1900. not(tf_smartlink_sections in target_info.flags)) or
  1901. current_module.islibrary or
  1902. (assigned(current_procinfo) and
  1903. ((po_inline in current_procinfo.procdef.procoptions) or
  1904. { globalasmsym is called normally before the body of a subroutine is parsed
  1905. so we cannot know if it will be auto inlined, so make all symbols of it
  1906. global if asked }
  1907. (not(po_noinline in current_procinfo.procdef.procoptions) and
  1908. (cs_opt_autoinline in current_settings.optimizerswitches)))
  1909. ) or
  1910. (vo_is_public in varoptions);
  1911. end;
  1912. procedure tabstractnormalvarsym.buildderef;
  1913. begin
  1914. inherited buildderef;
  1915. defaultconstsymderef.build(defaultconstsym);
  1916. end;
  1917. procedure tabstractnormalvarsym.deref;
  1918. begin
  1919. inherited deref;
  1920. defaultconstsym:=tsym(defaultconstsymderef.resolve);
  1921. end;
  1922. procedure tabstractnormalvarsym.ppuwrite(ppufile:tcompilerppufile);
  1923. begin
  1924. inherited ppuwrite(ppufile);
  1925. ppufile.putderef(defaultconstsymderef);
  1926. end;
  1927. function tabstractnormalvarsym.is_captured:boolean;
  1928. begin
  1929. result:=assigned(capture_sym);
  1930. end;
  1931. {****************************************************************************
  1932. Tstaticvarsym
  1933. ****************************************************************************}
  1934. constructor tstaticvarsym.create(const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);
  1935. begin
  1936. inherited create(staticvarsym,n,vsp,def,vopts);
  1937. fieldvarsymderef.reset;
  1938. {$ifdef symansistr}
  1939. _mangledname:='';
  1940. {$else symansistr}
  1941. _mangledname:=nil;
  1942. {$endif symansistr}
  1943. end;
  1944. constructor tstaticvarsym.create_dll(const n : TSymStr;vsp:tvarspez;def:tdef);
  1945. begin
  1946. tstaticvarsym(self).create(n,vsp,def,[vo_is_dll_var]);
  1947. end;
  1948. constructor tstaticvarsym.create_C(const n: TSymStr; const mangled : TSymStr;vsp:tvarspez;def:tdef);
  1949. begin
  1950. tstaticvarsym(self).create(n,vsp,def,[]);
  1951. set_mangledname(mangled);
  1952. end;
  1953. constructor tstaticvarsym.create_from_fieldvar(const n: TSymStr;fieldvar:tfieldvarsym);
  1954. begin
  1955. create(internal_static_field_name(n),fieldvar.varspez,fieldvar.vardef,[]);
  1956. fieldvarsym:=fieldvar;
  1957. end;
  1958. constructor tstaticvarsym.ppuload(ppufile:tcompilerppufile);
  1959. begin
  1960. inherited ppuload(staticvarsym,ppufile);
  1961. {$ifdef symansistr}
  1962. if vo_has_mangledname in varoptions then
  1963. _mangledname:=ppufile.getansistring
  1964. else
  1965. _mangledname:='';
  1966. {$else symansistr}
  1967. if vo_has_mangledname in varoptions then
  1968. _mangledname:=ppufile.getpshortstring
  1969. else
  1970. _mangledname:=nil;
  1971. {$endif symansistr}
  1972. if vo_has_section in varoptions then
  1973. section:=ppufile.getansistring;
  1974. ppufile.getderef(fieldvarsymderef);
  1975. ppuload_platform(ppufile);
  1976. end;
  1977. destructor tstaticvarsym.destroy;
  1978. begin
  1979. {$ifndef symansistr}
  1980. if assigned(_mangledname) then
  1981. begin
  1982. {$ifdef MEMDEBUG}
  1983. memmanglednames.start;
  1984. {$endif MEMDEBUG}
  1985. stringdispose(_mangledname);
  1986. {$ifdef MEMDEBUG}
  1987. memmanglednames.stop;
  1988. {$endif MEMDEBUG}
  1989. end;
  1990. stringdispose(_mangledbasename);
  1991. {$endif}
  1992. inherited destroy;
  1993. end;
  1994. procedure tstaticvarsym.ppuwrite(ppufile:tcompilerppufile);
  1995. begin
  1996. inherited ppuwrite(ppufile);
  1997. { write mangledname rather than _mangledname in case the mangledname
  1998. has not been calculated yet (can happen in case only the
  1999. mangledbasename has been set) }
  2000. if vo_has_mangledname in varoptions then
  2001. {$ifdef symansistr}
  2002. ppufile.putansistring(mangledname);
  2003. {$else symansistr}
  2004. ppufile.putstring(mangledname);
  2005. {$endif symansistr}
  2006. if vo_has_section in varoptions then
  2007. ppufile.putansistring(section);
  2008. ppufile.putderef(fieldvarsymderef);
  2009. writeentry(ppufile,ibstaticvarsym);
  2010. end;
  2011. procedure tstaticvarsym.buildderef;
  2012. begin
  2013. inherited buildderef;
  2014. fieldvarsymderef.build(fieldvarsym);
  2015. end;
  2016. procedure tstaticvarsym.deref;
  2017. begin
  2018. inherited deref;
  2019. fieldvarsym:=tfieldvarsym(fieldvarsymderef.resolve);
  2020. end;
  2021. function tstaticvarsym.mangledname:TSymStr;
  2022. var
  2023. usename,
  2024. prefix : TSymStr;
  2025. begin
  2026. {$ifdef symansistr}
  2027. if _mangledname='' then
  2028. {$else symansistr}
  2029. if not assigned(_mangledname) then
  2030. {$endif symansistr}
  2031. begin
  2032. if (vo_is_typed_const in varoptions) then
  2033. prefix:='TC'
  2034. else
  2035. prefix:='U';
  2036. {$ifdef symansistr}
  2037. if _mangledbasename='' then
  2038. usename:=name
  2039. else
  2040. usename:=_mangledbasename;
  2041. _mangledname:=make_mangledname(prefix,owner,usename);
  2042. {$else symansistr}
  2043. if not assigned(_mangledbasename) then
  2044. usename:=name
  2045. else
  2046. usename:=_mangledbasename^;
  2047. _mangledname:=stringdup(make_mangledname(prefix,owner,usename));
  2048. {$endif symansistr}
  2049. end;
  2050. {$ifdef symansistr}
  2051. result:=_mangledname;
  2052. {$else symansistr}
  2053. result:=_mangledname^;
  2054. {$endif symansistr}
  2055. end;
  2056. procedure tstaticvarsym.set_mangledbasename(const s: TSymStr);
  2057. begin
  2058. {$ifdef symansistr}
  2059. _mangledbasename:=s;
  2060. _mangledname:='';
  2061. {$else symansistr}
  2062. stringdispose(_mangledname);
  2063. stringdispose(_mangledbasename);
  2064. _mangledbasename:=stringdup(s);
  2065. {$endif symansistr}
  2066. include(varoptions,vo_has_mangledname);
  2067. end;
  2068. function tstaticvarsym.mangledbasename: TSymStr;
  2069. begin
  2070. {$ifdef symansistr}
  2071. result:=_mangledbasename;
  2072. {$else symansistr}
  2073. if assigned(_mangledbasename) then
  2074. result:=_mangledbasename^
  2075. else
  2076. result:='';
  2077. {$endif symansistr}
  2078. end;
  2079. procedure tstaticvarsym.set_mangledname(const s:TSymStr);
  2080. begin
  2081. {$ifdef symansistr}
  2082. _mangledname:=s;
  2083. {$else symansistr}
  2084. stringdispose(_mangledname);
  2085. _mangledname:=stringdup(s);
  2086. {$endif symansistr}
  2087. include(varoptions,vo_has_mangledname);
  2088. end;
  2089. procedure tstaticvarsym.set_raw_mangledname(const s: TSymStr);
  2090. begin
  2091. {$ifndef symansistr}
  2092. stringdispose(_mangledname);
  2093. _mangledname:=stringdup(s);
  2094. {$else}
  2095. _mangledname:=s;
  2096. {$endif}
  2097. include(varoptions,vo_has_mangledname);
  2098. end;
  2099. {****************************************************************************
  2100. TLOCALVARSYM
  2101. ****************************************************************************}
  2102. constructor tlocalvarsym.create(const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);
  2103. begin
  2104. inherited create(localvarsym,n,vsp,def,vopts);
  2105. end;
  2106. constructor tlocalvarsym.ppuload(ppufile:tcompilerppufile);
  2107. begin
  2108. inherited ppuload(localvarsym,ppufile);
  2109. ppuload_platform(ppufile);
  2110. end;
  2111. procedure tlocalvarsym.ppuwrite(ppufile:tcompilerppufile);
  2112. begin
  2113. inherited ppuwrite(ppufile);
  2114. writeentry(ppufile,iblocalvarsym);
  2115. end;
  2116. {****************************************************************************
  2117. TPARAVARSYM
  2118. ****************************************************************************}
  2119. constructor tparavarsym.create(const n : TSymStr;nr:word;vsp:tvarspez;def:tdef;vopts:tvaroptions);
  2120. begin
  2121. inherited create(paravarsym,n,vsp,def,vopts);
  2122. if (vsp in [vs_var,vs_value,vs_const,vs_constref]) and
  2123. not(vo_is_funcret in vopts) then
  2124. varstate := vs_initialised;
  2125. paranr:=nr;
  2126. paraloc[calleeside].init;
  2127. paraloc[callerside].init;
  2128. end;
  2129. destructor tparavarsym.destroy;
  2130. begin
  2131. paraloc[calleeside].done;
  2132. paraloc[callerside].done;
  2133. inherited destroy;
  2134. end;
  2135. constructor tparavarsym.ppuload(ppufile:tcompilerppufile);
  2136. begin
  2137. inherited ppuload(paravarsym,ppufile);
  2138. paranr:=ppufile.getword;
  2139. univpara:=ppufile.getboolean;
  2140. { The var state of parameter symbols is fixed after writing them so
  2141. we write them to the unit file.
  2142. This enables constant folding for inline procedures loaded from units
  2143. }
  2144. varstate:=tvarstate(ppufile.getbyte);
  2145. { read usage info }
  2146. refs:=ppufile.getbyte;
  2147. paraloc[calleeside].init;
  2148. paraloc[callerside].init;
  2149. if vo_has_explicit_paraloc in varoptions then
  2150. paraloc[callerside].ppuload(ppufile);
  2151. ppuload_platform(ppufile);
  2152. end;
  2153. procedure tparavarsym.ppuwrite(ppufile:tcompilerppufile);
  2154. var
  2155. oldintfcrc : boolean;
  2156. begin
  2157. inherited ppuwrite(ppufile);
  2158. ppufile.putword(paranr);
  2159. ppufile.putboolean(univpara);
  2160. { The var state of parameter symbols is fixed after writing them so
  2161. we write them to the unit file.
  2162. This enables constant folding for inline procedures loaded from units
  2163. }
  2164. oldintfcrc:=ppufile.do_crc;
  2165. ppufile.do_crc:=false;
  2166. ppufile.putbyte(ord(varstate));
  2167. { write also info about the usage of parameters,
  2168. the absolute usage does not matter }
  2169. ppufile.putbyte(min(1,refs));
  2170. ppufile.do_crc:=oldintfcrc;
  2171. if vo_has_explicit_paraloc in varoptions then
  2172. begin
  2173. paraloc[callerside].check_simple_location;
  2174. paraloc[callerside].ppuwrite(ppufile);
  2175. end;
  2176. writeentry(ppufile,ibparavarsym);
  2177. end;
  2178. function tparavarsym.needs_finalization:boolean;
  2179. begin
  2180. result:=(varspez=vs_value) and
  2181. (is_managed_type(vardef) or
  2182. (
  2183. (not (tabstractprocdef(owner.defowner).proccalloption in cdecl_pocalls)) and
  2184. (not paramanager.use_stackalloc) and
  2185. (is_open_array(vardef) or is_array_of_const(vardef))
  2186. )
  2187. );
  2188. end;
  2189. function tparavarsym.is_used: boolean;
  2190. begin
  2191. { Only the $parentfp parameter is supported for now }
  2192. result:=not (vo_is_parentfp in varoptions) or (varstate>vs_initialised);
  2193. end;
  2194. {****************************************************************************
  2195. TABSOLUTEVARSYM
  2196. ****************************************************************************}
  2197. constructor tabsolutevarsym.create(const n : TSymStr;def:tdef);
  2198. begin
  2199. inherited create(absolutevarsym,n,vs_value,def,[]);
  2200. ref:=nil;
  2201. end;
  2202. constructor tabsolutevarsym.create_ref(const n : TSymStr;def:tdef;_ref:tpropaccesslist);
  2203. begin
  2204. inherited create(absolutevarsym,n,vs_value,def,[]);
  2205. ref:=_ref;
  2206. end;
  2207. destructor tabsolutevarsym.destroy;
  2208. begin
  2209. if assigned(ref) then
  2210. ref.free;
  2211. inherited destroy;
  2212. end;
  2213. constructor tabsolutevarsym.ppuload(ppufile:tcompilerppufile);
  2214. begin
  2215. inherited ppuload(absolutevarsym,ppufile);
  2216. ref:=nil;
  2217. asmname:=nil;
  2218. abstyp:=absolutetyp(ppufile.getbyte);
  2219. case abstyp of
  2220. tovar :
  2221. ref:=ppufile.getpropaccesslist;
  2222. toasm :
  2223. asmname:=ppufile.getpshortstring;
  2224. toaddr :
  2225. addroffset:=ppufile.getpuint;
  2226. end;
  2227. ppuload_platform(ppufile);
  2228. end;
  2229. procedure tabsolutevarsym.ppuwrite(ppufile:tcompilerppufile);
  2230. begin
  2231. inherited ppuwrite(ppufile);
  2232. ppufile.putbyte(byte(abstyp));
  2233. case abstyp of
  2234. tovar :
  2235. ppufile.putpropaccesslist(ref);
  2236. toasm :
  2237. ppufile.putstring(asmname^);
  2238. toaddr :
  2239. ppufile.putpuint(addroffset);
  2240. end;
  2241. writeentry(ppufile,ibabsolutevarsym);
  2242. end;
  2243. procedure tabsolutevarsym.buildderef;
  2244. begin
  2245. inherited buildderef;
  2246. if (abstyp=tovar) then
  2247. ref.buildderef;
  2248. end;
  2249. procedure tabsolutevarsym.deref;
  2250. begin
  2251. inherited deref;
  2252. { own absolute deref }
  2253. if (abstyp=tovar) then
  2254. ref.resolve;
  2255. end;
  2256. function tabsolutevarsym.mangledname : TSymStr;
  2257. begin
  2258. case abstyp of
  2259. toasm :
  2260. mangledname:=asmname^;
  2261. toaddr :
  2262. mangledname:='$'+tostr(addroffset);
  2263. else
  2264. internalerror(200411062);
  2265. end;
  2266. end;
  2267. {****************************************************************************
  2268. TCONSTSYM
  2269. ****************************************************************************}
  2270. constructor tconstsym.create_ord(const n : TSymStr;t : tconsttyp;v : tconstexprint;def:tdef);
  2271. begin
  2272. inherited create(constsym,n);
  2273. fillchar(value, sizeof(value), #0);
  2274. consttyp:=t;
  2275. value.valueord:=v;
  2276. constdef:=def;
  2277. constdefderef.reset;
  2278. end;
  2279. constructor tconstsym.create_ordptr(const n : TSymStr;t : tconsttyp;v : tconstptruint;def:tdef);
  2280. begin
  2281. inherited create(constsym,n);
  2282. fillchar(value, sizeof(value), #0);
  2283. consttyp:=t;
  2284. value.valueordptr:=v;
  2285. constdef:=def;
  2286. constdefderef.reset;
  2287. end;
  2288. constructor tconstsym.create_ptr(const n : TSymStr;t : tconsttyp;v : pointer;def:tdef);
  2289. begin
  2290. inherited create(constsym,n);
  2291. fillchar(value, sizeof(value), #0);
  2292. consttyp:=t;
  2293. value.valueptr:=v;
  2294. constdef:=def;
  2295. constdefderef.reset;
  2296. end;
  2297. constructor tconstsym.create_string(const n : TSymStr;t : tconsttyp;str:pchar;l:longint;def: tdef);
  2298. begin
  2299. inherited create(constsym,n);
  2300. fillchar(value, sizeof(value), #0);
  2301. consttyp:=t;
  2302. value.valueptr:=str;
  2303. if assigned(def) then
  2304. constdef:=def
  2305. else
  2306. constdef:=carraydef.getreusable(cansichartype,l);
  2307. constdefderef.reset;
  2308. value.len:=l;
  2309. end;
  2310. constructor tconstsym.create_wstring(const n : TSymStr;t : tconsttyp;pw:pcompilerwidestring);
  2311. begin
  2312. inherited create(constsym,n);
  2313. fillchar(value, sizeof(value), #0);
  2314. consttyp:=t;
  2315. pcompilerwidestring(value.valueptr):=pw;
  2316. constdef:=carraydef.getreusable(cwidechartype,getlengthwidestring(pw));
  2317. constdefderef.reset;
  2318. value.len:=getlengthwidestring(pw);
  2319. end;
  2320. constructor tconstsym.create_undefined(const n : TSymStr;def: tdef);
  2321. begin
  2322. inherited create(constsym,n);
  2323. fillchar(value,sizeof(value),#0);
  2324. consttyp:=constnone;
  2325. constdef:=def;
  2326. end;
  2327. constructor tconstsym.ppuload(ppufile:tcompilerppufile);
  2328. var
  2329. pd : pbestreal;
  2330. ps : pnormalset;
  2331. pc : pchar;
  2332. pw : pcompilerwidestring;
  2333. i : longint;
  2334. begin
  2335. inherited ppuload(constsym,ppufile);
  2336. constdef:=nil;
  2337. consttyp:=tconsttyp(ppufile.getbyte);
  2338. fillchar(value, sizeof(value), #0);
  2339. case consttyp of
  2340. constord :
  2341. begin
  2342. ppufile.getderef(constdefderef);
  2343. value.valueord:=ppufile.getexprint;
  2344. end;
  2345. constpointer :
  2346. begin
  2347. ppufile.getderef(constdefderef);
  2348. value.valueordptr:=ppufile.getptruint;
  2349. end;
  2350. constwstring :
  2351. begin
  2352. initwidestring(pw);
  2353. setlengthwidestring(pw,ppufile.getlongint);
  2354. { don't use getdata, because the compilerwidechars may have to
  2355. be byteswapped
  2356. }
  2357. {$if sizeof(tcompilerwidechar) = 2}
  2358. for i:=0 to pw^.len-1 do
  2359. pw^.data[i]:=ppufile.getword;
  2360. {$elseif sizeof(tcompilerwidechar) = 4}
  2361. for i:=0 to pw^.len-1 do
  2362. pw^.data[i]:=cardinal(ppufile.getlongint);
  2363. {$else}
  2364. {$error Unsupported tcompilerwidechar size}
  2365. {$endif}
  2366. pcompilerwidestring(value.valueptr):=pw;
  2367. end;
  2368. conststring,
  2369. constresourcestring :
  2370. begin
  2371. ppufile.getderef(constdefderef);
  2372. value.len:=ppufile.getlongint;
  2373. getmem(pc,value.len+1);
  2374. ppufile.getdata(pc^,value.len);
  2375. pc[value.len]:=#0;
  2376. value.valueptr:=pc;
  2377. end;
  2378. constreal :
  2379. begin
  2380. ppufile.getderef(constdefderef);
  2381. new(pd);
  2382. pd^:=ppufile.getreal;
  2383. value.valueptr:=pd;
  2384. end;
  2385. constset :
  2386. begin
  2387. ppufile.getderef(constdefderef);
  2388. new(ps);
  2389. ppufile.getset(tppuset32(ps^));
  2390. value.valueptr:=ps;
  2391. end;
  2392. constguid :
  2393. begin
  2394. ppufile.getderef(constdefderef);
  2395. new(pguid(value.valueptr));
  2396. ppufile.getdata(value.valueptr^,sizeof(tguid));
  2397. end;
  2398. constnil :
  2399. ppufile.getderef(constdefderef);
  2400. else
  2401. Message1(unit_f_ppu_invalid_entry,tostr(ord(consttyp)));
  2402. end;
  2403. ppuload_platform(ppufile);
  2404. end;
  2405. destructor tconstsym.destroy;
  2406. begin
  2407. case consttyp of
  2408. constnone,
  2409. constord,
  2410. constpointer,
  2411. constnil:
  2412. ;
  2413. conststring,
  2414. constresourcestring :
  2415. freemem(pchar(value.valueptr),value.len+1);
  2416. constwstring :
  2417. donewidestring(pcompilerwidestring(value.valueptr));
  2418. constreal :
  2419. dispose(pbestreal(value.valueptr));
  2420. constset :
  2421. dispose(pnormalset(value.valueptr));
  2422. constguid :
  2423. dispose(pguid(value.valueptr));
  2424. end;
  2425. inherited destroy;
  2426. end;
  2427. procedure tconstsym.buildderef;
  2428. begin
  2429. inherited;
  2430. case consttyp of
  2431. constnil,constord,constreal,constpointer,constset,conststring,constresourcestring,constguid:
  2432. constdefderef.build(constdef);
  2433. constwstring:
  2434. ;
  2435. else
  2436. internalerror(2015120802);
  2437. end;
  2438. end;
  2439. procedure tconstsym.deref;
  2440. begin
  2441. case consttyp of
  2442. constnil,constord,constreal,constpointer,constset,conststring,constresourcestring,constguid:
  2443. constdef:=tdef(constdefderef.resolve);
  2444. constwstring:
  2445. constdef:=carraydef.getreusable(cwidechartype,getlengthwidestring(pcompilerwidestring(value.valueptr)));
  2446. else
  2447. internalerror(2015120801);
  2448. end
  2449. end;
  2450. procedure tconstsym.ppuwrite(ppufile:tcompilerppufile);
  2451. begin
  2452. inherited ppuwrite(ppufile);
  2453. ppufile.putbyte(byte(consttyp));
  2454. case consttyp of
  2455. constnil :
  2456. ppufile.putderef(constdefderef);
  2457. constord :
  2458. begin
  2459. ppufile.putderef(constdefderef);
  2460. ppufile.putexprint(value.valueord);
  2461. end;
  2462. constpointer :
  2463. begin
  2464. ppufile.putderef(constdefderef);
  2465. ppufile.putptruint(value.valueordptr);
  2466. end;
  2467. constwstring :
  2468. begin
  2469. { no need to store the def, we can reconstruct it }
  2470. ppufile.putlongint(getlengthwidestring(pcompilerwidestring(value.valueptr)));
  2471. ppufile.putdata(pcompilerwidestring(value.valueptr)^.data^,pcompilerwidestring(value.valueptr)^.len*sizeof(tcompilerwidechar));
  2472. end;
  2473. conststring,
  2474. constresourcestring :
  2475. begin
  2476. ppufile.putderef(constdefderef);
  2477. ppufile.putlongint(value.len);
  2478. ppufile.putdata(pchar(value.valueptr)^,value.len);
  2479. end;
  2480. constreal :
  2481. begin
  2482. ppufile.putderef(constdefderef);
  2483. ppufile.putreal(pbestreal(value.valueptr)^);
  2484. end;
  2485. constset :
  2486. begin
  2487. ppufile.putderef(constdefderef);
  2488. ppufile.putset(tppuset32(value.valueptr^));
  2489. end;
  2490. constguid :
  2491. begin
  2492. ppufile.putderef(constdefderef);
  2493. ppufile.putdata(value.valueptr^,sizeof(tguid));
  2494. end;
  2495. else
  2496. internalerror(13);
  2497. end;
  2498. writeentry(ppufile,ibconstsym);
  2499. end;
  2500. {$ifdef DEBUG_NODE_XML}
  2501. procedure TConstSym.XMLPrintConstData(var T: Text);
  2502. begin
  2503. WriteLn(T, PrintNodeIndention, '<type>', SanitiseXMLString(constdef.GetTypeName), '</type>');
  2504. case consttyp of
  2505. constnone:
  2506. ;
  2507. conststring,
  2508. constresourcestring,
  2509. constwstring:
  2510. begin
  2511. WriteLn(T, PrintNodeIndention, '<length>', value.len, '</length>');
  2512. if value.len = 0 then
  2513. WriteLn(T, PrintNodeIndention, '<value />')
  2514. else
  2515. WriteLn(T, PrintNodeIndention, '<value>', SanitiseXMLString(PChar(value.valueptr)), '</value>');
  2516. end;
  2517. constord,
  2518. constset:
  2519. WriteLn(T, PrintNodeIndention, '<value>', tostr(value.valueord), '</value>');
  2520. constpointer:
  2521. WriteLn(T, PrintNodeIndention, '<value>', WriteConstPUInt(value.valueordptr), '</value>');
  2522. constreal:
  2523. WriteLn(T, PrintNodeIndention, '<value>', PBestReal(value.valueptr)^, '</value>');
  2524. constnil:
  2525. WriteLn(T, PrintNodeIndention, '<value>nil</value>');
  2526. constguid:
  2527. WriteLn(T, PrintNodeIndention, '<value>', WriteGUID(PGUID(value.valueptr)^), '</value>');
  2528. end;
  2529. WriteLn(T, PrintNodeIndention, '<visibility>', visibility, '</visibility>');
  2530. if not (consttyp in [conststring, constresourcestring, constwstring]) then
  2531. { constdef.size will return an internal error for string
  2532. constants because constdef is an open array internally }
  2533. WriteLn(T, PrintNodeIndention, '<size>', constdef.size, '</size>');
  2534. // WriteLn(T, PrintNodeIndention, '<const_type>', consttyp, '</const_type>');
  2535. end;
  2536. {$endif DEBUG_NODE_XML}
  2537. {****************************************************************************
  2538. TENUMSYM
  2539. ****************************************************************************}
  2540. constructor tenumsym.create(const n : TSymStr;def : tenumdef;v : longint);
  2541. begin
  2542. inherited create(enumsym,n);
  2543. definition:=def;
  2544. definitionderef.reset;
  2545. value:=v;
  2546. end;
  2547. constructor tenumsym.ppuload(ppufile:tcompilerppufile);
  2548. begin
  2549. inherited ppuload(enumsym,ppufile);
  2550. ppufile.getderef(definitionderef);
  2551. value:=ppufile.getlongint;
  2552. ppuload_platform(ppufile);
  2553. end;
  2554. procedure tenumsym.buildderef;
  2555. begin
  2556. inherited;
  2557. definitionderef.build(definition);
  2558. end;
  2559. procedure tenumsym.deref;
  2560. begin
  2561. definition:=tenumdef(definitionderef.resolve);
  2562. end;
  2563. procedure tenumsym.ppuwrite(ppufile:tcompilerppufile);
  2564. begin
  2565. inherited ppuwrite(ppufile);
  2566. ppufile.putderef(definitionderef);
  2567. ppufile.putlongint(value);
  2568. writeentry(ppufile,ibenumsym);
  2569. end;
  2570. {****************************************************************************
  2571. TTYPESYM
  2572. ****************************************************************************}
  2573. constructor ttypesym.create(const n : TSymStr;def:tdef);
  2574. begin
  2575. inherited create(typesym,n);
  2576. typedef:=def;
  2577. typedefderef.reset;
  2578. { register the typesym for the definition }
  2579. if assigned(typedef) and
  2580. (typedef.typ<>errordef) and
  2581. not(assigned(typedef.typesym)) then
  2582. typedef.typesym:=self;
  2583. end;
  2584. destructor ttypesym.destroy;
  2585. begin
  2586. inherited destroy;
  2587. end;
  2588. constructor ttypesym.ppuload(ppufile:tcompilerppufile);
  2589. begin
  2590. inherited ppuload(typesym,ppufile);
  2591. ppufile.getderef(typedefderef);
  2592. fprettyname:=ppufile.getansistring;
  2593. ppuload_platform(ppufile);
  2594. end;
  2595. procedure ttypesym.buildderef;
  2596. begin
  2597. inherited;
  2598. typedefderef.build(typedef);
  2599. end;
  2600. procedure ttypesym.deref;
  2601. begin
  2602. typedef:=tdef(typedefderef.resolve);
  2603. end;
  2604. procedure ttypesym.ppuwrite(ppufile:tcompilerppufile);
  2605. begin
  2606. inherited ppuwrite(ppufile);
  2607. ppufile.putderef(typedefderef);
  2608. ppufile.putansistring(fprettyname);
  2609. writeentry(ppufile,ibtypesym);
  2610. end;
  2611. function ttypesym.prettyname : string;
  2612. begin
  2613. if fprettyname<>'' then
  2614. result:=fprettyname
  2615. else
  2616. result:=inherited prettyname;
  2617. end;
  2618. {****************************************************************************
  2619. TSYSSYM
  2620. ****************************************************************************}
  2621. var
  2622. syssym_list : TFPHashObjectList;
  2623. constructor tsyssym.create(const n : TSymStr;l : tinlinenumber);
  2624. var
  2625. s : shortstring;
  2626. begin
  2627. inherited create(syssym,n);
  2628. number:=l;
  2629. str(longint(l),s);
  2630. if assigned(syssym_list.find(s)) then
  2631. internalerror(2016060303);
  2632. syssym_list.add(s,self);
  2633. end;
  2634. constructor tsyssym.ppuload(ppufile:tcompilerppufile);
  2635. var
  2636. s : shortstring;
  2637. begin
  2638. inherited ppuload(syssym,ppufile);
  2639. number:=tinlinenumber(ppufile.getlongint);
  2640. ppuload_platform(ppufile);
  2641. str(longint(number),s);
  2642. if assigned(syssym_list.find(s)) then
  2643. internalerror(2016060304);
  2644. syssym_list.add(s,self);
  2645. end;
  2646. destructor tsyssym.destroy;
  2647. begin
  2648. inherited destroy;
  2649. end;
  2650. procedure tsyssym.ppuwrite(ppufile:tcompilerppufile);
  2651. begin
  2652. inherited ppuwrite(ppufile);
  2653. ppufile.putlongint(longint(number));
  2654. writeentry(ppufile,ibsyssym);
  2655. end;
  2656. class function tsyssym.find_by_number(l:longint):tsyssym;
  2657. var
  2658. s : shortstring;
  2659. begin
  2660. str(l,s);
  2661. result:=tsyssym(syssym_list.find(s));
  2662. end;
  2663. {*****************************************************************************
  2664. TMacro
  2665. *****************************************************************************}
  2666. constructor tmacro.create(const n : TSymStr);
  2667. begin
  2668. inherited create(macrosym,n);
  2669. owner:=nil;
  2670. defined:=false;
  2671. is_used:=false;
  2672. is_compiler_var:=false;
  2673. buftext:=nil;
  2674. buflen:=0;
  2675. end;
  2676. constructor tmacro.ppuload(ppufile:tcompilerppufile);
  2677. begin
  2678. inherited ppuload(macrosym,ppufile);
  2679. defined:=ppufile.getboolean;
  2680. is_compiler_var:=ppufile.getboolean;
  2681. is_used:=false;
  2682. buflen:= ppufile.getlongint;
  2683. if buflen > 0 then
  2684. begin
  2685. getmem(buftext, buflen);
  2686. ppufile.getdata(buftext^, buflen)
  2687. end
  2688. else
  2689. buftext:=nil;
  2690. end;
  2691. destructor tmacro.destroy;
  2692. begin
  2693. if assigned(buftext) then
  2694. freemem(buftext);
  2695. inherited destroy;
  2696. end;
  2697. procedure tmacro.ppuwrite(ppufile:tcompilerppufile);
  2698. begin
  2699. inherited ppuwrite(ppufile);
  2700. ppufile.putboolean(defined);
  2701. ppufile.putboolean(is_compiler_var);
  2702. ppufile.putlongint(buflen);
  2703. if buflen > 0 then
  2704. ppufile.putdata(buftext^,buflen);
  2705. writeentry(ppufile,ibmacrosym);
  2706. end;
  2707. function tmacro.GetCopy:tmacro;
  2708. var
  2709. p : tmacro;
  2710. begin
  2711. p:=tmacro.create(realname);
  2712. p.defined:=defined;
  2713. p.is_used:=is_used;
  2714. p.is_compiler_var:=is_compiler_var;
  2715. p.buflen:=buflen;
  2716. if assigned(buftext) then
  2717. begin
  2718. getmem(p.buftext,buflen);
  2719. move(buftext^,p.buftext^,buflen);
  2720. end;
  2721. Result:=p;
  2722. end;
  2723. procedure init_symsym;
  2724. begin
  2725. syssym_list:=tfphashobjectlist.create(false);
  2726. end;
  2727. procedure done_symsym;
  2728. begin
  2729. syssym_list.free;
  2730. end;
  2731. initialization
  2732. register_initdone_proc(@init_symsym,@done_symsym);
  2733. end.