mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-16 04:30:35 +01:00
* better support for indexed properties
This commit is contained in:
parent
cb06c9bcb8
commit
075b5188ee
@ -315,6 +315,11 @@ implementation
|
||||
until not try_to_consume(_SEMICOLON);
|
||||
dec(testcurobject);
|
||||
consume(_RECKKLAMMER);
|
||||
|
||||
{ the parser need to know if a property has parameters, the
|
||||
index parameter doesn't count (PFV) }
|
||||
if not(propertyparas.empty) then
|
||||
include(p.propoptions,ppo_hasparameters);
|
||||
end;
|
||||
{ overriden property ? }
|
||||
{ force property interface, if there is a property parameter }
|
||||
@ -344,9 +349,6 @@ implementation
|
||||
propertyparas.insert(hp2);
|
||||
pt.free;
|
||||
end;
|
||||
{ the parser need to know if a property has parameters }
|
||||
if not(propertyparas.empty) then
|
||||
include(p.propoptions,ppo_hasparameters);
|
||||
end
|
||||
else
|
||||
begin
|
||||
@ -388,9 +390,16 @@ implementation
|
||||
end;
|
||||
varsym :
|
||||
begin
|
||||
if not(propertyparas.empty) or
|
||||
not(is_equal(p.readaccess.def,p.proptype.def)) then
|
||||
Message(parser_e_ill_property_access_sym);
|
||||
if CheckTypes(p.readaccess.def,p.proptype.def) then
|
||||
begin
|
||||
{ property parameters are allowed if this is
|
||||
an indexed property, because the index is then
|
||||
the parameter.
|
||||
Note: In the help of Kylix it is written
|
||||
that it isn't allowed, but the compiler accepts it (PFV) }
|
||||
if (ppo_hasparameters in p.propoptions) then
|
||||
Message(parser_e_ill_property_access_sym);
|
||||
end;
|
||||
end;
|
||||
else
|
||||
Message(parser_e_ill_property_access_sym);
|
||||
@ -417,9 +426,16 @@ implementation
|
||||
end;
|
||||
varsym :
|
||||
begin
|
||||
if not(propertyparas.empty) or
|
||||
not(is_equal(p.writeaccess.def,p.proptype.def)) then
|
||||
Message(parser_e_ill_property_access_sym);
|
||||
if CheckTypes(p.writeaccess.def,p.proptype.def) then
|
||||
begin
|
||||
{ property parameters are allowed if this is
|
||||
an indexed property, because the index is then
|
||||
the parameter.
|
||||
Note: In the help of Kylix it is written
|
||||
that it isn't allowed, but the compiler accepts it (PFV) }
|
||||
if (ppo_hasparameters in p.propoptions) then
|
||||
Message(parser_e_ill_property_access_sym);
|
||||
end;
|
||||
end;
|
||||
else
|
||||
Message(parser_e_ill_property_access_sym);
|
||||
@ -461,7 +477,7 @@ implementation
|
||||
end;
|
||||
varsym :
|
||||
begin
|
||||
if not(propertyparas.empty) or
|
||||
if (ppo_hasparameters in p.propoptions) or
|
||||
not(is_boolean(p.storedaccess.def)) then
|
||||
Message(parser_e_stored_property_must_be_boolean);
|
||||
end;
|
||||
@ -1078,7 +1094,10 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.30 2001-10-21 12:33:06 peter
|
||||
Revision 1.31 2001-10-21 13:10:50 peter
|
||||
* better support for indexed properties
|
||||
|
||||
Revision 1.30 2001/10/21 12:33:06 peter
|
||||
* array access for properties added
|
||||
|
||||
Revision 1.29 2001/08/30 20:13:53 peter
|
||||
|
||||
@ -721,7 +721,7 @@ implementation
|
||||
paras:=nil;
|
||||
{ property parameters? read them only if the property really }
|
||||
{ has parameters }
|
||||
if ppo_hasparameters in tpropertysym(sym).propoptions then
|
||||
if (ppo_hasparameters in tpropertysym(sym).propoptions) then
|
||||
begin
|
||||
if token=_LECKKLAMMER then
|
||||
begin
|
||||
@ -729,12 +729,12 @@ implementation
|
||||
paras:=parse_paras(false,true);
|
||||
consume(_RECKKLAMMER);
|
||||
end;
|
||||
{ indexed property }
|
||||
if (ppo_indexed in tpropertysym(sym).propoptions) then
|
||||
begin
|
||||
p2:=cordconstnode.create(tpropertysym(sym).index,tpropertysym(sym).indextype);
|
||||
paras:=ccallparanode.create(p2,paras);
|
||||
end;
|
||||
end;
|
||||
{ indexed property }
|
||||
if (ppo_indexed in tpropertysym(sym).propoptions) then
|
||||
begin
|
||||
p2:=cordconstnode.create(tpropertysym(sym).index,tpropertysym(sym).indextype);
|
||||
paras:=ccallparanode.create(p2,paras);
|
||||
end;
|
||||
{ we need only a write property if a := follows }
|
||||
{ if not(afterassignment) and not(in_args) then }
|
||||
@ -749,6 +749,7 @@ implementation
|
||||
{ generate the method call }
|
||||
p1:=ccallnode.create(paras,
|
||||
tprocsym(tpropertysym(sym).writeaccess.firstsym^.sym),st,p1);
|
||||
paras:=nil;
|
||||
consume(_ASSIGNMENT);
|
||||
{ read the expression }
|
||||
getprocvar:=(tpropertysym(sym).proptype.def.deftype=procvardef);
|
||||
@ -761,9 +762,7 @@ implementation
|
||||
end;
|
||||
varsym :
|
||||
begin
|
||||
if assigned(paras) then
|
||||
message(parser_e_no_paras_allowed);
|
||||
{ subscribed access? }
|
||||
{ generate access code }
|
||||
symlist_to_node(p1,tpropertysym(sym).writeaccess);
|
||||
consume(_ASSIGNMENT);
|
||||
{ read the expression }
|
||||
@ -791,15 +790,14 @@ implementation
|
||||
case tpropertysym(sym).readaccess.firstsym^.sym.typ of
|
||||
varsym :
|
||||
begin
|
||||
if assigned(paras) then
|
||||
message(parser_e_no_paras_allowed);
|
||||
{ subscribed access? }
|
||||
{ generate access code }
|
||||
symlist_to_node(p1,tpropertysym(sym).readaccess);
|
||||
end;
|
||||
procsym :
|
||||
begin
|
||||
{ generate the method call }
|
||||
p1:=ccallnode.create(paras,tprocsym(tpropertysym(sym).readaccess.firstsym^.sym),st,p1);
|
||||
paras:=nil;
|
||||
include(p1.flags,nf_isproperty);
|
||||
end
|
||||
else
|
||||
@ -816,6 +814,9 @@ implementation
|
||||
Message(parser_e_no_procedure_to_access_property);
|
||||
end;
|
||||
end;
|
||||
{ release paras if not used }
|
||||
if assigned(paras) then
|
||||
paras.free;
|
||||
end;
|
||||
|
||||
|
||||
@ -2332,7 +2333,10 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.45 2001-10-21 12:33:07 peter
|
||||
Revision 1.46 2001-10-21 13:10:51 peter
|
||||
* better support for indexed properties
|
||||
|
||||
Revision 1.45 2001/10/21 12:33:07 peter
|
||||
* array access for properties added
|
||||
|
||||
Revision 1.44 2001/10/20 19:28:39 peter
|
||||
|
||||
Loading…
Reference in New Issue
Block a user