* support nil as default value

* when no default property is allowed don't check default value
This commit is contained in:
peter 2003-10-02 21:15:12 +00:00
parent 00801693bb
commit 939b642144

View File

@ -504,12 +504,21 @@ implementation
begin begin
if not(is_ordinal(p.proptype.def) or if not(is_ordinal(p.proptype.def) or
is_64bitint(p.proptype.def) or is_64bitint(p.proptype.def) or
is_class(p.proptype.def) or
(p.proptype.def.deftype in [classrefdef,pointerdef]) or
((p.proptype.def.deftype=setdef) and ((p.proptype.def.deftype=setdef) and
(tsetdef(p.proptype.def).settype=smallset))) or (tsetdef(p.proptype.def).settype=smallset))) or
((p.proptype.def.deftype=arraydef) and ((p.proptype.def.deftype=arraydef) and
(ppo_indexed in p.propoptions)) or (ppo_indexed in p.propoptions)) or
(ppo_hasparameters in p.propoptions) then (ppo_hasparameters in p.propoptions) then
begin
Message(parser_e_property_cant_have_a_default_value); Message(parser_e_property_cant_have_a_default_value);
{ Error recovery }
pt:=comp_expr(true);
pt.free;
end
else
begin
{ Get the result of the default, the firstpass is { Get the result of the default, the firstpass is
needed to support values like -1 } needed to support values like -1 }
pt:=comp_expr(true); pt:=comp_expr(true);
@ -522,12 +531,17 @@ implementation
inserttypeconv(pt,p.proptype); inserttypeconv(pt,p.proptype);
if not(is_constnode(pt)) then if not(is_constnode(pt)) then
Message(parser_e_property_default_value_must_const); Message(parser_e_property_default_value_must_const);
{ Set default value }
if pt.nodetype=setconstn then case pt.nodetype of
p.default:=plongint(tsetconstnode(pt).value_set)^ setconstn :
else p.default:=plongint(tsetconstnode(pt).value_set)^;
ordconstn :
p.default:=tordconstnode(pt).value; p.default:=tordconstnode(pt).value;
niln :
p.default:=0;
end;
pt.free; pt.free;
end;
end end
else if try_to_consume(_NODEFAULT) then else if try_to_consume(_NODEFAULT) then
begin begin
@ -1024,6 +1038,7 @@ implementation
if assigned(pd) then if assigned(pd) then
begin begin
parse_object_proc_directives(pd); parse_object_proc_directives(pd);
handle_calling_convention(pd);
calc_parast(pd); calc_parast(pd);
{ add definition to procsym } { add definition to procsym }
@ -1058,6 +1073,7 @@ implementation
parse_only:=true; parse_only:=true;
pd:=constructor_head; pd:=constructor_head;
parse_object_proc_directives(pd); parse_object_proc_directives(pd);
handle_calling_convention(pd);
calc_parast(pd); calc_parast(pd);
{ add definition to procsym } { add definition to procsym }
@ -1089,6 +1105,7 @@ implementation
parse_only:=true; parse_only:=true;
pd:=destructor_head; pd:=destructor_head;
parse_object_proc_directives(pd); parse_object_proc_directives(pd);
handle_calling_convention(pd);
calc_parast(pd); calc_parast(pd);
{ add definition to procsym } { add definition to procsym }
@ -1138,7 +1155,11 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.67 2003-06-13 21:19:30 peter Revision 1.68 2003-10-02 21:15:12 peter
* support nil as default value
* when no default property is allowed don't check default value
Revision 1.67 2003/06/13 21:19:30 peter
* current_procdef removed, use current_procinfo.procdef instead * current_procdef removed, use current_procinfo.procdef instead
Revision 1.66 2003/05/23 14:27:35 peter Revision 1.66 2003/05/23 14:27:35 peter