symsym.pas 81 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
  4. Implementation for the symbols types of the symtable
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit symsym;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. { common }
  23. cutils,
  24. { target }
  25. globtype,globals,
  26. { symtable }
  27. symconst,symbase,symtype,symdef,defcmp,
  28. { ppu }
  29. ppu,
  30. cclasses,symnot,
  31. { aasm }
  32. aasmbase,aasmtai,
  33. cpuinfo,cpubase,cgbase,cgutils,parabase
  34. ;
  35. type
  36. { this class is the base for all symbol objects }
  37. tstoredsym = class(tsym)
  38. public
  39. constructor create(const n : string);
  40. constructor ppuload(ppufile:tcompilerppufile);
  41. destructor destroy;override;
  42. procedure ppuwrite(ppufile:tcompilerppufile);virtual;
  43. {$ifdef GDB}
  44. function get_var_value(const s:string):string;
  45. function stabstr_evaluate(const s:string;vars:array of string):Pchar;
  46. procedure concatstabto(asmlist : taasmoutput);
  47. {$endif GDB}
  48. function mangledname : string; virtual;
  49. end;
  50. tlabelsym = class(tstoredsym)
  51. lab : tasmlabel;
  52. used,
  53. defined : boolean;
  54. code : pointer; { should be tnode }
  55. constructor create(const n : string; l : tasmlabel);
  56. constructor ppuload(ppufile:tcompilerppufile);
  57. function mangledname:string;override;
  58. procedure ppuwrite(ppufile:tcompilerppufile);override;
  59. {$ifdef GDB}
  60. function stabstring : pchar;override;
  61. {$endif GDB}
  62. end;
  63. tunitsym = class(Tstoredsym)
  64. unitsymtable : tsymtable;
  65. constructor create(const n : string;ref : tsymtable);
  66. constructor ppuload(ppufile:tcompilerppufile);
  67. destructor destroy;override;
  68. procedure ppuwrite(ppufile:tcompilerppufile);override;
  69. end;
  70. terrorsym = class(Tsym)
  71. constructor create;
  72. end;
  73. Tprocdefcallback = procedure(p:Tprocdef;arg:pointer);
  74. tprocsym = class(tstoredsym)
  75. protected
  76. pdlistfirst,
  77. pdlistlast : pprocdeflist; { linked list of overloaded procdefs }
  78. function getprocdef(nr:cardinal):Tprocdef;
  79. public
  80. procdef_count : byte;
  81. {$ifdef GDB}
  82. is_global : boolean;
  83. {$endif GDB}
  84. overloadchecked : boolean;
  85. property procdef[nr:cardinal]:Tprocdef read getprocdef;
  86. constructor create(const n : string);
  87. constructor ppuload(ppufile:tcompilerppufile);
  88. destructor destroy;override;
  89. { writes all declarations except the specified one }
  90. procedure write_parameter_lists(skipdef:tprocdef);
  91. { tests, if all procedures definitions are defined and not }
  92. { only forward }
  93. procedure check_forward;
  94. procedure unchain_overload;
  95. procedure ppuwrite(ppufile:tcompilerppufile);override;
  96. procedure buildderef;override;
  97. procedure deref;override;
  98. procedure addprocdef(p:tprocdef);
  99. procedure addprocdef_deref(const d:tderef);
  100. procedure add_para_match_to(Aprocsym:Tprocsym;cpoptions:tcompare_paras_options);
  101. procedure concat_procdefs_to(s:Tprocsym);
  102. procedure foreach_procdef_static(proc2call:Tprocdefcallback;arg:pointer);
  103. function first_procdef:Tprocdef;
  104. function last_procdef:Tprocdef;
  105. function search_procdef_nopara_boolret:Tprocdef;
  106. function search_procdef_bytype(pt:Tproctypeoption):Tprocdef;
  107. function search_procdef_bypara(para:tlist;retdef:tdef;cpoptions:tcompare_paras_options):Tprocdef;
  108. function search_procdef_byprocvardef(d:Tprocvardef):Tprocdef;
  109. function search_procdef_assignment_operator(fromdef,todef:tdef):Tprocdef;
  110. function write_references(ppufile:tcompilerppufile;locals:boolean):boolean;override;
  111. function is_visible_for_object(currobjdef:tdef):boolean;override;
  112. {$ifdef GDB}
  113. function stabstring : pchar;override;
  114. {$endif GDB}
  115. end;
  116. ttypesym = class(Tstoredsym)
  117. restype : ttype;
  118. constructor create(const n : string;const tt : ttype);
  119. constructor ppuload(ppufile:tcompilerppufile);
  120. procedure ppuwrite(ppufile:tcompilerppufile);override;
  121. procedure buildderef;override;
  122. procedure deref;override;
  123. function gettypedef:tdef;override;
  124. procedure load_references(ppufile:tcompilerppufile;locals:boolean);override;
  125. function write_references(ppufile:tcompilerppufile;locals:boolean):boolean;override;
  126. {$ifdef GDB}
  127. function stabstring : pchar;override;
  128. {$endif GDB}
  129. end;
  130. tabstractvarsym = class(tstoredsym)
  131. varoptions : tvaroptions;
  132. varspez : tvarspez; { sets the type of access }
  133. varregable : tvarregable;
  134. varstate : tvarstate;
  135. notifications : Tlinkedlist;
  136. constructor create(const n : string;vsp:tvarspez;const tt : ttype;vopts:tvaroptions);
  137. constructor ppuload(ppufile:tcompilerppufile);
  138. destructor destroy;override;
  139. procedure ppuwrite(ppufile:tcompilerppufile);override;
  140. procedure buildderef;override;
  141. procedure deref;override;
  142. function getsize : longint;
  143. function is_regvar:boolean;
  144. procedure trigger_notifications(what:Tnotification_flag);
  145. function register_notification(flags:Tnotification_flags;
  146. callback:Tnotification_callback):cardinal;
  147. procedure unregister_notification(id:cardinal);
  148. private
  149. procedure setvartype(const newtype: ttype);
  150. _vartype : ttype;
  151. public
  152. property vartype: ttype read _vartype write setvartype;
  153. end;
  154. tfieldvarsym = class(tabstractvarsym)
  155. fieldoffset : aint; { offset in record/object }
  156. constructor create(const n : string;vsp:tvarspez;const tt : ttype;vopts:tvaroptions);
  157. constructor ppuload(ppufile:tcompilerppufile);
  158. procedure ppuwrite(ppufile:tcompilerppufile);override;
  159. {$ifdef GDB}
  160. function stabstring : pchar;override;
  161. {$endif GDB}
  162. end;
  163. tabstractnormalvarsym = class(tabstractvarsym)
  164. defaultconstsym : tsym;
  165. defaultconstsymderef : tderef;
  166. localloc : TLocation; { register/reference for local var }
  167. constructor create(const n : string;vsp:tvarspez;const tt : ttype;vopts:tvaroptions);
  168. constructor ppuload(ppufile:tcompilerppufile);
  169. procedure ppuwrite(ppufile:tcompilerppufile);override;
  170. procedure buildderef;override;
  171. procedure deref;override;
  172. end;
  173. tlocalvarsym = class(tabstractnormalvarsym)
  174. constructor create(const n : string;vsp:tvarspez;const tt : ttype;vopts:tvaroptions);
  175. constructor ppuload(ppufile:tcompilerppufile);
  176. procedure ppuwrite(ppufile:tcompilerppufile);override;
  177. {$ifdef GDB}
  178. function stabstring : pchar;override;
  179. {$endif GDB}
  180. end;
  181. tparavarsym = class(tabstractnormalvarsym)
  182. paraloc : array[tcallercallee] of TCGPara;
  183. paranr : word; { position of this parameter }
  184. {$ifdef EXTDEBUG}
  185. eqval : tequaltype;
  186. {$endif EXTDEBUG}
  187. constructor create(const n : string;nr:word;vsp:tvarspez;const tt : ttype;vopts:tvaroptions);
  188. constructor ppuload(ppufile:tcompilerppufile);
  189. destructor destroy;override;
  190. procedure ppuwrite(ppufile:tcompilerppufile);override;
  191. {$ifdef GDB}
  192. function stabstring : pchar;override;
  193. {$endif GDB}
  194. end;
  195. tglobalvarsym = class(tabstractnormalvarsym)
  196. private
  197. _mangledname : pstring;
  198. public
  199. constructor create(const n : string;vsp:tvarspez;const tt : ttype;vopts:tvaroptions);
  200. constructor create_dll(const n : string;vsp:tvarspez;const tt : ttype);
  201. constructor create_C(const n,mangled : string;vsp:tvarspez;const tt : ttype);
  202. constructor ppuload(ppufile:tcompilerppufile);
  203. destructor destroy;override;
  204. procedure ppuwrite(ppufile:tcompilerppufile);override;
  205. function mangledname:string;override;
  206. procedure set_mangledname(const s:string);
  207. {$ifdef GDB}
  208. function stabstring : pchar;override;
  209. {$endif GDB}
  210. end;
  211. tabsolutevarsym = class(tabstractvarsym)
  212. public
  213. abstyp : absolutetyp;
  214. {$ifdef i386}
  215. absseg : boolean;
  216. {$endif i386}
  217. asmname : pstring;
  218. addroffset : aint;
  219. ref : tsymlist;
  220. constructor create(const n : string;const tt : ttype);
  221. constructor create_ref(const n : string;const tt : ttype;_ref:tsymlist);
  222. destructor destroy;override;
  223. constructor ppuload(ppufile:tcompilerppufile);
  224. procedure buildderef;override;
  225. procedure deref;override;
  226. function mangledname : string;override;
  227. procedure ppuwrite(ppufile:tcompilerppufile);override;
  228. {$ifdef gdb}
  229. function stabstring:Pchar;override;
  230. {$endif gdb}
  231. end;
  232. tpropertysym = class(Tstoredsym)
  233. propoptions : tpropertyoptions;
  234. propoverriden : tpropertysym;
  235. propoverridenderef : tderef;
  236. proptype,
  237. indextype : ttype;
  238. index,
  239. default : longint;
  240. readaccess,
  241. writeaccess,
  242. storedaccess : tsymlist;
  243. constructor create(const n : string);
  244. destructor destroy;override;
  245. constructor ppuload(ppufile:tcompilerppufile);
  246. function getsize : longint;
  247. procedure ppuwrite(ppufile:tcompilerppufile);override;
  248. function gettypedef:tdef;override;
  249. procedure buildderef;override;
  250. procedure deref;override;
  251. procedure dooverride(overriden:tpropertysym);
  252. end;
  253. ttypedconstsym = class(tstoredsym)
  254. private
  255. _mangledname : pstring;
  256. public
  257. typedconsttype : ttype;
  258. is_writable : boolean;
  259. constructor create(const n : string;p : tdef;writable : boolean);
  260. constructor createtype(const n : string;const tt : ttype;writable : boolean);
  261. constructor ppuload(ppufile:tcompilerppufile);
  262. destructor destroy;override;
  263. function mangledname : string;override;
  264. procedure ppuwrite(ppufile:tcompilerppufile);override;
  265. procedure buildderef;override;
  266. procedure deref;override;
  267. function getsize:longint;
  268. {$ifdef GDB}
  269. function stabstring : pchar;override;
  270. {$endif GDB}
  271. end;
  272. tconstvalue = record
  273. case integer of
  274. 0: (valueord : tconstexprint);
  275. 1: (valueordptr : tconstptruint);
  276. 2: (valueptr : pointer; len : longint);
  277. end;
  278. tconstsym = class(tstoredsym)
  279. consttype : ttype;
  280. consttyp : tconsttyp;
  281. value : tconstvalue;
  282. resstrindex : longint; { needed for resource strings }
  283. constructor create_ord(const n : string;t : tconsttyp;v : tconstexprint;const tt:ttype);
  284. constructor create_ordptr(const n : string;t : tconsttyp;v : tconstptruint;const tt:ttype);
  285. constructor create_ptr(const n : string;t : tconsttyp;v : pointer;const tt:ttype);
  286. constructor create_string(const n : string;t : tconsttyp;str:pchar;l:longint);
  287. constructor ppuload(ppufile:tcompilerppufile);
  288. destructor destroy;override;
  289. procedure buildderef;override;
  290. procedure deref;override;
  291. procedure ppuwrite(ppufile:tcompilerppufile);override;
  292. {$ifdef GDB}
  293. function stabstring : pchar;override;
  294. {$endif GDB}
  295. end;
  296. tenumsym = class(Tstoredsym)
  297. value : longint;
  298. definition : tenumdef;
  299. definitionderef : tderef;
  300. nextenum : tenumsym;
  301. constructor create(const n : string;def : tenumdef;v : longint);
  302. constructor ppuload(ppufile:tcompilerppufile);
  303. procedure ppuwrite(ppufile:tcompilerppufile);override;
  304. procedure buildderef;override;
  305. procedure deref;override;
  306. procedure order;
  307. end;
  308. tsyssym = class(Tstoredsym)
  309. number : longint;
  310. constructor create(const n : string;l : longint);
  311. constructor ppuload(ppufile:tcompilerppufile);
  312. destructor destroy;override;
  313. procedure ppuwrite(ppufile:tcompilerppufile);override;
  314. end;
  315. const
  316. maxmacrolen=16*1024;
  317. type
  318. pmacrobuffer = ^tmacrobuffer;
  319. tmacrobuffer = array[0..maxmacrolen-1] of char;
  320. tmacro = class(tstoredsym)
  321. {Normally true, but false when a previously defined macro is undef-ed}
  322. defined : boolean;
  323. {True if this is a mac style compiler variable, in which case no macro
  324. substitutions shall be done.}
  325. is_compiler_var : boolean;
  326. {Whether the macro was used. NOTE: A use of a macro which was never defined}
  327. {e. g. an IFDEF which returns false, will not be registered as used,}
  328. {since there is no place to register its use. }
  329. is_used : boolean;
  330. buftext : pchar;
  331. buflen : longint;
  332. constructor create(const n : string);
  333. constructor ppuload(ppufile:tcompilerppufile);
  334. procedure ppuwrite(ppufile:tcompilerppufile);override;
  335. destructor destroy;override;
  336. end;
  337. { compiler generated symbol to point to rtti and init/finalize tables }
  338. trttisym = class(tstoredsym)
  339. private
  340. _mangledname : pstring;
  341. public
  342. lab : tasmsymbol;
  343. rttityp : trttitype;
  344. constructor create(const n:string;rt:trttitype);
  345. constructor ppuload(ppufile:tcompilerppufile);
  346. destructor destroy;override;
  347. procedure ppuwrite(ppufile:tcompilerppufile);override;
  348. function mangledname:string;override;
  349. function get_label:tasmsymbol;
  350. end;
  351. var
  352. generrorsym : tsym;
  353. implementation
  354. uses
  355. { global }
  356. verbose,
  357. { target }
  358. systems,
  359. { symtable }
  360. defutil,symtable,
  361. { tree }
  362. node,
  363. { aasm }
  364. {$ifdef gdb}
  365. gdb,
  366. {$endif gdb}
  367. { codegen }
  368. paramgr,cresstr,
  369. procinfo
  370. ;
  371. {****************************************************************************
  372. Helpers
  373. ****************************************************************************}
  374. {****************************************************************************
  375. TSYM (base for all symtypes)
  376. ****************************************************************************}
  377. constructor tstoredsym.create(const n : string);
  378. begin
  379. inherited create(n);
  380. end;
  381. constructor tstoredsym.ppuload(ppufile:tcompilerppufile);
  382. var
  383. nr : word;
  384. s : string;
  385. begin
  386. nr:=ppufile.getword;
  387. s:=ppufile.getstring;
  388. if s[1]='$' then
  389. inherited createname(copy(s,2,255))
  390. else
  391. inherited createname(upper(s));
  392. _realname:=stringdup(s);
  393. typ:=abstractsym;
  394. { force the correct indexnr. must be after create! }
  395. indexnr:=nr;
  396. ppufile.getposinfo(fileinfo);
  397. ppufile.getsmallset(symoptions);
  398. lastref:=nil;
  399. defref:=nil;
  400. refs:=0;
  401. lastwritten:=nil;
  402. refcount:=0;
  403. {$ifdef GDB}
  404. isstabwritten := false;
  405. {$endif GDB}
  406. end;
  407. procedure tstoredsym.ppuwrite(ppufile:tcompilerppufile);
  408. begin
  409. ppufile.putword(indexnr);
  410. ppufile.putstring(_realname^);
  411. ppufile.putposinfo(fileinfo);
  412. ppufile.putsmallset(symoptions);
  413. end;
  414. destructor tstoredsym.destroy;
  415. begin
  416. if assigned(defref) then
  417. begin
  418. {$ifdef MEMDEBUG}
  419. membrowser.start;
  420. {$endif MEMDEBUG}
  421. defref.freechain;
  422. defref.free;
  423. {$ifdef MEMDEBUG}
  424. membrowser.stop;
  425. {$endif MEMDEBUG}
  426. end;
  427. inherited destroy;
  428. end;
  429. {$ifdef GDB}
  430. function Tstoredsym.get_var_value(const s:string):string;
  431. begin
  432. if s='mangledname' then
  433. get_var_value:=mangledname
  434. else
  435. get_var_value:=inherited get_var_value(s);
  436. end;
  437. function Tstoredsym.stabstr_evaluate(const s:string;vars:array of string):Pchar;
  438. begin
  439. stabstr_evaluate:=string_evaluate(s,@get_var_value,vars);
  440. end;
  441. procedure tstoredsym.concatstabto(asmlist : taasmoutput);
  442. var
  443. stabstr : Pchar;
  444. begin
  445. stabstr:=stabstring;
  446. if stabstr<>nil then
  447. asmlist.concat(Tai_stabs.create(stabstr));
  448. end;
  449. {$endif GDB}
  450. function tstoredsym.mangledname : string;
  451. begin
  452. internalerror(200204171);
  453. end;
  454. {****************************************************************************
  455. TLABELSYM
  456. ****************************************************************************}
  457. constructor tlabelsym.create(const n : string; l : tasmlabel);
  458. begin
  459. inherited create(n);
  460. typ:=labelsym;
  461. lab:=l;
  462. used:=false;
  463. defined:=false;
  464. code:=nil;
  465. end;
  466. constructor tlabelsym.ppuload(ppufile:tcompilerppufile);
  467. begin
  468. inherited ppuload(ppufile);
  469. typ:=labelsym;
  470. { this is all dummy
  471. it is only used for local browsing }
  472. lab:=nil;
  473. code:=nil;
  474. used:=false;
  475. defined:=true;
  476. end;
  477. function tlabelsym.mangledname:string;
  478. begin
  479. result:=lab.name;
  480. end;
  481. procedure tlabelsym.ppuwrite(ppufile:tcompilerppufile);
  482. begin
  483. if owner.symtabletype=globalsymtable then
  484. Message(sym_e_ill_label_decl)
  485. else
  486. begin
  487. inherited ppuwrite(ppufile);
  488. ppufile.writeentry(iblabelsym);
  489. end;
  490. end;
  491. {$ifdef GDB}
  492. function Tlabelsym.stabstring : pchar;
  493. begin
  494. stabstring:=stabstr_evaluate('"${name}",${N_LSYM},0,${line},0',[]);
  495. end;
  496. {$endif GDB}
  497. {****************************************************************************
  498. TUNITSYM
  499. ****************************************************************************}
  500. constructor tunitsym.create(const n : string;ref : tsymtable);
  501. var
  502. old_make_ref : boolean;
  503. begin
  504. old_make_ref:=make_ref;
  505. make_ref:=false;
  506. inherited create(n);
  507. make_ref:=old_make_ref;
  508. typ:=unitsym;
  509. unitsymtable:=ref;
  510. end;
  511. constructor tunitsym.ppuload(ppufile:tcompilerppufile);
  512. begin
  513. inherited ppuload(ppufile);
  514. typ:=unitsym;
  515. unitsymtable:=nil;
  516. end;
  517. destructor tunitsym.destroy;
  518. begin
  519. inherited destroy;
  520. end;
  521. procedure tunitsym.ppuwrite(ppufile:tcompilerppufile);
  522. begin
  523. inherited ppuwrite(ppufile);
  524. ppufile.writeentry(ibunitsym);
  525. end;
  526. {****************************************************************************
  527. TPROCSYM
  528. ****************************************************************************}
  529. constructor tprocsym.create(const n : string);
  530. begin
  531. inherited create(n);
  532. typ:=procsym;
  533. pdlistfirst:=nil;
  534. pdlistlast:=nil;
  535. owner:=nil;
  536. {$ifdef GDB}
  537. is_global:=false;
  538. {$endif GDB}
  539. { the tprocdef have their own symoptions, make the procsym
  540. always visible }
  541. symoptions:=[sp_public];
  542. overloadchecked:=false;
  543. procdef_count:=0;
  544. end;
  545. constructor tprocsym.ppuload(ppufile:tcompilerppufile);
  546. var
  547. pdderef : tderef;
  548. i,n : longint;
  549. begin
  550. inherited ppuload(ppufile);
  551. typ:=procsym;
  552. pdlistfirst:=nil;
  553. pdlistlast:=nil;
  554. procdef_count:=0;
  555. n:=ppufile.getword;
  556. for i:=1to n do
  557. begin
  558. ppufile.getderef(pdderef);
  559. addprocdef_deref(pdderef);
  560. end;
  561. {$ifdef GDB}
  562. is_global:=false;
  563. {$endif GDB}
  564. overloadchecked:=false;
  565. end;
  566. destructor tprocsym.destroy;
  567. var
  568. hp,p : pprocdeflist;
  569. begin
  570. p:=pdlistfirst;
  571. while assigned(p) do
  572. begin
  573. hp:=p^.next;
  574. dispose(p);
  575. p:=hp;
  576. end;
  577. inherited destroy;
  578. end;
  579. procedure tprocsym.ppuwrite(ppufile:tcompilerppufile);
  580. var
  581. p : pprocdeflist;
  582. n : word;
  583. begin
  584. inherited ppuwrite(ppufile);
  585. { count procdefs }
  586. n:=0;
  587. p:=pdlistfirst;
  588. while assigned(p) do
  589. begin
  590. { only write the proc definitions that belong
  591. to this procsym and are in the global symtable }
  592. if p^.own and
  593. (p^.def.owner.symtabletype in [globalsymtable,objectsymtable]) then
  594. inc(n);
  595. p:=p^.next;
  596. end;
  597. ppufile.putword(n);
  598. { write procdefs }
  599. p:=pdlistfirst;
  600. while assigned(p) do
  601. begin
  602. { only write the proc definitions that belong
  603. to this procsym and are in the global symtable }
  604. if p^.own and
  605. (p^.def.owner.symtabletype in [globalsymtable,objectsymtable]) then
  606. ppufile.putderef(p^.defderef);
  607. p:=p^.next;
  608. end;
  609. ppufile.writeentry(ibprocsym);
  610. end;
  611. procedure tprocsym.write_parameter_lists(skipdef:tprocdef);
  612. var
  613. p : pprocdeflist;
  614. begin
  615. p:=pdlistfirst;
  616. while assigned(p) do
  617. begin
  618. if p^.def<>skipdef then
  619. MessagePos1(p^.def.fileinfo,sym_h_param_list,p^.def.fullprocname(false));
  620. p:=p^.next;
  621. end;
  622. end;
  623. {Makes implicit externals (procedures declared in the interface
  624. section which do not have a counterpart in the implementation)
  625. to be an imported procedure. For mode macpas.}
  626. procedure import_implict_external(pd:tabstractprocdef);
  627. begin
  628. tprocdef(pd).forwarddef:=false;
  629. tprocdef(pd).setmangledname(target_info.CPrefix+tprocdef(pd).procsym.realname);
  630. end;
  631. procedure tprocsym.check_forward;
  632. var
  633. p : pprocdeflist;
  634. begin
  635. p:=pdlistfirst;
  636. while assigned(p) do
  637. begin
  638. if p^.own and (p^.def.forwarddef) then
  639. begin
  640. if (m_mac in aktmodeswitches) and (p^.def.interfacedef) then
  641. import_implict_external(p^.def)
  642. else
  643. begin
  644. MessagePos1(p^.def.fileinfo,sym_e_forward_not_resolved,p^.def.fullprocname(false));
  645. { Turn further error messages off }
  646. p^.def.forwarddef:=false;
  647. end
  648. end;
  649. p:=p^.next;
  650. end;
  651. end;
  652. procedure tprocsym.buildderef;
  653. var
  654. p : pprocdeflist;
  655. begin
  656. p:=pdlistfirst;
  657. while assigned(p) do
  658. begin
  659. if p^.own then
  660. p^.defderef.build(p^.def);
  661. p:=p^.next;
  662. end;
  663. end;
  664. procedure tprocsym.deref;
  665. var
  666. p : pprocdeflist;
  667. begin
  668. { We have removed the overloaded entries, because they
  669. are not valid anymore and we can't deref them because
  670. the unit were they come from is not necessary in
  671. our uses clause (PFV) }
  672. unchain_overload;
  673. { Deref our own procdefs }
  674. p:=pdlistfirst;
  675. while assigned(p) do
  676. begin
  677. if not p^.own then
  678. internalerror(200310291);
  679. p^.def:=tprocdef(p^.defderef.resolve);
  680. p:=p^.next;
  681. end;
  682. end;
  683. procedure tprocsym.addprocdef(p:tprocdef);
  684. var
  685. pd : pprocdeflist;
  686. begin
  687. new(pd);
  688. pd^.def:=p;
  689. pd^.defderef.reset;
  690. pd^.next:=nil;
  691. pd^.own:=(pd^.def.procsym=self);
  692. { Add at end of list to keep always
  693. a correct order, also after loading from ppu }
  694. if assigned(pdlistlast) then
  695. begin
  696. pdlistlast^.next:=pd;
  697. pdlistlast:=pd;
  698. end
  699. else
  700. begin
  701. pdlistfirst:=pd;
  702. pdlistlast:=pd;
  703. end;
  704. inc(procdef_count);
  705. end;
  706. procedure tprocsym.addprocdef_deref(const d:tderef);
  707. var
  708. pd : pprocdeflist;
  709. begin
  710. new(pd);
  711. pd^.def:=nil;
  712. pd^.defderef:=d;
  713. pd^.next:=nil;
  714. pd^.own:=true;
  715. { Add at end of list to keep always
  716. a correct order, also after loading from ppu }
  717. if assigned(pdlistlast) then
  718. begin
  719. pdlistlast^.next:=pd;
  720. pdlistlast:=pd;
  721. end
  722. else
  723. begin
  724. pdlistfirst:=pd;
  725. pdlistlast:=pd;
  726. end;
  727. inc(procdef_count);
  728. end;
  729. function Tprocsym.getprocdef(nr:cardinal):Tprocdef;
  730. var
  731. i : cardinal;
  732. pd : pprocdeflist;
  733. begin
  734. pd:=pdlistfirst;
  735. for i:=2 to nr do
  736. begin
  737. if not assigned(pd) then
  738. internalerror(200209051);
  739. pd:=pd^.next;
  740. end;
  741. getprocdef:=pd^.def;
  742. end;
  743. procedure Tprocsym.add_para_match_to(Aprocsym:Tprocsym;cpoptions:tcompare_paras_options);
  744. var
  745. pd:pprocdeflist;
  746. begin
  747. pd:=pdlistfirst;
  748. while assigned(pd) do
  749. begin
  750. if Aprocsym.search_procdef_bypara(pd^.def.paras,nil,cpoptions)=nil then
  751. Aprocsym.addprocdef(pd^.def);
  752. pd:=pd^.next;
  753. end;
  754. end;
  755. procedure Tprocsym.concat_procdefs_to(s:Tprocsym);
  756. var
  757. pd : pprocdeflist;
  758. begin
  759. pd:=pdlistfirst;
  760. while assigned(pd) do
  761. begin
  762. s.addprocdef(pd^.def);
  763. pd:=pd^.next;
  764. end;
  765. end;
  766. function Tprocsym.first_procdef:Tprocdef;
  767. begin
  768. if assigned(pdlistfirst) then
  769. first_procdef:=pdlistfirst^.def
  770. else
  771. first_procdef:=nil;
  772. end;
  773. function Tprocsym.last_procdef:Tprocdef;
  774. begin
  775. if assigned(pdlistlast) then
  776. last_procdef:=pdlistlast^.def
  777. else
  778. last_procdef:=nil;
  779. end;
  780. procedure Tprocsym.foreach_procdef_static(proc2call:Tprocdefcallback;arg:pointer);
  781. var
  782. p : pprocdeflist;
  783. begin
  784. p:=pdlistfirst;
  785. while assigned(p) do
  786. begin
  787. proc2call(p^.def,arg);
  788. p:=p^.next;
  789. end;
  790. end;
  791. function Tprocsym.search_procdef_nopara_boolret:Tprocdef;
  792. var
  793. p : pprocdeflist;
  794. begin
  795. search_procdef_nopara_boolret:=nil;
  796. p:=pdlistfirst;
  797. while p<>nil do
  798. begin
  799. if (p^.def.maxparacount=0) and
  800. is_boolean(p^.def.rettype.def) then
  801. begin
  802. search_procdef_nopara_boolret:=p^.def;
  803. break;
  804. end;
  805. p:=p^.next;
  806. end;
  807. end;
  808. function Tprocsym.search_procdef_bytype(pt:Tproctypeoption):Tprocdef;
  809. var
  810. p : pprocdeflist;
  811. begin
  812. search_procdef_bytype:=nil;
  813. p:=pdlistfirst;
  814. while p<>nil do
  815. begin
  816. if p^.def.proctypeoption=pt then
  817. begin
  818. search_procdef_bytype:=p^.def;
  819. break;
  820. end;
  821. p:=p^.next;
  822. end;
  823. end;
  824. function Tprocsym.search_procdef_bypara(para:tlist;retdef:tdef;
  825. cpoptions:tcompare_paras_options):Tprocdef;
  826. var
  827. pd : pprocdeflist;
  828. eq : tequaltype;
  829. begin
  830. search_procdef_bypara:=nil;
  831. pd:=pdlistfirst;
  832. while assigned(pd) do
  833. begin
  834. if assigned(retdef) then
  835. eq:=compare_defs(retdef,pd^.def.rettype.def,nothingn)
  836. else
  837. eq:=te_equal;
  838. if (eq>=te_equal) or
  839. ((cpo_allowconvert in cpoptions) and (eq>te_incompatible)) then
  840. begin
  841. eq:=compare_paras(para,pd^.def.paras,cp_value_equal_const,cpoptions);
  842. if (eq>=te_equal) or
  843. ((cpo_allowconvert in cpoptions) and (eq>te_incompatible)) then
  844. begin
  845. search_procdef_bypara:=pd^.def;
  846. break;
  847. end;
  848. end;
  849. pd:=pd^.next;
  850. end;
  851. end;
  852. function Tprocsym.search_procdef_byprocvardef(d:Tprocvardef):Tprocdef;
  853. var
  854. pd : pprocdeflist;
  855. eq,besteq : tequaltype;
  856. bestpd : tprocdef;
  857. begin
  858. { This function will return the pprocdef of pprocsym that
  859. is the best match for procvardef. When there are multiple
  860. matches it returns nil.}
  861. search_procdef_byprocvardef:=nil;
  862. bestpd:=nil;
  863. besteq:=te_incompatible;
  864. pd:=pdlistfirst;
  865. while assigned(pd) do
  866. begin
  867. eq:=proc_to_procvar_equal(pd^.def,d,false);
  868. if eq>=te_equal then
  869. begin
  870. { multiple procvars with the same equal level }
  871. if assigned(bestpd) and
  872. (besteq=eq) then
  873. exit;
  874. if eq>besteq then
  875. begin
  876. besteq:=eq;
  877. bestpd:=pd^.def;
  878. end;
  879. end;
  880. pd:=pd^.next;
  881. end;
  882. search_procdef_byprocvardef:=bestpd;
  883. end;
  884. function Tprocsym.search_procdef_assignment_operator(fromdef,todef:tdef):Tprocdef;
  885. var
  886. convtyp : tconverttype;
  887. pd : pprocdeflist;
  888. bestpd : tprocdef;
  889. eq,
  890. besteq : tequaltype;
  891. hpd : tprocdef;
  892. i : byte;
  893. begin
  894. result:=nil;
  895. bestpd:=nil;
  896. besteq:=te_incompatible;
  897. pd:=pdlistfirst;
  898. while assigned(pd) do
  899. begin
  900. if equal_defs(todef,pd^.def.rettype.def) then
  901. begin
  902. i:=0;
  903. { ignore vs_hidden parameters }
  904. while assigned(pd^.def.paras[i]) and
  905. (vo_is_hidden_para in tparavarsym(pd^.def.paras[i]).varoptions) do
  906. inc(i);
  907. if assigned(pd^.def.paras[i]) then
  908. begin
  909. eq:=compare_defs_ext(fromdef,tparavarsym(pd^.def.paras[i]).vartype.def,nothingn,convtyp,hpd,[]);
  910. if eq=te_exact then
  911. begin
  912. result:=pd^.def;
  913. exit;
  914. end;
  915. if eq>besteq then
  916. begin
  917. bestpd:=pd^.def;
  918. besteq:=eq;
  919. end;
  920. end;
  921. end;
  922. pd:=pd^.next;
  923. end;
  924. result:=bestpd;
  925. end;
  926. function tprocsym.write_references(ppufile:tcompilerppufile;locals:boolean) : boolean;
  927. var
  928. p : pprocdeflist;
  929. begin
  930. write_references:=false;
  931. if not inherited write_references(ppufile,locals) then
  932. exit;
  933. write_references:=true;
  934. p:=pdlistfirst;
  935. while assigned(p) do
  936. begin
  937. if p^.own then
  938. p^.def.write_references(ppufile,locals);
  939. p:=p^.next;
  940. end;
  941. end;
  942. procedure tprocsym.unchain_overload;
  943. var
  944. p,hp : pprocdeflist;
  945. begin
  946. { remove all overloaded procdefs from the
  947. procdeflist that are not in the current symtable }
  948. overloadchecked:=false;
  949. p:=pdlistfirst;
  950. { reset new lists }
  951. pdlistfirst:=nil;
  952. pdlistlast:=nil;
  953. while assigned(p) do
  954. begin
  955. hp:=p^.next;
  956. if p^.own then
  957. begin
  958. { keep, add to list }
  959. if assigned(pdlistlast) then
  960. begin
  961. pdlistlast^.next:=p;
  962. pdlistlast:=p;
  963. end
  964. else
  965. begin
  966. pdlistfirst:=p;
  967. pdlistlast:=p;
  968. end;
  969. p^.next:=nil;
  970. end
  971. else
  972. begin
  973. { remove }
  974. dispose(p);
  975. dec(procdef_count);
  976. end;
  977. p:=hp;
  978. end;
  979. end;
  980. function tprocsym.is_visible_for_object(currobjdef:tdef):boolean;
  981. var
  982. p : pprocdeflist;
  983. begin
  984. { This procsym is visible, when there is at least
  985. one of the procdefs visible }
  986. result:=false;
  987. p:=pdlistfirst;
  988. while assigned(p) do
  989. begin
  990. if p^.own and
  991. p^.def.is_visible_for_object(tobjectdef(currobjdef)) then
  992. begin
  993. result:=true;
  994. exit;
  995. end;
  996. p:=p^.next;
  997. end;
  998. end;
  999. {$ifdef GDB}
  1000. function tprocsym.stabstring : pchar;
  1001. begin
  1002. internalerror(200111171);
  1003. result:=nil;
  1004. end;
  1005. {$endif GDB}
  1006. {****************************************************************************
  1007. TERRORSYM
  1008. ****************************************************************************}
  1009. constructor terrorsym.create;
  1010. begin
  1011. inherited create('');
  1012. typ:=errorsym;
  1013. end;
  1014. {****************************************************************************
  1015. TPROPERTYSYM
  1016. ****************************************************************************}
  1017. constructor tpropertysym.create(const n : string);
  1018. begin
  1019. inherited create(n);
  1020. typ:=propertysym;
  1021. propoptions:=[];
  1022. index:=0;
  1023. default:=0;
  1024. proptype.reset;
  1025. indextype.reset;
  1026. readaccess:=tsymlist.create;
  1027. writeaccess:=tsymlist.create;
  1028. storedaccess:=tsymlist.create;
  1029. end;
  1030. constructor tpropertysym.ppuload(ppufile:tcompilerppufile);
  1031. begin
  1032. inherited ppuload(ppufile);
  1033. typ:=propertysym;
  1034. ppufile.getsmallset(propoptions);
  1035. if (ppo_is_override in propoptions) then
  1036. begin
  1037. ppufile.getderef(propoverridenderef);
  1038. { we need to have these objects initialized }
  1039. readaccess:=tsymlist.create;
  1040. writeaccess:=tsymlist.create;
  1041. storedaccess:=tsymlist.create;
  1042. end
  1043. else
  1044. begin
  1045. ppufile.gettype(proptype);
  1046. index:=ppufile.getlongint;
  1047. default:=ppufile.getlongint;
  1048. ppufile.gettype(indextype);
  1049. readaccess:=ppufile.getsymlist;
  1050. writeaccess:=ppufile.getsymlist;
  1051. storedaccess:=ppufile.getsymlist;
  1052. end;
  1053. end;
  1054. destructor tpropertysym.destroy;
  1055. begin
  1056. readaccess.free;
  1057. writeaccess.free;
  1058. storedaccess.free;
  1059. inherited destroy;
  1060. end;
  1061. function tpropertysym.gettypedef:tdef;
  1062. begin
  1063. gettypedef:=proptype.def;
  1064. end;
  1065. procedure tpropertysym.buildderef;
  1066. begin
  1067. if (ppo_is_override in propoptions) then
  1068. begin
  1069. propoverridenderef.build(propoverriden);
  1070. end
  1071. else
  1072. begin
  1073. proptype.buildderef;
  1074. indextype.buildderef;
  1075. readaccess.buildderef;
  1076. writeaccess.buildderef;
  1077. storedaccess.buildderef;
  1078. end;
  1079. end;
  1080. procedure tpropertysym.deref;
  1081. begin
  1082. if (ppo_is_override in propoptions) then
  1083. begin
  1084. propoverriden:=tpropertysym(propoverridenderef.resolve);
  1085. dooverride(propoverriden);
  1086. end
  1087. else
  1088. begin
  1089. proptype.resolve;
  1090. indextype.resolve;
  1091. readaccess.resolve;
  1092. writeaccess.resolve;
  1093. storedaccess.resolve;
  1094. end;
  1095. end;
  1096. function tpropertysym.getsize : longint;
  1097. begin
  1098. getsize:=0;
  1099. end;
  1100. procedure tpropertysym.ppuwrite(ppufile:tcompilerppufile);
  1101. begin
  1102. inherited ppuwrite(ppufile);
  1103. ppufile.putsmallset(propoptions);
  1104. if (ppo_is_override in propoptions) then
  1105. ppufile.putderef(propoverridenderef)
  1106. else
  1107. begin
  1108. ppufile.puttype(proptype);
  1109. ppufile.putlongint(index);
  1110. ppufile.putlongint(default);
  1111. ppufile.puttype(indextype);
  1112. ppufile.putsymlist(readaccess);
  1113. ppufile.putsymlist(writeaccess);
  1114. ppufile.putsymlist(storedaccess);
  1115. end;
  1116. ppufile.writeentry(ibpropertysym);
  1117. end;
  1118. procedure tpropertysym.dooverride(overriden:tpropertysym);
  1119. begin
  1120. propoverriden:=overriden;
  1121. proptype:=overriden.proptype;
  1122. propoptions:=overriden.propoptions+[ppo_is_override];
  1123. index:=overriden.index;
  1124. default:=overriden.default;
  1125. indextype:=overriden.indextype;
  1126. readaccess.free;
  1127. readaccess:=overriden.readaccess.getcopy;
  1128. writeaccess.free;
  1129. writeaccess:=overriden.writeaccess.getcopy;
  1130. storedaccess.free;
  1131. storedaccess:=overriden.storedaccess.getcopy;
  1132. end;
  1133. {****************************************************************************
  1134. TABSTRACTVARSYM
  1135. ****************************************************************************}
  1136. constructor tabstractvarsym.create(const n : string;vsp:tvarspez;const tt : ttype;vopts:tvaroptions);
  1137. begin
  1138. inherited create(n);
  1139. vartype:=tt;
  1140. varspez:=vsp;
  1141. varstate:=vs_declared;
  1142. varoptions:=vopts;
  1143. end;
  1144. constructor tabstractvarsym.ppuload(ppufile:tcompilerppufile);
  1145. begin
  1146. inherited ppuload(ppufile);
  1147. varstate:=vs_used;
  1148. varspez:=tvarspez(ppufile.getbyte);
  1149. varregable:=tvarregable(ppufile.getbyte);
  1150. ppufile.gettype(_vartype);
  1151. ppufile.getsmallset(varoptions);
  1152. end;
  1153. destructor tabstractvarsym.destroy;
  1154. begin
  1155. if assigned(notifications) then
  1156. notifications.destroy;
  1157. inherited destroy;
  1158. end;
  1159. procedure tabstractvarsym.buildderef;
  1160. begin
  1161. vartype.buildderef;
  1162. end;
  1163. procedure tabstractvarsym.deref;
  1164. begin
  1165. vartype.resolve;
  1166. end;
  1167. procedure tabstractvarsym.ppuwrite(ppufile:tcompilerppufile);
  1168. var
  1169. oldintfcrc : boolean;
  1170. begin
  1171. inherited ppuwrite(ppufile);
  1172. ppufile.putbyte(byte(varspez));
  1173. oldintfcrc:=ppufile.do_crc;
  1174. ppufile.do_crc:=false;
  1175. ppufile.putbyte(byte(varregable));
  1176. ppufile.do_crc:=oldintfcrc;
  1177. ppufile.puttype(vartype);
  1178. ppufile.putsmallset(varoptions);
  1179. end;
  1180. function tabstractvarsym.getsize : longint;
  1181. begin
  1182. if assigned(vartype.def) and
  1183. ((vartype.def.deftype<>arraydef) or
  1184. tarraydef(vartype.def).isDynamicArray or
  1185. (tarraydef(vartype.def).highrange>=tarraydef(vartype.def).lowrange)) then
  1186. result:=vartype.def.size
  1187. else
  1188. result:=0;
  1189. end;
  1190. function tabstractvarsym.is_regvar:boolean;
  1191. begin
  1192. { Register variables are not allowed in the following cases:
  1193. - regvars are disabled
  1194. - exceptions are used (after an exception is raised the contents of the
  1195. registers is not valid anymore)
  1196. - it has a local copy
  1197. - the value needs to be in memory (i.e. reference counted) }
  1198. result:=(cs_regvars in aktglobalswitches) and
  1199. not(pi_has_assembler_block in current_procinfo.flags) and
  1200. not(pi_uses_exceptions in current_procinfo.flags) and
  1201. not(vo_has_local_copy in varoptions) and
  1202. (varregable<>vr_none);
  1203. end;
  1204. procedure tabstractvarsym.trigger_notifications(what:Tnotification_flag);
  1205. var n:Tnotification;
  1206. begin
  1207. if assigned(notifications) then
  1208. begin
  1209. n:=Tnotification(notifications.first);
  1210. while assigned(n) do
  1211. begin
  1212. if what in n.flags then
  1213. n.callback(what,self);
  1214. n:=Tnotification(n.next);
  1215. end;
  1216. end;
  1217. end;
  1218. function Tabstractvarsym.register_notification(flags:Tnotification_flags;callback:
  1219. Tnotification_callback):cardinal;
  1220. var n:Tnotification;
  1221. begin
  1222. if not assigned(notifications) then
  1223. notifications:=Tlinkedlist.create;
  1224. n:=Tnotification.create(flags,callback);
  1225. register_notification:=n.id;
  1226. notifications.concat(n);
  1227. end;
  1228. procedure Tabstractvarsym.unregister_notification(id:cardinal);
  1229. var n:Tnotification;
  1230. begin
  1231. if not assigned(notifications) then
  1232. internalerror(200212311)
  1233. else
  1234. begin
  1235. n:=Tnotification(notifications.first);
  1236. while assigned(n) do
  1237. begin
  1238. if n.id=id then
  1239. begin
  1240. notifications.remove(n);
  1241. n.destroy;
  1242. exit;
  1243. end;
  1244. n:=Tnotification(n.next);
  1245. end;
  1246. internalerror(200212311)
  1247. end;
  1248. end;
  1249. procedure tabstractvarsym.setvartype(const newtype: ttype);
  1250. begin
  1251. _vartype := newtype;
  1252. { can we load the value into a register ? }
  1253. if not assigned(owner) or
  1254. (owner.symtabletype in [localsymtable,parasymtable]) or
  1255. (
  1256. (owner.symtabletype=staticsymtable) and
  1257. not(cs_create_pic in aktmoduleswitches)
  1258. ) then
  1259. begin
  1260. if tstoreddef(vartype.def).is_intregable then
  1261. varregable:=vr_intreg
  1262. else
  1263. {$warning TODO: no fpu regvar in staticsymtable yet, need initialization with 0}
  1264. if (
  1265. not assigned(owner) or
  1266. (owner.symtabletype<>staticsymtable)
  1267. ) and
  1268. tstoreddef(vartype.def).is_fpuregable then
  1269. varregable:=vr_fpureg;
  1270. end;
  1271. end;
  1272. {****************************************************************************
  1273. TFIELDVARSYM
  1274. ****************************************************************************}
  1275. constructor tfieldvarsym.create(const n : string;vsp:tvarspez;const tt : ttype;vopts:tvaroptions);
  1276. begin
  1277. inherited create(n,vsp,tt,vopts);
  1278. typ:=fieldvarsym;
  1279. fieldoffset:=0;
  1280. end;
  1281. constructor tfieldvarsym.ppuload(ppufile:tcompilerppufile);
  1282. begin
  1283. inherited ppuload(ppufile);
  1284. typ:=fieldvarsym;
  1285. fieldoffset:=ppufile.getaint;
  1286. end;
  1287. procedure tfieldvarsym.ppuwrite(ppufile:tcompilerppufile);
  1288. begin
  1289. inherited ppuwrite(ppufile);
  1290. ppufile.putaint(fieldoffset);
  1291. ppufile.writeentry(ibfieldvarsym);
  1292. end;
  1293. {$ifdef GDB}
  1294. function tfieldvarsym.stabstring:Pchar;
  1295. var
  1296. st : string;
  1297. begin
  1298. stabstring:=nil;
  1299. case owner.symtabletype of
  1300. objectsymtable :
  1301. begin
  1302. if (sp_static in symoptions) then
  1303. begin
  1304. st:=tstoreddef(vartype.def).numberstring;
  1305. if (cs_gdb_gsym in aktglobalswitches) then
  1306. st:='G'+st
  1307. else
  1308. st:='S'+st;
  1309. stabstring:=stabstr_evaluate('"${ownername}__${name}:$1",${N_LCSYM},0,${line},${mangledname}',[st]);
  1310. end;
  1311. end;
  1312. end;
  1313. end;
  1314. {$endif GDB}
  1315. {****************************************************************************
  1316. TABSTRACTNORMALVARSYM
  1317. ****************************************************************************}
  1318. constructor tabstractnormalvarsym.create(const n : string;vsp:tvarspez;const tt : ttype;vopts:tvaroptions);
  1319. begin
  1320. inherited create(n,vsp,tt,vopts);
  1321. fillchar(localloc,sizeof(localloc),0);
  1322. defaultconstsym:=nil;
  1323. end;
  1324. constructor tabstractnormalvarsym.ppuload(ppufile:tcompilerppufile);
  1325. begin
  1326. inherited ppuload(ppufile);
  1327. fillchar(localloc,sizeof(localloc),0);
  1328. ppufile.getderef(defaultconstsymderef);
  1329. end;
  1330. procedure tabstractnormalvarsym.buildderef;
  1331. begin
  1332. inherited buildderef;
  1333. defaultconstsymderef.build(defaultconstsym);
  1334. end;
  1335. procedure tabstractnormalvarsym.deref;
  1336. begin
  1337. inherited deref;
  1338. defaultconstsym:=tsym(defaultconstsymderef.resolve);
  1339. end;
  1340. procedure tabstractnormalvarsym.ppuwrite(ppufile:tcompilerppufile);
  1341. begin
  1342. inherited ppuwrite(ppufile);
  1343. ppufile.putderef(defaultconstsymderef);
  1344. end;
  1345. {****************************************************************************
  1346. TGLOBALVARSYM
  1347. ****************************************************************************}
  1348. constructor tglobalvarsym.create(const n : string;vsp:tvarspez;const tt : ttype;vopts:tvaroptions);
  1349. begin
  1350. inherited create(n,vsp,tt,vopts);
  1351. typ:=globalvarsym;
  1352. _mangledname:=nil;
  1353. end;
  1354. constructor tglobalvarsym.create_dll(const n : string;vsp:tvarspez;const tt : ttype);
  1355. begin
  1356. tglobalvarsym(self).create(n,vsp,tt,[vo_is_dll_var]);
  1357. end;
  1358. constructor tglobalvarsym.create_C(const n,mangled : string;vsp:tvarspez;const tt : ttype);
  1359. begin
  1360. tglobalvarsym(self).create(n,vsp,tt,[]);
  1361. set_mangledname(mangled);
  1362. end;
  1363. constructor tglobalvarsym.ppuload(ppufile:tcompilerppufile);
  1364. begin
  1365. inherited ppuload(ppufile);
  1366. typ:=globalvarsym;
  1367. if vo_has_mangledname in varoptions then
  1368. _mangledname:=stringdup(ppufile.getstring)
  1369. else
  1370. _mangledname:=nil;
  1371. end;
  1372. destructor tglobalvarsym.destroy;
  1373. begin
  1374. if assigned(_mangledname) then
  1375. begin
  1376. {$ifdef MEMDEBUG}
  1377. memmanglednames.start;
  1378. {$endif MEMDEBUG}
  1379. stringdispose(_mangledname);
  1380. {$ifdef MEMDEBUG}
  1381. memmanglednames.stop;
  1382. {$endif MEMDEBUG}
  1383. end;
  1384. inherited destroy;
  1385. end;
  1386. procedure tglobalvarsym.ppuwrite(ppufile:tcompilerppufile);
  1387. begin
  1388. inherited ppuwrite(ppufile);
  1389. if vo_has_mangledname in varoptions then
  1390. ppufile.putstring(_mangledname^);
  1391. ppufile.writeentry(ibglobalvarsym);
  1392. end;
  1393. function tglobalvarsym.mangledname:string;
  1394. begin
  1395. if not assigned(_mangledname) then
  1396. begin
  1397. {$ifdef compress}
  1398. _mangledname:=stringdup(minilzw_encode(make_mangledname('U',owner,name)));
  1399. {$else}
  1400. _mangledname:=stringdup(make_mangledname('U',owner,name));
  1401. {$endif}
  1402. end;
  1403. result:=_mangledname^;
  1404. end;
  1405. procedure tglobalvarsym.set_mangledname(const s:string);
  1406. begin
  1407. stringdispose(_mangledname);
  1408. {$ifdef compress}
  1409. _mangledname:=stringdup(minilzw_encode(s));
  1410. {$else}
  1411. _mangledname:=stringdup(s);
  1412. {$endif}
  1413. include(varoptions,vo_has_mangledname);
  1414. end;
  1415. {$ifdef GDB}
  1416. function Tglobalvarsym.stabstring:Pchar;
  1417. var st:string;
  1418. threadvaroffset:string;
  1419. regidx:Tregisterindex;
  1420. begin
  1421. result:=nil;
  1422. st:=tstoreddef(vartype.def).numberstring;
  1423. case localloc.loc of
  1424. LOC_REGISTER,
  1425. LOC_CREGISTER,
  1426. LOC_MMREGISTER,
  1427. LOC_CMMREGISTER,
  1428. LOC_FPUREGISTER,
  1429. LOC_CFPUREGISTER :
  1430. begin
  1431. regidx:=findreg_by_number(localloc.register);
  1432. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1433. { this is the register order for GDB}
  1434. if regidx<>0 then
  1435. stabstring:=stabstr_evaluate('"${name}:r$1",${N_RSYM},0,${line},$2',[st,tostr(regstabs_table[regidx])]);
  1436. end;
  1437. else
  1438. begin
  1439. if (vo_is_thread_var in varoptions) then
  1440. threadvaroffset:='+'+tostr(sizeof(aint))
  1441. else
  1442. threadvaroffset:='';
  1443. { Here we used S instead of
  1444. because with G GDB doesn't look at the address field
  1445. but searches the same name or with a leading underscore
  1446. but these names don't exist in pascal !}
  1447. if (cs_gdb_gsym in aktglobalswitches) then
  1448. st:='G'+st
  1449. else
  1450. st:='S'+st;
  1451. stabstring:=stabstr_evaluate('"${name}:$1",${N_LCSYM},0,${line},${mangledname}$2',[st,threadvaroffset]);
  1452. end;
  1453. end;
  1454. end;
  1455. {$endif GDB}
  1456. {****************************************************************************
  1457. TLOCALVARSYM
  1458. ****************************************************************************}
  1459. constructor tlocalvarsym.create(const n : string;vsp:tvarspez;const tt : ttype;vopts:tvaroptions);
  1460. begin
  1461. inherited create(n,vsp,tt,vopts);
  1462. typ:=localvarsym;
  1463. end;
  1464. constructor tlocalvarsym.ppuload(ppufile:tcompilerppufile);
  1465. begin
  1466. inherited ppuload(ppufile);
  1467. typ:=localvarsym;
  1468. end;
  1469. procedure tlocalvarsym.ppuwrite(ppufile:tcompilerppufile);
  1470. begin
  1471. inherited ppuwrite(ppufile);
  1472. ppufile.writeentry(iblocalvarsym);
  1473. end;
  1474. {$ifdef GDB}
  1475. function tlocalvarsym.stabstring:Pchar;
  1476. var st:string;
  1477. regidx:Tregisterindex;
  1478. begin
  1479. stabstring:=nil;
  1480. { There is no space allocated for not referenced locals }
  1481. if (owner.symtabletype=localsymtable) and (refs=0) then
  1482. exit;
  1483. st:=tstoreddef(vartype.def).numberstring;
  1484. case localloc.loc of
  1485. LOC_REGISTER,
  1486. LOC_CREGISTER,
  1487. LOC_MMREGISTER,
  1488. LOC_CMMREGISTER,
  1489. LOC_FPUREGISTER,
  1490. LOC_CFPUREGISTER :
  1491. begin
  1492. regidx:=findreg_by_number(localloc.register);
  1493. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1494. { this is the register order for GDB}
  1495. if regidx<>0 then
  1496. stabstring:=stabstr_evaluate('"${name}:r$1",${N_RSYM},0,${line},$2',[st,tostr(regstabs_table[regidx])]);
  1497. end;
  1498. LOC_REFERENCE :
  1499. { offset to ebp => will not work if the framepointer is esp
  1500. so some optimizing will make things harder to debug }
  1501. stabstring:=stabstr_evaluate('"${name}:$1",${N_TSYM},0,${line},$2',[st,tostr(localloc.reference.offset)])
  1502. else
  1503. internalerror(2003091814);
  1504. end;
  1505. end;
  1506. {$endif GDB}
  1507. {****************************************************************************
  1508. TPARAVARSYM
  1509. ****************************************************************************}
  1510. constructor tparavarsym.create(const n : string;nr:word;vsp:tvarspez;const tt : ttype;vopts:tvaroptions);
  1511. begin
  1512. inherited create(n,vsp,tt,vopts);
  1513. typ:=paravarsym;
  1514. paranr:=nr;
  1515. paraloc[calleeside].init;
  1516. paraloc[callerside].init;
  1517. end;
  1518. destructor tparavarsym.destroy;
  1519. begin
  1520. paraloc[calleeside].done;
  1521. paraloc[callerside].done;
  1522. inherited destroy;
  1523. end;
  1524. constructor tparavarsym.ppuload(ppufile:tcompilerppufile);
  1525. var
  1526. b : byte;
  1527. begin
  1528. inherited ppuload(ppufile);
  1529. paranr:=ppufile.getword;
  1530. paraloc[calleeside].init;
  1531. paraloc[callerside].init;
  1532. if vo_has_explicit_paraloc in varoptions then
  1533. begin
  1534. b:=ppufile.getbyte;
  1535. if b<>sizeof(paraloc[callerside].location^) then
  1536. internalerror(200411154);
  1537. ppufile.getdata(paraloc[callerside].add_location^,sizeof(paraloc[callerside].location^));
  1538. paraloc[callerside].size:=paraloc[callerside].location^.size;
  1539. end;
  1540. typ:=paravarsym;
  1541. end;
  1542. procedure tparavarsym.ppuwrite(ppufile:tcompilerppufile);
  1543. begin
  1544. inherited ppuwrite(ppufile);
  1545. ppufile.putword(paranr);
  1546. if vo_has_explicit_paraloc in varoptions then
  1547. begin
  1548. paraloc[callerside].check_simple_location;
  1549. ppufile.putbyte(sizeof(paraloc[callerside].location^));
  1550. ppufile.putdata(paraloc[callerside].location^,sizeof(paraloc[callerside].location^));
  1551. end;
  1552. ppufile.writeentry(ibparavarsym);
  1553. end;
  1554. {$ifdef GDB}
  1555. function tparavarsym.stabstring:Pchar;
  1556. var st:string;
  1557. regidx:Tregisterindex;
  1558. c:char;
  1559. begin
  1560. result:=nil;
  1561. { set loc to LOC_REFERENCE to get somewhat usable debugging info for -Or }
  1562. { while stabs aren't adapted for regvars yet }
  1563. if (vo_is_self in varoptions) then
  1564. begin
  1565. case localloc.loc of
  1566. LOC_REGISTER,
  1567. LOC_CREGISTER:
  1568. regidx:=findreg_by_number(localloc.register);
  1569. LOC_REFERENCE: ;
  1570. else
  1571. internalerror(2003091815);
  1572. end;
  1573. if (po_classmethod in current_procinfo.procdef.procoptions) or
  1574. (po_staticmethod in current_procinfo.procdef.procoptions) then
  1575. begin
  1576. if (localloc.loc=LOC_REFERENCE) then
  1577. stabstring:=stabstr_evaluate('"pvmt:p$1",${N_TSYM},0,0,$2',
  1578. [Tstoreddef(pvmttype.def).numberstring,tostr(localloc.reference.offset)]);
  1579. (* else
  1580. stabstring:=stabstr_evaluate('"pvmt:r$1",${N_RSYM},0,0,$2',
  1581. [Tstoreddef(pvmttype.def).numberstring,tostr(regstabs_table[regidx])]) *)
  1582. end
  1583. else
  1584. begin
  1585. if not(is_class(current_procinfo.procdef._class)) then
  1586. c:='v'
  1587. else
  1588. c:='p';
  1589. if (localloc.loc=LOC_REFERENCE) then
  1590. stabstring:=stabstr_evaluate('"$$t:$1",${N_TSYM},0,0,$2',
  1591. [c+current_procinfo.procdef._class.numberstring,tostr(localloc.reference.offset)]);
  1592. (* else
  1593. stabstring:=stabstr_evaluate('"$$t:r$1",${N_RSYM},0,0,$2',
  1594. [c+current_procinfo.procdef._class.numberstring,tostr(regstabs_table[regidx])]); *)
  1595. end;
  1596. end
  1597. else
  1598. begin
  1599. st:=tstoreddef(vartype.def).numberstring;
  1600. if paramanager.push_addr_param(varspez,vartype.def,tprocdef(owner.defowner).proccalloption) and
  1601. not(vo_has_local_copy in varoptions) and
  1602. not is_open_string(vartype.def) then
  1603. st := 'v'+st { should be 'i' but 'i' doesn't work }
  1604. else
  1605. st := 'p'+st;
  1606. case localloc.loc of
  1607. LOC_REGISTER,
  1608. LOC_CREGISTER,
  1609. LOC_MMREGISTER,
  1610. LOC_CMMREGISTER,
  1611. LOC_FPUREGISTER,
  1612. LOC_CFPUREGISTER :
  1613. begin
  1614. regidx:=findreg_by_number(localloc.register);
  1615. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1616. { this is the register order for GDB}
  1617. if regidx<>0 then
  1618. stabstring:=stabstr_evaluate('"${name}:r$1",${N_RSYM},0,${line},$2',[st,tostr(regstabs_table[regidx])]);
  1619. end;
  1620. LOC_REFERENCE :
  1621. { offset to ebp => will not work if the framepointer is esp
  1622. so some optimizing will make things harder to debug }
  1623. stabstring:=stabstr_evaluate('"${name}:$1",${N_TSYM},0,${line},$2',[st,tostr(localloc.reference.offset)])
  1624. else
  1625. internalerror(2003091814);
  1626. end;
  1627. end;
  1628. end;
  1629. {$endif GDB}
  1630. {****************************************************************************
  1631. TABSOLUTEVARSYM
  1632. ****************************************************************************}
  1633. constructor tabsolutevarsym.create(const n : string;const tt : ttype);
  1634. begin
  1635. inherited create(n,vs_value,tt,[]);
  1636. typ:=absolutevarsym;
  1637. ref:=nil;
  1638. end;
  1639. constructor tabsolutevarsym.create_ref(const n : string;const tt : ttype;_ref:tsymlist);
  1640. begin
  1641. inherited create(n,vs_value,tt,[]);
  1642. typ:=absolutevarsym;
  1643. ref:=_ref;
  1644. end;
  1645. destructor tabsolutevarsym.destroy;
  1646. begin
  1647. if assigned(ref) then
  1648. ref.free;
  1649. inherited destroy;
  1650. end;
  1651. constructor tabsolutevarsym.ppuload(ppufile:tcompilerppufile);
  1652. begin
  1653. inherited ppuload(ppufile);
  1654. typ:=absolutevarsym;
  1655. ref:=nil;
  1656. asmname:=nil;
  1657. abstyp:=absolutetyp(ppufile.getbyte);
  1658. {$ifdef i386}
  1659. absseg:=false;
  1660. {$endif i386}
  1661. case abstyp of
  1662. tovar :
  1663. ref:=ppufile.getsymlist;
  1664. toasm :
  1665. asmname:=stringdup(ppufile.getstring);
  1666. toaddr :
  1667. begin
  1668. addroffset:=ppufile.getaint;
  1669. {$ifdef i386}
  1670. absseg:=boolean(ppufile.getbyte);
  1671. {$endif i386}
  1672. end;
  1673. end;
  1674. end;
  1675. procedure tabsolutevarsym.ppuwrite(ppufile:tcompilerppufile);
  1676. begin
  1677. inherited ppuwrite(ppufile);
  1678. ppufile.putbyte(byte(abstyp));
  1679. case abstyp of
  1680. tovar :
  1681. ppufile.putsymlist(ref);
  1682. toasm :
  1683. ppufile.putstring(asmname^);
  1684. toaddr :
  1685. begin
  1686. ppufile.putaint(addroffset);
  1687. {$ifdef i386}
  1688. ppufile.putbyte(byte(absseg));
  1689. {$endif i386}
  1690. end;
  1691. end;
  1692. ppufile.writeentry(ibabsolutevarsym);
  1693. end;
  1694. procedure tabsolutevarsym.buildderef;
  1695. begin
  1696. inherited buildderef;
  1697. if (abstyp=tovar) then
  1698. ref.buildderef;
  1699. end;
  1700. procedure tabsolutevarsym.deref;
  1701. begin
  1702. inherited deref;
  1703. { own absolute deref }
  1704. if (abstyp=tovar) then
  1705. ref.resolve;
  1706. end;
  1707. function tabsolutevarsym.mangledname : string;
  1708. begin
  1709. case abstyp of
  1710. toasm :
  1711. mangledname:=asmname^;
  1712. toaddr :
  1713. mangledname:='$'+tostr(addroffset);
  1714. else
  1715. internalerror(200411061);
  1716. end;
  1717. end;
  1718. {$ifdef GDB}
  1719. function tabsolutevarsym.stabstring:Pchar;
  1720. begin
  1721. stabstring:=nil;
  1722. end;
  1723. {$endif GDB}
  1724. {****************************************************************************
  1725. TTYPEDCONSTSYM
  1726. *****************************************************************************}
  1727. constructor ttypedconstsym.create(const n : string;p : tdef;writable : boolean);
  1728. begin
  1729. inherited create(n);
  1730. typ:=typedconstsym;
  1731. typedconsttype.setdef(p);
  1732. is_writable:=writable;
  1733. end;
  1734. constructor ttypedconstsym.createtype(const n : string;const tt : ttype;writable : boolean);
  1735. begin
  1736. inherited create(n);
  1737. typ:=typedconstsym;
  1738. typedconsttype:=tt;
  1739. is_writable:=writable;
  1740. end;
  1741. constructor ttypedconstsym.ppuload(ppufile:tcompilerppufile);
  1742. begin
  1743. inherited ppuload(ppufile);
  1744. typ:=typedconstsym;
  1745. ppufile.gettype(typedconsttype);
  1746. is_writable:=boolean(ppufile.getbyte);
  1747. end;
  1748. destructor ttypedconstsym.destroy;
  1749. begin
  1750. if assigned(_mangledname) then
  1751. begin
  1752. {$ifdef MEMDEBUG}
  1753. memmanglednames.start;
  1754. {$endif MEMDEBUG}
  1755. stringdispose(_mangledname);
  1756. {$ifdef MEMDEBUG}
  1757. memmanglednames.stop;
  1758. {$endif MEMDEBUG}
  1759. end;
  1760. inherited destroy;
  1761. end;
  1762. function ttypedconstsym.mangledname:string;
  1763. begin
  1764. if not assigned(_mangledname) then
  1765. begin
  1766. {$ifdef compress}
  1767. _mangledname:=stringdup(make_mangledname('TC',owner,name));
  1768. {$else}
  1769. _mangledname:=stringdup(make_mangledname('TC',owner,name));
  1770. {$endif}
  1771. end;
  1772. result:=_mangledname^;
  1773. end;
  1774. function ttypedconstsym.getsize : longint;
  1775. begin
  1776. if assigned(typedconsttype.def) then
  1777. getsize:=typedconsttype.def.size
  1778. else
  1779. getsize:=0;
  1780. end;
  1781. procedure ttypedconstsym.buildderef;
  1782. begin
  1783. typedconsttype.buildderef;
  1784. end;
  1785. procedure ttypedconstsym.deref;
  1786. begin
  1787. typedconsttype.resolve;
  1788. end;
  1789. procedure ttypedconstsym.ppuwrite(ppufile:tcompilerppufile);
  1790. begin
  1791. inherited ppuwrite(ppufile);
  1792. ppufile.puttype(typedconsttype);
  1793. ppufile.putbyte(byte(is_writable));
  1794. ppufile.writeentry(ibtypedconstsym);
  1795. end;
  1796. {$ifdef GDB}
  1797. function ttypedconstsym.stabstring : pchar;
  1798. var st:char;
  1799. begin
  1800. if (cs_gdb_gsym in aktglobalswitches) and (owner.symtabletype=globalsymtable) then
  1801. st:='G'
  1802. else
  1803. st:='S';
  1804. stabstring:=stabstr_evaluate('"${name}:$1$2",${N_STSYM},0,${line},${mangledname}',
  1805. [st,Tstoreddef(typedconsttype.def).numberstring]);
  1806. end;
  1807. {$endif GDB}
  1808. {****************************************************************************
  1809. TCONSTSYM
  1810. ****************************************************************************}
  1811. constructor tconstsym.create_ord(const n : string;t : tconsttyp;v : tconstexprint;const tt:ttype);
  1812. begin
  1813. inherited create(n);
  1814. fillchar(value, sizeof(value), #0);
  1815. typ:=constsym;
  1816. consttyp:=t;
  1817. value.valueord:=v;
  1818. ResStrIndex:=0;
  1819. consttype:=tt;
  1820. end;
  1821. constructor tconstsym.create_ordptr(const n : string;t : tconsttyp;v : tconstptruint;const tt:ttype);
  1822. begin
  1823. inherited create(n);
  1824. fillchar(value, sizeof(value), #0);
  1825. typ:=constsym;
  1826. consttyp:=t;
  1827. value.valueordptr:=v;
  1828. ResStrIndex:=0;
  1829. consttype:=tt;
  1830. end;
  1831. constructor tconstsym.create_ptr(const n : string;t : tconsttyp;v : pointer;const tt:ttype);
  1832. begin
  1833. inherited create(n);
  1834. fillchar(value, sizeof(value), #0);
  1835. typ:=constsym;
  1836. consttyp:=t;
  1837. value.valueptr:=v;
  1838. ResStrIndex:=0;
  1839. consttype:=tt;
  1840. end;
  1841. constructor tconstsym.create_string(const n : string;t : tconsttyp;str:pchar;l:longint);
  1842. begin
  1843. inherited create(n);
  1844. fillchar(value, sizeof(value), #0);
  1845. typ:=constsym;
  1846. consttyp:=t;
  1847. value.valueptr:=str;
  1848. consttype.reset;
  1849. value.len:=l;
  1850. if t=constresourcestring then
  1851. ResStrIndex:=ResourceStrings.Register(name,pchar(value.valueptr),value.len);
  1852. end;
  1853. constructor tconstsym.ppuload(ppufile:tcompilerppufile);
  1854. var
  1855. pd : pbestreal;
  1856. ps : pnormalset;
  1857. pc : pchar;
  1858. begin
  1859. inherited ppuload(ppufile);
  1860. typ:=constsym;
  1861. consttype.reset;
  1862. consttyp:=tconsttyp(ppufile.getbyte);
  1863. fillchar(value, sizeof(value), #0);
  1864. case consttyp of
  1865. constord :
  1866. begin
  1867. ppufile.gettype(consttype);
  1868. value.valueord:=ppufile.getexprint;
  1869. end;
  1870. constpointer :
  1871. begin
  1872. ppufile.gettype(consttype);
  1873. value.valueordptr:=ppufile.getptruint;
  1874. end;
  1875. conststring,
  1876. constresourcestring :
  1877. begin
  1878. value.len:=ppufile.getlongint;
  1879. getmem(pc,value.len+1);
  1880. ppufile.getdata(pc^,value.len);
  1881. if consttyp=constresourcestring then
  1882. ResStrIndex:=ppufile.getlongint;
  1883. value.valueptr:=pc;
  1884. end;
  1885. constreal :
  1886. begin
  1887. new(pd);
  1888. pd^:=ppufile.getreal;
  1889. value.valueptr:=pd;
  1890. end;
  1891. constset :
  1892. begin
  1893. ppufile.gettype(consttype);
  1894. new(ps);
  1895. ppufile.getnormalset(ps^);
  1896. value.valueptr:=ps;
  1897. end;
  1898. constguid :
  1899. begin
  1900. new(pguid(value.valueptr));
  1901. ppufile.getdata(value.valueptr^,sizeof(tguid));
  1902. end;
  1903. constnil : ;
  1904. else
  1905. Message1(unit_f_ppu_invalid_entry,tostr(ord(consttyp)));
  1906. end;
  1907. end;
  1908. destructor tconstsym.destroy;
  1909. begin
  1910. case consttyp of
  1911. conststring,
  1912. constresourcestring :
  1913. freemem(pchar(value.valueptr),value.len+1);
  1914. constreal :
  1915. dispose(pbestreal(value.valueptr));
  1916. constset :
  1917. dispose(pnormalset(value.valueptr));
  1918. constguid :
  1919. dispose(pguid(value.valueptr));
  1920. end;
  1921. inherited destroy;
  1922. end;
  1923. procedure tconstsym.buildderef;
  1924. begin
  1925. if consttyp in [constord,constpointer,constset] then
  1926. consttype.buildderef;
  1927. end;
  1928. procedure tconstsym.deref;
  1929. begin
  1930. if consttyp in [constord,constpointer,constset] then
  1931. consttype.resolve;
  1932. end;
  1933. procedure tconstsym.ppuwrite(ppufile:tcompilerppufile);
  1934. begin
  1935. inherited ppuwrite(ppufile);
  1936. ppufile.putbyte(byte(consttyp));
  1937. case consttyp of
  1938. constnil : ;
  1939. constord :
  1940. begin
  1941. ppufile.puttype(consttype);
  1942. ppufile.putexprint(value.valueord);
  1943. end;
  1944. constpointer :
  1945. begin
  1946. ppufile.puttype(consttype);
  1947. ppufile.putptruint(value.valueordptr);
  1948. end;
  1949. conststring,
  1950. constresourcestring :
  1951. begin
  1952. ppufile.putlongint(value.len);
  1953. ppufile.putdata(pchar(value.valueptr)^,value.len);
  1954. if consttyp=constresourcestring then
  1955. ppufile.putlongint(ResStrIndex);
  1956. end;
  1957. constreal :
  1958. ppufile.putreal(pbestreal(value.valueptr)^);
  1959. constset :
  1960. begin
  1961. ppufile.puttype(consttype);
  1962. ppufile.putnormalset(value.valueptr^);
  1963. end;
  1964. constguid :
  1965. ppufile.putdata(value.valueptr^,sizeof(tguid));
  1966. else
  1967. internalerror(13);
  1968. end;
  1969. ppufile.writeentry(ibconstsym);
  1970. end;
  1971. {$ifdef GDB}
  1972. function Tconstsym.stabstring:Pchar;
  1973. var st : string;
  1974. begin
  1975. {even GDB v4.16 only now 'i' 'r' and 'e' !!!}
  1976. case consttyp of
  1977. conststring:
  1978. st:='s'''+backspace_quote(octal_quote(strpas(pchar(value.valueptr)),[#0..#9,#11,#12,#14..#31,'''']),['"','\',#10,#13])+'''';
  1979. constord:
  1980. st:='i'+tostr(value.valueord);
  1981. constpointer:
  1982. st:='i'+tostr(value.valueordptr);
  1983. constreal:
  1984. begin
  1985. system.str(pbestreal(value.valueptr)^,st);
  1986. st := 'r'+st;
  1987. end;
  1988. { if we don't know just put zero !! }
  1989. else st:='i0';
  1990. {***SETCONST}
  1991. {constset:;} {*** I don't know what to do with a set.}
  1992. { sets are not recognized by GDB}
  1993. {***}
  1994. end;
  1995. { valgrind does not support constants }
  1996. if cs_gdb_valgrind in aktglobalswitches then
  1997. stabstring:=nil
  1998. else
  1999. stabstring:=stabstr_evaluate('"${name}:c=$1;",${N_FUNCTION},0,${line},0',[st]);
  2000. end;
  2001. {$endif GDB}
  2002. {****************************************************************************
  2003. TENUMSYM
  2004. ****************************************************************************}
  2005. constructor tenumsym.create(const n : string;def : tenumdef;v : longint);
  2006. begin
  2007. inherited create(n);
  2008. typ:=enumsym;
  2009. definition:=def;
  2010. value:=v;
  2011. { First entry? Then we need to set the minval }
  2012. if def.firstenum=nil then
  2013. begin
  2014. if v>0 then
  2015. def.has_jumps:=true;
  2016. def.setmin(v);
  2017. def.setmax(v);
  2018. end
  2019. else
  2020. begin
  2021. { check for jumps }
  2022. if v>def.max+1 then
  2023. def.has_jumps:=true;
  2024. { update low and high }
  2025. if def.min>v then
  2026. def.setmin(v);
  2027. if def.max<v then
  2028. def.setmax(v);
  2029. end;
  2030. order;
  2031. end;
  2032. constructor tenumsym.ppuload(ppufile:tcompilerppufile);
  2033. begin
  2034. inherited ppuload(ppufile);
  2035. typ:=enumsym;
  2036. ppufile.getderef(definitionderef);
  2037. value:=ppufile.getlongint;
  2038. nextenum := Nil;
  2039. end;
  2040. procedure tenumsym.buildderef;
  2041. begin
  2042. definitionderef.build(definition);
  2043. end;
  2044. procedure tenumsym.deref;
  2045. begin
  2046. definition:=tenumdef(definitionderef.resolve);
  2047. order;
  2048. end;
  2049. procedure tenumsym.order;
  2050. var
  2051. sym : tenumsym;
  2052. begin
  2053. sym := tenumsym(definition.firstenum);
  2054. if sym = nil then
  2055. begin
  2056. definition.firstenum := self;
  2057. nextenum := nil;
  2058. exit;
  2059. end;
  2060. { reorder the symbols in increasing value }
  2061. if value < sym.value then
  2062. begin
  2063. nextenum := sym;
  2064. definition.firstenum := self;
  2065. end
  2066. else
  2067. begin
  2068. while (sym.value <= value) and assigned(sym.nextenum) do
  2069. sym := sym.nextenum;
  2070. nextenum := sym.nextenum;
  2071. sym.nextenum := self;
  2072. end;
  2073. end;
  2074. procedure tenumsym.ppuwrite(ppufile:tcompilerppufile);
  2075. begin
  2076. inherited ppuwrite(ppufile);
  2077. ppufile.putderef(definitionderef);
  2078. ppufile.putlongint(value);
  2079. ppufile.writeentry(ibenumsym);
  2080. end;
  2081. {****************************************************************************
  2082. TTYPESYM
  2083. ****************************************************************************}
  2084. constructor ttypesym.create(const n : string;const tt : ttype);
  2085. begin
  2086. inherited create(n);
  2087. typ:=typesym;
  2088. restype:=tt;
  2089. { register the typesym for the definition }
  2090. if assigned(restype.def) and
  2091. (restype.def.deftype<>errordef) and
  2092. not(assigned(restype.def.typesym)) then
  2093. restype.def.typesym:=self;
  2094. end;
  2095. constructor ttypesym.ppuload(ppufile:tcompilerppufile);
  2096. begin
  2097. inherited ppuload(ppufile);
  2098. typ:=typesym;
  2099. ppufile.gettype(restype);
  2100. end;
  2101. function ttypesym.gettypedef:tdef;
  2102. begin
  2103. gettypedef:=restype.def;
  2104. end;
  2105. procedure ttypesym.buildderef;
  2106. begin
  2107. restype.buildderef;
  2108. end;
  2109. procedure ttypesym.deref;
  2110. begin
  2111. restype.resolve;
  2112. end;
  2113. procedure ttypesym.ppuwrite(ppufile:tcompilerppufile);
  2114. begin
  2115. inherited ppuwrite(ppufile);
  2116. ppufile.puttype(restype);
  2117. ppufile.writeentry(ibtypesym);
  2118. end;
  2119. procedure ttypesym.load_references(ppufile:tcompilerppufile;locals:boolean);
  2120. begin
  2121. inherited load_references(ppufile,locals);
  2122. if (restype.def.deftype=recorddef) then
  2123. tstoredsymtable(trecorddef(restype.def).symtable).load_references(ppufile,locals);
  2124. if (restype.def.deftype=objectdef) then
  2125. tstoredsymtable(tobjectdef(restype.def).symtable).load_references(ppufile,locals);
  2126. end;
  2127. function ttypesym.write_references(ppufile:tcompilerppufile;locals:boolean):boolean;
  2128. var
  2129. d : tderef;
  2130. begin
  2131. d.reset;
  2132. if not inherited write_references(ppufile,locals) then
  2133. begin
  2134. { write address of this symbol if record or object
  2135. even if no real refs are there
  2136. because we need it for the symtable }
  2137. if (restype.def.deftype in [recorddef,objectdef]) then
  2138. begin
  2139. d.build(self);
  2140. ppufile.putderef(d);
  2141. ppufile.writeentry(ibsymref);
  2142. end;
  2143. end;
  2144. write_references:=true;
  2145. if (restype.def.deftype=recorddef) then
  2146. tstoredsymtable(trecorddef(restype.def).symtable).write_references(ppufile,locals);
  2147. if (restype.def.deftype=objectdef) then
  2148. tstoredsymtable(tobjectdef(restype.def).symtable).write_references(ppufile,locals);
  2149. end;
  2150. {$ifdef GDB}
  2151. function ttypesym.stabstring : pchar;
  2152. var stabchar:string[2];
  2153. begin
  2154. stabstring:=nil;
  2155. if restype.def<>nil then
  2156. begin
  2157. if restype.def.deftype in tagtypes then
  2158. stabchar:='Tt'
  2159. else
  2160. stabchar:='t';
  2161. stabstring:=stabstr_evaluate('"${name}:$1$2",${N_LSYM},0,${line},0',[stabchar,tstoreddef(restype.def).numberstring]);
  2162. end;
  2163. end;
  2164. {$endif GDB}
  2165. {****************************************************************************
  2166. TSYSSYM
  2167. ****************************************************************************}
  2168. constructor tsyssym.create(const n : string;l : longint);
  2169. begin
  2170. inherited create(n);
  2171. typ:=syssym;
  2172. number:=l;
  2173. end;
  2174. constructor tsyssym.ppuload(ppufile:tcompilerppufile);
  2175. begin
  2176. inherited ppuload(ppufile);
  2177. typ:=syssym;
  2178. number:=ppufile.getlongint;
  2179. end;
  2180. destructor tsyssym.destroy;
  2181. begin
  2182. inherited destroy;
  2183. end;
  2184. procedure tsyssym.ppuwrite(ppufile:tcompilerppufile);
  2185. begin
  2186. inherited ppuwrite(ppufile);
  2187. ppufile.putlongint(number);
  2188. ppufile.writeentry(ibsyssym);
  2189. end;
  2190. {*****************************************************************************
  2191. TMacro
  2192. *****************************************************************************}
  2193. constructor tmacro.create(const n : string);
  2194. begin
  2195. inherited create(n);
  2196. typ:= macrosym;
  2197. owner:= nil;
  2198. defined:=false;
  2199. is_used:=false;
  2200. is_compiler_var:= false;
  2201. buftext:=nil;
  2202. buflen:=0;
  2203. end;
  2204. constructor tmacro.ppuload(ppufile:tcompilerppufile);
  2205. begin
  2206. inherited ppuload(ppufile);
  2207. typ:=macrosym;
  2208. name:=ppufile.getstring;
  2209. defined:=boolean(ppufile.getbyte);
  2210. is_compiler_var:=boolean(ppufile.getbyte);
  2211. is_used:=false;
  2212. buflen:= ppufile.getlongint;
  2213. if buflen > 0 then
  2214. begin
  2215. getmem(buftext, buflen);
  2216. ppufile.getdata(buftext^, buflen)
  2217. end
  2218. else
  2219. buftext:=nil;
  2220. end;
  2221. destructor tmacro.destroy;
  2222. begin
  2223. if assigned(buftext) then
  2224. freemem(buftext,buflen);
  2225. inherited destroy;
  2226. end;
  2227. procedure tmacro.ppuwrite(ppufile:tcompilerppufile);
  2228. begin
  2229. inherited ppuwrite(ppufile);
  2230. ppufile.putstring(name);
  2231. ppufile.putbyte(byte(defined));
  2232. ppufile.putbyte(byte(is_compiler_var));
  2233. ppufile.putlongint(buflen);
  2234. if buflen > 0 then
  2235. ppufile.putdata(buftext^,buflen);
  2236. ppufile.writeentry(ibmacrosym);
  2237. end;
  2238. {****************************************************************************
  2239. TRTTISYM
  2240. ****************************************************************************}
  2241. constructor trttisym.create(const n:string;rt:trttitype);
  2242. const
  2243. prefix : array[trttitype] of string[5]=('$rtti','$init');
  2244. begin
  2245. inherited create(prefix[rt]+n);
  2246. include(symoptions,sp_internal);
  2247. typ:=rttisym;
  2248. lab:=nil;
  2249. rttityp:=rt;
  2250. end;
  2251. destructor trttisym.destroy;
  2252. begin
  2253. if assigned(_mangledname) then
  2254. begin
  2255. {$ifdef MEMDEBUG}
  2256. memmanglednames.start;
  2257. {$endif MEMDEBUG}
  2258. stringdispose(_mangledname);
  2259. {$ifdef MEMDEBUG}
  2260. memmanglednames.stop;
  2261. {$endif MEMDEBUG}
  2262. end;
  2263. inherited destroy;
  2264. end;
  2265. constructor trttisym.ppuload(ppufile:tcompilerppufile);
  2266. begin
  2267. inherited ppuload(ppufile);
  2268. typ:=rttisym;
  2269. lab:=nil;
  2270. rttityp:=trttitype(ppufile.getbyte);
  2271. end;
  2272. procedure trttisym.ppuwrite(ppufile:tcompilerppufile);
  2273. begin
  2274. inherited ppuwrite(ppufile);
  2275. ppufile.putbyte(byte(rttityp));
  2276. ppufile.writeentry(ibrttisym);
  2277. end;
  2278. function trttisym.mangledname : string;
  2279. const
  2280. prefix : array[trttitype] of string[5]=('RTTI_','INIT_');
  2281. begin
  2282. if not assigned(_mangledname) then
  2283. _mangledname:=stringdup(make_mangledname(prefix[rttityp],owner,Copy(name,5,255)));
  2284. result:=_mangledname^;
  2285. end;
  2286. function trttisym.get_label:tasmsymbol;
  2287. begin
  2288. { the label is always a global label }
  2289. if not assigned(lab) then
  2290. lab:=objectlibrary.newasmsymbol(mangledname,AB_EXTERNAL,AT_DATA);
  2291. get_label:=lab;
  2292. end;
  2293. end.
  2294. {
  2295. $Log$
  2296. Revision 1.199 2005-01-09 20:24:43 olle
  2297. * rework of macro subsystem
  2298. + exportable macros for mode macpas
  2299. Revision 1.198 2005/01/04 16:38:54 peter
  2300. * fix setting minval for enum with specified values
  2301. Revision 1.197 2005/01/03 22:27:56 peter
  2302. * insert stack_check helper call before doing register allocation
  2303. so the used registers can't be reused when parameters are loaded
  2304. into register variables
  2305. Revision 1.196 2004/12/07 16:11:52 peter
  2306. * set vo_explicit_paraloc flag
  2307. Revision 1.195 2004/11/29 20:50:37 peter
  2308. * uninited results
  2309. Revision 1.194 2004/11/17 22:21:35 peter
  2310. mangledname setting moved to place after the complete proc declaration is read
  2311. import generation moved to place where body is also parsed (still gives problems with win32)
  2312. Revision 1.193 2004/11/16 22:09:57 peter
  2313. * _mangledname for symbols moved only to symbols that really need it
  2314. * overload number removed, add function result type to the mangledname fo
  2315. procdefs
  2316. Revision 1.192 2004/11/15 23:35:31 peter
  2317. * tparaitem removed, use tparavarsym instead
  2318. * parameter order is now calculated from paranr value in tparavarsym
  2319. Revision 1.191 2004/11/08 22:09:59 peter
  2320. * tvarsym splitted
  2321. Revision 1.190 2004/11/04 17:09:54 peter
  2322. fixed debuginfo for variables in staticsymtable
  2323. Revision 1.189 2004/10/31 21:45:03 peter
  2324. * generic tlocation
  2325. * move tlocation to cgutils
  2326. Revision 1.188 2004/10/15 09:14:17 mazen
  2327. - remove $IFDEF DELPHI and related code
  2328. - remove $IFDEF FPCPROCVAR and related code
  2329. Revision 1.187 2004/10/13 18:47:45 peter
  2330. * fix misplaced begin..end for self stabs
  2331. * no fpu regable for staticsymtable
  2332. Revision 1.186 2004/10/12 14:34:49 peter
  2333. * fixed visibility for procsyms
  2334. * fixed override check when there was no entry yet
  2335. Revision 1.185 2004/10/11 20:48:34 peter
  2336. * don't generate stabs for self when it is in a regvar
  2337. Revision 1.184 2004/10/11 15:48:15 peter
  2338. * small regvar for para fixes
  2339. * function tvarsym.is_regvar added
  2340. * tvarsym.getvaluesize removed, use getsize instead
  2341. Revision 1.183 2004/10/10 21:08:55 peter
  2342. * parameter regvar fixes
  2343. Revision 1.182 2004/10/10 20:22:53 peter
  2344. * symtable allocation rewritten
  2345. * loading of parameters to local temps/regs cleanup
  2346. * regvar support for parameters
  2347. * regvar support for staticsymtable (main body)
  2348. Revision 1.181 2004/10/10 09:31:28 peter
  2349. regvar ppu writing doesn't affect any crc
  2350. Revision 1.180 2004/10/08 17:09:43 peter
  2351. * tvarsym.varregable added, split vo_regable from varoptions
  2352. Revision 1.179 2004/10/06 19:26:50 jonas
  2353. * regvar fixes from Peter
  2354. Revision 1.178 2004/10/01 15:22:22 peter
  2355. * don't add stabs for register variables
  2356. Revision 1.177 2004/09/26 17:45:30 peter
  2357. * simple regvar support, not yet finished
  2358. Revision 1.176 2004/09/21 17:25:12 peter
  2359. * paraloc branch merged
  2360. Revision 1.175.4.1 2004/08/31 20:43:06 peter
  2361. * paraloc patch
  2362. Revision 1.175 2004/08/15 12:06:03 jonas
  2363. * add cprefix to procedures which are autoamtically marked as external in
  2364. macpas mode
  2365. Revision 1.174 2004/06/20 08:55:30 florian
  2366. * logs truncated
  2367. Revision 1.173 2004/06/16 20:07:09 florian
  2368. * dwarf branch merged
  2369. Revision 1.172 2004/05/22 23:32:52 peter
  2370. quote all low ascii chars in stabs
  2371. Revision 1.171 2004/05/11 22:52:48 olle
  2372. * Moved import_implicit_external to symsym
  2373. Revision 1.170 2004/05/11 18:29:41 olle
  2374. + mode macpas: support for implicit external
  2375. Revision 1.169.2.3 2004/05/01 16:02:09 peter
  2376. * POINTER_SIZE replaced with sizeof(aint)
  2377. * aint,aword,tconst*int moved to globtype
  2378. }