symsym.pas 83 KB

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