* check for object in extended new

This commit is contained in:
peter 1999-10-27 16:06:19 +00:00
parent e2134ddcab
commit e0fe0916fd

View File

@ -1595,70 +1595,56 @@ unit pexpr;
if (pd^.deftype<>pointerdef) then if (pd^.deftype<>pointerdef) then
Message1(type_e_pointer_type_expected,pd^.typename) Message1(type_e_pointer_type_expected,pd^.typename)
else if {(ppointerdef(pd)^.definition^.deftype<>objectdef)}
token=_RKLAMMER then
begin
if (ppointerdef(pd)^.definition^.deftype=objectdef) and
(oo_has_vmt in pobjectdef(ppointerdef(pd)^.definition)^.objectoptions) then
Message(parser_w_use_extended_syntax_for_objects);
p1:=gensinglenode(newn,nil);
p1^.resulttype:=pd2;
consume(_RKLAMMER);
(*Message(parser_e_pointer_to_class_expected);
{ if an error occurs, read til the end of
the new statement }
p1:=genzeronode(errorn);
l:=1;
while true do
begin
case token of
_LKLAMMER : inc(l);
_RKLAMMER : dec(l);
end;
consume(token);
if l=0 then
break;
end;*)
end
else else
begin if token=_RKLAMMER then
disposetree(p1); begin
p1:=genzeronode(hnewn); if (ppointerdef(pd)^.definition^.deftype=objectdef) and
p1^.resulttype:=ppointerdef(pd)^.definition; (oo_has_vmt in pobjectdef(ppointerdef(pd)^.definition)^.objectoptions) then
consume(_COMMA); Message(parser_w_use_extended_syntax_for_objects);
afterassignment:=false; p1:=gensinglenode(newn,nil);
{ determines the current object defintion } p1^.resulttype:=pd2;
classh:=pobjectdef(ppointerdef(pd)^.definition); consume(_RKLAMMER);
{ check for an abstract class } end
if (oo_has_abstract in classh^.objectoptions) then else
Message(sym_e_no_instance_of_abstract_object); begin
disposetree(p1);
{ search the constructor also in the symbol tables of p1:=genzeronode(hnewn);
the parents } p1^.resulttype:=ppointerdef(pd)^.definition;
consume(_COMMA);
{ no constructor found } afterassignment:=false;
sym:=nil; { determines the current object defintion }
while assigned(classh) do classh:=pobjectdef(ppointerdef(pd)^.definition);
begin if classh^.deftype<>objectdef then
sym:=pvarsym(classh^.symtable^.search(pattern)); Message(parser_e_pointer_to_class_expected)
srsymtable:=classh^.symtable; else
if assigned(sym) then begin
break; { check for an abstract class }
classh:=classh^.childof; if (oo_has_abstract in classh^.objectoptions) then
end; Message(sym_e_no_instance_of_abstract_object);
{ search the constructor also in the symbol tables of
consume(_ID); the parents }
do_member_read(false,sym,p1,pd,again); sym:=nil;
if (p1^.treetype<>calln) or while assigned(classh) do
(assigned(p1^.procdefinition) and begin
(p1^.procdefinition^.proctypeoption<>potype_constructor)) then sym:=pvarsym(classh^.symtable^.search(pattern));
Message(parser_e_expr_have_to_be_constructor_call); srsymtable:=classh^.symtable;
p1:=gensinglenode(newn,p1); if assigned(sym) then
{ set the resulttype } break;
p1^.resulttype:=pd2; classh:=classh^.childof;
consume(_RKLAMMER); end;
end; consume(_ID);
postfixoperators; do_member_read(false,sym,p1,pd,again);
if (p1^.treetype<>calln) or
(assigned(p1^.procdefinition) and
(p1^.procdefinition^.proctypeoption<>potype_constructor)) then
Message(parser_e_expr_have_to_be_constructor_call);
end;
p1:=gensinglenode(newn,p1);
{ set the resulttype }
p1^.resulttype:=pd2;
consume(_RKLAMMER);
end;
postfixoperators;
end; end;
_SELF : begin _SELF : begin
again:=true; again:=true;
@ -2117,7 +2103,10 @@ _LECKKLAMMER : begin
end. end.
{ {
$Log$ $Log$
Revision 1.151 1999-10-26 12:30:44 peter Revision 1.152 1999-10-27 16:06:19 peter
* check for object in extended new
Revision 1.151 1999/10/26 12:30:44 peter
* const parameter is now checked * const parameter is now checked
* better and generic check if a node can be used for assigning * better and generic check if a node can be used for assigning
* export fixes * export fixes