symsym.pas 86 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802
  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. cpuinfo,
  26. { symtable }
  27. symconst,symbase,symtype,symdef,
  28. { ppu }
  29. ppu,symppu,
  30. { aasm }
  31. aasmbase,aasmtai,cpubase,
  32. globals
  33. ;
  34. type
  35. {************************************************
  36. TSym
  37. ************************************************}
  38. { this object is the base for all symbol objects }
  39. tstoredsym = class(tsym)
  40. protected
  41. _mangledname : pstring;
  42. public
  43. {$ifdef GDB}
  44. isstabwritten : boolean;
  45. {$endif GDB}
  46. refs : longint;
  47. lastref,
  48. defref,
  49. lastwritten : tref;
  50. refcount : longint;
  51. constructor create(const n : string);
  52. constructor loadsym(ppufile:tcompilerppufile);
  53. destructor destroy;override;
  54. procedure ppuwrite(ppufile:tcompilerppufile);virtual;abstract;
  55. procedure writesym(ppufile:tcompilerppufile);
  56. procedure deref;override;
  57. procedure insert_in_data;virtual;
  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. defs : pprocdeflist; { linked list of overloaded procdefs }
  99. public
  100. is_global : boolean;
  101. overloadchecked : boolean;
  102. overloadcount : longint; { amount of overloaded functions in this module }
  103. constructor create(const n : string);
  104. constructor ppuload(ppufile:tcompilerppufile);
  105. destructor destroy;override;
  106. { writes all declarations except the specified one }
  107. procedure write_parameter_lists(skipdef:tprocdef);
  108. { tests, if all procedures definitions are defined and not }
  109. { only forward }
  110. procedure check_forward;
  111. procedure unchain_overload;
  112. procedure ppuwrite(ppufile:tcompilerppufile);override;
  113. procedure deref;override;
  114. procedure addprocdef(p:tprocdef);
  115. function procdef_count:byte;
  116. function procdef(nr:byte):Tprocdef;
  117. procedure add_para_match_to(Aprocsym:Tprocsym);
  118. procedure concat_procdefs_to(s:Tprocsym);
  119. procedure foreach_procdef_static(proc2call:Tprocdefcallback;arg:pointer);
  120. function first_procdef:Tprocdef;
  121. function last_procdef:Tprocdef;
  122. function search_procdef_bytype(pt:Tproctypeoption):Tprocdef;
  123. function search_procdef_bypara(params:Tparalinkedlist):Tprocdef;
  124. function search_procdef_byprocvardef(d:Tprocvardef):Tprocdef;
  125. function search_procdef_byretdef_by1paradef(retdef,firstpara:Tdef;
  126. matchtype:Tdefmatch):Tprocdef;
  127. function write_references(ppufile:tcompilerppufile;locals:boolean):boolean;override;
  128. {$ifdef GDB}
  129. function stabstring : pchar;override;
  130. procedure concatstabto(asmlist : taasmoutput);override;
  131. {$endif GDB}
  132. end;
  133. ttypesym = class(tstoredsym)
  134. restype : ttype;
  135. {$ifdef GDB}
  136. isusedinstab : boolean;
  137. {$endif GDB}
  138. constructor create(const n : string;const tt : ttype);
  139. constructor ppuload(ppufile:tcompilerppufile);
  140. procedure ppuwrite(ppufile:tcompilerppufile);override;
  141. procedure deref;override;
  142. function gettypedef:tdef;override;
  143. procedure load_references(ppufile:tcompilerppufile;locals:boolean);override;
  144. function write_references(ppufile:tcompilerppufile;locals:boolean):boolean;override;
  145. {$ifdef GDB}
  146. function stabstring : pchar;override;
  147. procedure concatstabto(asmlist : taasmoutput);override;
  148. {$endif GDB}
  149. end;
  150. tvarsym = class(tstoredsym)
  151. address : longint;
  152. localvarsym : tvarsym;
  153. vartype : ttype;
  154. varoptions : tvaroptions;
  155. reg : tregister; { if reg<>R_NO, then the variable is an register variable }
  156. varspez : tvarspez; { sets the type of access }
  157. varstate : tvarstate;
  158. constructor create(const n : string;const tt : ttype);
  159. constructor create_dll(const n : string;const tt : ttype);
  160. constructor create_C(const n,mangled : string;const tt : ttype);
  161. constructor ppuload(ppufile:tcompilerppufile);
  162. destructor destroy;override;
  163. procedure ppuwrite(ppufile:tcompilerppufile);override;
  164. procedure deref;override;
  165. procedure generate_mangledname;override;
  166. procedure set_mangledname(const s:string);
  167. procedure insert_in_data;override;
  168. function getsize : longint;
  169. function getvaluesize : longint;
  170. function getpushsize : longint;
  171. {$ifdef GDB}
  172. function stabstring : pchar;override;
  173. procedure concatstabto(asmlist : taasmoutput);override;
  174. {$endif GDB}
  175. end;
  176. tpropertysym = class(tstoredsym)
  177. propoptions : tpropertyoptions;
  178. propoverriden : tpropertysym;
  179. proptype,
  180. indextype : ttype;
  181. index,
  182. default : longint;
  183. readaccess,
  184. writeaccess,
  185. storedaccess : tsymlist;
  186. constructor create(const n : string);
  187. destructor destroy;override;
  188. constructor ppuload(ppufile:tcompilerppufile);
  189. function getsize : longint;
  190. procedure ppuwrite(ppufile:tcompilerppufile);override;
  191. function gettypedef:tdef;override;
  192. procedure deref;override;
  193. procedure dooverride(overriden:tpropertysym);
  194. {$ifdef GDB}
  195. function stabstring : pchar;override;
  196. procedure concatstabto(asmlist : taasmoutput);override;
  197. {$endif GDB}
  198. end;
  199. tfuncretsym = class(tstoredsym)
  200. returntype : ttype;
  201. address : longint;
  202. funcretstate : tvarstate;
  203. constructor create(const n : string;const tt : ttype);
  204. constructor ppuload(ppufile:tcompilerppufile);
  205. destructor destroy;override;
  206. procedure ppuwrite(ppufile:tcompilerppufile);override;
  207. procedure deref;override;
  208. procedure insert_in_data;override;
  209. {$ifdef GDB}
  210. procedure concatstabto(asmlist : taasmoutput);override;
  211. {$endif GDB}
  212. end;
  213. tabsolutesym = class(tvarsym)
  214. abstyp : absolutetyp;
  215. absseg : boolean;
  216. ref : tstoredsym;
  217. asmname : pstring;
  218. constructor create(const n : string;const tt : ttype);
  219. constructor ppuload(ppufile:tcompilerppufile);
  220. procedure deref;override;
  221. function mangledname : string;
  222. procedure ppuwrite(ppufile:tcompilerppufile);override;
  223. procedure insert_in_data;override;
  224. {$ifdef GDB}
  225. procedure concatstabto(asmlist : taasmoutput);override;
  226. {$endif GDB}
  227. end;
  228. ttypedconstsym = class(tstoredsym)
  229. typedconsttype : ttype;
  230. is_writable : boolean;
  231. constructor create(const n : string;p : tdef;writable : boolean);
  232. constructor createtype(const n : string;const tt : ttype;writable : boolean);
  233. constructor ppuload(ppufile:tcompilerppufile);
  234. destructor destroy;override;
  235. procedure generate_mangledname;override;
  236. procedure ppuwrite(ppufile:tcompilerppufile);override;
  237. procedure deref;override;
  238. function getsize:longint;
  239. procedure insert_in_data;override;
  240. {$ifdef GDB}
  241. function stabstring : pchar;override;
  242. {$endif GDB}
  243. end;
  244. tconstsym = class(tstoredsym)
  245. consttype : ttype;
  246. consttyp : tconsttyp;
  247. resstrindex, { needed for resource strings }
  248. valueord : tconstexprint; { used for ordinal values }
  249. valueordptr : TConstPtrUInt; { used for pointer values }
  250. valueptr : pointer; { used for string, set, real values }
  251. len : longint; { len is needed for string length }
  252. constructor create_ord(const n : string;t : tconsttyp;v : tconstexprint);
  253. constructor create_ord_typed(const n : string;t : tconsttyp;v : tconstexprint;const tt:ttype);
  254. constructor create_ordptr_typed(const n : string;t : tconsttyp;v : tconstptruint;const tt:ttype);
  255. constructor create_ptr(const n : string;t : tconsttyp;v : pointer);
  256. constructor create_ptr_typed(const n : string;t : tconsttyp;v : pointer;const tt:ttype);
  257. constructor create_string(const n : string;t : tconsttyp;str:pchar;l:longint);
  258. constructor ppuload(ppufile:tcompilerppufile);
  259. destructor destroy;override;
  260. function mangledname : string;
  261. procedure deref;override;
  262. procedure ppuwrite(ppufile:tcompilerppufile);override;
  263. {$ifdef GDB}
  264. function stabstring : pchar;override;
  265. procedure concatstabto(asmlist : taasmoutput);override;
  266. {$endif GDB}
  267. end;
  268. tenumsym = class(tstoredsym)
  269. value : longint;
  270. definition : tenumdef;
  271. nextenum : tenumsym;
  272. constructor create(const n : string;def : tenumdef;v : longint);
  273. constructor ppuload(ppufile:tcompilerppufile);
  274. procedure ppuwrite(ppufile:tcompilerppufile);override;
  275. procedure deref;override;
  276. procedure order;
  277. {$ifdef GDB}
  278. procedure concatstabto(asmlist : taasmoutput);override;
  279. {$endif GDB}
  280. end;
  281. tsyssym = class(tstoredsym)
  282. number : longint;
  283. constructor create(const n : string;l : longint);
  284. constructor ppuload(ppufile:tcompilerppufile);
  285. destructor destroy;override;
  286. procedure ppuwrite(ppufile:tcompilerppufile);override;
  287. {$ifdef GDB}
  288. procedure concatstabto(asmlist : taasmoutput);override;
  289. {$endif GDB}
  290. end;
  291. { compiler generated symbol to point to rtti and init/finalize tables }
  292. trttisym = class(tstoredsym)
  293. lab : tasmsymbol;
  294. rttityp : trttitype;
  295. constructor create(const n:string;rt:trttitype);
  296. constructor ppuload(ppufile:tcompilerppufile);
  297. procedure ppuwrite(ppufile:tcompilerppufile);override;
  298. function mangledname:string;
  299. function get_label:tasmsymbol;
  300. end;
  301. { register variables }
  302. pregvarinfo = ^tregvarinfo;
  303. tregvarinfo = record
  304. regvars : array[1..maxvarregs] of tvarsym;
  305. regvars_para : array[1..maxvarregs] of boolean;
  306. regvars_refs : array[1..maxvarregs] of longint;
  307. fpuregvars : array[1..maxfpuvarregs] of tvarsym;
  308. fpuregvars_para : array[1..maxfpuvarregs] of boolean;
  309. fpuregvars_refs : array[1..maxfpuvarregs] of longint;
  310. end;
  311. var
  312. aktprocsym : tprocsym; { pointer to the symbol for the
  313. currently be parsed procedure }
  314. aktprocdef : tprocdef;
  315. aktcallprocdef : tabstractprocdef; { pointer to the definition of the
  316. currently called procedure,
  317. only set/unset in ncal }
  318. aktvarsym : tvarsym; { pointer to the symbol for the
  319. currently read var, only used
  320. for variable directives }
  321. generrorsym : tsym;
  322. otsym : tvarsym;
  323. const
  324. current_object_option : tsymoptions = [sp_public];
  325. { rtti and init/final }
  326. procedure generate_rtti(p:tsym);
  327. procedure generate_inittable(p:tsym);
  328. implementation
  329. uses
  330. {$ifdef Delphi}
  331. sysutils,
  332. {$else Delphi}
  333. strings,
  334. {$endif Delphi}
  335. { global }
  336. globtype,verbose,
  337. { target }
  338. systems,
  339. { symtable }
  340. symtable,defbase,
  341. {$ifdef GDB}
  342. gdb,
  343. {$endif GDB}
  344. { tree }
  345. node,
  346. { aasm }
  347. aasmcpu,
  348. { module }
  349. fmodule,
  350. { codegen }
  351. paramgr,cgbase,cresstr
  352. ;
  353. {****************************************************************************
  354. Helpers
  355. ****************************************************************************}
  356. {****************************************************************************
  357. TSYM (base for all symtypes)
  358. ****************************************************************************}
  359. constructor tstoredsym.create(const n : string);
  360. begin
  361. inherited create(n);
  362. symoptions:=current_object_option;
  363. {$ifdef GDB}
  364. isstabwritten := false;
  365. {$endif GDB}
  366. fileinfo:=akttokenpos;
  367. defref:=nil;
  368. refs:=0;
  369. lastwritten:=nil;
  370. refcount:=0;
  371. if (cs_browser in aktmoduleswitches) and make_ref then
  372. begin
  373. defref:=tref.create(defref,@akttokenpos);
  374. inc(refcount);
  375. end;
  376. lastref:=defref;
  377. _mangledname:=nil;
  378. end;
  379. constructor tstoredsym.loadsym(ppufile:tcompilerppufile);
  380. var
  381. s : string;
  382. nr : word;
  383. begin
  384. nr:=ppufile.getword;
  385. s:=ppufile.getstring;
  386. inherited create(s);
  387. { force the correct indexnr. must be after create! }
  388. indexnr:=nr;
  389. ppufile.getsmallset(symoptions);
  390. ppufile.getposinfo(fileinfo);
  391. lastref:=nil;
  392. defref:=nil;
  393. refs:=0;
  394. lastwritten:=nil;
  395. refcount:=0;
  396. _mangledname:=nil;
  397. {$ifdef GDB}
  398. isstabwritten := false;
  399. {$endif GDB}
  400. end;
  401. procedure tstoredsym.deref;
  402. begin
  403. end;
  404. procedure tstoredsym.load_references(ppufile:tcompilerppufile;locals:boolean);
  405. var
  406. pos : tfileposinfo;
  407. move_last : boolean;
  408. begin
  409. move_last:=lastwritten=lastref;
  410. while (not ppufile.endofentry) do
  411. begin
  412. ppufile.getposinfo(pos);
  413. inc(refcount);
  414. lastref:=tref.create(lastref,@pos);
  415. lastref.is_written:=true;
  416. if refcount=1 then
  417. defref:=lastref;
  418. end;
  419. if move_last then
  420. lastwritten:=lastref;
  421. end;
  422. { big problem here :
  423. wrong refs were written because of
  424. interface parsing of other units PM
  425. moduleindex must be checked !! }
  426. function tstoredsym.write_references(ppufile:tcompilerppufile;locals:boolean):boolean;
  427. var
  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. if assigned(lastwritten) then
  439. ref:=lastwritten
  440. else
  441. ref:=defref;
  442. while assigned(ref) do
  443. begin
  444. if ref.moduleindex=current_module.unit_index then
  445. begin
  446. { write address to this symbol }
  447. if not symref_written then
  448. begin
  449. ppufile.putderef(self);
  450. symref_written:=true;
  451. end;
  452. ppufile.putposinfo(ref.posinfo);
  453. ref.is_written:=true;
  454. if move_last then
  455. lastwritten:=ref;
  456. end
  457. else if not ref.is_written then
  458. move_last:=false
  459. else if move_last then
  460. lastwritten:=ref;
  461. ref:=ref.nextref;
  462. end;
  463. if symref_written then
  464. ppufile.writeentry(ibsymref);
  465. write_references:=symref_written;
  466. end;
  467. destructor tstoredsym.destroy;
  468. begin
  469. if assigned(_mangledname) then
  470. stringdispose(_mangledname);
  471. if assigned(defref) then
  472. begin
  473. defref.freechain;
  474. defref.free;
  475. end;
  476. inherited destroy;
  477. end;
  478. procedure tstoredsym.writesym(ppufile:tcompilerppufile);
  479. begin
  480. ppufile.putword(indexnr);
  481. ppufile.putstring(_realname^);
  482. ppufile.putsmallset(symoptions);
  483. ppufile.putposinfo(fileinfo);
  484. end;
  485. { for most symbol types there is nothing to do at all }
  486. procedure tstoredsym.insert_in_data;
  487. begin
  488. end;
  489. {$ifdef GDB}
  490. function tstoredsym.stabstring : pchar;
  491. begin
  492. stabstring:=strpnew('"'+name+'",'+tostr(N_LSYM)+',0,'+
  493. tostr(fileinfo.line)+',0');
  494. end;
  495. procedure tstoredsym.concatstabto(asmlist : taasmoutput);
  496. var
  497. stab_str : pchar;
  498. begin
  499. if not isstabwritten then
  500. begin
  501. stab_str := stabstring;
  502. { count_dbx(stab_str); moved to GDB.PAS }
  503. asmList.concat(Tai_stabs.Create(stab_str));
  504. isstabwritten:=true;
  505. end;
  506. end;
  507. {$endif GDB}
  508. function tstoredsym.is_visible_for_proc(currprocdef:tprocdef):boolean;
  509. begin
  510. is_visible_for_proc:=false;
  511. { private symbols are allowed when we are in the same
  512. module as they are defined }
  513. if (sp_private in symoptions) and
  514. (owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  515. (owner.defowner.owner.unitid<>0) then
  516. exit;
  517. { protected symbols are vissible in the module that defines them and
  518. also visible to related objects }
  519. if (sp_protected in symoptions) and
  520. (
  521. (
  522. (owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  523. (owner.defowner.owner.unitid<>0)
  524. ) and
  525. not(
  526. assigned(currprocdef) and
  527. assigned(currprocdef._class) and
  528. currprocdef._class.is_related(tobjectdef(owner.defowner))
  529. )
  530. ) then
  531. exit;
  532. is_visible_for_proc:=true;
  533. end;
  534. function tstoredsym.is_visible_for_object(currobjdef:tobjectdef):boolean;
  535. begin
  536. is_visible_for_object:=false;
  537. { private symbols are allowed when we are in the same
  538. module as they are defined }
  539. if (sp_private in symoptions) and
  540. (owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  541. (owner.defowner.owner.unitid<>0) then
  542. exit;
  543. { protected symbols are vissible in the module that defines them and
  544. also visible to related objects }
  545. if (sp_protected in symoptions) and
  546. (
  547. (
  548. (owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  549. (owner.defowner.owner.unitid<>0)
  550. ) and
  551. not(
  552. assigned(currobjdef) and
  553. currobjdef.is_related(tobjectdef(owner.defowner))
  554. )
  555. ) then
  556. exit;
  557. is_visible_for_object:=true;
  558. end;
  559. function tstoredsym.mangledname : string;
  560. begin
  561. if not assigned(_mangledname) then
  562. begin
  563. generate_mangledname;
  564. if not assigned(_mangledname) then
  565. internalerror(200204171);
  566. end;
  567. mangledname:=_mangledname^
  568. end;
  569. {****************************************************************************
  570. TLABELSYM
  571. ****************************************************************************}
  572. constructor tlabelsym.create(const n : string; l : tasmlabel);
  573. begin
  574. inherited create(n);
  575. typ:=labelsym;
  576. lab:=l;
  577. used:=false;
  578. defined:=false;
  579. code:=nil;
  580. end;
  581. constructor tlabelsym.ppuload(ppufile:tcompilerppufile);
  582. begin
  583. inherited loadsym(ppufile);
  584. typ:=labelsym;
  585. { this is all dummy
  586. it is only used for local browsing }
  587. lab:=nil;
  588. code:=nil;
  589. used:=false;
  590. defined:=true;
  591. end;
  592. destructor tlabelsym.destroy;
  593. begin
  594. inherited destroy;
  595. end;
  596. procedure tlabelsym.generate_mangledname;
  597. begin
  598. _mangledname:=stringdup(lab.name);
  599. end;
  600. procedure tlabelsym.ppuwrite(ppufile:tcompilerppufile);
  601. begin
  602. if owner.symtabletype=globalsymtable then
  603. Message(sym_e_ill_label_decl)
  604. else
  605. begin
  606. inherited writesym(ppufile);
  607. ppufile.writeentry(iblabelsym);
  608. end;
  609. end;
  610. {****************************************************************************
  611. TUNITSYM
  612. ****************************************************************************}
  613. constructor tunitsym.create(const n : string;ref : tsymtable);
  614. var
  615. old_make_ref : boolean;
  616. begin
  617. old_make_ref:=make_ref;
  618. make_ref:=false;
  619. inherited create(n);
  620. make_ref:=old_make_ref;
  621. typ:=unitsym;
  622. unitsymtable:=ref;
  623. if assigned(ref) and
  624. (ref.symtabletype=globalsymtable) then
  625. begin
  626. prevsym:=tglobalsymtable(ref).unitsym;
  627. tglobalsymtable(ref).unitsym:=self;
  628. end;
  629. end;
  630. constructor tunitsym.ppuload(ppufile:tcompilerppufile);
  631. begin
  632. inherited loadsym(ppufile);
  633. typ:=unitsym;
  634. unitsymtable:=nil;
  635. prevsym:=nil;
  636. refs:=0;
  637. end;
  638. { we need to remove it from the prevsym chain ! }
  639. procedure tunitsym.restoreunitsym;
  640. var pus,ppus : tunitsym;
  641. begin
  642. if assigned(unitsymtable) and
  643. (unitsymtable.symtabletype=globalsymtable) then
  644. begin
  645. ppus:=nil;
  646. pus:=tglobalsymtable(unitsymtable).unitsym;
  647. if pus=self then
  648. tglobalsymtable(unitsymtable).unitsym:=prevsym
  649. else while assigned(pus) do
  650. begin
  651. if pus=self then
  652. begin
  653. ppus.prevsym:=prevsym;
  654. break;
  655. end
  656. else
  657. begin
  658. ppus:=pus;
  659. pus:=ppus.prevsym;
  660. end;
  661. end;
  662. end;
  663. unitsymtable:=nil;
  664. prevsym:=nil;
  665. end;
  666. destructor tunitsym.destroy;
  667. begin
  668. restoreunitsym;
  669. inherited destroy;
  670. end;
  671. procedure tunitsym.ppuwrite(ppufile:tcompilerppufile);
  672. begin
  673. inherited writesym(ppufile);
  674. ppufile.writeentry(ibunitsym);
  675. end;
  676. {$ifdef GDB}
  677. procedure tunitsym.concatstabto(asmlist : taasmoutput);
  678. begin
  679. {Nothing to write to stabs !}
  680. end;
  681. {$endif GDB}
  682. {****************************************************************************
  683. TPROCSYM
  684. ****************************************************************************}
  685. constructor tprocsym.create(const n : string);
  686. begin
  687. inherited create(n);
  688. typ:=procsym;
  689. defs:=nil;
  690. owner:=nil;
  691. is_global:=false;
  692. overloadchecked:=false;
  693. overloadcount:=0;
  694. end;
  695. constructor tprocsym.ppuload(ppufile:tcompilerppufile);
  696. var
  697. pd : tprocdef;
  698. begin
  699. inherited loadsym(ppufile);
  700. typ:=procsym;
  701. defs:=nil;
  702. repeat
  703. pd:=tprocdef(ppufile.getderef);
  704. if pd=nil then
  705. break;
  706. addprocdef(pd);
  707. until false;
  708. is_global:=false;
  709. overloadchecked:=false;
  710. overloadcount:=-1; { invalid, not used anymore }
  711. end;
  712. destructor tprocsym.destroy;
  713. var
  714. hp,p : pprocdeflist;
  715. begin
  716. p:=defs;
  717. while assigned(p) do
  718. begin
  719. hp:=p^.next;
  720. dispose(p);
  721. p:=hp;
  722. end;
  723. inherited destroy;
  724. end;
  725. procedure tprocsym.write_parameter_lists(skipdef:tprocdef);
  726. var
  727. p : pprocdeflist;
  728. begin
  729. p:=defs;
  730. while assigned(p) do
  731. begin
  732. if p^.def<>skipdef then
  733. MessagePos1(p^.def.fileinfo,sym_b_param_list,p^.def.fullprocname);
  734. p:=p^.next;
  735. end;
  736. end;
  737. procedure tprocsym.check_forward;
  738. var
  739. p : pprocdeflist;
  740. begin
  741. p:=defs;
  742. while assigned(p) do
  743. begin
  744. if (p^.def.procsym=self) and
  745. (p^.def.forwarddef) then
  746. begin
  747. MessagePos1(fileinfo,sym_e_forward_not_resolved,p^.def.fullprocname);
  748. { Turn futher error messages off }
  749. p^.def.forwarddef:=false;
  750. end;
  751. p:=p^.next;
  752. end;
  753. end;
  754. procedure tprocsym.deref;
  755. var
  756. p : pprocdeflist;
  757. begin
  758. p:=defs;
  759. while assigned(p) do
  760. begin
  761. resolvedef(pointer(p^.def));
  762. p:=p^.next;
  763. end;
  764. end;
  765. procedure tprocsym.addprocdef(p:tprocdef);
  766. var
  767. pd : pprocdeflist;
  768. begin
  769. new(pd);
  770. pd^.def:=p;
  771. pd^.next:=defs;
  772. defs:=pd;
  773. end;
  774. function Tprocsym.procdef_count:byte;
  775. var pd:Pprocdeflist;
  776. begin
  777. procdef_count:=0;
  778. pd:=defs;
  779. while assigned(pd) do
  780. begin
  781. inc(procdef_count);
  782. pd:=pd^.next;
  783. end;
  784. end;
  785. function Tprocsym.procdef(nr:byte):Tprocdef;
  786. var i:byte;
  787. pd:Pprocdeflist;
  788. begin
  789. pd:=defs;
  790. for i:=2 to nr do
  791. pd:=pd^.next;
  792. procdef:=pd^.def;
  793. end;
  794. procedure Tprocsym.add_para_match_to(Aprocsym:Tprocsym);
  795. var pd:Pprocdeflist;
  796. begin
  797. pd:=defs;
  798. while assigned(pd) do
  799. begin
  800. if Aprocsym.search_procdef_bypara(pd^.def.para)=nil then
  801. Aprocsym.addprocdef(pd^.def);
  802. pd:=pd^.next;
  803. end;
  804. end;
  805. procedure Tprocsym.concat_procdefs_to(s:Tprocsym);
  806. var pd:Pprocdeflist;
  807. begin
  808. pd:=defs;
  809. while assigned(defs) do
  810. begin
  811. s.addprocdef(pd^.def);
  812. pd:=pd^.next;
  813. end;
  814. end;
  815. function Tprocsym.first_procdef:Tprocdef;
  816. begin
  817. first_procdef:=defs^.def;
  818. end;
  819. function Tprocsym.last_procdef:Tprocdef;
  820. var pd:Pprocdeflist;
  821. begin
  822. pd:=defs;
  823. while assigned(pd) do
  824. begin
  825. last_procdef:=pd^.def;
  826. pd:=pd^.next;
  827. end;
  828. end;
  829. procedure Tprocsym.foreach_procdef_static(proc2call:Tprocdefcallback;arg:pointer);
  830. var p:Pprocdeflist;
  831. begin
  832. p:=defs;
  833. while assigned(p) do
  834. begin
  835. proc2call(p^.def,arg);
  836. p:=p^.next;
  837. end;
  838. end;
  839. function Tprocsym.search_procdef_bytype(pt:Tproctypeoption):Tprocdef;
  840. var p:Pprocdeflist;
  841. begin
  842. search_procdef_bytype:=nil;
  843. p:=defs;
  844. while p<>nil do
  845. begin
  846. if p^.def.proctypeoption=pt then
  847. begin
  848. search_procdef_bytype:=p^.def;
  849. break;
  850. end;
  851. p:=p^.next;
  852. end;
  853. end;
  854. function Tprocsym.search_procdef_bypara(params:Tparalinkedlist):Tprocdef;
  855. var pd:Pprocdeflist;
  856. begin
  857. search_procdef_bypara:=nil;
  858. pd:=defs;
  859. while assigned(pd) do
  860. begin
  861. if equal_paras(pd^.def.para,params,cp_value_equal_const) then
  862. begin
  863. search_procdef_bypara:=pd^.def;
  864. break;
  865. end;
  866. pd:=pd^.next;
  867. end;
  868. end;
  869. function Tprocsym.search_procdef_byprocvardef(d:Tprocvardef):Tprocdef;
  870. var pd:Pprocdeflist;
  871. begin
  872. {This function will return the pprocdef of pprocsym that
  873. is the best match for procvardef. When there are multiple
  874. matches it returns nil.}
  875. {Try to find an exact match first.}
  876. search_procdef_byprocvardef:=nil;
  877. pd:=defs;
  878. while assigned(pd) do
  879. begin
  880. if proc_to_procvar_equal(pd^.def,d,true) then
  881. begin
  882. { already found a match ? Then stop and return nil }
  883. if assigned(search_procdef_byprocvardef) then
  884. begin
  885. search_procdef_byprocvardef:=nil;
  886. break;
  887. end;
  888. search_procdef_byprocvardef:=pd^.def;
  889. end;
  890. pd:=pd^.next;
  891. end;
  892. {Try a convertable match, if no exact match was found.}
  893. if not assigned(search_procdef_byprocvardef) and not assigned(pd) then
  894. begin
  895. pd:=defs;
  896. while assigned(pd) do
  897. begin
  898. if proc_to_procvar_equal(pd^.def,d,false) then
  899. begin
  900. { already found a match ? Then stop and return nil }
  901. if assigned(search_procdef_byprocvardef) then
  902. begin
  903. search_procdef_byprocvardef:=nil;
  904. break;
  905. end;
  906. search_procdef_byprocvardef:=pd^.def;
  907. end;
  908. pd:=pd^.next;
  909. end;
  910. end;
  911. end;
  912. function Tprocsym.search_procdef_byretdef_by1paradef(retdef,firstpara:Tdef;
  913. matchtype:Tdefmatch):Tprocdef;
  914. var pd:Pprocdeflist;
  915. convtyp:Tconverttype;
  916. a,b:boolean;
  917. begin
  918. search_procdef_byretdef_by1paradef:=nil;
  919. pd:=defs;
  920. while assigned(pd) do
  921. begin
  922. a:=is_equal(retdef,pd^.def.rettype.def);
  923. {Alert alert alert alert alert alert alert!!!
  924. Make sure you never call isconvertable when a=false. You get
  925. endless recursion then. Originally a and b were placed in a
  926. single if statement. There was only one reason that it worked:
  927. short circuit boolean eval.}
  928. if a then
  929. case matchtype of
  930. dm_exact:
  931. b:=TParaItem(pd^.def.para.first).paratype.def=firstpara;
  932. dm_equal:
  933. b:=is_equal(Tparaitem(pd^.def.para.first).paratype.def,firstpara);
  934. dm_convertl1:
  935. b:=isconvertable(firstpara,Tparaitem(pd^.def.para.first).paratype.def,
  936. convtyp,ordconstn,false)=1;
  937. end;
  938. if a and b then
  939. begin
  940. search_procdef_byretdef_by1paradef:=pd^.def;
  941. break;
  942. end;
  943. pd:=pd^.next;
  944. end;
  945. end;
  946. procedure tprocsym.ppuwrite(ppufile:tcompilerppufile);
  947. var
  948. p : pprocdeflist;
  949. begin
  950. inherited writesym(ppufile);
  951. p:=defs;
  952. while assigned(p) do
  953. begin
  954. { only write the proc definitions that belong
  955. to this procsym }
  956. if (p^.def.procsym=self) then
  957. ppufile.putderef(p^.def);
  958. p:=p^.next;
  959. end;
  960. ppufile.putderef(nil);
  961. ppufile.writeentry(ibprocsym);
  962. end;
  963. function tprocsym.write_references(ppufile:tcompilerppufile;locals:boolean) : boolean;
  964. var
  965. p : pprocdeflist;
  966. begin
  967. write_references:=false;
  968. if not inherited write_references(ppufile,locals) then
  969. exit;
  970. write_references:=true;
  971. p:=defs;
  972. while assigned(p) do
  973. begin
  974. if (p^.def.procsym=self) then
  975. p^.def.write_references(ppufile,locals);
  976. p:=p^.next;
  977. end;
  978. end;
  979. procedure tprocsym.unchain_overload;
  980. var
  981. p,hp,
  982. first,
  983. last : pprocdeflist;
  984. begin
  985. { remove all overloaded procdefs from the
  986. procdeflist that are not in the current symtable }
  987. first:=nil;
  988. last:=nil;
  989. p:=defs;
  990. while assigned(p) do
  991. begin
  992. hp:=p^.next;
  993. if (p^.def.procsym=self) then
  994. begin
  995. { keep in list }
  996. if not assigned(first) then
  997. begin
  998. first:=p;
  999. last:=p;
  1000. end
  1001. else
  1002. last^.next:=p;
  1003. last:=p;
  1004. p^.next:=nil;
  1005. end
  1006. else
  1007. begin
  1008. { remove }
  1009. dispose(p);
  1010. end;
  1011. p:=hp;
  1012. end;
  1013. defs:=first;
  1014. end;
  1015. {$ifdef GDB}
  1016. function tprocsym.stabstring : pchar;
  1017. begin
  1018. internalerror(200111171);
  1019. stabstring:=nil;
  1020. end;
  1021. procedure tprocsym.concatstabto(asmlist : taasmoutput);
  1022. begin
  1023. internalerror(200111172);
  1024. end;
  1025. {$endif GDB}
  1026. {****************************************************************************
  1027. TERRORSYM
  1028. ****************************************************************************}
  1029. constructor terrorsym.create;
  1030. begin
  1031. inherited create('');
  1032. typ:=errorsym;
  1033. end;
  1034. {****************************************************************************
  1035. TPROPERTYSYM
  1036. ****************************************************************************}
  1037. constructor tpropertysym.create(const n : string);
  1038. begin
  1039. inherited create(n);
  1040. typ:=propertysym;
  1041. propoptions:=[];
  1042. index:=0;
  1043. default:=0;
  1044. proptype.reset;
  1045. indextype.reset;
  1046. readaccess:=tsymlist.create;
  1047. writeaccess:=tsymlist.create;
  1048. storedaccess:=tsymlist.create;
  1049. end;
  1050. constructor tpropertysym.ppuload(ppufile:tcompilerppufile);
  1051. begin
  1052. inherited loadsym(ppufile);
  1053. typ:=propertysym;
  1054. ppufile.getsmallset(propoptions);
  1055. if (ppo_is_override in propoptions) then
  1056. begin
  1057. propoverriden:=tpropertysym(ppufile.getderef);
  1058. { we need to have these objects initialized }
  1059. readaccess:=tsymlist.create;
  1060. writeaccess:=tsymlist.create;
  1061. storedaccess:=tsymlist.create;
  1062. end
  1063. else
  1064. begin
  1065. ppufile.gettype(proptype);
  1066. index:=ppufile.getlongint;
  1067. default:=ppufile.getlongint;
  1068. ppufile.gettype(indextype);
  1069. readaccess:=ppufile.getsymlist;
  1070. writeaccess:=ppufile.getsymlist;
  1071. storedaccess:=ppufile.getsymlist;
  1072. end;
  1073. end;
  1074. destructor tpropertysym.destroy;
  1075. begin
  1076. readaccess.free;
  1077. writeaccess.free;
  1078. storedaccess.free;
  1079. inherited destroy;
  1080. end;
  1081. function tpropertysym.gettypedef:tdef;
  1082. begin
  1083. gettypedef:=proptype.def;
  1084. end;
  1085. procedure tpropertysym.deref;
  1086. begin
  1087. if (ppo_is_override in propoptions) then
  1088. begin
  1089. resolvesym(pointer(propoverriden));
  1090. dooverride(propoverriden);
  1091. end
  1092. else
  1093. begin
  1094. proptype.resolve;
  1095. indextype.resolve;
  1096. readaccess.resolve;
  1097. writeaccess.resolve;
  1098. storedaccess.resolve;
  1099. end;
  1100. end;
  1101. function tpropertysym.getsize : longint;
  1102. begin
  1103. getsize:=0;
  1104. end;
  1105. procedure tpropertysym.ppuwrite(ppufile:tcompilerppufile);
  1106. begin
  1107. inherited writesym(ppufile);
  1108. ppufile.putsmallset(propoptions);
  1109. if (ppo_is_override in propoptions) then
  1110. ppufile.putderef(propoverriden)
  1111. else
  1112. begin
  1113. ppufile.puttype(proptype);
  1114. ppufile.putlongint(index);
  1115. ppufile.putlongint(default);
  1116. ppufile.puttype(indextype);
  1117. ppufile.putsymlist(readaccess);
  1118. ppufile.putsymlist(writeaccess);
  1119. ppufile.putsymlist(storedaccess);
  1120. end;
  1121. ppufile.writeentry(ibpropertysym);
  1122. end;
  1123. procedure tpropertysym.dooverride(overriden:tpropertysym);
  1124. begin
  1125. propoverriden:=overriden;
  1126. proptype:=overriden.proptype;
  1127. propoptions:=overriden.propoptions+[ppo_is_override];
  1128. index:=overriden.index;
  1129. default:=overriden.default;
  1130. indextype:=overriden.indextype;
  1131. readaccess.free;
  1132. readaccess:=overriden.readaccess.getcopy;
  1133. writeaccess.free;
  1134. writeaccess:=overriden.writeaccess.getcopy;
  1135. storedaccess.free;
  1136. storedaccess:=overriden.storedaccess.getcopy;
  1137. end;
  1138. {$ifdef GDB}
  1139. function tpropertysym.stabstring : pchar;
  1140. begin
  1141. { !!!! don't know how to handle }
  1142. stabstring:=strpnew('');
  1143. end;
  1144. procedure tpropertysym.concatstabto(asmlist : taasmoutput);
  1145. begin
  1146. { !!!! don't know how to handle }
  1147. end;
  1148. {$endif GDB}
  1149. {****************************************************************************
  1150. TFUNCRETSYM
  1151. ****************************************************************************}
  1152. constructor tfuncretsym.create(const n : string;const tt:ttype);
  1153. begin
  1154. inherited create(n);
  1155. typ:=funcretsym;
  1156. returntype:=tt;
  1157. funcretstate:=vs_declared;
  1158. { address valid for ret in param only }
  1159. { otherwise set by insert }
  1160. address:=procinfo.return_offset;
  1161. end;
  1162. constructor tfuncretsym.ppuload(ppufile:tcompilerppufile);
  1163. begin
  1164. inherited loadsym(ppufile);
  1165. ppufile.gettype(returntype);
  1166. address:=ppufile.getlongint;
  1167. typ:=funcretsym;
  1168. end;
  1169. destructor tfuncretsym.destroy;
  1170. begin
  1171. inherited destroy;
  1172. end;
  1173. procedure tfuncretsym.ppuwrite(ppufile:tcompilerppufile);
  1174. begin
  1175. inherited writesym(ppufile);
  1176. ppufile.puttype(returntype);
  1177. ppufile.putlongint(address);
  1178. ppufile.writeentry(ibfuncretsym);
  1179. funcretstate:=vs_used;
  1180. end;
  1181. procedure tfuncretsym.deref;
  1182. begin
  1183. returntype.resolve;
  1184. end;
  1185. {$ifdef GDB}
  1186. procedure tfuncretsym.concatstabto(asmlist : taasmoutput);
  1187. begin
  1188. { Nothing to do here, it is done in genexitcode }
  1189. end;
  1190. {$endif GDB}
  1191. procedure tfuncretsym.insert_in_data;
  1192. var
  1193. varalign,l : longint;
  1194. begin
  1195. { if retoffset is already set then reuse it, this is needed
  1196. when inserting the result variable }
  1197. if procinfo.return_offset<>0 then
  1198. address:=procinfo.return_offset
  1199. else
  1200. begin
  1201. { allocate space in local if ret in register }
  1202. if paramanager.ret_in_reg(returntype.def) then
  1203. begin
  1204. l:=returntype.def.size;
  1205. varalign:=size_2_align(l);
  1206. varalign:=used_align(varalign,aktalignment.localalignmin,owner.dataalignment);
  1207. address:=align(owner.datasize+l,varalign);
  1208. owner.datasize:=address;
  1209. procinfo.return_offset:=-address;
  1210. end;
  1211. end;
  1212. end;
  1213. {****************************************************************************
  1214. TABSOLUTESYM
  1215. ****************************************************************************}
  1216. constructor tabsolutesym.create(const n : string;const tt : ttype);
  1217. begin
  1218. inherited create(n,tt);
  1219. typ:=absolutesym;
  1220. end;
  1221. constructor tabsolutesym.ppuload(ppufile:tcompilerppufile);
  1222. begin
  1223. { Note: This needs to load everything of tvarsym.write }
  1224. inherited ppuload(ppufile);
  1225. { load absolute }
  1226. typ:=absolutesym;
  1227. ref:=nil;
  1228. address:=0;
  1229. asmname:=nil;
  1230. abstyp:=absolutetyp(ppufile.getbyte);
  1231. absseg:=false;
  1232. case abstyp of
  1233. tovar :
  1234. asmname:=stringdup(ppufile.getstring);
  1235. toasm :
  1236. asmname:=stringdup(ppufile.getstring);
  1237. toaddr :
  1238. begin
  1239. address:=ppufile.getlongint;
  1240. absseg:=boolean(ppufile.getbyte);
  1241. end;
  1242. end;
  1243. end;
  1244. procedure tabsolutesym.ppuwrite(ppufile:tcompilerppufile);
  1245. var
  1246. hvo : tvaroptions;
  1247. begin
  1248. { Note: This needs to write everything of tvarsym.write }
  1249. inherited writesym(ppufile);
  1250. ppufile.putbyte(byte(varspez));
  1251. ppufile.putlongint(address);
  1252. { write only definition or definitionsym }
  1253. ppufile.puttype(vartype);
  1254. hvo:=varoptions-[vo_regable];
  1255. ppufile.putsmallset(hvo);
  1256. ppufile.putbyte(byte(abstyp));
  1257. case abstyp of
  1258. tovar :
  1259. ppufile.putstring(ref.name);
  1260. toasm :
  1261. ppufile.putstring(asmname^);
  1262. toaddr :
  1263. begin
  1264. ppufile.putlongint(address);
  1265. ppufile.putbyte(byte(absseg));
  1266. end;
  1267. end;
  1268. ppufile.writeentry(ibabsolutesym);
  1269. end;
  1270. procedure tabsolutesym.deref;
  1271. var
  1272. srsym : tsym;
  1273. srsymtable : tsymtable;
  1274. begin
  1275. { inheritance of varsym.deref ! }
  1276. vartype.resolve;
  1277. { own absolute deref }
  1278. if (abstyp=tovar) and (asmname<>nil) then
  1279. begin
  1280. { search previous loaded symtables }
  1281. searchsym(asmname^,srsym,srsymtable);
  1282. if not assigned(srsym) then
  1283. srsym:=searchsymonlyin(owner,asmname^);
  1284. if not assigned(srsym) then
  1285. srsym:=generrorsym;
  1286. ref:=tstoredsym(srsym);
  1287. stringdispose(asmname);
  1288. end;
  1289. end;
  1290. function tabsolutesym.mangledname : string;
  1291. begin
  1292. case abstyp of
  1293. tovar :
  1294. begin
  1295. case ref.typ of
  1296. varsym :
  1297. mangledname:=tvarsym(ref).mangledname;
  1298. else
  1299. internalerror(200111011);
  1300. end;
  1301. end;
  1302. toasm :
  1303. mangledname:=asmname^;
  1304. toaddr :
  1305. mangledname:='$'+tostr(address);
  1306. else
  1307. internalerror(10002);
  1308. end;
  1309. end;
  1310. procedure tabsolutesym.insert_in_data;
  1311. begin
  1312. end;
  1313. {$ifdef GDB}
  1314. procedure tabsolutesym.concatstabto(asmlist : taasmoutput);
  1315. begin
  1316. { I don't know how to handle this !! }
  1317. end;
  1318. {$endif GDB}
  1319. {****************************************************************************
  1320. TVARSYM
  1321. ****************************************************************************}
  1322. constructor tvarsym.create(const n : string;const tt : ttype);
  1323. begin
  1324. inherited create(n);
  1325. typ:=varsym;
  1326. vartype:=tt;
  1327. _mangledname:=nil;
  1328. varspez:=vs_value;
  1329. address:=0;
  1330. localvarsym:=nil;
  1331. refs:=0;
  1332. varstate:=vs_used;
  1333. varoptions:=[];
  1334. { can we load the value into a register ? }
  1335. if tstoreddef(tt.def).is_intregable then
  1336. include(varoptions,vo_regable)
  1337. else
  1338. exclude(varoptions,vo_regable);
  1339. if tstoreddef(tt.def).is_fpuregable then
  1340. include(varoptions,vo_fpuregable)
  1341. else
  1342. exclude(varoptions,vo_fpuregable);
  1343. reg:=R_NO;
  1344. end;
  1345. constructor tvarsym.create_dll(const n : string;const tt : ttype);
  1346. begin
  1347. tvarsym(self).create(n,tt);
  1348. include(varoptions,vo_is_dll_var);
  1349. end;
  1350. constructor tvarsym.create_C(const n,mangled : string;const tt : ttype);
  1351. begin
  1352. tvarsym(self).create(n,tt);
  1353. include(varoptions,vo_is_C_var);
  1354. stringdispose(_mangledname);
  1355. _mangledname:=stringdup(mangled);
  1356. end;
  1357. constructor tvarsym.ppuload(ppufile:tcompilerppufile);
  1358. begin
  1359. inherited loadsym(ppufile);
  1360. typ:=varsym;
  1361. reg:=R_NO;
  1362. refs := 0;
  1363. varstate:=vs_used;
  1364. varspez:=tvarspez(ppufile.getbyte);
  1365. address:=ppufile.getlongint;
  1366. localvarsym:=nil;
  1367. ppufile.gettype(vartype);
  1368. ppufile.getsmallset(varoptions);
  1369. if (vo_is_C_var in varoptions) then
  1370. _mangledname:=stringdup(ppufile.getstring);
  1371. end;
  1372. destructor tvarsym.destroy;
  1373. begin
  1374. inherited destroy;
  1375. end;
  1376. procedure tvarsym.deref;
  1377. begin
  1378. vartype.resolve;
  1379. end;
  1380. procedure tvarsym.ppuwrite(ppufile:tcompilerppufile);
  1381. var
  1382. hvo : tvaroptions;
  1383. begin
  1384. inherited writesym(ppufile);
  1385. ppufile.putbyte(byte(varspez));
  1386. ppufile.putlongint(address);
  1387. ppufile.puttype(vartype);
  1388. { symbols which are load are never candidates for a register,
  1389. turn off the regable }
  1390. hvo:=varoptions-[vo_regable,vo_fpuregable];
  1391. ppufile.putsmallset(hvo);
  1392. if (vo_is_C_var in varoptions) then
  1393. ppufile.putstring(mangledname);
  1394. ppufile.writeentry(ibvarsym);
  1395. end;
  1396. procedure tvarsym.generate_mangledname;
  1397. begin
  1398. _mangledname:=stringdup(mangledname_prefix('U',owner)+name);
  1399. end;
  1400. procedure tvarsym.set_mangledname(const s:string);
  1401. begin
  1402. stringdispose(_mangledname);
  1403. _mangledname:=stringdup(s);
  1404. end;
  1405. function tvarsym.getsize : longint;
  1406. begin
  1407. if assigned(vartype.def) then
  1408. getsize:=vartype.def.size
  1409. else
  1410. getsize:=0;
  1411. end;
  1412. function tvarsym.getvaluesize : longint;
  1413. begin
  1414. if assigned(vartype.def) and
  1415. (varspez=vs_value) and
  1416. ((vartype.def.deftype<>arraydef) or
  1417. tarraydef(vartype.def).isDynamicArray or
  1418. (tarraydef(vartype.def).highrange>=tarraydef(vartype.def).lowrange)) then
  1419. getvaluesize:=vartype.def.size
  1420. else
  1421. getvaluesize:=0;
  1422. end;
  1423. function tvarsym.getpushsize : longint;
  1424. begin
  1425. if assigned(vartype.def) then
  1426. begin
  1427. case varspez of
  1428. vs_out,
  1429. vs_var :
  1430. getpushsize:=pointer_size;
  1431. vs_value,
  1432. vs_const :
  1433. begin
  1434. if paramanager.push_addr_param(vartype.def) then
  1435. getpushsize:=pointer_size
  1436. else
  1437. getpushsize:=vartype.def.size;
  1438. end;
  1439. end;
  1440. end
  1441. else
  1442. getpushsize:=0;
  1443. end;
  1444. procedure tvarsym.insert_in_data;
  1445. var
  1446. varalign,
  1447. l,modulo : longint;
  1448. storefilepos : tfileposinfo;
  1449. begin
  1450. if (vo_is_external in varoptions) then
  1451. exit;
  1452. { handle static variables of objects especially }
  1453. if read_member and (owner.symtabletype=objectsymtable) and
  1454. (sp_static in symoptions) then
  1455. begin
  1456. { the data filed is generated in parser.pas
  1457. with a tobject_FIELDNAME variable }
  1458. { this symbol can't be loaded to a register }
  1459. exclude(varoptions,vo_regable);
  1460. exclude(varoptions,vo_fpuregable);
  1461. end
  1462. else
  1463. if not(read_member) then
  1464. begin
  1465. { made problems with parameters etc. ! (FK) }
  1466. { check for instance of an abstract object or class }
  1467. {
  1468. if (tvarsym(sym).definition.deftype=objectdef) and
  1469. ((tobjectdef(tvarsym(sym).definition).options and oo_is_abstract)<>0) then
  1470. Message(sym_e_no_instance_of_abstract_object);
  1471. }
  1472. storefilepos:=aktfilepos;
  1473. aktfilepos:=akttokenpos;
  1474. if (vo_is_thread_var in varoptions) then
  1475. l:=pointer_size
  1476. else
  1477. l:=getvaluesize;
  1478. case owner.symtabletype of
  1479. stt_exceptsymtable:
  1480. { can contain only one symbol, address calculated later }
  1481. ;
  1482. localsymtable :
  1483. begin
  1484. varstate:=vs_declared;
  1485. varalign:=size_2_align(l);
  1486. varalign:=used_align(varalign,aktalignment.localalignmin,aktalignment.localalignmax);
  1487. {$ifdef powerpc}
  1488. { on the powerpc, the local variables are accessed with a positiv offset }
  1489. address:=align(owner.datasize,varalign);
  1490. owner.datasize:=address+l;
  1491. {$else powerpc}
  1492. address:=align(owner.datasize+l,varalign);
  1493. owner.datasize:=address;
  1494. {$endif powerpc}
  1495. end;
  1496. staticsymtable :
  1497. begin
  1498. { enable unitialized warning for local symbols }
  1499. varstate:=vs_declared;
  1500. varalign:=size_2_align(l);
  1501. varalign:=used_align(varalign,aktalignment.varalignmin,aktalignment.varalignmax);
  1502. address:=align(owner.datasize,varalign);
  1503. { insert cut for smartlinking or alignment }
  1504. if (cs_create_smart in aktmoduleswitches) then
  1505. bssSegment.concat(Tai_cut.Create)
  1506. else if (address<>owner.datasize) then
  1507. bssSegment.concat(Tai_align.create(varalign));
  1508. owner.datasize:=address+l;
  1509. {$ifdef GDB}
  1510. if cs_debuginfo in aktmoduleswitches then
  1511. concatstabto(bsssegment);
  1512. {$endif GDB}
  1513. if (cs_create_smart in aktmoduleswitches) or
  1514. DLLSource or
  1515. (vo_is_exported in varoptions) or
  1516. (vo_is_C_var in varoptions) then
  1517. bssSegment.concat(Tai_datablock.Create_global(mangledname,l))
  1518. else
  1519. bssSegment.concat(Tai_datablock.Create(mangledname,l));
  1520. {Global variables (in implementation part of course)
  1521. *can* be loaded into registers, they just may not be
  1522. accessed from procedures. The lexlevel test in nld.pas,
  1523. Tloadnode.pass_1, should take care of this.
  1524. If for some reason you think it isn't safe, try isolating
  1525. and disabling those specific cases, because small programs
  1526. without procedures can be very speed critical. For example,
  1527. think of benchmarks and programming contests. Also, new
  1528. users often test the quality of the code the compiler
  1529. generates and they do that with small programs, we should
  1530. show them the full optimizing power. (DM)}
  1531. {exclude(varoptions,vo_regable);
  1532. exclude(varoptions,vo_fpuregable);}
  1533. end;
  1534. globalsymtable :
  1535. begin
  1536. varalign:=size_2_align(l);
  1537. varalign:=used_align(varalign,aktalignment.varalignmin,aktalignment.varalignmax);
  1538. address:=align(owner.datasize,varalign);
  1539. { insert cut for smartlinking or alignment }
  1540. if (cs_create_smart in aktmoduleswitches) then
  1541. bssSegment.concat(Tai_cut.Create)
  1542. else if (address<>owner.datasize) then
  1543. bssSegment.concat(Tai_align.create(varalign));
  1544. owner.datasize:=address+l;
  1545. {$ifdef GDB}
  1546. if cs_debuginfo in aktmoduleswitches then
  1547. concatstabto(bsssegment);
  1548. {$endif GDB}
  1549. bssSegment.concat(Tai_datablock.Create_global(mangledname,l));
  1550. { this symbol can't be loaded to a register }
  1551. exclude(varoptions,vo_regable);
  1552. exclude(varoptions,vo_fpuregable);
  1553. end;
  1554. recordsymtable,
  1555. objectsymtable :
  1556. begin
  1557. { this symbol can't be loaded to a register }
  1558. exclude(varoptions,vo_regable);
  1559. exclude(varoptions,vo_fpuregable);
  1560. { get the alignment size }
  1561. if (aktalignment.recordalignmax=-1) then
  1562. begin
  1563. varalign:=vartype.def.alignment;
  1564. if (varalign>4) and ((varalign mod 4)<>0) and
  1565. (vartype.def.deftype=arraydef) then
  1566. begin
  1567. Message1(sym_w_wrong_C_pack,vartype.def.typename);
  1568. end;
  1569. if varalign=0 then
  1570. varalign:=l;
  1571. if (owner.dataalignment<aktalignment.maxCrecordalign) then
  1572. begin
  1573. if (varalign>16) and (owner.dataalignment<32) then
  1574. owner.dataalignment:=32
  1575. else if (varalign>12) and (owner.dataalignment<16) then
  1576. owner.dataalignment:=16
  1577. { 12 is needed for long double }
  1578. else if (varalign>8) and (owner.dataalignment<12) then
  1579. owner.dataalignment:=12
  1580. else if (varalign>4) and (owner.dataalignment<8) then
  1581. owner.dataalignment:=8
  1582. else if (varalign>2) and (owner.dataalignment<4) then
  1583. owner.dataalignment:=4
  1584. else if (varalign>1) and (owner.dataalignment<2) then
  1585. owner.dataalignment:=2;
  1586. end;
  1587. owner.dataalignment:=max(owner.dataalignment,aktalignment.maxCrecordalign);
  1588. end
  1589. else
  1590. varalign:=vartype.def.alignment;
  1591. if varalign=0 then
  1592. varalign:=size_2_align(l);
  1593. varalign:=used_align(varalign,aktalignment.recordalignmin,owner.dataalignment);
  1594. address:=align(owner.datasize,varalign);
  1595. owner.datasize:=address+l;
  1596. end;
  1597. parasymtable :
  1598. begin
  1599. { here we need the size of a push instead of the
  1600. size of the data }
  1601. l:=getpushsize;
  1602. varalign:=size_2_align(l);
  1603. varstate:=vs_assigned;
  1604. { we need the new datasize already aligned so we can't
  1605. use the align_address here }
  1606. address:=owner.datasize;
  1607. varalign:=used_align(varalign,owner.dataalignment,owner.dataalignment);
  1608. owner.datasize:=align(address+l,varalign);
  1609. end
  1610. else
  1611. begin
  1612. modulo:=owner.datasize and 3;
  1613. if (l>=4) and (modulo<>0) then
  1614. inc(owner.datasize,4-modulo)
  1615. else
  1616. if (l>=2) and ((modulo and 1)<>0) then
  1617. inc(owner.datasize);
  1618. address:=owner.datasize;
  1619. inc(owner.datasize,l);
  1620. end;
  1621. end;
  1622. aktfilepos:=storefilepos;
  1623. end;
  1624. end;
  1625. {$ifdef GDB}
  1626. function tvarsym.stabstring : pchar;
  1627. var
  1628. st : string;
  1629. begin
  1630. st:=tstoreddef(vartype.def).numberstring;
  1631. if (owner.symtabletype = objectsymtable) and
  1632. (sp_static in symoptions) then
  1633. begin
  1634. if (cs_gdb_gsym in aktglobalswitches) then st := 'G'+st else st := 'S'+st;
  1635. stabstring := strpnew('"'+upper(owner.name^)+'__'+name+':'+st+
  1636. '",'+
  1637. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname);
  1638. end
  1639. else if (owner.symtabletype = globalsymtable) then
  1640. begin
  1641. { Here we used S instead of
  1642. because with G GDB doesn't look at the address field
  1643. but searches the same name or with a leading underscore
  1644. but these names don't exist in pascal !}
  1645. if (cs_gdb_gsym in aktglobalswitches) then st := 'G'+st else st := 'S'+st;
  1646. stabstring := strpnew('"'+name+':'+st+'",'+
  1647. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname);
  1648. end
  1649. else if owner.symtabletype = staticsymtable then
  1650. begin
  1651. stabstring := strpnew('"'+name+':S'+st+'",'+
  1652. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname);
  1653. end
  1654. else if (owner.symtabletype in [parasymtable,inlineparasymtable]) then
  1655. begin
  1656. case varspez of
  1657. vs_out,
  1658. vs_var : st := 'v'+st;
  1659. vs_value,
  1660. vs_const : if paramanager.push_addr_param(vartype.def) then
  1661. st := 'v'+st { should be 'i' but 'i' doesn't work }
  1662. else
  1663. st := 'p'+st;
  1664. end;
  1665. stabstring := strpnew('"'+name+':'+st+'",'+
  1666. tostr(N_tsym)+',0,'+tostr(fileinfo.line)+','+
  1667. tostr(address+owner.address_fixup));
  1668. {offset to ebp => will not work if the framepointer is esp
  1669. so some optimizing will make things harder to debug }
  1670. end
  1671. else if (owner.symtabletype in [localsymtable,inlinelocalsymtable]) then
  1672. if reg<>R_NO then
  1673. begin
  1674. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1675. { this is the register order for GDB}
  1676. stabstring:=strpnew('"'+name+':r'+st+'",'+
  1677. tostr(N_RSYM)+',0,'+
  1678. tostr(fileinfo.line)+','+tostr(stab_regindex[reg]));
  1679. end
  1680. else
  1681. { I don't know if this will work (PM) }
  1682. if (vo_is_C_var in varoptions) then
  1683. stabstring := strpnew('"'+name+':S'+st+'",'+
  1684. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname)
  1685. else
  1686. stabstring := strpnew('"'+name+':'+st+'",'+
  1687. tostr(N_LSYM)+',0,'+tostr(fileinfo.line)+',-'+tostr(address-owner.address_fixup))
  1688. else
  1689. stabstring := inherited stabstring;
  1690. end;
  1691. procedure tvarsym.concatstabto(asmlist : taasmoutput);
  1692. var stab_str : pchar;
  1693. begin
  1694. inherited concatstabto(asmlist);
  1695. if (owner.symtabletype=parasymtable) and
  1696. (reg<>R_NO) then
  1697. begin
  1698. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1699. { this is the register order for GDB}
  1700. stab_str:=strpnew('"'+name+':r'
  1701. +tstoreddef(vartype.def).numberstring+'",'+
  1702. tostr(N_RSYM)+',0,'+
  1703. tostr(fileinfo.line)+','+tostr(stab_regindex[reg]));
  1704. asmList.concat(Tai_stabs.Create(stab_str));
  1705. end;
  1706. end;
  1707. {$endif GDB}
  1708. {****************************************************************************
  1709. TTYPEDCONSTSYM
  1710. *****************************************************************************}
  1711. constructor ttypedconstsym.create(const n : string;p : tdef;writable : boolean);
  1712. begin
  1713. inherited create(n);
  1714. typ:=typedconstsym;
  1715. typedconsttype.setdef(p);
  1716. is_writable:=writable;
  1717. end;
  1718. constructor ttypedconstsym.createtype(const n : string;const tt : ttype;writable : boolean);
  1719. begin
  1720. inherited create(n);
  1721. typ:=typedconstsym;
  1722. typedconsttype:=tt;
  1723. is_writable:=writable;
  1724. end;
  1725. constructor ttypedconstsym.ppuload(ppufile:tcompilerppufile);
  1726. begin
  1727. inherited loadsym(ppufile);
  1728. typ:=typedconstsym;
  1729. ppufile.gettype(typedconsttype);
  1730. is_writable:=boolean(ppufile.getbyte);
  1731. end;
  1732. destructor ttypedconstsym.destroy;
  1733. begin
  1734. inherited destroy;
  1735. end;
  1736. procedure ttypedconstsym.generate_mangledname;
  1737. begin
  1738. _mangledname:=stringdup(mangledname_prefix('TC',owner)+name);
  1739. end;
  1740. function ttypedconstsym.getsize : longint;
  1741. begin
  1742. if assigned(typedconsttype.def) then
  1743. getsize:=typedconsttype.def.size
  1744. else
  1745. getsize:=0;
  1746. end;
  1747. procedure ttypedconstsym.deref;
  1748. begin
  1749. typedconsttype.resolve;
  1750. end;
  1751. procedure ttypedconstsym.ppuwrite(ppufile:tcompilerppufile);
  1752. begin
  1753. inherited writesym(ppufile);
  1754. ppufile.puttype(typedconsttype);
  1755. ppufile.putbyte(byte(is_writable));
  1756. ppufile.writeentry(ibtypedconstsym);
  1757. end;
  1758. procedure ttypedconstsym.insert_in_data;
  1759. var
  1760. curconstsegment : taasmoutput;
  1761. address,l,varalign : longint;
  1762. storefilepos : tfileposinfo;
  1763. begin
  1764. storefilepos:=aktfilepos;
  1765. aktfilepos:=akttokenpos;
  1766. if is_writable then
  1767. curconstsegment:=datasegment
  1768. else
  1769. curconstsegment:=consts;
  1770. l:=getsize;
  1771. varalign:=size_2_align(l);
  1772. varalign:=used_align(varalign,aktalignment.constalignmin,aktalignment.constalignmax);
  1773. address:=align(owner.datasize,varalign);
  1774. { insert cut for smartlinking or alignment }
  1775. if (cs_create_smart in aktmoduleswitches) then
  1776. curconstSegment.concat(Tai_cut.Create)
  1777. else if (address<>owner.datasize) then
  1778. curconstSegment.concat(Tai_align.create(varalign));
  1779. owner.datasize:=address+l;
  1780. {$ifdef GDB}
  1781. if cs_debuginfo in aktmoduleswitches then
  1782. concatstabto(curconstsegment);
  1783. {$endif GDB}
  1784. if (owner.symtabletype=globalsymtable) then
  1785. begin
  1786. if (owner.unitid=0) then
  1787. curconstSegment.concat(Tai_symbol.Createdataname_global(mangledname,getsize));
  1788. end
  1789. else
  1790. begin
  1791. if (cs_create_smart in aktmoduleswitches) or
  1792. DLLSource then
  1793. curconstSegment.concat(Tai_symbol.Createdataname_global(mangledname,getsize))
  1794. else
  1795. curconstSegment.concat(Tai_symbol.Createdataname(mangledname,getsize));
  1796. end;
  1797. aktfilepos:=storefilepos;
  1798. end;
  1799. {$ifdef GDB}
  1800. function ttypedconstsym.stabstring : pchar;
  1801. var
  1802. st : char;
  1803. begin
  1804. if (cs_gdb_gsym in aktglobalswitches) and (owner.symtabletype=globalsymtable) then
  1805. st := 'G'
  1806. else
  1807. st := 'S';
  1808. stabstring := strpnew('"'+name+':'+st+
  1809. tstoreddef(typedconsttype.def).numberstring+'",'+tostr(n_STSYM)+',0,'+
  1810. tostr(fileinfo.line)+','+mangledname);
  1811. end;
  1812. {$endif GDB}
  1813. {****************************************************************************
  1814. TCONSTSYM
  1815. ****************************************************************************}
  1816. constructor tconstsym.create_ord(const n : string;t : tconsttyp;v : TConstExprInt);
  1817. begin
  1818. inherited create(n);
  1819. typ:=constsym;
  1820. consttyp:=t;
  1821. valueord:=v;
  1822. valueordptr:=0;
  1823. valueptr:=nil;
  1824. ResStrIndex:=0;
  1825. consttype.reset;
  1826. len:=0;
  1827. end;
  1828. constructor tconstsym.create_ord_typed(const n : string;t : tconsttyp;v : tconstexprint;const tt:ttype);
  1829. begin
  1830. inherited create(n);
  1831. typ:=constsym;
  1832. consttyp:=t;
  1833. valueord:=v;
  1834. valueordptr:=0;
  1835. valueptr:=nil;
  1836. ResStrIndex:=0;
  1837. consttype:=tt;
  1838. len:=0;
  1839. end;
  1840. constructor tconstsym.create_ordptr_typed(const n : string;t : tconsttyp;v : tconstptruint;const tt:ttype);
  1841. begin
  1842. inherited create(n);
  1843. typ:=constsym;
  1844. consttyp:=t;
  1845. valueord:=0;
  1846. valueordptr:=v;
  1847. valueptr:=nil;
  1848. ResStrIndex:=0;
  1849. consttype:=tt;
  1850. len:=0;
  1851. end;
  1852. constructor tconstsym.create_ptr(const n : string;t : tconsttyp;v : pointer);
  1853. begin
  1854. inherited create(n);
  1855. typ:=constsym;
  1856. consttyp:=t;
  1857. valueord:=0;
  1858. valueordptr:=0;
  1859. valueptr:=v;
  1860. ResStrIndex:=0;
  1861. consttype.reset;
  1862. len:=0;
  1863. end;
  1864. constructor tconstsym.create_ptr_typed(const n : string;t : tconsttyp;v : pointer;const tt:ttype);
  1865. begin
  1866. inherited create(n);
  1867. typ:=constsym;
  1868. consttyp:=t;
  1869. valueord:=0;
  1870. valueordptr:=0;
  1871. valueptr:=v;
  1872. ResStrIndex:=0;
  1873. consttype:=tt;
  1874. len:=0;
  1875. end;
  1876. constructor tconstsym.create_string(const n : string;t : tconsttyp;str:pchar;l:longint);
  1877. begin
  1878. inherited create(n);
  1879. typ:=constsym;
  1880. consttyp:=t;
  1881. valueord:=0;
  1882. valueordptr:=0;
  1883. valueptr:=str;
  1884. consttype.reset;
  1885. len:=l;
  1886. if t=constresourcestring then
  1887. ResStrIndex:=ResourceStrings.Register(name,pchar(valueptr),len);
  1888. end;
  1889. constructor tconstsym.ppuload(ppufile:tcompilerppufile);
  1890. var
  1891. pd : pbestreal;
  1892. ps : pnormalset;
  1893. pc : pchar;
  1894. l1,l2 : longint;
  1895. begin
  1896. inherited loadsym(ppufile);
  1897. typ:=constsym;
  1898. consttype.reset;
  1899. consttyp:=tconsttyp(ppufile.getbyte);
  1900. valueord:=0;
  1901. valueordptr:=0;
  1902. valueptr:=nil;
  1903. case consttyp of
  1904. constint:
  1905. valueord:=ppufile.getexprint;
  1906. constwchar,
  1907. constbool,
  1908. constchar :
  1909. valueord:=ppufile.getlongint;
  1910. constord :
  1911. begin
  1912. ppufile.gettype(consttype);
  1913. valueord:=ppufile.getexprint;
  1914. end;
  1915. constpointer :
  1916. begin
  1917. ppufile.gettype(consttype);
  1918. valueordptr:=ppufile.getptruint;
  1919. end;
  1920. conststring,
  1921. constresourcestring :
  1922. begin
  1923. len:=ppufile.getlongint;
  1924. getmem(pc,len+1);
  1925. ppufile.getdata(pc^,len);
  1926. if consttyp=constresourcestring then
  1927. ResStrIndex:=ppufile.getlongint;
  1928. valueptr:=pc;
  1929. end;
  1930. constreal :
  1931. begin
  1932. new(pd);
  1933. pd^:=ppufile.getreal;
  1934. valueptr:=pd;
  1935. end;
  1936. constset :
  1937. begin
  1938. ppufile.gettype(consttype);
  1939. new(ps);
  1940. ppufile.getnormalset(ps^);
  1941. valueptr:=ps;
  1942. end;
  1943. constnil : ;
  1944. else
  1945. Message1(unit_f_ppu_invalid_entry,tostr(ord(consttyp)));
  1946. end;
  1947. end;
  1948. destructor tconstsym.destroy;
  1949. begin
  1950. case consttyp of
  1951. conststring,
  1952. constresourcestring :
  1953. freemem(pchar(valueptr),len+1);
  1954. constreal :
  1955. dispose(pbestreal(valueptr));
  1956. constset :
  1957. dispose(pnormalset(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(valueord);
  1978. constbool,
  1979. constchar :
  1980. ppufile.putlongint(valueord);
  1981. constord :
  1982. begin
  1983. ppufile.puttype(consttype);
  1984. ppufile.putexprint(valueord);
  1985. end;
  1986. constpointer :
  1987. begin
  1988. ppufile.puttype(consttype);
  1989. ppufile.putptruint(valueordptr);
  1990. end;
  1991. conststring,
  1992. constresourcestring :
  1993. begin
  1994. ppufile.putlongint(len);
  1995. ppufile.putdata(pchar(valueptr)^,len);
  1996. if consttyp=constresourcestring then
  1997. ppufile.putlongint(ResStrIndex);
  1998. end;
  1999. constreal :
  2000. ppufile.putreal(pbestreal(valueptr)^);
  2001. constset :
  2002. begin
  2003. ppufile.puttype(consttype);
  2004. ppufile.putnormalset(valueptr^);
  2005. end;
  2006. else
  2007. internalerror(13);
  2008. end;
  2009. ppufile.writeentry(ibconstsym);
  2010. end;
  2011. {$ifdef GDB}
  2012. function tconstsym.stabstring : pchar;
  2013. var st : string;
  2014. begin
  2015. {even GDB v4.16 only now 'i' 'r' and 'e' !!!}
  2016. case consttyp of
  2017. conststring : begin
  2018. st := 's'''+strpas(pchar(valueptr))+'''';
  2019. end;
  2020. constbool,
  2021. constint,
  2022. constord,
  2023. constchar : st := 'i'+int64tostr(valueord);
  2024. constpointer :
  2025. st := 'i'+int64tostr(valueordptr);
  2026. constreal : begin
  2027. system.str(pbestreal(valueptr)^,st);
  2028. st := 'r'+st;
  2029. end;
  2030. { if we don't know just put zero !! }
  2031. else st:='i0';
  2032. {***SETCONST}
  2033. {constset:;} {*** I don't know what to do with a set.}
  2034. { sets are not recognized by GDB}
  2035. {***}
  2036. end;
  2037. stabstring := strpnew('"'+name+':c='+st+'",'+tostr(N_function)+',0,'+
  2038. tostr(fileinfo.line)+',0');
  2039. end;
  2040. procedure tconstsym.concatstabto(asmlist : taasmoutput);
  2041. begin
  2042. if consttyp <> conststring then
  2043. inherited concatstabto(asmlist);
  2044. end;
  2045. {$endif GDB}
  2046. {****************************************************************************
  2047. TENUMSYM
  2048. ****************************************************************************}
  2049. constructor tenumsym.create(const n : string;def : tenumdef;v : longint);
  2050. begin
  2051. inherited create(n);
  2052. typ:=enumsym;
  2053. definition:=def;
  2054. value:=v;
  2055. { check for jumps }
  2056. if v>def.max+1 then
  2057. def.has_jumps:=true;
  2058. { update low and high }
  2059. if def.min>v then
  2060. def.setmin(v);
  2061. if def.max<v then
  2062. def.setmax(v);
  2063. order;
  2064. end;
  2065. constructor tenumsym.ppuload(ppufile:tcompilerppufile);
  2066. begin
  2067. inherited loadsym(ppufile);
  2068. typ:=enumsym;
  2069. definition:=tenumdef(ppufile.getderef);
  2070. value:=ppufile.getlongint;
  2071. nextenum := Nil;
  2072. end;
  2073. procedure tenumsym.deref;
  2074. begin
  2075. resolvedef(pointer(definition));
  2076. order;
  2077. end;
  2078. procedure tenumsym.order;
  2079. var
  2080. sym : tenumsym;
  2081. begin
  2082. sym := tenumsym(definition.firstenum);
  2083. if sym = nil then
  2084. begin
  2085. definition.firstenum := self;
  2086. nextenum := nil;
  2087. exit;
  2088. end;
  2089. { reorder the symbols in increasing value }
  2090. if value < sym.value then
  2091. begin
  2092. nextenum := sym;
  2093. definition.firstenum := self;
  2094. end
  2095. else
  2096. begin
  2097. while (sym.value <= value) and assigned(sym.nextenum) do
  2098. sym := sym.nextenum;
  2099. nextenum := sym.nextenum;
  2100. sym.nextenum := self;
  2101. end;
  2102. end;
  2103. procedure tenumsym.ppuwrite(ppufile:tcompilerppufile);
  2104. begin
  2105. inherited writesym(ppufile);
  2106. ppufile.putderef(definition);
  2107. ppufile.putlongint(value);
  2108. ppufile.writeentry(ibenumsym);
  2109. end;
  2110. {$ifdef GDB}
  2111. procedure tenumsym.concatstabto(asmlist : taasmoutput);
  2112. begin
  2113. {enum elements have no stab !}
  2114. end;
  2115. {$EndIf GDB}
  2116. {****************************************************************************
  2117. TTYPESYM
  2118. ****************************************************************************}
  2119. constructor ttypesym.create(const n : string;const tt : ttype);
  2120. begin
  2121. inherited create(n);
  2122. typ:=typesym;
  2123. restype:=tt;
  2124. {$ifdef GDB}
  2125. isusedinstab := false;
  2126. {$endif GDB}
  2127. { register the typesym for the definition }
  2128. if assigned(restype.def) and
  2129. (restype.def.deftype<>errordef) and
  2130. not(assigned(restype.def.typesym)) then
  2131. restype.def.typesym:=self;
  2132. end;
  2133. constructor ttypesym.ppuload(ppufile:tcompilerppufile);
  2134. begin
  2135. inherited loadsym(ppufile);
  2136. typ:=typesym;
  2137. {$ifdef GDB}
  2138. isusedinstab := false;
  2139. {$endif GDB}
  2140. ppufile.gettype(restype);
  2141. end;
  2142. function ttypesym.gettypedef:tdef;
  2143. begin
  2144. gettypedef:=restype.def;
  2145. end;
  2146. procedure ttypesym.deref;
  2147. begin
  2148. restype.resolve;
  2149. end;
  2150. procedure ttypesym.ppuwrite(ppufile:tcompilerppufile);
  2151. begin
  2152. inherited writesym(ppufile);
  2153. ppufile.puttype(restype);
  2154. ppufile.writeentry(ibtypesym);
  2155. end;
  2156. procedure ttypesym.load_references(ppufile:tcompilerppufile;locals:boolean);
  2157. begin
  2158. inherited load_references(ppufile,locals);
  2159. if (restype.def.deftype=recorddef) then
  2160. tstoredsymtable(trecorddef(restype.def).symtable).load_references(ppufile,locals);
  2161. if (restype.def.deftype=objectdef) then
  2162. tstoredsymtable(tobjectdef(restype.def).symtable).load_references(ppufile,locals);
  2163. end;
  2164. function ttypesym.write_references(ppufile:tcompilerppufile;locals:boolean):boolean;
  2165. begin
  2166. if not inherited write_references(ppufile,locals) then
  2167. begin
  2168. { write address of this symbol if record or object
  2169. even if no real refs are there
  2170. because we need it for the symtable }
  2171. if (restype.def.deftype in [recorddef,objectdef]) then
  2172. begin
  2173. ppufile.putderef(self);
  2174. ppufile.writeentry(ibsymref);
  2175. end;
  2176. end;
  2177. write_references:=true;
  2178. if (restype.def.deftype=recorddef) then
  2179. tstoredsymtable(trecorddef(restype.def).symtable).write_references(ppufile,locals);
  2180. if (restype.def.deftype=objectdef) then
  2181. tstoredsymtable(tobjectdef(restype.def).symtable).write_references(ppufile,locals);
  2182. end;
  2183. {$ifdef GDB}
  2184. function ttypesym.stabstring : pchar;
  2185. var
  2186. stabchar : string[2];
  2187. short : string;
  2188. begin
  2189. if restype.def.deftype in tagtypes then
  2190. stabchar := 'Tt'
  2191. else
  2192. stabchar := 't';
  2193. short := '"'+name+':'+stabchar+tstoreddef(restype.def).numberstring
  2194. +'",'+tostr(N_LSYM)+',0,'+tostr(fileinfo.line)+',0';
  2195. stabstring := strpnew(short);
  2196. end;
  2197. procedure ttypesym.concatstabto(asmlist : taasmoutput);
  2198. begin
  2199. {not stabs for forward defs }
  2200. if assigned(restype.def) then
  2201. if (restype.def.typesym = self) then
  2202. tstoreddef(restype.def).concatstabto(asmlist)
  2203. else
  2204. inherited concatstabto(asmlist);
  2205. end;
  2206. {$endif GDB}
  2207. {****************************************************************************
  2208. TSYSSYM
  2209. ****************************************************************************}
  2210. constructor tsyssym.create(const n : string;l : longint);
  2211. begin
  2212. inherited create(n);
  2213. typ:=syssym;
  2214. number:=l;
  2215. end;
  2216. constructor tsyssym.ppuload(ppufile:tcompilerppufile);
  2217. begin
  2218. inherited loadsym(ppufile);
  2219. typ:=syssym;
  2220. number:=ppufile.getlongint;
  2221. end;
  2222. destructor tsyssym.destroy;
  2223. begin
  2224. inherited destroy;
  2225. end;
  2226. procedure tsyssym.ppuwrite(ppufile:tcompilerppufile);
  2227. begin
  2228. inherited writesym(ppufile);
  2229. ppufile.putlongint(number);
  2230. ppufile.writeentry(ibsyssym);
  2231. end;
  2232. {$ifdef GDB}
  2233. procedure tsyssym.concatstabto(asmlist : taasmoutput);
  2234. begin
  2235. end;
  2236. {$endif GDB}
  2237. {****************************************************************************
  2238. TRTTISYM
  2239. ****************************************************************************}
  2240. constructor trttisym.create(const n:string;rt:trttitype);
  2241. const
  2242. prefix : array[trttitype] of string[5]=('$rtti','$init');
  2243. begin
  2244. inherited create(prefix[rt]+n);
  2245. typ:=rttisym;
  2246. lab:=nil;
  2247. rttityp:=rt;
  2248. end;
  2249. constructor trttisym.ppuload(ppufile:tcompilerppufile);
  2250. begin
  2251. inherited loadsym(ppufile);
  2252. typ:=rttisym;
  2253. lab:=nil;
  2254. rttityp:=trttitype(ppufile.getbyte);
  2255. end;
  2256. procedure trttisym.ppuwrite(ppufile:tcompilerppufile);
  2257. begin
  2258. inherited writesym(ppufile);
  2259. ppufile.putbyte(byte(rttityp));
  2260. ppufile.writeentry(ibrttisym);
  2261. end;
  2262. function trttisym.mangledname : string;
  2263. const
  2264. prefix : array[trttitype] of string[5]=('RTTI_','INIT_');
  2265. var
  2266. s : string;
  2267. p : tsymtable;
  2268. begin
  2269. s:='';
  2270. p:=owner;
  2271. while assigned(p) and (p.symtabletype=localsymtable) do
  2272. begin
  2273. s:=s+'_'+p.defowner.name;
  2274. p:=p.defowner.owner;
  2275. end;
  2276. if not(p.symtabletype in [globalsymtable,staticsymtable]) then
  2277. internalerror(200108265);
  2278. mangledname:=prefix[rttityp]+p.name^+s+'$_'+Copy(name,5,255);
  2279. end;
  2280. function trttisym.get_label:tasmsymbol;
  2281. begin
  2282. { the label is always a global label }
  2283. if not assigned(lab) then
  2284. lab:=objectlibrary.newasmsymboltype(mangledname,AB_GLOBAL,AT_DATA);
  2285. get_label:=lab;
  2286. end;
  2287. { persistent rtti generation }
  2288. procedure generate_rtti(p:tsym);
  2289. var
  2290. rsym : trttisym;
  2291. def : tstoreddef;
  2292. begin
  2293. { rtti can only be generated for classes that are always typesyms }
  2294. if not(p.typ=typesym) then
  2295. internalerror(200108261);
  2296. def:=tstoreddef(ttypesym(p).restype.def);
  2297. { only create rtti once for each definition }
  2298. if not(df_has_rttitable in def.defoptions) then
  2299. begin
  2300. { definition should be in the same symtable as the symbol }
  2301. if p.owner<>def.owner then
  2302. internalerror(200108262);
  2303. { create rttisym }
  2304. rsym:=trttisym.create(p.name,fullrtti);
  2305. p.owner.insert(rsym);
  2306. { register rttisym in definition }
  2307. include(def.defoptions,df_has_rttitable);
  2308. def.rttitablesym:=rsym;
  2309. { write rtti data }
  2310. def.write_child_rtti_data(fullrtti);
  2311. if (cs_create_smart in aktmoduleswitches) then
  2312. rttiList.concat(Tai_cut.Create);
  2313. rttiList.concat(Tai_symbol.Create(rsym.get_label,0));
  2314. def.write_rtti_data(fullrtti);
  2315. rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
  2316. end;
  2317. end;
  2318. { persistent init table generation }
  2319. procedure generate_inittable(p:tsym);
  2320. var
  2321. rsym : trttisym;
  2322. def : tstoreddef;
  2323. begin
  2324. { anonymous types are also allowed for records that can be varsym }
  2325. case p.typ of
  2326. typesym :
  2327. def:=tstoreddef(ttypesym(p).restype.def);
  2328. varsym :
  2329. def:=tstoreddef(tvarsym(p).vartype.def);
  2330. else
  2331. internalerror(200108263);
  2332. end;
  2333. { only create inittable once for each definition }
  2334. if not(df_has_inittable in def.defoptions) then
  2335. begin
  2336. { definition should be in the same symtable as the symbol }
  2337. if p.owner<>def.owner then
  2338. internalerror(200108264);
  2339. { create rttisym }
  2340. rsym:=trttisym.create(p.name,initrtti);
  2341. p.owner.insert(rsym);
  2342. { register rttisym in definition }
  2343. include(def.defoptions,df_has_inittable);
  2344. def.inittablesym:=rsym;
  2345. { write inittable data }
  2346. def.write_child_rtti_data(initrtti);
  2347. if (cs_create_smart in aktmoduleswitches) then
  2348. rttiList.concat(Tai_cut.Create);
  2349. rttiList.concat(Tai_symbol.Create(rsym.get_label,0));
  2350. def.write_rtti_data(initrtti);
  2351. rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
  2352. end;
  2353. end;
  2354. end.
  2355. {
  2356. $Log$
  2357. Revision 1.55 2002-08-20 16:54:40 peter
  2358. * write address of varsym always
  2359. Revision 1.54 2002/08/20 10:31:26 daniel
  2360. * Tcallnode.det_resulttype rewritten
  2361. Revision 1.53 2002/08/18 20:06:27 peter
  2362. * inlining is now also allowed in interface
  2363. * renamed write/load to ppuwrite/ppuload
  2364. * tnode storing in ppu
  2365. * nld,ncon,nbas are already updated for storing in ppu
  2366. Revision 1.52 2002/08/17 09:23:42 florian
  2367. * first part of procinfo rewrite
  2368. Revision 1.51 2002/08/16 14:24:59 carl
  2369. * issameref() to test if two references are the same (then emit no opcodes)
  2370. + ret_in_reg to replace ret_in_acc
  2371. (fix some register allocation bugs at the same time)
  2372. + save_std_register now has an extra parameter which is the
  2373. usedinproc registers
  2374. Revision 1.50 2002/08/13 21:40:57 florian
  2375. * more fixes for ppc calling conventions
  2376. Revision 1.49 2002/08/12 15:08:40 carl
  2377. + stab register indexes for powerpc (moved from gdb to cpubase)
  2378. + tprocessor enumeration moved to cpuinfo
  2379. + linker in target_info is now a class
  2380. * many many updates for m68k (will soon start to compile)
  2381. - removed some ifdef or correct them for correct cpu
  2382. Revision 1.48 2002/08/11 14:32:28 peter
  2383. * renamed current_library to objectlibrary
  2384. Revision 1.47 2002/08/11 13:24:14 peter
  2385. * saving of asmsymbols in ppu supported
  2386. * asmsymbollist global is removed and moved into a new class
  2387. tasmlibrarydata that will hold the info of a .a file which
  2388. corresponds with a single module. Added librarydata to tmodule
  2389. to keep the library info stored for the module. In the future the
  2390. objectfiles will also be stored to the tasmlibrarydata class
  2391. * all getlabel/newasmsymbol and friends are moved to the new class
  2392. Revision 1.46 2002/07/23 10:13:23 daniel
  2393. * Added important comment
  2394. Revision 1.45 2002/07/23 09:51:26 daniel
  2395. * Tried to make Tprocsym.defs protected. I didn't succeed but the cleanups
  2396. are worth comitting.
  2397. Revision 1.44 2002/07/20 17:45:29 daniel
  2398. * Register variables are now possible for global variables too. This is
  2399. important for small programs without procedures.
  2400. Revision 1.43 2002/07/20 11:57:58 florian
  2401. * types.pas renamed to defbase.pas because D6 contains a types
  2402. unit so this would conflicts if D6 programms are compiled
  2403. + Willamette/SSE2 instructions to assembler added
  2404. Revision 1.42 2002/07/11 14:41:31 florian
  2405. * start of the new generic parameter handling
  2406. Revision 1.41 2002/07/10 07:24:40 jonas
  2407. * memory leak fixes from Sergey Korshunoff
  2408. Revision 1.40 2002/07/01 18:46:27 peter
  2409. * internal linker
  2410. * reorganized aasm layer
  2411. Revision 1.39 2002/05/18 13:34:18 peter
  2412. * readded missing revisions
  2413. Revision 1.38 2002/05/16 19:46:45 carl
  2414. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  2415. + try to fix temp allocation (still in ifdef)
  2416. + generic constructor calls
  2417. + start of tassembler / tmodulebase class cleanup
  2418. Revision 1.36 2002/05/12 16:53:15 peter
  2419. * moved entry and exitcode to ncgutil and cgobj
  2420. * foreach gets extra argument for passing local data to the
  2421. iterator function
  2422. * -CR checks also class typecasts at runtime by changing them
  2423. into as
  2424. * fixed compiler to cycle with the -CR option
  2425. * fixed stabs with elf writer, finally the global variables can
  2426. be watched
  2427. * removed a lot of routines from cga unit and replaced them by
  2428. calls to cgobj
  2429. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  2430. u32bit then the other is typecasted also to u32bit without giving
  2431. a rangecheck warning/error.
  2432. * fixed pascal calling method with reversing also the high tree in
  2433. the parast, detected by tcalcst3 test
  2434. Revision 1.35 2002/04/19 15:46:03 peter
  2435. * mangledname rewrite, tprocdef.mangledname is now created dynamicly
  2436. in most cases and not written to the ppu
  2437. * add mangeledname_prefix() routine to generate the prefix of
  2438. manglednames depending on the current procedure, object and module
  2439. * removed static procprefix since the mangledname is now build only
  2440. on demand from tprocdef.mangledname
  2441. Revision 1.34 2002/04/16 16:12:47 peter
  2442. * give error when using enums with jumps as array index
  2443. * allow char as enum value
  2444. Revision 1.33 2002/04/15 19:08:22 carl
  2445. + target_info.size_of_pointer -> pointer_size
  2446. + some cleanup of unused types/variables
  2447. Revision 1.32 2002/04/07 13:37:29 carl
  2448. + change unit use
  2449. Revision 1.31 2002/02/03 09:30:04 peter
  2450. * more fixes for protected handling
  2451. }