symsym.pas 90 KB

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