From 1c777108136802ad05eb01bfc6341de201d67fcf Mon Sep 17 00:00:00 2001 From: pierre Date: Tue, 23 Jan 2007 05:46:29 +0000 Subject: [PATCH] + added code for reference list creation for tsym + tsym.IncRefCount both increments refs and creates a reference entry + tsym.IncRefCountBy only increments refs git-svn-id: trunk@6140 - --- compiler/symtype.pas | 45 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/compiler/symtype.pas b/compiler/symtype.pas index 5401f7a876..ba95e88338 100644 --- a/compiler/symtype.pas +++ b/compiler/symtype.pas @@ -27,9 +27,7 @@ interface uses { common } cutils, -{$ifdef MEMDEBUG} cclasses, -{$endif MEMDEBUG} { global } globtype,globals, { symtable } @@ -99,8 +97,10 @@ interface fileinfo : tfileposinfo; symoptions : tsymoptions; refs : longint; + reflist : TLinkedList; isdbgwritten : boolean; constructor create(st:tsymtyp;const aname:string); + destructor destroy;override; function mangledname:string; virtual; procedure buildderef;virtual; procedure deref;virtual; @@ -110,6 +110,10 @@ interface } function is_visible_for_object(currobjdef:tdef;context : tdef):boolean;virtual; procedure ChangeOwner(st:TSymtable); + procedure IncRefCount; + procedure IncRefCountBy(AValue : longint); + procedure MaybeCreateRefList; + procedure AddRef; end; tsymarr = array[0..maxlongint div sizeof(pointer)-1] of tsym; @@ -199,6 +203,7 @@ interface implementation uses + crefs, verbose, fmodule ; @@ -324,12 +329,48 @@ implementation inherited CreateNotOwned; realname:=aname; typ:=st; + RefList:=nil; symoptions:=[]; fileinfo:=current_tokenpos; isdbgwritten := false; symoptions:=current_object_option; end; + destructor Tsym.destroy; + begin + if assigned(RefList) then + RefList.Free; + inherited Destroy; + end; + + procedure Tsym.IncRefCount; + begin + inc(refs); + if cs_browser in current_settings.moduleswitches then + begin + MaybeCreateRefList; + AddRef; + end; + end; + + procedure Tsym.IncRefCountBy(AValue : longint); + begin + inc(refs,AValue); + end; + + procedure Tsym.MaybeCreateRefList; + begin + if not assigned(reflist) then + reflist:=TRefLinkedList.create; + end; + + procedure Tsym.AddRef; + var + RefItem: TRefItem; + begin + RefItem:=TRefItem.Create(current_tokenpos); + RefList.Concat(RefItem); + end; procedure Tsym.buildderef; begin