symsym.pas 89 KB

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