symsym.pas 85 KB

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