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

View File

@ -104,13 +104,11 @@ interface
procedure freeinstance;override;
function getcopy:TSymtable;
procedure clear;virtual;
// function rename(const olds,news:TIDString):TSymEntry;
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 FindWithHash(const s:THashedIDString) : TSymEntry;virtual;
procedure insertdef(def:TDefEntry);virtual;
// procedure deletedef(def:TDefEntry);virtual;
function iscurrentunit:boolean;virtual;
end;
@ -275,20 +273,26 @@ implementation
end;
procedure TSymtable.insert(sym:TSymEntry);
procedure TSymtable.insert(sym:TSymEntry;checkdup:boolean=true);
var
hashedid : THashedIDString;
begin
if sym.realname[1]='$' then
hashedid.id:=Copy(sym.realname,2,255)
else
hashedid.id:=Upper(sym.realname);
{ First check for duplicates, this can change the symbol name
in case of a duplicate entry }
checkduplicate(hashedid,sym);
if checkdup then
begin
if sym.realname[1]='$' then
hashedid.id:=Copy(sym.realname,2,255)
else
hashedid.id:=Upper(sym.realname);
{ 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
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;
end;

View File

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