* fix hiding of symbols

git-svn-id: trunk@5272 -
This commit is contained in:
peter 2006-11-07 08:53:15 +00:00
parent 99309202bc
commit 0c8796c210
3 changed files with 23 additions and 21 deletions

View File

@ -629,7 +629,6 @@ implementation
aprocsym : tprocsym; aprocsym : tprocsym;
popclass : boolean; popclass : boolean;
ImplIntf : TImplementedInterface; ImplIntf : TImplementedInterface;
hashedid : THashedIDString;
begin begin
{ Save the position where this procedure really starts } { Save the position where this procedure really starts }
procstartfilepos:=current_tokenpos; procstartfilepos:=current_tokenpos;
@ -780,10 +779,7 @@ implementation
if (m_fpc in current_settings.modeswitches) then if (m_fpc in current_settings.modeswitches) then
Message1(parser_e_overloaded_no_procedure,srsym.realname) Message1(parser_e_overloaded_no_procedure,srsym.realname)
else else
begin Message1(sym_e_duplicate_id,srsym.realname);
hashedid.id:='';
duplicatesym(hashedid,nil,srsym);
end;
{ rename the name to an unique name to avoid an { rename the name to an unique name to avoid an
error when inserting the symbol in the symtable } error when inserting the symbol in the symtable }
orgsp:=orgsp+'$'+tostr(current_filepos.line); orgsp:=orgsp+'$'+tostr(current_filepos.line);

View File

@ -104,13 +104,11 @@ interface
procedure freeinstance;override; procedure freeinstance;override;
function getcopy:TSymtable; function getcopy:TSymtable;
procedure clear;virtual; procedure clear;virtual;
// function rename(const olds,news:TIDString):TSymEntry;
function checkduplicate(var s:THashedIDString;sym:TSymEntry):boolean;virtual; function checkduplicate(var s:THashedIDString;sym:TSymEntry):boolean;virtual;
procedure insert(sym:TSymEntry);virtual; procedure insert(sym:TSymEntry;checkdup:boolean=true);
function Find(const s:TIDString) : TSymEntry; function Find(const s:TIDString) : TSymEntry;
function FindWithHash(const s:THashedIDString) : TSymEntry;virtual; function FindWithHash(const s:THashedIDString) : TSymEntry;virtual;
procedure insertdef(def:TDefEntry);virtual; procedure insertdef(def:TDefEntry);virtual;
// procedure deletedef(def:TDefEntry);virtual;
function iscurrentunit:boolean;virtual; function iscurrentunit:boolean;virtual;
end; end;
@ -275,20 +273,26 @@ implementation
end; end;
procedure TSymtable.insert(sym:TSymEntry); procedure TSymtable.insert(sym:TSymEntry;checkdup:boolean=true);
var var
hashedid : THashedIDString; hashedid : THashedIDString;
begin begin
if sym.realname[1]='$' then if checkdup then
hashedid.id:=Copy(sym.realname,2,255) begin
else if sym.realname[1]='$' then
hashedid.id:=Upper(sym.realname); hashedid.id:=Copy(sym.realname,2,255)
{ First check for duplicates, this can change the symbol name else
in case of a duplicate entry } hashedid.id:=Upper(sym.realname);
checkduplicate(hashedid,sym); { First check for duplicates, this can change the symbol name
in case of a duplicate entry }
checkduplicate(hashedid,sym);
end;
{ Now we can insert the symbol, any duplicate entries { Now we can insert the symbol, any duplicate entries
are renamed to an unique (and for users unaccessible) name } are renamed to an unique (and for users unaccessible) name }
sym.ChangeOwnerAndName(SymList,hashedid.id); if sym.realname[1]='$' then
sym.ChangeOwnerAndName(SymList,Copy(sym.realname,2,255))
else
sym.ChangeOwnerAndName(SymList,Upper(sym.realname));
sym.Owner:=self; sym.Owner:=self;
end; end;

View File

@ -371,7 +371,7 @@ implementation
else else
Message1(unit_f_ppu_invalid_entry,tostr(b)); Message1(unit_f_ppu_invalid_entry,tostr(b));
end; end;
Insert(sym); Insert(sym,false);
until false; until false;
end; end;
@ -1049,7 +1049,7 @@ implementation
) then ) then
begin begin
{ but private ids can be reused } { but private ids can be reused }
hsym:=search_class_member(tobjectdef(defowner),sym.name); hsym:=search_class_member(tobjectdef(defowner),hashedid.id);
if assigned(hsym) and if assigned(hsym) and
tsym(hsym).is_visible_for_object(tobjectdef(defowner),tobjectdef(defowner)) then tsym(hsym).is_visible_for_object(tobjectdef(defowner),tobjectdef(defowner)) then
begin begin
@ -1157,9 +1157,11 @@ implementation
(vo_is_funcret in tabstractvarsym(sym).varoptions) and (vo_is_funcret in tabstractvarsym(sym).varoptions) and
not((m_result in current_settings.modeswitches) and not((m_result in current_settings.modeswitches) and
(vo_is_result in tabstractvarsym(sym).varoptions)) then (vo_is_result in tabstractvarsym(sym).varoptions)) then
HideSym(sym) Hidesym(sym)
else else
DuplicateSym(hashedid,sym,hsym); DuplicateSym(hashedid,sym,hsym);
result:=true;
exit;
end; end;
{ check ObjectSymtable, skip this for funcret sym because { check ObjectSymtable, skip this for funcret sym because
@ -1424,7 +1426,7 @@ implementation
procedure hidesym(sym:TSymEntry); procedure hidesym(sym:TSymEntry);
begin begin
sym.realname:='$hidden'+sym.name; sym.realname:='$hidden'+sym.realname;
include(tsym(sym).symoptions,sp_hidden); include(tsym(sym).symoptions,sp_hidden);
end; end;