symsym.pas 85 KB

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