symsym.pas 86 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804
  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. if read_member then
  1252. ppufile.putlongint(address);
  1253. { write only definition or definitionsym }
  1254. ppufile.puttype(vartype);
  1255. hvo:=varoptions-[vo_regable];
  1256. ppufile.putsmallset(hvo);
  1257. ppufile.putbyte(byte(abstyp));
  1258. case abstyp of
  1259. tovar :
  1260. ppufile.putstring(ref.name);
  1261. toasm :
  1262. ppufile.putstring(asmname^);
  1263. toaddr :
  1264. begin
  1265. ppufile.putlongint(address);
  1266. ppufile.putbyte(byte(absseg));
  1267. end;
  1268. end;
  1269. ppufile.writeentry(ibabsolutesym);
  1270. end;
  1271. procedure tabsolutesym.deref;
  1272. var
  1273. srsym : tsym;
  1274. srsymtable : tsymtable;
  1275. begin
  1276. { inheritance of varsym.deref ! }
  1277. vartype.resolve;
  1278. { own absolute deref }
  1279. if (abstyp=tovar) and (asmname<>nil) then
  1280. begin
  1281. { search previous loaded symtables }
  1282. searchsym(asmname^,srsym,srsymtable);
  1283. if not assigned(srsym) then
  1284. srsym:=searchsymonlyin(owner,asmname^);
  1285. if not assigned(srsym) then
  1286. srsym:=generrorsym;
  1287. ref:=tstoredsym(srsym);
  1288. stringdispose(asmname);
  1289. end;
  1290. end;
  1291. function tabsolutesym.mangledname : string;
  1292. begin
  1293. case abstyp of
  1294. tovar :
  1295. begin
  1296. case ref.typ of
  1297. varsym :
  1298. mangledname:=tvarsym(ref).mangledname;
  1299. else
  1300. internalerror(200111011);
  1301. end;
  1302. end;
  1303. toasm :
  1304. mangledname:=asmname^;
  1305. toaddr :
  1306. mangledname:='$'+tostr(address);
  1307. else
  1308. internalerror(10002);
  1309. end;
  1310. end;
  1311. procedure tabsolutesym.insert_in_data;
  1312. begin
  1313. end;
  1314. {$ifdef GDB}
  1315. procedure tabsolutesym.concatstabto(asmlist : taasmoutput);
  1316. begin
  1317. { I don't know how to handle this !! }
  1318. end;
  1319. {$endif GDB}
  1320. {****************************************************************************
  1321. TVARSYM
  1322. ****************************************************************************}
  1323. constructor tvarsym.create(const n : string;const tt : ttype);
  1324. begin
  1325. inherited create(n);
  1326. typ:=varsym;
  1327. vartype:=tt;
  1328. _mangledname:=nil;
  1329. varspez:=vs_value;
  1330. address:=0;
  1331. localvarsym:=nil;
  1332. refs:=0;
  1333. varstate:=vs_used;
  1334. varoptions:=[];
  1335. { can we load the value into a register ? }
  1336. if tstoreddef(tt.def).is_intregable then
  1337. include(varoptions,vo_regable)
  1338. else
  1339. exclude(varoptions,vo_regable);
  1340. if tstoreddef(tt.def).is_fpuregable then
  1341. include(varoptions,vo_fpuregable)
  1342. else
  1343. exclude(varoptions,vo_fpuregable);
  1344. reg:=R_NO;
  1345. end;
  1346. constructor tvarsym.create_dll(const n : string;const tt : ttype);
  1347. begin
  1348. tvarsym(self).create(n,tt);
  1349. include(varoptions,vo_is_dll_var);
  1350. end;
  1351. constructor tvarsym.create_C(const n,mangled : string;const tt : ttype);
  1352. begin
  1353. tvarsym(self).create(n,tt);
  1354. include(varoptions,vo_is_C_var);
  1355. stringdispose(_mangledname);
  1356. _mangledname:=stringdup(mangled);
  1357. end;
  1358. constructor tvarsym.ppuload(ppufile:tcompilerppufile);
  1359. begin
  1360. inherited loadsym(ppufile);
  1361. typ:=varsym;
  1362. reg:=R_NO;
  1363. refs := 0;
  1364. varstate:=vs_used;
  1365. varspez:=tvarspez(ppufile.getbyte);
  1366. if read_member then
  1367. address:=ppufile.getlongint
  1368. else
  1369. address:=0;
  1370. localvarsym:=nil;
  1371. ppufile.gettype(vartype);
  1372. ppufile.getsmallset(varoptions);
  1373. if (vo_is_C_var in varoptions) then
  1374. _mangledname:=stringdup(ppufile.getstring);
  1375. end;
  1376. destructor tvarsym.destroy;
  1377. begin
  1378. inherited destroy;
  1379. end;
  1380. procedure tvarsym.deref;
  1381. begin
  1382. vartype.resolve;
  1383. end;
  1384. procedure tvarsym.ppuwrite(ppufile:tcompilerppufile);
  1385. var
  1386. hvo : tvaroptions;
  1387. begin
  1388. inherited writesym(ppufile);
  1389. ppufile.putbyte(byte(varspez));
  1390. if read_member then
  1391. ppufile.putlongint(address);
  1392. ppufile.puttype(vartype);
  1393. { symbols which are load are never candidates for a register,
  1394. turn off the regable }
  1395. hvo:=varoptions-[vo_regable,vo_fpuregable];
  1396. ppufile.putsmallset(hvo);
  1397. if (vo_is_C_var in varoptions) then
  1398. ppufile.putstring(mangledname);
  1399. ppufile.writeentry(ibvarsym);
  1400. end;
  1401. procedure tvarsym.generate_mangledname;
  1402. begin
  1403. _mangledname:=stringdup(mangledname_prefix('U',owner)+name);
  1404. end;
  1405. procedure tvarsym.set_mangledname(const s:string);
  1406. begin
  1407. stringdispose(_mangledname);
  1408. _mangledname:=stringdup(s);
  1409. end;
  1410. function tvarsym.getsize : longint;
  1411. begin
  1412. if assigned(vartype.def) then
  1413. getsize:=vartype.def.size
  1414. else
  1415. getsize:=0;
  1416. end;
  1417. function tvarsym.getvaluesize : longint;
  1418. begin
  1419. if assigned(vartype.def) and
  1420. (varspez=vs_value) and
  1421. ((vartype.def.deftype<>arraydef) or
  1422. tarraydef(vartype.def).isDynamicArray or
  1423. (tarraydef(vartype.def).highrange>=tarraydef(vartype.def).lowrange)) then
  1424. getvaluesize:=vartype.def.size
  1425. else
  1426. getvaluesize:=0;
  1427. end;
  1428. function tvarsym.getpushsize : longint;
  1429. begin
  1430. if assigned(vartype.def) then
  1431. begin
  1432. case varspez of
  1433. vs_out,
  1434. vs_var :
  1435. getpushsize:=pointer_size;
  1436. vs_value,
  1437. vs_const :
  1438. begin
  1439. if paramanager.push_addr_param(vartype.def) then
  1440. getpushsize:=pointer_size
  1441. else
  1442. getpushsize:=vartype.def.size;
  1443. end;
  1444. end;
  1445. end
  1446. else
  1447. getpushsize:=0;
  1448. end;
  1449. procedure tvarsym.insert_in_data;
  1450. var
  1451. varalign,
  1452. l,modulo : longint;
  1453. storefilepos : tfileposinfo;
  1454. begin
  1455. if (vo_is_external in varoptions) then
  1456. exit;
  1457. { handle static variables of objects especially }
  1458. if read_member and (owner.symtabletype=objectsymtable) and
  1459. (sp_static in symoptions) then
  1460. begin
  1461. { the data filed is generated in parser.pas
  1462. with a tobject_FIELDNAME variable }
  1463. { this symbol can't be loaded to a register }
  1464. exclude(varoptions,vo_regable);
  1465. exclude(varoptions,vo_fpuregable);
  1466. end
  1467. else
  1468. if not(read_member) then
  1469. begin
  1470. { made problems with parameters etc. ! (FK) }
  1471. { check for instance of an abstract object or class }
  1472. {
  1473. if (tvarsym(sym).definition.deftype=objectdef) and
  1474. ((tobjectdef(tvarsym(sym).definition).options and oo_is_abstract)<>0) then
  1475. Message(sym_e_no_instance_of_abstract_object);
  1476. }
  1477. storefilepos:=aktfilepos;
  1478. aktfilepos:=akttokenpos;
  1479. if (vo_is_thread_var in varoptions) then
  1480. l:=pointer_size
  1481. else
  1482. l:=getvaluesize;
  1483. case owner.symtabletype of
  1484. stt_exceptsymtable:
  1485. { can contain only one symbol, address calculated later }
  1486. ;
  1487. localsymtable :
  1488. begin
  1489. varstate:=vs_declared;
  1490. varalign:=size_2_align(l);
  1491. varalign:=used_align(varalign,aktalignment.localalignmin,aktalignment.localalignmax);
  1492. {$ifdef powerpc}
  1493. { on the powerpc, the local variables are accessed with a positiv offset }
  1494. address:=align(owner.datasize,varalign);
  1495. owner.datasize:=address+l;
  1496. {$else powerpc}
  1497. address:=align(owner.datasize+l,varalign);
  1498. owner.datasize:=address;
  1499. {$endif powerpc}
  1500. end;
  1501. staticsymtable :
  1502. begin
  1503. { enable unitialized warning for local symbols }
  1504. varstate:=vs_declared;
  1505. varalign:=size_2_align(l);
  1506. varalign:=used_align(varalign,aktalignment.varalignmin,aktalignment.varalignmax);
  1507. address:=align(owner.datasize,varalign);
  1508. { insert cut for smartlinking or alignment }
  1509. if (cs_create_smart in aktmoduleswitches) then
  1510. bssSegment.concat(Tai_cut.Create)
  1511. else if (address<>owner.datasize) then
  1512. bssSegment.concat(Tai_align.create(varalign));
  1513. owner.datasize:=address+l;
  1514. {$ifdef GDB}
  1515. if cs_debuginfo in aktmoduleswitches then
  1516. concatstabto(bsssegment);
  1517. {$endif GDB}
  1518. if (cs_create_smart in aktmoduleswitches) or
  1519. DLLSource or
  1520. (vo_is_exported in varoptions) or
  1521. (vo_is_C_var in varoptions) then
  1522. bssSegment.concat(Tai_datablock.Create_global(mangledname,l))
  1523. else
  1524. bssSegment.concat(Tai_datablock.Create(mangledname,l));
  1525. {Global variables (in implementation part of course)
  1526. *can* be loaded into registers, they just may not be
  1527. accessed from procedures. The lexlevel test in nld.pas,
  1528. Tloadnode.pass_1, should take care of this.
  1529. If for some reason you think it isn't safe, try isolating
  1530. and disabling those specific cases, because small programs
  1531. without procedures can be very speed critical. For example,
  1532. think of benchmarks and programming contests. Also, new
  1533. users often test the quality of the code the compiler
  1534. generates and they do that with small programs, we should
  1535. show them the full optimizing power. (DM)}
  1536. {exclude(varoptions,vo_regable);
  1537. exclude(varoptions,vo_fpuregable);}
  1538. end;
  1539. globalsymtable :
  1540. begin
  1541. varalign:=size_2_align(l);
  1542. varalign:=used_align(varalign,aktalignment.varalignmin,aktalignment.varalignmax);
  1543. address:=align(owner.datasize,varalign);
  1544. { insert cut for smartlinking or alignment }
  1545. if (cs_create_smart in aktmoduleswitches) then
  1546. bssSegment.concat(Tai_cut.Create)
  1547. else if (address<>owner.datasize) then
  1548. bssSegment.concat(Tai_align.create(varalign));
  1549. owner.datasize:=address+l;
  1550. {$ifdef GDB}
  1551. if cs_debuginfo in aktmoduleswitches then
  1552. concatstabto(bsssegment);
  1553. {$endif GDB}
  1554. bssSegment.concat(Tai_datablock.Create_global(mangledname,l));
  1555. { this symbol can't be loaded to a register }
  1556. exclude(varoptions,vo_regable);
  1557. exclude(varoptions,vo_fpuregable);
  1558. end;
  1559. recordsymtable,
  1560. objectsymtable :
  1561. begin
  1562. { this symbol can't be loaded to a register }
  1563. exclude(varoptions,vo_regable);
  1564. exclude(varoptions,vo_fpuregable);
  1565. { get the alignment size }
  1566. if (aktalignment.recordalignmax=-1) then
  1567. begin
  1568. varalign:=vartype.def.alignment;
  1569. if (varalign>4) and ((varalign mod 4)<>0) and
  1570. (vartype.def.deftype=arraydef) then
  1571. begin
  1572. Message1(sym_w_wrong_C_pack,vartype.def.typename);
  1573. end;
  1574. if varalign=0 then
  1575. varalign:=l;
  1576. if (owner.dataalignment<aktalignment.maxCrecordalign) then
  1577. begin
  1578. if (varalign>16) and (owner.dataalignment<32) then
  1579. owner.dataalignment:=32
  1580. else if (varalign>12) and (owner.dataalignment<16) then
  1581. owner.dataalignment:=16
  1582. { 12 is needed for long double }
  1583. else if (varalign>8) and (owner.dataalignment<12) then
  1584. owner.dataalignment:=12
  1585. else if (varalign>4) and (owner.dataalignment<8) then
  1586. owner.dataalignment:=8
  1587. else if (varalign>2) and (owner.dataalignment<4) then
  1588. owner.dataalignment:=4
  1589. else if (varalign>1) and (owner.dataalignment<2) then
  1590. owner.dataalignment:=2;
  1591. end;
  1592. owner.dataalignment:=max(owner.dataalignment,aktalignment.maxCrecordalign);
  1593. end
  1594. else
  1595. varalign:=vartype.def.alignment;
  1596. if varalign=0 then
  1597. varalign:=size_2_align(l);
  1598. varalign:=used_align(varalign,aktalignment.recordalignmin,owner.dataalignment);
  1599. address:=align(owner.datasize,varalign);
  1600. owner.datasize:=address+l;
  1601. end;
  1602. parasymtable :
  1603. begin
  1604. { here we need the size of a push instead of the
  1605. size of the data }
  1606. l:=getpushsize;
  1607. varalign:=size_2_align(l);
  1608. varstate:=vs_assigned;
  1609. { we need the new datasize already aligned so we can't
  1610. use the align_address here }
  1611. address:=owner.datasize;
  1612. varalign:=used_align(varalign,owner.dataalignment,owner.dataalignment);
  1613. owner.datasize:=align(address+l,varalign);
  1614. end
  1615. else
  1616. begin
  1617. modulo:=owner.datasize and 3;
  1618. if (l>=4) and (modulo<>0) then
  1619. inc(owner.datasize,4-modulo)
  1620. else
  1621. if (l>=2) and ((modulo and 1)<>0) then
  1622. inc(owner.datasize);
  1623. address:=owner.datasize;
  1624. inc(owner.datasize,l);
  1625. end;
  1626. end;
  1627. aktfilepos:=storefilepos;
  1628. end;
  1629. end;
  1630. {$ifdef GDB}
  1631. function tvarsym.stabstring : pchar;
  1632. var
  1633. st : string;
  1634. begin
  1635. st:=tstoreddef(vartype.def).numberstring;
  1636. if (owner.symtabletype = objectsymtable) and
  1637. (sp_static in symoptions) then
  1638. begin
  1639. if (cs_gdb_gsym in aktglobalswitches) then st := 'G'+st else st := 'S'+st;
  1640. stabstring := strpnew('"'+upper(owner.name^)+'__'+name+':'+st+
  1641. '",'+
  1642. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname);
  1643. end
  1644. else if (owner.symtabletype = globalsymtable) then
  1645. begin
  1646. { Here we used S instead of
  1647. because with G GDB doesn't look at the address field
  1648. but searches the same name or with a leading underscore
  1649. but these names don't exist in pascal !}
  1650. if (cs_gdb_gsym in aktglobalswitches) then st := 'G'+st else st := 'S'+st;
  1651. stabstring := strpnew('"'+name+':'+st+'",'+
  1652. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname);
  1653. end
  1654. else if owner.symtabletype = staticsymtable then
  1655. begin
  1656. stabstring := strpnew('"'+name+':S'+st+'",'+
  1657. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname);
  1658. end
  1659. else if (owner.symtabletype in [parasymtable,inlineparasymtable]) then
  1660. begin
  1661. case varspez of
  1662. vs_out,
  1663. vs_var : st := 'v'+st;
  1664. vs_value,
  1665. vs_const : if paramanager.push_addr_param(vartype.def) then
  1666. st := 'v'+st { should be 'i' but 'i' doesn't work }
  1667. else
  1668. st := 'p'+st;
  1669. end;
  1670. stabstring := strpnew('"'+name+':'+st+'",'+
  1671. tostr(N_tsym)+',0,'+tostr(fileinfo.line)+','+
  1672. tostr(address+owner.address_fixup));
  1673. {offset to ebp => will not work if the framepointer is esp
  1674. so some optimizing will make things harder to debug }
  1675. end
  1676. else if (owner.symtabletype in [localsymtable,inlinelocalsymtable]) then
  1677. if reg<>R_NO then
  1678. begin
  1679. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1680. { this is the register order for GDB}
  1681. stabstring:=strpnew('"'+name+':r'+st+'",'+
  1682. tostr(N_RSYM)+',0,'+
  1683. tostr(fileinfo.line)+','+tostr(stab_regindex[reg]));
  1684. end
  1685. else
  1686. { I don't know if this will work (PM) }
  1687. if (vo_is_C_var in varoptions) then
  1688. stabstring := strpnew('"'+name+':S'+st+'",'+
  1689. tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname)
  1690. else
  1691. stabstring := strpnew('"'+name+':'+st+'",'+
  1692. tostr(N_LSYM)+',0,'+tostr(fileinfo.line)+',-'+tostr(address-owner.address_fixup))
  1693. else
  1694. stabstring := inherited stabstring;
  1695. end;
  1696. procedure tvarsym.concatstabto(asmlist : taasmoutput);
  1697. var stab_str : pchar;
  1698. begin
  1699. inherited concatstabto(asmlist);
  1700. if (owner.symtabletype=parasymtable) and
  1701. (reg<>R_NO) then
  1702. begin
  1703. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1704. { this is the register order for GDB}
  1705. stab_str:=strpnew('"'+name+':r'
  1706. +tstoreddef(vartype.def).numberstring+'",'+
  1707. tostr(N_RSYM)+',0,'+
  1708. tostr(fileinfo.line)+','+tostr(stab_regindex[reg]));
  1709. asmList.concat(Tai_stabs.Create(stab_str));
  1710. end;
  1711. end;
  1712. {$endif GDB}
  1713. {****************************************************************************
  1714. TTYPEDCONSTSYM
  1715. *****************************************************************************}
  1716. constructor ttypedconstsym.create(const n : string;p : tdef;writable : boolean);
  1717. begin
  1718. inherited create(n);
  1719. typ:=typedconstsym;
  1720. typedconsttype.setdef(p);
  1721. is_writable:=writable;
  1722. end;
  1723. constructor ttypedconstsym.createtype(const n : string;const tt : ttype;writable : boolean);
  1724. begin
  1725. inherited create(n);
  1726. typ:=typedconstsym;
  1727. typedconsttype:=tt;
  1728. is_writable:=writable;
  1729. end;
  1730. constructor ttypedconstsym.ppuload(ppufile:tcompilerppufile);
  1731. begin
  1732. inherited loadsym(ppufile);
  1733. typ:=typedconstsym;
  1734. ppufile.gettype(typedconsttype);
  1735. is_writable:=boolean(ppufile.getbyte);
  1736. end;
  1737. destructor ttypedconstsym.destroy;
  1738. begin
  1739. inherited destroy;
  1740. end;
  1741. procedure ttypedconstsym.generate_mangledname;
  1742. begin
  1743. _mangledname:=stringdup(mangledname_prefix('TC',owner)+name);
  1744. end;
  1745. function ttypedconstsym.getsize : longint;
  1746. begin
  1747. if assigned(typedconsttype.def) then
  1748. getsize:=typedconsttype.def.size
  1749. else
  1750. getsize:=0;
  1751. end;
  1752. procedure ttypedconstsym.deref;
  1753. begin
  1754. typedconsttype.resolve;
  1755. end;
  1756. procedure ttypedconstsym.ppuwrite(ppufile:tcompilerppufile);
  1757. begin
  1758. inherited writesym(ppufile);
  1759. ppufile.puttype(typedconsttype);
  1760. ppufile.putbyte(byte(is_writable));
  1761. ppufile.writeentry(ibtypedconstsym);
  1762. end;
  1763. procedure ttypedconstsym.insert_in_data;
  1764. var
  1765. curconstsegment : taasmoutput;
  1766. address,l,varalign : longint;
  1767. storefilepos : tfileposinfo;
  1768. begin
  1769. storefilepos:=aktfilepos;
  1770. aktfilepos:=akttokenpos;
  1771. if is_writable then
  1772. curconstsegment:=datasegment
  1773. else
  1774. curconstsegment:=consts;
  1775. l:=getsize;
  1776. varalign:=size_2_align(l);
  1777. varalign:=used_align(varalign,aktalignment.constalignmin,aktalignment.constalignmax);
  1778. address:=align(owner.datasize,varalign);
  1779. { insert cut for smartlinking or alignment }
  1780. if (cs_create_smart in aktmoduleswitches) then
  1781. curconstSegment.concat(Tai_cut.Create)
  1782. else if (address<>owner.datasize) then
  1783. curconstSegment.concat(Tai_align.create(varalign));
  1784. owner.datasize:=address+l;
  1785. {$ifdef GDB}
  1786. if cs_debuginfo in aktmoduleswitches then
  1787. concatstabto(curconstsegment);
  1788. {$endif GDB}
  1789. if (owner.symtabletype=globalsymtable) then
  1790. begin
  1791. if (owner.unitid=0) then
  1792. curconstSegment.concat(Tai_symbol.Createdataname_global(mangledname,getsize));
  1793. end
  1794. else
  1795. begin
  1796. if (cs_create_smart in aktmoduleswitches) or
  1797. DLLSource then
  1798. curconstSegment.concat(Tai_symbol.Createdataname_global(mangledname,getsize))
  1799. else
  1800. curconstSegment.concat(Tai_symbol.Createdataname(mangledname,getsize));
  1801. end;
  1802. aktfilepos:=storefilepos;
  1803. end;
  1804. {$ifdef GDB}
  1805. function ttypedconstsym.stabstring : pchar;
  1806. var
  1807. st : char;
  1808. begin
  1809. if (cs_gdb_gsym in aktglobalswitches) and (owner.symtabletype=globalsymtable) then
  1810. st := 'G'
  1811. else
  1812. st := 'S';
  1813. stabstring := strpnew('"'+name+':'+st+
  1814. tstoreddef(typedconsttype.def).numberstring+'",'+tostr(n_STSYM)+',0,'+
  1815. tostr(fileinfo.line)+','+mangledname);
  1816. end;
  1817. {$endif GDB}
  1818. {****************************************************************************
  1819. TCONSTSYM
  1820. ****************************************************************************}
  1821. constructor tconstsym.create_ord(const n : string;t : tconsttyp;v : TConstExprInt);
  1822. begin
  1823. inherited create(n);
  1824. typ:=constsym;
  1825. consttyp:=t;
  1826. valueord:=v;
  1827. valueordptr:=0;
  1828. valueptr:=nil;
  1829. ResStrIndex:=0;
  1830. consttype.reset;
  1831. len:=0;
  1832. end;
  1833. constructor tconstsym.create_ord_typed(const n : string;t : tconsttyp;v : tconstexprint;const tt:ttype);
  1834. begin
  1835. inherited create(n);
  1836. typ:=constsym;
  1837. consttyp:=t;
  1838. valueord:=v;
  1839. valueordptr:=0;
  1840. valueptr:=nil;
  1841. ResStrIndex:=0;
  1842. consttype:=tt;
  1843. len:=0;
  1844. end;
  1845. constructor tconstsym.create_ordptr_typed(const n : string;t : tconsttyp;v : tconstptruint;const tt:ttype);
  1846. begin
  1847. inherited create(n);
  1848. typ:=constsym;
  1849. consttyp:=t;
  1850. valueord:=0;
  1851. valueordptr:=v;
  1852. valueptr:=nil;
  1853. ResStrIndex:=0;
  1854. consttype:=tt;
  1855. len:=0;
  1856. end;
  1857. constructor tconstsym.create_ptr(const n : string;t : tconsttyp;v : pointer);
  1858. begin
  1859. inherited create(n);
  1860. typ:=constsym;
  1861. consttyp:=t;
  1862. valueord:=0;
  1863. valueordptr:=0;
  1864. valueptr:=v;
  1865. ResStrIndex:=0;
  1866. consttype.reset;
  1867. len:=0;
  1868. end;
  1869. constructor tconstsym.create_ptr_typed(const n : string;t : tconsttyp;v : pointer;const tt:ttype);
  1870. begin
  1871. inherited create(n);
  1872. typ:=constsym;
  1873. consttyp:=t;
  1874. valueord:=0;
  1875. valueordptr:=0;
  1876. valueptr:=v;
  1877. ResStrIndex:=0;
  1878. consttype:=tt;
  1879. len:=0;
  1880. end;
  1881. constructor tconstsym.create_string(const n : string;t : tconsttyp;str:pchar;l:longint);
  1882. begin
  1883. inherited create(n);
  1884. typ:=constsym;
  1885. consttyp:=t;
  1886. valueord:=0;
  1887. valueordptr:=0;
  1888. valueptr:=str;
  1889. consttype.reset;
  1890. len:=l;
  1891. if t=constresourcestring then
  1892. ResStrIndex:=ResourceStrings.Register(name,pchar(valueptr),len);
  1893. end;
  1894. constructor tconstsym.ppuload(ppufile:tcompilerppufile);
  1895. var
  1896. pd : pbestreal;
  1897. ps : pnormalset;
  1898. pc : pchar;
  1899. l1,l2 : longint;
  1900. begin
  1901. inherited loadsym(ppufile);
  1902. typ:=constsym;
  1903. consttype.reset;
  1904. consttyp:=tconsttyp(ppufile.getbyte);
  1905. valueord:=0;
  1906. valueordptr:=0;
  1907. valueptr:=nil;
  1908. case consttyp of
  1909. constint:
  1910. valueord:=ppufile.getexprint;
  1911. constwchar,
  1912. constbool,
  1913. constchar :
  1914. valueord:=ppufile.getlongint;
  1915. constord :
  1916. begin
  1917. ppufile.gettype(consttype);
  1918. valueord:=ppufile.getexprint;
  1919. end;
  1920. constpointer :
  1921. begin
  1922. ppufile.gettype(consttype);
  1923. valueordptr:=ppufile.getptruint;
  1924. end;
  1925. conststring,
  1926. constresourcestring :
  1927. begin
  1928. len:=ppufile.getlongint;
  1929. getmem(pc,len+1);
  1930. ppufile.getdata(pc^,len);
  1931. if consttyp=constresourcestring then
  1932. ResStrIndex:=ppufile.getlongint;
  1933. valueptr:=pc;
  1934. end;
  1935. constreal :
  1936. begin
  1937. new(pd);
  1938. pd^:=ppufile.getreal;
  1939. valueptr:=pd;
  1940. end;
  1941. constset :
  1942. begin
  1943. ppufile.gettype(consttype);
  1944. new(ps);
  1945. ppufile.getnormalset(ps^);
  1946. valueptr:=ps;
  1947. end;
  1948. constnil : ;
  1949. else
  1950. Message1(unit_f_ppu_invalid_entry,tostr(ord(consttyp)));
  1951. end;
  1952. end;
  1953. destructor tconstsym.destroy;
  1954. begin
  1955. case consttyp of
  1956. conststring,
  1957. constresourcestring :
  1958. freemem(pchar(valueptr),len+1);
  1959. constreal :
  1960. dispose(pbestreal(valueptr));
  1961. constset :
  1962. dispose(pnormalset(valueptr));
  1963. end;
  1964. inherited destroy;
  1965. end;
  1966. function tconstsym.mangledname : string;
  1967. begin
  1968. mangledname:=name;
  1969. end;
  1970. procedure tconstsym.deref;
  1971. begin
  1972. if consttyp in [constord,constpointer,constset] then
  1973. consttype.resolve;
  1974. end;
  1975. procedure tconstsym.ppuwrite(ppufile:tcompilerppufile);
  1976. begin
  1977. inherited writesym(ppufile);
  1978. ppufile.putbyte(byte(consttyp));
  1979. case consttyp of
  1980. constnil : ;
  1981. constint:
  1982. ppufile.putexprint(valueord);
  1983. constbool,
  1984. constchar :
  1985. ppufile.putlongint(valueord);
  1986. constord :
  1987. begin
  1988. ppufile.puttype(consttype);
  1989. ppufile.putexprint(valueord);
  1990. end;
  1991. constpointer :
  1992. begin
  1993. ppufile.puttype(consttype);
  1994. ppufile.putptruint(valueordptr);
  1995. end;
  1996. conststring,
  1997. constresourcestring :
  1998. begin
  1999. ppufile.putlongint(len);
  2000. ppufile.putdata(pchar(valueptr)^,len);
  2001. if consttyp=constresourcestring then
  2002. ppufile.putlongint(ResStrIndex);
  2003. end;
  2004. constreal :
  2005. ppufile.putreal(pbestreal(valueptr)^);
  2006. constset :
  2007. begin
  2008. ppufile.puttype(consttype);
  2009. ppufile.putnormalset(valueptr^);
  2010. end;
  2011. else
  2012. internalerror(13);
  2013. end;
  2014. ppufile.writeentry(ibconstsym);
  2015. end;
  2016. {$ifdef GDB}
  2017. function tconstsym.stabstring : pchar;
  2018. var st : string;
  2019. begin
  2020. {even GDB v4.16 only now 'i' 'r' and 'e' !!!}
  2021. case consttyp of
  2022. conststring : begin
  2023. st := 's'''+strpas(pchar(valueptr))+'''';
  2024. end;
  2025. constbool,
  2026. constint,
  2027. constord,
  2028. constchar : st := 'i'+int64tostr(valueord);
  2029. constpointer :
  2030. st := 'i'+int64tostr(valueordptr);
  2031. constreal : begin
  2032. system.str(pbestreal(valueptr)^,st);
  2033. st := 'r'+st;
  2034. end;
  2035. { if we don't know just put zero !! }
  2036. else st:='i0';
  2037. {***SETCONST}
  2038. {constset:;} {*** I don't know what to do with a set.}
  2039. { sets are not recognized by GDB}
  2040. {***}
  2041. end;
  2042. stabstring := strpnew('"'+name+':c='+st+'",'+tostr(N_function)+',0,'+
  2043. tostr(fileinfo.line)+',0');
  2044. end;
  2045. procedure tconstsym.concatstabto(asmlist : taasmoutput);
  2046. begin
  2047. if consttyp <> conststring then
  2048. inherited concatstabto(asmlist);
  2049. end;
  2050. {$endif GDB}
  2051. {****************************************************************************
  2052. TENUMSYM
  2053. ****************************************************************************}
  2054. constructor tenumsym.create(const n : string;def : tenumdef;v : longint);
  2055. begin
  2056. inherited create(n);
  2057. typ:=enumsym;
  2058. definition:=def;
  2059. value:=v;
  2060. { check for jumps }
  2061. if v>def.max+1 then
  2062. def.has_jumps:=true;
  2063. { update low and high }
  2064. if def.min>v then
  2065. def.setmin(v);
  2066. if def.max<v then
  2067. def.setmax(v);
  2068. order;
  2069. end;
  2070. constructor tenumsym.ppuload(ppufile:tcompilerppufile);
  2071. begin
  2072. inherited loadsym(ppufile);
  2073. typ:=enumsym;
  2074. definition:=tenumdef(ppufile.getderef);
  2075. value:=ppufile.getlongint;
  2076. nextenum := Nil;
  2077. end;
  2078. procedure tenumsym.deref;
  2079. begin
  2080. resolvedef(pointer(definition));
  2081. order;
  2082. end;
  2083. procedure tenumsym.order;
  2084. var
  2085. sym : tenumsym;
  2086. begin
  2087. sym := tenumsym(definition.firstenum);
  2088. if sym = nil then
  2089. begin
  2090. definition.firstenum := self;
  2091. nextenum := nil;
  2092. exit;
  2093. end;
  2094. { reorder the symbols in increasing value }
  2095. if value < sym.value then
  2096. begin
  2097. nextenum := sym;
  2098. definition.firstenum := self;
  2099. end
  2100. else
  2101. begin
  2102. while (sym.value <= value) and assigned(sym.nextenum) do
  2103. sym := sym.nextenum;
  2104. nextenum := sym.nextenum;
  2105. sym.nextenum := self;
  2106. end;
  2107. end;
  2108. procedure tenumsym.ppuwrite(ppufile:tcompilerppufile);
  2109. begin
  2110. inherited writesym(ppufile);
  2111. ppufile.putderef(definition);
  2112. ppufile.putlongint(value);
  2113. ppufile.writeentry(ibenumsym);
  2114. end;
  2115. {$ifdef GDB}
  2116. procedure tenumsym.concatstabto(asmlist : taasmoutput);
  2117. begin
  2118. {enum elements have no stab !}
  2119. end;
  2120. {$EndIf GDB}
  2121. {****************************************************************************
  2122. TTYPESYM
  2123. ****************************************************************************}
  2124. constructor ttypesym.create(const n : string;const tt : ttype);
  2125. begin
  2126. inherited create(n);
  2127. typ:=typesym;
  2128. restype:=tt;
  2129. {$ifdef GDB}
  2130. isusedinstab := false;
  2131. {$endif GDB}
  2132. { register the typesym for the definition }
  2133. if assigned(restype.def) and
  2134. (restype.def.deftype<>errordef) and
  2135. not(assigned(restype.def.typesym)) then
  2136. restype.def.typesym:=self;
  2137. end;
  2138. constructor ttypesym.ppuload(ppufile:tcompilerppufile);
  2139. begin
  2140. inherited loadsym(ppufile);
  2141. typ:=typesym;
  2142. {$ifdef GDB}
  2143. isusedinstab := false;
  2144. {$endif GDB}
  2145. ppufile.gettype(restype);
  2146. end;
  2147. function ttypesym.gettypedef:tdef;
  2148. begin
  2149. gettypedef:=restype.def;
  2150. end;
  2151. procedure ttypesym.deref;
  2152. begin
  2153. restype.resolve;
  2154. end;
  2155. procedure ttypesym.ppuwrite(ppufile:tcompilerppufile);
  2156. begin
  2157. inherited writesym(ppufile);
  2158. ppufile.puttype(restype);
  2159. ppufile.writeentry(ibtypesym);
  2160. end;
  2161. procedure ttypesym.load_references(ppufile:tcompilerppufile;locals:boolean);
  2162. begin
  2163. inherited load_references(ppufile,locals);
  2164. if (restype.def.deftype=recorddef) then
  2165. tstoredsymtable(trecorddef(restype.def).symtable).load_references(ppufile,locals);
  2166. if (restype.def.deftype=objectdef) then
  2167. tstoredsymtable(tobjectdef(restype.def).symtable).load_references(ppufile,locals);
  2168. end;
  2169. function ttypesym.write_references(ppufile:tcompilerppufile;locals:boolean):boolean;
  2170. begin
  2171. if not inherited write_references(ppufile,locals) then
  2172. begin
  2173. { write address of this symbol if record or object
  2174. even if no real refs are there
  2175. because we need it for the symtable }
  2176. if (restype.def.deftype in [recorddef,objectdef]) then
  2177. begin
  2178. ppufile.putderef(self);
  2179. ppufile.writeentry(ibsymref);
  2180. end;
  2181. end;
  2182. write_references:=true;
  2183. if (restype.def.deftype=recorddef) then
  2184. tstoredsymtable(trecorddef(restype.def).symtable).write_references(ppufile,locals);
  2185. if (restype.def.deftype=objectdef) then
  2186. tstoredsymtable(tobjectdef(restype.def).symtable).write_references(ppufile,locals);
  2187. end;
  2188. {$ifdef GDB}
  2189. function ttypesym.stabstring : pchar;
  2190. var
  2191. stabchar : string[2];
  2192. short : string;
  2193. begin
  2194. if restype.def.deftype in tagtypes then
  2195. stabchar := 'Tt'
  2196. else
  2197. stabchar := 't';
  2198. short := '"'+name+':'+stabchar+tstoreddef(restype.def).numberstring
  2199. +'",'+tostr(N_LSYM)+',0,'+tostr(fileinfo.line)+',0';
  2200. stabstring := strpnew(short);
  2201. end;
  2202. procedure ttypesym.concatstabto(asmlist : taasmoutput);
  2203. begin
  2204. {not stabs for forward defs }
  2205. if assigned(restype.def) then
  2206. if (restype.def.typesym = self) then
  2207. tstoreddef(restype.def).concatstabto(asmlist)
  2208. else
  2209. inherited concatstabto(asmlist);
  2210. end;
  2211. {$endif GDB}
  2212. {****************************************************************************
  2213. TSYSSYM
  2214. ****************************************************************************}
  2215. constructor tsyssym.create(const n : string;l : longint);
  2216. begin
  2217. inherited create(n);
  2218. typ:=syssym;
  2219. number:=l;
  2220. end;
  2221. constructor tsyssym.ppuload(ppufile:tcompilerppufile);
  2222. begin
  2223. inherited loadsym(ppufile);
  2224. typ:=syssym;
  2225. number:=ppufile.getlongint;
  2226. end;
  2227. destructor tsyssym.destroy;
  2228. begin
  2229. inherited destroy;
  2230. end;
  2231. procedure tsyssym.ppuwrite(ppufile:tcompilerppufile);
  2232. begin
  2233. inherited writesym(ppufile);
  2234. ppufile.putlongint(number);
  2235. ppufile.writeentry(ibsyssym);
  2236. end;
  2237. {$ifdef GDB}
  2238. procedure tsyssym.concatstabto(asmlist : taasmoutput);
  2239. begin
  2240. end;
  2241. {$endif GDB}
  2242. {****************************************************************************
  2243. TRTTISYM
  2244. ****************************************************************************}
  2245. constructor trttisym.create(const n:string;rt:trttitype);
  2246. const
  2247. prefix : array[trttitype] of string[5]=('$rtti','$init');
  2248. begin
  2249. inherited create(prefix[rt]+n);
  2250. typ:=rttisym;
  2251. lab:=nil;
  2252. rttityp:=rt;
  2253. end;
  2254. constructor trttisym.ppuload(ppufile:tcompilerppufile);
  2255. begin
  2256. inherited loadsym(ppufile);
  2257. typ:=rttisym;
  2258. lab:=nil;
  2259. rttityp:=trttitype(ppufile.getbyte);
  2260. end;
  2261. procedure trttisym.ppuwrite(ppufile:tcompilerppufile);
  2262. begin
  2263. inherited writesym(ppufile);
  2264. ppufile.putbyte(byte(rttityp));
  2265. ppufile.writeentry(ibrttisym);
  2266. end;
  2267. function trttisym.mangledname : string;
  2268. const
  2269. prefix : array[trttitype] of string[5]=('RTTI_','INIT_');
  2270. var
  2271. s : string;
  2272. p : tsymtable;
  2273. begin
  2274. s:='';
  2275. p:=owner;
  2276. while assigned(p) and (p.symtabletype=localsymtable) do
  2277. begin
  2278. s:=s+'_'+p.defowner.name;
  2279. p:=p.defowner.owner;
  2280. end;
  2281. if not(p.symtabletype in [globalsymtable,staticsymtable]) then
  2282. internalerror(200108265);
  2283. mangledname:=prefix[rttityp]+p.name^+s+'$_'+Copy(name,5,255);
  2284. end;
  2285. function trttisym.get_label:tasmsymbol;
  2286. begin
  2287. { the label is always a global label }
  2288. if not assigned(lab) then
  2289. lab:=objectlibrary.newasmsymboltype(mangledname,AB_GLOBAL,AT_DATA);
  2290. get_label:=lab;
  2291. end;
  2292. { persistent rtti generation }
  2293. procedure generate_rtti(p:tsym);
  2294. var
  2295. rsym : trttisym;
  2296. def : tstoreddef;
  2297. begin
  2298. { rtti can only be generated for classes that are always typesyms }
  2299. if not(p.typ=typesym) then
  2300. internalerror(200108261);
  2301. def:=tstoreddef(ttypesym(p).restype.def);
  2302. { only create rtti once for each definition }
  2303. if not(df_has_rttitable in def.defoptions) then
  2304. begin
  2305. { definition should be in the same symtable as the symbol }
  2306. if p.owner<>def.owner then
  2307. internalerror(200108262);
  2308. { create rttisym }
  2309. rsym:=trttisym.create(p.name,fullrtti);
  2310. p.owner.insert(rsym);
  2311. { register rttisym in definition }
  2312. include(def.defoptions,df_has_rttitable);
  2313. def.rttitablesym:=rsym;
  2314. { write rtti data }
  2315. def.write_child_rtti_data(fullrtti);
  2316. if (cs_create_smart in aktmoduleswitches) then
  2317. rttiList.concat(Tai_cut.Create);
  2318. rttiList.concat(Tai_symbol.Create(rsym.get_label,0));
  2319. def.write_rtti_data(fullrtti);
  2320. rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
  2321. end;
  2322. end;
  2323. { persistent init table generation }
  2324. procedure generate_inittable(p:tsym);
  2325. var
  2326. rsym : trttisym;
  2327. def : tstoreddef;
  2328. begin
  2329. { anonymous types are also allowed for records that can be varsym }
  2330. case p.typ of
  2331. typesym :
  2332. def:=tstoreddef(ttypesym(p).restype.def);
  2333. varsym :
  2334. def:=tstoreddef(tvarsym(p).vartype.def);
  2335. else
  2336. internalerror(200108263);
  2337. end;
  2338. { only create inittable once for each definition }
  2339. if not(df_has_inittable in def.defoptions) then
  2340. begin
  2341. { definition should be in the same symtable as the symbol }
  2342. if p.owner<>def.owner then
  2343. internalerror(200108264);
  2344. { create rttisym }
  2345. rsym:=trttisym.create(p.name,initrtti);
  2346. p.owner.insert(rsym);
  2347. { register rttisym in definition }
  2348. include(def.defoptions,df_has_inittable);
  2349. def.inittablesym:=rsym;
  2350. { write inittable data }
  2351. def.write_child_rtti_data(initrtti);
  2352. if (cs_create_smart in aktmoduleswitches) then
  2353. rttiList.concat(Tai_cut.Create);
  2354. rttiList.concat(Tai_symbol.Create(rsym.get_label,0));
  2355. def.write_rtti_data(initrtti);
  2356. rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
  2357. end;
  2358. end;
  2359. end.
  2360. {
  2361. $Log$
  2362. Revision 1.54 2002-08-20 10:31:26 daniel
  2363. * Tcallnode.det_resulttype rewritten
  2364. Revision 1.53 2002/08/18 20:06:27 peter
  2365. * inlining is now also allowed in interface
  2366. * renamed write/load to ppuwrite/ppuload
  2367. * tnode storing in ppu
  2368. * nld,ncon,nbas are already updated for storing in ppu
  2369. Revision 1.52 2002/08/17 09:23:42 florian
  2370. * first part of procinfo rewrite
  2371. Revision 1.51 2002/08/16 14:24:59 carl
  2372. * issameref() to test if two references are the same (then emit no opcodes)
  2373. + ret_in_reg to replace ret_in_acc
  2374. (fix some register allocation bugs at the same time)
  2375. + save_std_register now has an extra parameter which is the
  2376. usedinproc registers
  2377. Revision 1.50 2002/08/13 21:40:57 florian
  2378. * more fixes for ppc calling conventions
  2379. Revision 1.49 2002/08/12 15:08:40 carl
  2380. + stab register indexes for powerpc (moved from gdb to cpubase)
  2381. + tprocessor enumeration moved to cpuinfo
  2382. + linker in target_info is now a class
  2383. * many many updates for m68k (will soon start to compile)
  2384. - removed some ifdef or correct them for correct cpu
  2385. Revision 1.48 2002/08/11 14:32:28 peter
  2386. * renamed current_library to objectlibrary
  2387. Revision 1.47 2002/08/11 13:24:14 peter
  2388. * saving of asmsymbols in ppu supported
  2389. * asmsymbollist global is removed and moved into a new class
  2390. tasmlibrarydata that will hold the info of a .a file which
  2391. corresponds with a single module. Added librarydata to tmodule
  2392. to keep the library info stored for the module. In the future the
  2393. objectfiles will also be stored to the tasmlibrarydata class
  2394. * all getlabel/newasmsymbol and friends are moved to the new class
  2395. Revision 1.46 2002/07/23 10:13:23 daniel
  2396. * Added important comment
  2397. Revision 1.45 2002/07/23 09:51:26 daniel
  2398. * Tried to make Tprocsym.defs protected. I didn't succeed but the cleanups
  2399. are worth comitting.
  2400. Revision 1.44 2002/07/20 17:45:29 daniel
  2401. * Register variables are now possible for global variables too. This is
  2402. important for small programs without procedures.
  2403. Revision 1.43 2002/07/20 11:57:58 florian
  2404. * types.pas renamed to defbase.pas because D6 contains a types
  2405. unit so this would conflicts if D6 programms are compiled
  2406. + Willamette/SSE2 instructions to assembler added
  2407. Revision 1.42 2002/07/11 14:41:31 florian
  2408. * start of the new generic parameter handling
  2409. Revision 1.41 2002/07/10 07:24:40 jonas
  2410. * memory leak fixes from Sergey Korshunoff
  2411. Revision 1.40 2002/07/01 18:46:27 peter
  2412. * internal linker
  2413. * reorganized aasm layer
  2414. Revision 1.39 2002/05/18 13:34:18 peter
  2415. * readded missing revisions
  2416. Revision 1.38 2002/05/16 19:46:45 carl
  2417. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  2418. + try to fix temp allocation (still in ifdef)
  2419. + generic constructor calls
  2420. + start of tassembler / tmodulebase class cleanup
  2421. Revision 1.36 2002/05/12 16:53:15 peter
  2422. * moved entry and exitcode to ncgutil and cgobj
  2423. * foreach gets extra argument for passing local data to the
  2424. iterator function
  2425. * -CR checks also class typecasts at runtime by changing them
  2426. into as
  2427. * fixed compiler to cycle with the -CR option
  2428. * fixed stabs with elf writer, finally the global variables can
  2429. be watched
  2430. * removed a lot of routines from cga unit and replaced them by
  2431. calls to cgobj
  2432. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  2433. u32bit then the other is typecasted also to u32bit without giving
  2434. a rangecheck warning/error.
  2435. * fixed pascal calling method with reversing also the high tree in
  2436. the parast, detected by tcalcst3 test
  2437. Revision 1.35 2002/04/19 15:46:03 peter
  2438. * mangledname rewrite, tprocdef.mangledname is now created dynamicly
  2439. in most cases and not written to the ppu
  2440. * add mangeledname_prefix() routine to generate the prefix of
  2441. manglednames depending on the current procedure, object and module
  2442. * removed static procprefix since the mangledname is now build only
  2443. on demand from tprocdef.mangledname
  2444. Revision 1.34 2002/04/16 16:12:47 peter
  2445. * give error when using enums with jumps as array index
  2446. * allow char as enum value
  2447. Revision 1.33 2002/04/15 19:08:22 carl
  2448. + target_info.size_of_pointer -> pointer_size
  2449. + some cleanup of unused types/variables
  2450. Revision 1.32 2002/04/07 13:37:29 carl
  2451. + change unit use
  2452. Revision 1.31 2002/02/03 09:30:04 peter
  2453. * more fixes for protected handling
  2454. }