This commit is contained in:
parent
7d744570ec
commit
088639816b
|
|
@ -1,9 +1,9 @@
|
|||
//
|
||||
// This CSharp output file generated by Gardens Point LEX
|
||||
// Version: 1.1.3.301
|
||||
// Machine: DESKTOP-A6LT9RI
|
||||
// DateTime: 09.08.2018 15:12:55
|
||||
// UserName: ?????????
|
||||
// Machine: IVAN-PC
|
||||
// DateTime: 10.08.2018 11:14:50
|
||||
// UserName: Ivan
|
||||
// GPLEX input file <ABCPascal.lex>
|
||||
// GPLEX frame file <embedded resource>
|
||||
//
|
||||
|
|
|
|||
|
|
@ -2000,6 +2000,8 @@ simple_property_definition
|
|||
pa = proc_attribute.attr_virtual;
|
||||
else if ($6.name.ToLower() == "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, @$);
|
||||
}
|
||||
;
|
||||
|
|
@ -3888,6 +3890,8 @@ property_modificator
|
|||
{ $$ = $1; }
|
||||
| tkOverride
|
||||
{ $$ = $1; }
|
||||
| tkAbstract
|
||||
{ $$ = $1; }
|
||||
;
|
||||
|
||||
property_specifier_directives
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
25
TestSuite/property5.pas
Normal file
25
TestSuite/property5.pas
Normal 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
25
TestSuite/property6.pas
Normal 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.
|
||||
|
|
@ -3699,6 +3699,19 @@ namespace PascalABCCompiler.TreeConverter
|
|||
property_node overrided_property = FindPropertyToOverride(cpn);
|
||||
if (overrided_property == null)
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -4060,7 +4060,8 @@ namespace PascalABCCompiler.TreeConverter
|
|||
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)
|
||||
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();
|
||||
//TODO: Спросить у Саши как получить тип параметра - var,const и т.д.
|
||||
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);
|
||||
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");
|
||||
}
|
||||
|
|
@ -4226,7 +4227,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
convertion_data_and_alghoritms.check_node_parser_error(_simple_property.accessors.write_accessor);
|
||||
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");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue