symsym.pas 86 KB

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