This commit is contained in:
Бондарев Иван 2018-08-10 12:21:09 +02:00
parent 7d744570ec
commit 088639816b
7 changed files with 918 additions and 843 deletions

View file

@ -1,9 +1,9 @@
// //
// This CSharp output file generated by Gardens Point LEX // This CSharp output file generated by Gardens Point LEX
// Version: 1.1.3.301 // Version: 1.1.3.301
// Machine: DESKTOP-A6LT9RI // Machine: IVAN-PC
// DateTime: 09.08.2018 15:12:55 // DateTime: 10.08.2018 11:14:50
// UserName: ????????? // UserName: Ivan
// GPLEX input file <ABCPascal.lex> // GPLEX input file <ABCPascal.lex>
// GPLEX frame file <embedded resource> // GPLEX frame file <embedded resource>
// //

View file

@ -2000,6 +2000,8 @@ simple_property_definition
pa = proc_attribute.attr_virtual; pa = proc_attribute.attr_virtual;
else if ($6.name.ToLower() == "override") else if ($6.name.ToLower() == "override")
pa = proc_attribute.attr_override; pa = proc_attribute.attr_override;
else if ($6.name.ToLower() == "abstract")
pa = proc_attribute.attr_abstract;
$$ = NewSimplePropertyDefinition($2 as method_name, $3 as property_interface, $4 as property_accessors, pa, $8 as property_array_default, @$); $$ = NewSimplePropertyDefinition($2 as method_name, $3 as property_interface, $4 as property_accessors, pa, $8 as property_array_default, @$);
} }
; ;
@ -3888,6 +3890,8 @@ property_modificator
{ $$ = $1; } { $$ = $1; }
| tkOverride | tkOverride
{ $$ = $1; } { $$ = $1; }
| tkAbstract
{ $$ = $1; }
; ;
property_specifier_directives property_specifier_directives

File diff suppressed because it is too large Load diff

25
TestSuite/property5.pas Normal file
View file

@ -0,0 +1,25 @@
type
IInt = interface
property p1: byte read write;
end;
TClass = class(IInt)
b: byte;
public property p1: byte read b write b;
end;
TClass2 = class(IInt)
b: byte;
function getb := b;
procedure setb(value: byte) := b := value;
public property p1: byte read getb write setb;
end;
begin
var o: IInt := new TClass;
o.p1 := 2;
assert(o.p1 = 2);
o := new TClass2;
o.p1 := 2;
assert(o.p1 = 2);
end.

25
TestSuite/property6.pas Normal file
View file

@ -0,0 +1,25 @@
type
TBaseClass = abstract class
property p1: byte read write; abstract;
end;
TClass = class(TBaseClass)
b: byte;
property p1: byte read b write b; override;
end;
TClass2 = class(TBaseClass)
b: byte;
function getb := b;
procedure setb(value: byte) := b := value;
property p1: byte read getb write setb; override;
end;
begin
var o: TBaseClass := new TClass;
o.p1 := 2;
assert(o.p1 = 2);
o := new TClass2;
o.p1 := 2;
assert(o.p1 = 2);
end.

View file

@ -3699,6 +3699,19 @@ namespace PascalABCCompiler.TreeConverter
property_node overrided_property = FindPropertyToOverride(cpn); property_node overrided_property = FindPropertyToOverride(cpn);
if (overrided_property == null) if (overrided_property == null)
AddError(cpn.loc, "NO_PROPERTY_TO_OVERRIDE"); AddError(cpn.loc, "NO_PROPERTY_TO_OVERRIDE");
else
{
if (cpn.get_function is common_method_node)
{
(cpn.get_function as common_method_node).overrided_method = overrided_property.get_function;
(cpn.get_function as common_method_node).polymorphic_state = SemanticTree.polymorphic_state.ps_virtual;
}
if (cpn.set_function is common_method_node)
{
(cpn.set_function as common_method_node).overrided_method = overrided_property.set_function;
(cpn.set_function as common_method_node).polymorphic_state = SemanticTree.polymorphic_state.ps_virtual;
}
}
} }
public void set_override(common_method_node cmn) public void set_override(common_method_node cmn)

View file

@ -4060,7 +4060,8 @@ namespace PascalABCCompiler.TreeConverter
pn.polymorphic_state = SemanticTree.polymorphic_state.ps_static; pn.polymorphic_state = SemanticTree.polymorphic_state.ps_static;
if (_simple_property.virt_over_none_attr == proc_attribute.attr_virtual || _simple_property.virt_over_none_attr == proc_attribute.attr_override) if (_simple_property.virt_over_none_attr == proc_attribute.attr_virtual || _simple_property.virt_over_none_attr == proc_attribute.attr_override)
pn.polymorphic_state = SemanticTree.polymorphic_state.ps_virtual; pn.polymorphic_state = SemanticTree.polymorphic_state.ps_virtual;
else if (_simple_property.virt_over_none_attr == proc_attribute.attr_abstract)
pn.polymorphic_state = SemanticTree.polymorphic_state.ps_virtual_abstract;
parameter_list pal_big = new parameter_list(); parameter_list pal_big = new parameter_list();
//TODO: Спросить у Саши как получить тип параметра - var,const и т.д. //TODO: Спросить у Саши как получить тип параметра - var,const и т.д.
if (_simple_property.parameter_list != null) if (_simple_property.parameter_list != null)
@ -4098,7 +4099,7 @@ namespace PascalABCCompiler.TreeConverter
convertion_data_and_alghoritms.check_node_parser_error(_simple_property.accessors.read_accessor); convertion_data_and_alghoritms.check_node_parser_error(_simple_property.accessors.read_accessor);
if (_simple_property.accessors.read_accessor.accessor_name == null) if (_simple_property.accessors.read_accessor.accessor_name == null)
{ {
if (!context.converted_type.IsInterface) if (!context.converted_type.IsInterface && _simple_property.virt_over_none_attr != proc_attribute.attr_abstract)
{ {
AddError(get_location(_simple_property.accessors.read_accessor), "ACCESSOR_NAME_EXPECTED"); AddError(get_location(_simple_property.accessors.read_accessor), "ACCESSOR_NAME_EXPECTED");
} }
@ -4226,7 +4227,7 @@ namespace PascalABCCompiler.TreeConverter
convertion_data_and_alghoritms.check_node_parser_error(_simple_property.accessors.write_accessor); convertion_data_and_alghoritms.check_node_parser_error(_simple_property.accessors.write_accessor);
if (_simple_property.accessors.write_accessor.accessor_name == null) if (_simple_property.accessors.write_accessor.accessor_name == null)
{ {
if (!context.converted_type.IsInterface) if (!context.converted_type.IsInterface && _simple_property.virt_over_none_attr != proc_attribute.attr_abstract)
{ {
AddError(get_location(_simple_property.accessors.write_accessor), "ACCESSOR_NAME_EXPECTED"); AddError(get_location(_simple_property.accessors.write_accessor), "ACCESSOR_NAME_EXPECTED");
} }