symtype.pas 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
  4. This unit handles the symbol tables
  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 symtype;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. { common }
  23. cutils,
  24. {$ifdef MEMDEBUG}
  25. cclasses,
  26. {$endif MEMDEBUG}
  27. { global }
  28. globtype,globals,
  29. { symtable }
  30. symconst,symbase,
  31. { aasm }
  32. aasmbase,ppu,cpuinfo
  33. ;
  34. type
  35. {************************************************
  36. Required Forwards
  37. ************************************************}
  38. tsym = class;
  39. Tcompilerppufile=class;
  40. {************************************************
  41. TRef
  42. ************************************************}
  43. tref = class
  44. nextref : tref;
  45. posinfo : tfileposinfo;
  46. moduleindex : longint;
  47. is_written : boolean;
  48. constructor create(ref:tref;pos:pfileposinfo);
  49. procedure freechain;
  50. destructor destroy;override;
  51. end;
  52. {************************************************
  53. TDef
  54. ************************************************}
  55. tgetsymtable = (gs_none,gs_record,gs_local,gs_para);
  56. tdef = class(tdefentry)
  57. typesym : tsym; { which type the definition was generated this def }
  58. defoptions : tdefoptions;
  59. constructor create;
  60. procedure buildderef;virtual;abstract;
  61. procedure buildderefimpl;virtual;abstract;
  62. procedure deref;virtual;abstract;
  63. procedure derefimpl;virtual;abstract;
  64. function typename:string;
  65. function gettypename:string;virtual;
  66. function mangledparaname:string;
  67. function getmangledparaname:string;virtual;abstract;
  68. function size:longint;virtual;abstract;
  69. function alignment:longint;virtual;abstract;
  70. function getparentdef:tdef;virtual;
  71. function getsymtable(t:tgetsymtable):tsymtable;virtual;
  72. function is_publishable:boolean;virtual;abstract;
  73. function needs_inittable:boolean;virtual;abstract;
  74. end;
  75. {************************************************
  76. TSym
  77. ************************************************}
  78. { this object is the base for all symbol objects }
  79. tsym = class(tsymentry)
  80. protected
  81. public
  82. _realname : pstring;
  83. fileinfo : tfileposinfo;
  84. symoptions : tsymoptions;
  85. refs : longint;
  86. lastref,
  87. defref,
  88. lastwritten : tref;
  89. refcount : longint;
  90. {$ifdef GDB}
  91. isstabwritten : boolean;
  92. function get_var_value(const s:string):string;
  93. function stabstr_evaluate(const s:string;vars:array of string):Pchar;
  94. function stabstring : pchar;virtual;
  95. {$endif GDB}
  96. constructor create(const n : string);
  97. constructor loadsym(ppufile:tcompilerppufile);
  98. destructor destroy;override;
  99. procedure ppuwrite(ppufile:tcompilerppufile);virtual;abstract;
  100. procedure writesym(ppufile:tcompilerppufile);
  101. function realname:string;
  102. procedure buildderef;virtual;
  103. { procedure buildderefimpl;virtual;abstract;}
  104. procedure deref;virtual;
  105. { procedure derefimpl;virtual;abstract;}
  106. function gettypedef:tdef;virtual;
  107. procedure load_references(ppufile:tcompilerppufile;locals:boolean);virtual;
  108. function write_references(ppufile:tcompilerppufile;locals:boolean):boolean;virtual;
  109. function is_visible_for_object(currobjdef:Tdef):boolean;
  110. end;
  111. {************************************************
  112. TDeref
  113. ************************************************}
  114. tderef = object
  115. dataidx : longint;
  116. procedure reset;
  117. procedure build(s:tsymtableentry);
  118. function resolve:tsymtableentry;
  119. end;
  120. {************************************************
  121. TType
  122. ************************************************}
  123. ttype = object
  124. def : tdef;
  125. sym : tsym;
  126. deref : tderef;
  127. procedure reset;
  128. procedure setdef(p:tdef);
  129. procedure setsym(p:tsym);
  130. procedure resolve;
  131. procedure buildderef;
  132. end;
  133. {************************************************
  134. TSymList
  135. ************************************************}
  136. psymlistitem = ^tsymlistitem;
  137. tsymlistitem = record
  138. sltype : tsltype;
  139. next : psymlistitem;
  140. case byte of
  141. 0 : (sym : tsym; symderef : tderef);
  142. 1 : (value : longint);
  143. 2 : (tt : ttype);
  144. end;
  145. tsymlist = class
  146. procdef : tdef;
  147. procdefderef : tderef;
  148. firstsym,
  149. lastsym : psymlistitem;
  150. constructor create;
  151. destructor destroy;override;
  152. function empty:boolean;
  153. procedure addsym(slt:tsltype;p:tsym);
  154. procedure addsymderef(slt:tsltype;const d:tderef);
  155. procedure addconst(slt:tsltype;v:longint);
  156. procedure addtype(slt:tsltype;const tt:ttype);
  157. procedure clear;
  158. function getcopy:tsymlist;
  159. procedure resolve;
  160. procedure buildderef;
  161. end;
  162. {************************************************
  163. Tcompilerppufile
  164. ************************************************}
  165. tcompilerppufile=class(tppufile)
  166. public
  167. procedure checkerror;
  168. procedure getguid(var g: tguid);
  169. function getexprint:tconstexprint;
  170. function getptruint:TConstPtrUInt;
  171. procedure getposinfo(var p:tfileposinfo);
  172. procedure getderef(var d:tderef);
  173. function getsymlist:tsymlist;
  174. procedure gettype(var t:ttype);
  175. function getasmsymbol:tasmsymbol;
  176. procedure putguid(const g: tguid);
  177. procedure putexprint(v:tconstexprint);
  178. procedure PutPtrUInt(v:TConstPtrUInt);
  179. procedure putposinfo(const p:tfileposinfo);
  180. procedure putderef(const d:tderef);
  181. procedure putsymlist(p:tsymlist);
  182. procedure puttype(const t:ttype);
  183. procedure putasmsymbol(s:tasmsymbol);
  184. end;
  185. {$ifdef MEMDEBUG}
  186. var
  187. membrowser,
  188. memrealnames,
  189. memmanglednames,
  190. memprocpara,
  191. memprocparast,
  192. memproclocalst,
  193. memprocnodetree : tmemdebug;
  194. {$endif MEMDEBUG}
  195. const
  196. current_object_option : tsymoptions = [sp_public];
  197. implementation
  198. uses
  199. verbose,
  200. fmodule,
  201. symdef
  202. {$ifdef GDB}
  203. ,gdb
  204. {$endif GDB}
  205. ;
  206. {****************************************************************************
  207. Tdef
  208. ****************************************************************************}
  209. constructor tdef.create;
  210. begin
  211. inherited create;
  212. deftype:=abstractdef;
  213. owner := nil;
  214. typesym := nil;
  215. defoptions:=[];
  216. end;
  217. function tdef.typename:string;
  218. begin
  219. if assigned(typesym) and
  220. not(deftype in [procvardef,procdef]) and
  221. assigned(typesym._realname) and
  222. (typesym._realname^[1]<>'$') then
  223. typename:=typesym._realname^
  224. else
  225. typename:=gettypename;
  226. end;
  227. function tdef.gettypename : string;
  228. begin
  229. gettypename:='<unknown type>'
  230. end;
  231. function tdef.mangledparaname:string;
  232. begin
  233. if assigned(typesym) then
  234. mangledparaname:=typesym.name
  235. else
  236. mangledparaname:=getmangledparaname;
  237. end;
  238. function tdef.getparentdef:tdef;
  239. begin
  240. result:=nil;
  241. end;
  242. function tdef.getsymtable(t:tgetsymtable):tsymtable;
  243. begin
  244. getsymtable:=nil;
  245. end;
  246. {****************************************************************************
  247. TSYM (base for all symtypes)
  248. ****************************************************************************}
  249. constructor tsym.create(const n : string);
  250. begin
  251. if n[1]='$' then
  252. inherited createname(copy(n,2,255))
  253. else
  254. inherited createname(upper(n));
  255. _realname:=stringdup(n);
  256. typ:=abstractsym;
  257. symoptions:=[];
  258. defref:=nil;
  259. refs:=0;
  260. lastwritten:=nil;
  261. refcount:=0;
  262. fileinfo:=akttokenpos;
  263. if (cs_browser in aktmoduleswitches) and make_ref then
  264. begin
  265. defref:=tref.create(defref,@akttokenpos);
  266. inc(refcount);
  267. end;
  268. lastref:=defref;
  269. {$ifdef GDB}
  270. isstabwritten := false;
  271. {$endif GDB}
  272. symoptions:=current_object_option;
  273. end;
  274. constructor tsym.loadsym(ppufile:tcompilerppufile);
  275. var
  276. s : string;
  277. nr : word;
  278. begin
  279. nr:=ppufile.getword;
  280. s:=ppufile.getstring;
  281. if s[1]='$' then
  282. inherited createname(copy(s,2,255))
  283. else
  284. inherited createname(upper(s));
  285. _realname:=stringdup(s);
  286. typ:=abstractsym;
  287. { force the correct indexnr. must be after create! }
  288. indexnr:=nr;
  289. ppufile.getposinfo(fileinfo);
  290. ppufile.getsmallset(symoptions);
  291. lastref:=nil;
  292. defref:=nil;
  293. refs:=0;
  294. lastwritten:=nil;
  295. refcount:=0;
  296. {$ifdef GDB}
  297. isstabwritten := false;
  298. {$endif GDB}
  299. end;
  300. destructor tsym.destroy;
  301. begin
  302. {$ifdef MEMDEBUG}
  303. memrealnames.start;
  304. {$endif MEMDEBUG}
  305. stringdispose(_realname);
  306. {$ifdef MEMDEBUG}
  307. memrealnames.stop;
  308. {$endif MEMDEBUG}
  309. inherited destroy;
  310. end;
  311. procedure Tsym.writesym(ppufile:tcompilerppufile);
  312. begin
  313. ppufile.putword(indexnr);
  314. ppufile.putstring(_realname^);
  315. ppufile.putposinfo(fileinfo);
  316. ppufile.putsmallset(symoptions);
  317. end;
  318. procedure Tsym.buildderef;
  319. begin
  320. end;
  321. procedure Tsym.deref;
  322. begin
  323. end;
  324. {$ifdef GDB}
  325. function Tsym.get_var_value(const s:string):string;
  326. begin
  327. if s='name' then
  328. get_var_value:=name
  329. else if s='ownername' then
  330. get_var_value:=owner.name^
  331. else if s='line' then
  332. get_var_value:=tostr(fileinfo.line)
  333. else if s='N_LSYM' then
  334. get_var_value:=tostr(N_LSYM)
  335. else if s='N_LCSYM' then
  336. get_var_value:=tostr(N_LCSYM)
  337. else if s='N_RSYM' then
  338. get_var_value:=tostr(N_RSYM)
  339. else if s='N_TSYM' then
  340. get_var_value:=tostr(N_TSYM)
  341. else if s='N_STSYM' then
  342. get_var_value:=tostr(N_STSYM)
  343. else if s='N_FUNCTION' then
  344. get_var_value:=tostr(N_FUNCTION)
  345. else
  346. internalerror(200401152);
  347. end;
  348. function Tsym.stabstr_evaluate(const s:string;vars:array of string):Pchar;
  349. begin
  350. stabstr_evaluate:=string_evaluate(s,@get_var_value,vars);
  351. end;
  352. function Tsym.stabstring : pchar;
  353. begin
  354. (* stabstring:=stabstr_evaluate('"${name}",${N_LSYM},0,${line},0',[]); *)
  355. stabstring:=nil;
  356. end;
  357. {
  358. procedure Tsym.concatstabto(asmlist : taasmoutput);
  359. var
  360. stab_str : pchar;
  361. begin
  362. if not isstabwritten then
  363. begin
  364. stab_str := stabstring;
  365. if assigned(stab_str) then
  366. asmList.concat(Tai_stabs.Create(stab_str));
  367. isstabwritten:=true;
  368. end;
  369. end;}
  370. {$endif GDB}
  371. function tsym.realname : string;
  372. begin
  373. if assigned(_realname) then
  374. realname:=_realname^
  375. else
  376. realname:=name;
  377. end;
  378. function tsym.gettypedef:tdef;
  379. begin
  380. gettypedef:=nil;
  381. end;
  382. procedure Tsym.load_references(ppufile:tcompilerppufile;locals:boolean);
  383. var
  384. pos : tfileposinfo;
  385. move_last : boolean;
  386. begin
  387. move_last:=lastwritten=lastref;
  388. while (not ppufile.endofentry) do
  389. begin
  390. ppufile.getposinfo(pos);
  391. inc(refcount);
  392. lastref:=tref.create(lastref,@pos);
  393. lastref.is_written:=true;
  394. if refcount=1 then
  395. defref:=lastref;
  396. end;
  397. if move_last then
  398. lastwritten:=lastref;
  399. end;
  400. { big problem here :
  401. wrong refs were written because of
  402. interface parsing of other units PM
  403. moduleindex must be checked !! }
  404. function Tsym.write_references(ppufile:tcompilerppufile;locals:boolean):boolean;
  405. var
  406. d : tderef;
  407. ref : tref;
  408. symref_written,move_last : boolean;
  409. begin
  410. write_references:=false;
  411. if lastwritten=lastref then
  412. exit;
  413. { should we update lastref }
  414. move_last:=true;
  415. symref_written:=false;
  416. { write symbol refs }
  417. d.reset;
  418. if assigned(lastwritten) then
  419. ref:=lastwritten
  420. else
  421. ref:=defref;
  422. while assigned(ref) do
  423. begin
  424. if ref.moduleindex=current_module.unit_index then
  425. begin
  426. { write address to this symbol }
  427. if not symref_written then
  428. begin
  429. d.build(self);
  430. ppufile.putderef(d);
  431. symref_written:=true;
  432. end;
  433. ppufile.putposinfo(ref.posinfo);
  434. ref.is_written:=true;
  435. if move_last then
  436. lastwritten:=ref;
  437. end
  438. else if not ref.is_written then
  439. move_last:=false
  440. else if move_last then
  441. lastwritten:=ref;
  442. ref:=ref.nextref;
  443. end;
  444. if symref_written then
  445. ppufile.writeentry(ibsymref);
  446. write_references:=symref_written;
  447. end;
  448. function Tsym.is_visible_for_object(currobjdef:Tdef):boolean;
  449. begin
  450. is_visible_for_object:=false;
  451. { private symbols are allowed when we are in the same
  452. module as they are defined }
  453. if (sp_private in symoptions) and
  454. assigned(owner.defowner) and
  455. (owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  456. (owner.defowner.owner.unitid<>0) then
  457. exit;
  458. { protected symbols are vissible in the module that defines them and
  459. also visible to related objects }
  460. if (sp_protected in symoptions) and
  461. (
  462. (
  463. assigned(owner.defowner) and
  464. (owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  465. (owner.defowner.owner.unitid<>0)
  466. ) and
  467. not(
  468. assigned(currobjdef) and
  469. Tobjectdef(currobjdef).is_related(tobjectdef(owner.defowner))
  470. )
  471. ) then
  472. exit;
  473. is_visible_for_object:=true;
  474. end;
  475. {****************************************************************************
  476. TRef
  477. ****************************************************************************}
  478. constructor tref.create(ref :tref;pos : pfileposinfo);
  479. begin
  480. nextref:=nil;
  481. if pos<>nil then
  482. posinfo:=pos^;
  483. if assigned(current_module) then
  484. moduleindex:=current_module.unit_index;
  485. if assigned(ref) then
  486. ref.nextref:=self;
  487. is_written:=false;
  488. end;
  489. procedure tref.freechain;
  490. var
  491. p,q : tref;
  492. begin
  493. p:=nextref;
  494. nextref:=nil;
  495. while assigned(p) do
  496. begin
  497. q:=p.nextref;
  498. p.free;
  499. p:=q;
  500. end;
  501. end;
  502. destructor tref.destroy;
  503. begin
  504. nextref:=nil;
  505. end;
  506. {****************************************************************************
  507. TType
  508. ****************************************************************************}
  509. procedure ttype.reset;
  510. begin
  511. def:=nil;
  512. sym:=nil;
  513. end;
  514. procedure ttype.setdef(p:tdef);
  515. begin
  516. def:=p;
  517. sym:=nil;
  518. end;
  519. procedure ttype.setsym(p:tsym);
  520. begin
  521. sym:=p;
  522. def:=p.gettypedef;
  523. if not assigned(def) then
  524. internalerror(1234005);
  525. end;
  526. procedure ttype.resolve;
  527. var
  528. p : tsymtableentry;
  529. begin
  530. p:=deref.resolve;
  531. if assigned(p) then
  532. begin
  533. if p is tsym then
  534. begin
  535. setsym(tsym(p));
  536. if not assigned(def) then
  537. internalerror(200212272);
  538. end
  539. else
  540. begin
  541. setdef(tdef(p));
  542. end;
  543. end
  544. else
  545. reset;
  546. end;
  547. procedure ttype.buildderef;
  548. begin
  549. { Write symbol references when the symbol is a redefine,
  550. but don't write symbol references for the current unit
  551. and for the system unit }
  552. if assigned(sym) and
  553. (
  554. (sym<>def.typesym) or
  555. ((sym.owner.unitid<>0) and
  556. (sym.owner.unitid<>1))
  557. ) then
  558. deref.build(sym)
  559. else
  560. deref.build(def);
  561. end;
  562. {****************************************************************************
  563. TSymList
  564. ****************************************************************************}
  565. constructor tsymlist.create;
  566. begin
  567. procdef:=nil; { needed for procedures }
  568. firstsym:=nil;
  569. lastsym:=nil;
  570. end;
  571. destructor tsymlist.destroy;
  572. begin
  573. clear;
  574. end;
  575. function tsymlist.empty:boolean;
  576. begin
  577. empty:=(firstsym=nil);
  578. end;
  579. procedure tsymlist.clear;
  580. var
  581. hp : psymlistitem;
  582. begin
  583. while assigned(firstsym) do
  584. begin
  585. hp:=firstsym;
  586. firstsym:=firstsym^.next;
  587. dispose(hp);
  588. end;
  589. firstsym:=nil;
  590. lastsym:=nil;
  591. procdef:=nil;
  592. end;
  593. procedure tsymlist.addsym(slt:tsltype;p:tsym);
  594. var
  595. hp : psymlistitem;
  596. begin
  597. if not assigned(p) then
  598. internalerror(200110203);
  599. new(hp);
  600. fillchar(hp^,sizeof(tsymlistitem),0);
  601. hp^.sltype:=slt;
  602. hp^.sym:=p;
  603. hp^.symderef.reset;
  604. if assigned(lastsym) then
  605. lastsym^.next:=hp
  606. else
  607. firstsym:=hp;
  608. lastsym:=hp;
  609. end;
  610. procedure tsymlist.addsymderef(slt:tsltype;const d:tderef);
  611. var
  612. hp : psymlistitem;
  613. begin
  614. new(hp);
  615. fillchar(hp^,sizeof(tsymlistitem),0);
  616. hp^.sltype:=slt;
  617. hp^.symderef:=d;
  618. if assigned(lastsym) then
  619. lastsym^.next:=hp
  620. else
  621. firstsym:=hp;
  622. lastsym:=hp;
  623. end;
  624. procedure tsymlist.addconst(slt:tsltype;v:longint);
  625. var
  626. hp : psymlistitem;
  627. begin
  628. new(hp);
  629. fillchar(hp^,sizeof(tsymlistitem),0);
  630. hp^.sltype:=slt;
  631. hp^.value:=v;
  632. if assigned(lastsym) then
  633. lastsym^.next:=hp
  634. else
  635. firstsym:=hp;
  636. lastsym:=hp;
  637. end;
  638. procedure tsymlist.addtype(slt:tsltype;const tt:ttype);
  639. var
  640. hp : psymlistitem;
  641. begin
  642. new(hp);
  643. fillchar(hp^,sizeof(tsymlistitem),0);
  644. hp^.sltype:=slt;
  645. hp^.tt:=tt;
  646. if assigned(lastsym) then
  647. lastsym^.next:=hp
  648. else
  649. firstsym:=hp;
  650. lastsym:=hp;
  651. end;
  652. function tsymlist.getcopy:tsymlist;
  653. var
  654. hp : tsymlist;
  655. hp2 : psymlistitem;
  656. hpn : psymlistitem;
  657. begin
  658. hp:=tsymlist.create;
  659. hp.procdef:=procdef;
  660. hp2:=firstsym;
  661. while assigned(hp2) do
  662. begin
  663. new(hpn);
  664. hpn^:=hp2^;
  665. hpn^.next:=nil;
  666. if assigned(hp.lastsym) then
  667. hp.lastsym^.next:=hpn
  668. else
  669. hp.firstsym:=hpn;
  670. hp.lastsym:=hpn;
  671. hp2:=hp2^.next;
  672. end;
  673. getcopy:=hp;
  674. end;
  675. procedure tsymlist.resolve;
  676. var
  677. hp : psymlistitem;
  678. begin
  679. procdef:=tdef(procdefderef.resolve);
  680. hp:=firstsym;
  681. while assigned(hp) do
  682. begin
  683. case hp^.sltype of
  684. sl_call,
  685. sl_load,
  686. sl_subscript :
  687. hp^.sym:=tsym(hp^.symderef.resolve);
  688. sl_typeconv :
  689. hp^.tt.resolve;
  690. sl_vec :
  691. ;
  692. else
  693. internalerror(200110205);
  694. end;
  695. hp:=hp^.next;
  696. end;
  697. end;
  698. procedure tsymlist.buildderef;
  699. var
  700. hp : psymlistitem;
  701. begin
  702. procdefderef.build(procdef);
  703. hp:=firstsym;
  704. while assigned(hp) do
  705. begin
  706. case hp^.sltype of
  707. sl_call,
  708. sl_load,
  709. sl_subscript :
  710. hp^.symderef.build(hp^.sym);
  711. sl_typeconv :
  712. hp^.tt.buildderef;
  713. sl_vec :
  714. ;
  715. else
  716. internalerror(200110205);
  717. end;
  718. hp:=hp^.next;
  719. end;
  720. end;
  721. {****************************************************************************
  722. Tderef
  723. ****************************************************************************}
  724. procedure tderef.reset;
  725. begin
  726. dataidx:=-1;
  727. end;
  728. procedure tderef.build(s:tsymtableentry);
  729. var
  730. len : byte;
  731. data : array[0..255] of byte;
  732. function is_child(currdef,ownerdef:tdef):boolean;
  733. begin
  734. while assigned(currdef) and
  735. (currdef<>ownerdef) do
  736. currdef:=currdef.getparentdef;
  737. result:=assigned(currdef);
  738. end;
  739. procedure addowner(s:tsymtableentry);
  740. begin
  741. if not assigned(s.owner) then
  742. internalerror(200306063);
  743. case s.owner.symtabletype of
  744. globalsymtable :
  745. begin
  746. if s.owner.unitid=0 then
  747. begin
  748. data[len]:=ord(deref_aktglobal);
  749. inc(len);
  750. end
  751. else
  752. begin
  753. { check if the unit is available in the uses
  754. clause, else it's an error }
  755. if s.owner.unitid=$ffff then
  756. internalerror(200306063);
  757. data[len]:=ord(deref_unit);
  758. data[len+1]:=s.owner.unitid shr 8;
  759. data[len+2]:=s.owner.unitid and $ff;
  760. inc(len,3);
  761. end;
  762. end;
  763. staticsymtable :
  764. begin
  765. { only references to the current static symtable are allowed }
  766. if s.owner<>aktstaticsymtable then
  767. internalerror(200306233);
  768. data[len]:=ord(deref_aktstatic);
  769. inc(len);
  770. end;
  771. localsymtable :
  772. begin
  773. addowner(s.owner.defowner);
  774. data[len]:=ord(deref_def);
  775. data[len+1]:=s.owner.defowner.indexnr shr 8;
  776. data[len+2]:=s.owner.defowner.indexnr and $ff;
  777. data[len+3]:=ord(deref_local);
  778. inc(len,4);
  779. end;
  780. parasymtable :
  781. begin
  782. addowner(s.owner.defowner);
  783. data[len]:=ord(deref_def);
  784. data[len+1]:=s.owner.defowner.indexnr shr 8;
  785. data[len+2]:=s.owner.defowner.indexnr and $ff;
  786. data[len+3]:=ord(deref_para);
  787. inc(len,4);
  788. end;
  789. objectsymtable,
  790. recordsymtable :
  791. begin
  792. addowner(s.owner.defowner);
  793. data[len]:=ord(deref_def);
  794. data[len+1]:=s.owner.defowner.indexnr shr 8;
  795. data[len+2]:=s.owner.defowner.indexnr and $ff;
  796. data[len+3]:=ord(deref_record);
  797. inc(len,4);
  798. end;
  799. else
  800. internalerror(200306065);
  801. end;
  802. if len>252 then
  803. internalerror(200306062);
  804. end;
  805. procedure addparentobject(currdef,ownerdef:tdef);
  806. var
  807. nextdef : tdef;
  808. begin
  809. if not assigned(currdef) then
  810. internalerror(200306185);
  811. { Already handled by derefaktrecordindex }
  812. if currdef=ownerdef then
  813. internalerror(200306188);
  814. { Generate a direct reference to the top parent
  815. class available in the current unit, this is required because
  816. the parent class is maybe not resolved yet and therefor
  817. has the childof value not available yet }
  818. while (currdef<>ownerdef) do
  819. begin
  820. nextdef:=currdef.getparentdef;
  821. { objects are only allowed in globalsymtable,staticsymtable this check is
  822. needed because we need the unitid }
  823. if not(nextdef.owner.symtabletype in [globalsymtable,staticsymtable]) then
  824. internalerror(200306187);
  825. { Next parent is in a different unit, then stop }
  826. if nextdef.owner.unitid<>0 then
  827. break;
  828. currdef:=nextdef;
  829. end;
  830. { Add reference where to start the parent lookup }
  831. if currdef=aktrecordsymtable.defowner then
  832. begin
  833. data[len]:=ord(deref_aktrecord);
  834. inc(len);
  835. end
  836. else
  837. begin
  838. if currdef.owner.symtabletype=globalsymtable then
  839. data[len]:=ord(deref_aktglobal)
  840. else
  841. data[len]:=ord(deref_aktstatic);
  842. data[len+1]:=ord(deref_def);
  843. data[len+2]:=currdef.indexnr shr 8;
  844. data[len+3]:=currdef.indexnr and $ff;
  845. data[len+4]:=ord(deref_record);
  846. inc(len,5);
  847. end;
  848. { When the current found parent in this module is not the owner we
  849. add derefs for the parent classes not available in this unit }
  850. while (currdef<>ownerdef) do
  851. begin
  852. data[len]:=ord(deref_parent_object);
  853. inc(len);
  854. currdef:=currdef.getparentdef;
  855. { It should be valid as it is checked by is_child }
  856. if not assigned(currdef) then
  857. internalerror(200306186);
  858. end;
  859. end;
  860. begin
  861. { skip length byte }
  862. len:=1;
  863. if assigned(s) then
  864. begin
  865. { Static symtable of current unit ? }
  866. if (s.owner.symtabletype=staticsymtable) and
  867. (s.owner.unitid=0) then
  868. begin
  869. data[len]:=ord(deref_aktstatic);
  870. inc(len);
  871. end
  872. { Global symtable of current unit ? }
  873. else if (s.owner.symtabletype=globalsymtable) and
  874. (s.owner.unitid=0) then
  875. begin
  876. data[len]:=ord(deref_aktglobal);
  877. inc(len);
  878. end
  879. { Current record/object symtable ? }
  880. else if (s.owner=aktrecordsymtable) then
  881. begin
  882. data[len]:=ord(deref_aktrecord);
  883. inc(len);
  884. end
  885. { Current local symtable ? }
  886. else if (s.owner=aktlocalsymtable) then
  887. begin
  888. data[len]:=ord(deref_aktlocal);
  889. inc(len);
  890. end
  891. { Current para symtable ? }
  892. else if (s.owner=aktparasymtable) then
  893. begin
  894. data[len]:=ord(deref_aktpara);
  895. inc(len);
  896. end
  897. { Parent class? }
  898. else if assigned(aktrecordsymtable) and
  899. (aktrecordsymtable.symtabletype=objectsymtable) and
  900. (s.owner.symtabletype=objectsymtable) and
  901. is_child(tdef(aktrecordsymtable.defowner),tdef(s.owner.defowner)) then
  902. begin
  903. addparentobject(tdef(aktrecordsymtable.defowner),tdef(s.owner.defowner));
  904. end
  905. else
  906. { Default, start by building from unit symtable }
  907. begin
  908. addowner(s);
  909. end;
  910. { Add index of the symbol/def }
  911. if s is tsym then
  912. data[len]:=ord(deref_sym)
  913. else
  914. data[len]:=ord(deref_def);
  915. data[len+1]:=s.indexnr shr 8;
  916. data[len+2]:=s.indexnr and $ff;
  917. inc(len,3);
  918. end
  919. else
  920. begin
  921. { nil pointer }
  922. data[len]:=0;
  923. inc(len);
  924. end;
  925. { store data length in first byte }
  926. data[0]:=len-1;
  927. { store index and write to derefdata }
  928. dataidx:=current_module.derefdata.size;
  929. current_module.derefdata.write(data,len);
  930. end;
  931. function tderef.resolve:tsymtableentry;
  932. var
  933. pd : tdef;
  934. pm : tmodule;
  935. typ : tdereftype;
  936. st : tsymtable;
  937. idx : word;
  938. i : longint;
  939. len : byte;
  940. data : array[0..255] of byte;
  941. begin
  942. result:=nil;
  943. { not initialized }
  944. if dataidx=-1 then
  945. internalerror(200306067);
  946. { read data }
  947. current_module.derefdata.seek(dataidx);
  948. if current_module.derefdata.read(len,1)<>1 then
  949. internalerror(200310221);
  950. if len>0 then
  951. begin
  952. if current_module.derefdata.read(data,len)<>len then
  953. internalerror(200310222);
  954. end;
  955. { process data }
  956. st:=nil;
  957. i:=0;
  958. while (i<len) do
  959. begin
  960. typ:=tdereftype(data[i]);
  961. inc(i);
  962. case typ of
  963. deref_nil :
  964. begin
  965. result:=nil;
  966. { Only allowed when no other deref is available }
  967. if len<>1 then
  968. internalerror(200306232);
  969. end;
  970. deref_sym :
  971. begin
  972. if not assigned(st) then
  973. internalerror(200309141);
  974. idx:=(data[i] shl 8) or data[i+1];
  975. inc(i,2);
  976. result:=st.getsymnr(idx);
  977. end;
  978. deref_def :
  979. begin
  980. if not assigned(st) then
  981. internalerror(200309142);
  982. idx:=(data[i] shl 8) or data[i+1];
  983. inc(i,2);
  984. result:=st.getdefnr(idx);
  985. end;
  986. deref_aktrecord :
  987. st:=aktrecordsymtable;
  988. deref_aktstatic :
  989. st:=aktstaticsymtable;
  990. deref_aktglobal :
  991. st:=aktglobalsymtable;
  992. deref_aktlocal :
  993. st:=aktlocalsymtable;
  994. deref_aktpara :
  995. st:=aktparasymtable;
  996. deref_unit :
  997. begin
  998. idx:=(data[i] shl 8) or data[i+1];
  999. inc(i,2);
  1000. if idx>current_module.mapsize then
  1001. internalerror(200306231);
  1002. pm:=current_module.map[idx].u;
  1003. if not assigned(pm) then
  1004. internalerror(200212273);
  1005. st:=pm.globalsymtable;
  1006. end;
  1007. deref_local :
  1008. begin
  1009. if not assigned(result) then
  1010. internalerror(200306069);
  1011. st:=tdef(result).getsymtable(gs_local);
  1012. result:=nil;
  1013. if not assigned(st) then
  1014. internalerror(200212275);
  1015. end;
  1016. deref_para :
  1017. begin
  1018. if not assigned(result) then
  1019. internalerror(2003060610);
  1020. st:=tdef(result).getsymtable(gs_para);
  1021. result:=nil;
  1022. if not assigned(st) then
  1023. internalerror(200212276);
  1024. end;
  1025. deref_record :
  1026. begin
  1027. if not assigned(result) then
  1028. internalerror(200306068);
  1029. st:=tdef(result).getsymtable(gs_record);
  1030. result:=nil;
  1031. if not assigned(st) then
  1032. internalerror(200212274);
  1033. end;
  1034. deref_parent_object :
  1035. begin
  1036. { load current object symtable if no
  1037. symtable is available yet }
  1038. if st=nil then
  1039. begin
  1040. st:=aktrecordsymtable;
  1041. if not assigned(st) then
  1042. internalerror(200306068);
  1043. end;
  1044. if st.symtabletype<>objectsymtable then
  1045. internalerror(200306189);
  1046. pd:=tdef(st.defowner).getparentdef;
  1047. if not assigned(pd) then
  1048. internalerror(200306184);
  1049. st:=pd.getsymtable(gs_record);
  1050. if not assigned(st) then
  1051. internalerror(200212274);
  1052. end;
  1053. else
  1054. internalerror(200212277);
  1055. end;
  1056. end;
  1057. end;
  1058. {*****************************************************************************
  1059. TCompilerPPUFile
  1060. *****************************************************************************}
  1061. procedure tcompilerppufile.checkerror;
  1062. begin
  1063. if error then
  1064. Message(unit_f_ppu_read_error);
  1065. end;
  1066. procedure tcompilerppufile.getguid(var g: tguid);
  1067. begin
  1068. getdata(g,sizeof(g));
  1069. end;
  1070. function tcompilerppufile.getexprint:tconstexprint;
  1071. var
  1072. l1,l2 : longint;
  1073. begin
  1074. if sizeof(tconstexprint)=8 then
  1075. begin
  1076. l1:=getlongint;
  1077. l2:=getlongint;
  1078. {$ifopt R+}
  1079. {$define Range_check_on}
  1080. {$endif opt R+}
  1081. {$R- needed here }
  1082. {$ifdef Delphi}
  1083. result:=int64(l1)+(int64(l2) shl 32);
  1084. {$else}
  1085. result:=qword(l1)+(int64(l2) shl 32);
  1086. {$endif}
  1087. {$ifdef Range_check_on}
  1088. {$R+}
  1089. {$undef Range_check_on}
  1090. {$endif Range_check_on}
  1091. end
  1092. else
  1093. result:=tconstexprint(getlongint);
  1094. end;
  1095. function tcompilerppufile.getPtrUInt:TConstPtrUInt;
  1096. var
  1097. l1,l2 : longint;
  1098. begin
  1099. if sizeof(TConstPtrUInt)=8 then
  1100. begin
  1101. l1:=getlongint;
  1102. l2:=getlongint;
  1103. {$ifopt R+}
  1104. {$define Range_check_on}
  1105. {$endif opt R+}
  1106. {$R- needed here }
  1107. {$ifdef Delphi}
  1108. result:=int64(l1)+(int64(l2) shl 32);
  1109. {$else}
  1110. result:=qword(l1)+(int64(l2) shl 32);
  1111. {$endif}
  1112. {$ifdef Range_check_on}
  1113. {$R+}
  1114. {$undef Range_check_on}
  1115. {$endif Range_check_on}
  1116. end
  1117. else
  1118. result:=TConstPtrUInt(getlongint);
  1119. end;
  1120. procedure tcompilerppufile.getposinfo(var p:tfileposinfo);
  1121. var
  1122. info : byte;
  1123. begin
  1124. {
  1125. info byte layout in bits:
  1126. 0-1 - amount of bytes for fileindex
  1127. 2-3 - amount of bytes for line
  1128. 4-5 - amount of bytes for column
  1129. }
  1130. info:=getbyte;
  1131. case (info and $03) of
  1132. 0 : p.fileindex:=getbyte;
  1133. 1 : p.fileindex:=getword;
  1134. 2 : p.fileindex:=(getbyte shl 16) or getword;
  1135. 3 : p.fileindex:=getlongint;
  1136. end;
  1137. case ((info shr 2) and $03) of
  1138. 0 : p.line:=getbyte;
  1139. 1 : p.line:=getword;
  1140. 2 : p.line:=(getbyte shl 16) or getword;
  1141. 3 : p.line:=getlongint;
  1142. end;
  1143. case ((info shr 4) and $03) of
  1144. 0 : p.column:=getbyte;
  1145. 1 : p.column:=getword;
  1146. 2 : p.column:=(getbyte shl 16) or getword;
  1147. 3 : p.column:=getlongint;
  1148. end;
  1149. end;
  1150. procedure tcompilerppufile.getderef(var d:tderef);
  1151. begin
  1152. d.dataidx:=getlongint;
  1153. end;
  1154. function tcompilerppufile.getsymlist:tsymlist;
  1155. var
  1156. symderef : tderef;
  1157. tt : ttype;
  1158. slt : tsltype;
  1159. idx : longint;
  1160. p : tsymlist;
  1161. begin
  1162. p:=tsymlist.create;
  1163. getderef(p.procdefderef);
  1164. repeat
  1165. slt:=tsltype(getbyte);
  1166. case slt of
  1167. sl_none :
  1168. break;
  1169. sl_call,
  1170. sl_load,
  1171. sl_subscript :
  1172. begin
  1173. getderef(symderef);
  1174. p.addsymderef(slt,symderef);
  1175. end;
  1176. sl_typeconv :
  1177. begin
  1178. gettype(tt);
  1179. p.addtype(slt,tt);
  1180. end;
  1181. sl_vec :
  1182. begin
  1183. idx:=getlongint;
  1184. p.addconst(slt,idx);
  1185. end;
  1186. else
  1187. internalerror(200110204);
  1188. end;
  1189. until false;
  1190. getsymlist:=tsymlist(p);
  1191. end;
  1192. procedure tcompilerppufile.gettype(var t:ttype);
  1193. begin
  1194. getderef(t.deref);
  1195. t.def:=nil;
  1196. t.sym:=nil;
  1197. end;
  1198. function tcompilerppufile.getasmsymbol:tasmsymbol;
  1199. begin
  1200. getasmsymbol:=tasmsymbol(pointer(getlongint));
  1201. end;
  1202. procedure tcompilerppufile.putposinfo(const p:tfileposinfo);
  1203. var
  1204. oldcrc : boolean;
  1205. info : byte;
  1206. begin
  1207. { posinfo is not relevant for changes in PPU }
  1208. oldcrc:=do_crc;
  1209. do_crc:=false;
  1210. {
  1211. info byte layout in bits:
  1212. 0-1 - amount of bytes for fileindex
  1213. 2-3 - amount of bytes for line
  1214. 4-5 - amount of bytes for column
  1215. }
  1216. info:=0;
  1217. { calculate info byte }
  1218. if (p.fileindex>$ff) then
  1219. begin
  1220. if (p.fileindex<=$ffff) then
  1221. info:=info or $1
  1222. else
  1223. if (p.fileindex<=$ffffff) then
  1224. info:=info or $2
  1225. else
  1226. info:=info or $3;
  1227. end;
  1228. if (p.line>$ff) then
  1229. begin
  1230. if (p.line<=$ffff) then
  1231. info:=info or $4
  1232. else
  1233. if (p.line<=$ffffff) then
  1234. info:=info or $8
  1235. else
  1236. info:=info or $c;
  1237. end;
  1238. if (p.column>$ff) then
  1239. begin
  1240. if (p.column<=$ffff) then
  1241. info:=info or $10
  1242. else
  1243. if (p.column<=$ffffff) then
  1244. info:=info or $20
  1245. else
  1246. info:=info or $30;
  1247. end;
  1248. { write data }
  1249. putbyte(info);
  1250. case (info and $03) of
  1251. 0 : putbyte(p.fileindex);
  1252. 1 : putword(p.fileindex);
  1253. 2 : begin
  1254. putbyte(p.fileindex shr 16);
  1255. putword(p.fileindex and $ffff);
  1256. end;
  1257. 3 : putlongint(p.fileindex);
  1258. end;
  1259. case ((info shr 2) and $03) of
  1260. 0 : putbyte(p.line);
  1261. 1 : putword(p.line);
  1262. 2 : begin
  1263. putbyte(p.line shr 16);
  1264. putword(p.line and $ffff);
  1265. end;
  1266. 3 : putlongint(p.line);
  1267. end;
  1268. case ((info shr 4) and $03) of
  1269. 0 : putbyte(p.column);
  1270. 1 : putword(p.column);
  1271. 2 : begin
  1272. putbyte(p.column shr 16);
  1273. putword(p.column and $ffff);
  1274. end;
  1275. 3 : putlongint(p.column);
  1276. end;
  1277. do_crc:=oldcrc;
  1278. end;
  1279. procedure tcompilerppufile.putguid(const g: tguid);
  1280. begin
  1281. putdata(g,sizeof(g));
  1282. end;
  1283. procedure tcompilerppufile.putexprint(v:tconstexprint);
  1284. begin
  1285. if sizeof(TConstExprInt)=8 then
  1286. begin
  1287. putlongint(longint(lo(v)));
  1288. putlongint(longint(hi(v)));
  1289. end
  1290. else if sizeof(TConstExprInt)=4 then
  1291. putlongint(longint(v))
  1292. else
  1293. internalerror(2002082601);
  1294. end;
  1295. procedure tcompilerppufile.PutPtrUInt(v:TConstPtrUInt);
  1296. begin
  1297. if sizeof(TConstPtrUInt)=8 then
  1298. begin
  1299. putlongint(longint(lo(v)));
  1300. putlongint(longint(hi(v)));
  1301. end
  1302. else if sizeof(TConstPtrUInt)=4 then
  1303. putlongint(longint(v))
  1304. else
  1305. internalerror(2002082601);
  1306. end;
  1307. procedure tcompilerppufile.putderef(const d:tderef);
  1308. var
  1309. oldcrc : boolean;
  1310. begin
  1311. oldcrc:=do_crc;
  1312. do_crc:=false;
  1313. putlongint(d.dataidx);
  1314. do_crc:=oldcrc;
  1315. end;
  1316. procedure tcompilerppufile.putsymlist(p:tsymlist);
  1317. var
  1318. hp : psymlistitem;
  1319. begin
  1320. putderef(p.procdefderef);
  1321. hp:=p.firstsym;
  1322. while assigned(hp) do
  1323. begin
  1324. putbyte(byte(hp^.sltype));
  1325. case hp^.sltype of
  1326. sl_call,
  1327. sl_load,
  1328. sl_subscript :
  1329. putderef(hp^.symderef);
  1330. sl_typeconv :
  1331. puttype(hp^.tt);
  1332. sl_vec :
  1333. putlongint(hp^.value);
  1334. else
  1335. internalerror(200110205);
  1336. end;
  1337. hp:=hp^.next;
  1338. end;
  1339. putbyte(byte(sl_none));
  1340. end;
  1341. procedure tcompilerppufile.puttype(const t:ttype);
  1342. begin
  1343. putderef(t.deref);
  1344. end;
  1345. procedure tcompilerppufile.putasmsymbol(s:tasmsymbol);
  1346. begin
  1347. if assigned(s) then
  1348. begin
  1349. if s.ppuidx=-1 then
  1350. begin
  1351. inc(objectlibrary.asmsymbolppuidx);
  1352. s.ppuidx:=objectlibrary.asmsymbolppuidx;
  1353. end;
  1354. putlongint(s.ppuidx);
  1355. end
  1356. else
  1357. putlongint(0);
  1358. end;
  1359. {$ifdef MEMDEBUG}
  1360. initialization
  1361. membrowser:=TMemDebug.create('BrowserRefs');
  1362. membrowser.stop;
  1363. memrealnames:=TMemDebug.create('Realnames');
  1364. memrealnames.stop;
  1365. memmanglednames:=TMemDebug.create('Manglednames');
  1366. memmanglednames.stop;
  1367. memprocpara:=TMemDebug.create('ProcPara');
  1368. memprocpara.stop;
  1369. memprocparast:=TMemDebug.create('ProcParaSt');
  1370. memprocparast.stop;
  1371. memproclocalst:=TMemDebug.create('ProcLocalSt');
  1372. memproclocalst.stop;
  1373. memprocnodetree:=TMemDebug.create('ProcNodeTree');
  1374. memprocnodetree.stop;
  1375. finalization
  1376. membrowser.free;
  1377. memrealnames.free;
  1378. memmanglednames.free;
  1379. memprocpara.free;
  1380. memprocparast.free;
  1381. memproclocalst.free;
  1382. memprocnodetree.free;
  1383. {$endif MEMDEBUG}
  1384. end.
  1385. {
  1386. $Log$
  1387. Revision 1.39 2004-02-11 19:59:06 peter
  1388. * fix compilation without GDB
  1389. Revision 1.38 2004/01/31 22:48:31 daniel
  1390. * Fix stabs generation problem reported by Jonas
  1391. Revision 1.37 2004/01/31 21:09:58 daniel
  1392. * Stabs lineinfo problem fixed
  1393. Revision 1.36 2004/01/31 18:40:15 daniel
  1394. * Last steps before removal of aasmtai dependency in symsym can be
  1395. accomplished.
  1396. Revision 1.35 2004/01/26 16:12:28 daniel
  1397. * reginfo now also only allocated during register allocation
  1398. * third round of gdb cleanups: kick out most of concatstabto
  1399. Revision 1.34 2003/11/10 22:02:52 peter
  1400. * cross unit inlining fixed
  1401. Revision 1.33 2003/10/28 15:36:01 peter
  1402. * absolute to object field supported, fixes tb0458
  1403. Revision 1.32 2003/10/23 14:44:07 peter
  1404. * splitted buildderef and buildderefimpl to fix interface crc
  1405. calculation
  1406. Revision 1.31 2003/10/22 20:40:00 peter
  1407. * write derefdata in a separate ppu entry
  1408. Revision 1.30 2003/10/22 15:22:33 peter
  1409. * fixed unitsym-globalsymtable relation so the uses of a unit
  1410. is counted correctly
  1411. Revision 1.29 2003/10/17 14:38:32 peter
  1412. * 64k registers supported
  1413. * fixed some memory leaks
  1414. Revision 1.28 2003/10/07 16:06:30 peter
  1415. * tsymlist.def renamed to tsymlist.procdef
  1416. * tsymlist.procdef is now only used to store the procdef
  1417. Revision 1.27 2003/09/14 12:58:29 peter
  1418. * give IE when st is not assigned in deref
  1419. Revision 1.26 2003/06/25 18:31:23 peter
  1420. * sym,def resolving partly rewritten to support also parent objects
  1421. not directly available through the uses clause
  1422. Revision 1.25 2003/06/07 20:26:32 peter
  1423. * re-resolving added instead of reloading from ppu
  1424. * tderef object added to store deref info for resolving
  1425. Revision 1.24 2002/12/29 18:26:31 peter
  1426. * also use gettypename for procdef always
  1427. Revision 1.23 2002/12/29 14:57:50 peter
  1428. * unit loading changed to first register units and load them
  1429. afterwards. This is needed to support uses xxx in yyy correctly
  1430. * unit dependency check fixed
  1431. Revision 1.22 2002/09/05 19:29:46 peter
  1432. * memdebug enhancements
  1433. Revision 1.21 2002/08/18 20:06:28 peter
  1434. * inlining is now also allowed in interface
  1435. * renamed write/load to ppuwrite/ppuload
  1436. * tnode storing in ppu
  1437. * nld,ncon,nbas are already updated for storing in ppu
  1438. Revision 1.20 2002/08/11 13:24:16 peter
  1439. * saving of asmsymbols in ppu supported
  1440. * asmsymbollist global is removed and moved into a new class
  1441. tasmlibrarydata that will hold the info of a .a file which
  1442. corresponds with a single module. Added librarydata to tmodule
  1443. to keep the library info stored for the module. In the future the
  1444. objectfiles will also be stored to the tasmlibrarydata class
  1445. * all getlabel/newasmsymbol and friends are moved to the new class
  1446. Revision 1.19 2002/07/01 18:46:29 peter
  1447. * internal linker
  1448. * reorganized aasm layer
  1449. Revision 1.18 2002/05/18 13:34:21 peter
  1450. * readded missing revisions
  1451. Revision 1.17 2002/05/16 19:46:45 carl
  1452. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1453. + try to fix temp allocation (still in ifdef)
  1454. + generic constructor calls
  1455. + start of tassembler / tmodulebase class cleanup
  1456. Revision 1.15 2002/05/12 16:53:15 peter
  1457. * moved entry and exitcode to ncgutil and cgobj
  1458. * foreach gets extra argument for passing local data to the
  1459. iterator function
  1460. * -CR checks also class typecasts at runtime by changing them
  1461. into as
  1462. * fixed compiler to cycle with the -CR option
  1463. * fixed stabs with elf writer, finally the global variables can
  1464. be watched
  1465. * removed a lot of routines from cga unit and replaced them by
  1466. calls to cgobj
  1467. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  1468. u32bit then the other is typecasted also to u32bit without giving
  1469. a rangecheck warning/error.
  1470. * fixed pascal calling method with reversing also the high tree in
  1471. the parast, detected by tcalcst3 test
  1472. Revision 1.14 2002/04/19 15:46:04 peter
  1473. * mangledname rewrite, tprocdef.mangledname is now created dynamicly
  1474. in most cases and not written to the ppu
  1475. * add mangeledname_prefix() routine to generate the prefix of
  1476. manglednames depending on the current procedure, object and module
  1477. * removed static procprefix since the mangledname is now build only
  1478. on demand from tprocdef.mangledname
  1479. }
  1480. end.