* store symoptions also for procdef

* check symoptions (private,public) when calculating possible
    overload candidates
This commit is contained in:
peter 2003-03-17 15:54:22 +00:00
parent 12cff8cae8
commit ec66760702
6 changed files with 162 additions and 68 deletions

View File

@ -1245,13 +1245,22 @@ type
for j:=1 to symtableprocentry.procdef_count do
begin
pd:=symtableprocentry.procdef[j];
{ only when the # of parameter are supported by the
procedure }
if (paralength>=pd.minparacount) and
((po_varargs in pd.procoptions) or { varargs }
(paralength<=pd.maxparacount)) then
proc_add(pd);
end;
{ Is the procdef visible? This needs to be checked on
procdef level since a symbol can contain both private and
public declarations. But the check should not be done
when the callnode is generated by a property }
if (nf_isproperty in flags) or
(pd.owner.symtabletype<>objectsymtable) or
pd.is_visible_for_proc(aktprocdef) then
begin
{ only when the # of parameter are supported by the
procedure }
if (paralength>=pd.minparacount) and
((po_varargs in pd.procoptions) or { varargs }
(paralength<=pd.maxparacount)) then
proc_add(pd);
end;
end;
{ remember if the procedure is declared with the overload directive,
it's information is still needed also after all procs are removed }
@ -2386,7 +2395,12 @@ begin
end.
{
$Log$
Revision 1.128 2003-02-19 22:00:14 daniel
Revision 1.129 2003-03-17 15:54:22 peter
* store symoptions also for procdef
* check symoptions (private,public) when calculating possible
overload candidates
Revision 1.128 2003/02/19 22:00:14 daniel
* Code generator converted to new register notation
- Horribily outdated todo.txt removed

View File

@ -632,8 +632,9 @@ implementation
{ add procsym to the procdef }
aktprocdef.procsym:=aktprocsym;
{ save file position }
{ save file position and symbol options }
aktprocdef.fileinfo:=procstartfilepos;
aktprocdef.symoptions:=current_object_option;
{ this must also be inserted in the right symtable !! PM }
{ otherwise we get subbtle problems with
@ -2116,7 +2117,12 @@ const
end.
{
$Log$
Revision 1.105 2003-01-15 20:02:28 carl
Revision 1.106 2003-03-17 15:54:22 peter
* store symoptions also for procdef
* check symoptions (private,public) when calculating possible
overload candidates
Revision 1.105 2003/01/15 20:02:28 carl
* fix highname problem
Revision 1.104 2003/01/12 15:42:23 peter

View File

@ -41,7 +41,7 @@ type
{$endif Test_Double_checksum}
const
CurrentPPUVersion=30;
CurrentPPUVersion=31;
{ buffer sizes }
maxentrysize = 1024;
@ -985,7 +985,12 @@ end;
end.
{
$Log$
Revision 1.29 2003-01-08 18:43:56 daniel
Revision 1.30 2003-03-17 15:54:22 peter
* store symoptions also for procdef
* check symoptions (private,public) when calculating possible
overload candidates
Revision 1.29 2003/01/08 18:43:56 daniel
* Tregister changed into a record
Revision 1.28 2002/11/15 01:58:53 peter

View File

@ -481,11 +481,13 @@ interface
overloadnumber : word;
messageinf : tmessageinf;
{$ifndef EXTDEBUG}
{ where is this function defined, needed here because there
{ where is this function defined and what were the symbol
flags, needed here because there
is only one symbol for all overloaded functions
EXTDEBUG has fileinfo in tdef (PFV) }
fileinfo : tfileposinfo;
{$endif}
symoptions : tsymoptions;
{ symbol owning this definition }
procsym : tsym;
{ alias names }
@ -543,6 +545,7 @@ interface
function cplusplusmangledname : string;
function is_methodpointer:boolean;override;
function is_addressonly:boolean;override;
function is_visible_for_proc(currprocdef:tprocdef):boolean;
{ debug }
{$ifdef GDB}
function stabstring : pchar;override;
@ -3414,6 +3417,7 @@ implementation
_class := tobjectdef(ppufile.getderef);
procsym := tsym(ppufile.getderef);
ppufile.getposinfo(fileinfo);
ppufile.getsmallset(symoptions);
{ inline stuff }
if proccalloption=pocall_inline then
begin
@ -3540,6 +3544,7 @@ implementation
ppufile.putderef(_class);
ppufile.putderef(procsym);
ppufile.putposinfo(fileinfo);
ppufile.putsmallset(symoptions);
{ inline stuff references to localsymtable, no influence
on the crc }
@ -3635,6 +3640,38 @@ implementation
end;
function tprocdef.is_visible_for_proc(currprocdef:tprocdef):boolean;
begin
is_visible_for_proc:=false;
{ private symbols are allowed when we are in the same
module as they are defined }
if (sp_private in symoptions) and
assigned(owner.defowner) and
(owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
(owner.defowner.owner.unitid<>0) then
exit;
{ protected symbols are vissible in the module that defines them and
also visible to related objects }
if (sp_protected in symoptions) and
(
(
(owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
(owner.defowner.owner.unitid<>0)
) and
not(
assigned(currprocdef) and
assigned(currprocdef._class) and
currprocdef._class.is_related(tobjectdef(owner.defowner))
)
) then
exit;
is_visible_for_proc:=true;
end;
function tprocdef.getsymtable(t:tgetsymtable):tsymtable;
begin
case t of
@ -5656,7 +5693,12 @@ implementation
end.
{
$Log$
Revision 1.129 2003-02-19 22:00:14 daniel
Revision 1.130 2003-03-17 15:54:22 peter
* store symoptions also for procdef
* check symoptions (private,public) when calculating possible
overload candidates
Revision 1.129 2003/02/19 22:00:14 daniel
* Code generator converted to new register notation
- Horribily outdated todo.txt removed

View File

@ -438,8 +438,8 @@ implementation
inherited create(s);
{ force the correct indexnr. must be after create! }
indexnr:=nr;
ppufile.getsmallset(symoptions);
ppufile.getposinfo(fileinfo);
ppufile.getsmallset(symoptions);
lastref:=nil;
defref:=nil;
refs:=0;
@ -555,8 +555,8 @@ implementation
begin
ppufile.putword(indexnr);
ppufile.putstring(_realname^);
ppufile.putsmallset(symoptions);
ppufile.putposinfo(fileinfo);
ppufile.putsmallset(symoptions);
end;
@ -2563,7 +2563,12 @@ implementation
end.
{
$Log$
Revision 1.93 2003-01-15 01:44:33 peter
Revision 1.94 2003-03-17 15:54:22 peter
* store symoptions also for procdef
* check symoptions (private,public) when calculating possible
overload candidates
Revision 1.93 2003/01/15 01:44:33 peter
* merged methodpointer fixes from 1.0.x
Revision 1.92 2003/01/09 21:52:38 peter

View File

@ -548,6 +548,56 @@ begin
end;
procedure readsymoptions;
type
tsymoption=(sp_none,
sp_public,
sp_private,
sp_published,
sp_protected,
sp_forwarddef,
sp_static,
sp_primary_typesym { this is for typesym, to know who is the primary symbol of a def }
);
tsymoptions=set of tsymoption;
tsymopt=record
mask : tsymoption;
str : string[30];
end;
const
symopts=7;
symopt : array[1..symopts] of tsymopt=(
(mask:sp_public; str:'Public'),
(mask:sp_private; str:'Private'),
(mask:sp_published; str:'Published'),
(mask:sp_protected; str:'Protected'),
(mask:sp_forwarddef; str:'ForwardDef'),
(mask:sp_static; str:'Static'),
(mask:sp_primary_typesym;str:'PrimaryTypeSym')
);
var
symoptions : tsymoptions;
i : longint;
first : boolean;
begin
ppufile.getsmallset(symoptions);
if symoptions<>[] then
begin
first:=true;
for i:=1to symopts do
if (symopt[i].mask in symoptions) then
begin
if first then
first:=false
else
write(', ');
write(symopt[i].str);
end;
end;
writeln;
end;
{ Read abstract procdef and return if inline procdef }
type
tproccalloption=(pocall_none,
@ -669,7 +719,7 @@ var
procoptions : tprocoptions;
i,params : longint;
first : boolean;
paraloc : array[0..10] of byte;
paraloc : array[0..15] of byte;
begin
write(space,' Return type : ');
readtype;
@ -720,6 +770,8 @@ begin
readsymref;
write(space,' Symbol : ');
readsymref;
write(space,' Location : ');
writeln('<not yet implemented>');
ppufile.getdata(paraloc,sizeof(paraloc));
dec(params);
until params=0;
@ -728,57 +780,13 @@ end;
procedure readcommonsym(const s:string);
type
tsymoption=(sp_none,
sp_public,
sp_private,
sp_published,
sp_protected,
sp_forwarddef,
sp_static,
sp_primary_typesym { this is for typesym, to know who is the primary symbol of a def }
);
tsymoptions=set of tsymoption;
tsymopt=record
mask : tsymoption;
str : string[30];
end;
const
symopts=7;
symopt : array[1..symopts] of tsymopt=(
(mask:sp_public; str:'Public'),
(mask:sp_private; str:'Private'),
(mask:sp_published; str:'Published'),
(mask:sp_protected; str:'Protected'),
(mask:sp_forwarddef; str:'ForwardDef'),
(mask:sp_static; str:'Static'),
(mask:sp_primary_typesym;str:'PrimaryTypeSym')
);
var
symoptions : tsymoptions;
i : longint;
first : boolean;
begin
writeln(space,'** Symbol Nr. ',ppufile.getword,' **');
writeln(space,s,ppufile.getstring);
ppufile.getsmallset(symoptions);
if symoptions<>[] then
begin
write(space,' File Pos: ');
readposinfo;
write(space,' SymOptions: ');
first:=true;
for i:=1to symopts do
if (symopt[i].mask in symoptions) then
begin
if first then
first:=false
else
write(', ');
write(symopt[i].str);
end;
writeln;
end;
write(space,' File Pos: ');
readposinfo;
write(space,' SymOptions: ');
readsymoptions;
end;
@ -1282,7 +1290,13 @@ begin
begin
readcommondef('Procedure definition');
calloption:=read_abstract_proc_def;
write (space,' Used Registers : ');
write (space,' Used IntRegs : ');
getnormalset(regs);
writeln('<not yet implemented>');
write (space,' Used OtherRegs : ');
getnormalset(regs);
writeln('<not yet implemented>');
{$ifdef OLDRA}
case ttargetcpu(header.cpu) of
i386 :
getusedregisters_i386
@ -1292,6 +1306,7 @@ begin
writeln('<not yet implemented>');
end;
end;
{$endif OLDRA}
if (getbyte<>0) then
writeln(space,' Mangled name : ',getstring);
writeln(space,' Overload Number : ',getword);
@ -1302,6 +1317,8 @@ begin
readsymref;
write (space,' File Pos : ');
readposinfo;
write (space,' SymOptions : ');
readsymoptions;
if (calloption=pocall_inline) then
begin
write (space,' FuncretSym : ');
@ -1910,7 +1927,12 @@ begin
end.
{
$Log$
Revision 1.35 2003-01-03 22:16:29 peter
Revision 1.36 2003-03-17 15:54:22 peter
* store symoptions also for procdef
* check symoptions (private,public) when calculating possible
overload candidates
Revision 1.35 2003/01/03 22:16:29 peter
* updated for absolutesym and varsym
Revision 1.34 2002/11/17 16:32:04 carl