symsym.pas 92 KB

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