fix #1605
This commit is contained in:
parent
5705e03dc7
commit
17fe2c3df0
|
|
@ -1,9 +1,9 @@
|
|||
//
|
||||
// This CSharp output file generated by Gardens Point LEX
|
||||
// Version: 1.1.3.301
|
||||
// Machine: DESKTOP-G8V08V4
|
||||
// DateTime: 26.12.2018 21:06:31
|
||||
// UserName: ?????????
|
||||
// Machine: DESKTOP-IF20NRO
|
||||
// DateTime: 1/20/2019 4:28:12 PM
|
||||
// UserName: FatCow
|
||||
// GPLEX input file <ABCPascal.lex>
|
||||
// GPLEX frame file <embedded resource>
|
||||
//
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@
|
|||
%type <stn> array_defaultproperty
|
||||
%type <stn> meth_modificators optional_method_modificators optional_method_modificators1
|
||||
%type <id> meth_modificator property_modificator
|
||||
%type <ex> optional_property_initialization
|
||||
%type <stn> proc_call
|
||||
%type <stn> proc_func_constr_destr_decl proc_func_decl inclass_proc_func_decl inclass_proc_func_decl_noclass constr_destr_decl inclass_constr_destr_decl
|
||||
%type <stn> method_decl proc_func_constr_destr_decl_with_attr proc_func_decl_noclass
|
||||
|
|
@ -1960,19 +1961,26 @@ simple_property_definition
|
|||
{
|
||||
parsertools.AddErrorFromResource("STATIC_PROPERTIES_CANNOT_HAVE_ATTRBUTE_{0}",@7,$7.name);
|
||||
}
|
||||
| tkAuto tkProperty qualified_identifier property_interface tkSemiColon
|
||||
| tkAuto tkProperty qualified_identifier property_interface optional_property_initialization tkSemiColon
|
||||
{
|
||||
$$ = NewSimplePropertyDefinition($3 as method_name, $4 as property_interface, null, proc_attribute.attr_none, null, @$);
|
||||
($$ as simple_property).is_auto = true;
|
||||
($$ as simple_property).initial_value = $5;
|
||||
}
|
||||
| class_or_static tkAuto tkProperty qualified_identifier property_interface tkSemiColon
|
||||
| class_or_static tkAuto tkProperty qualified_identifier property_interface optional_property_initialization tkSemiColon
|
||||
{
|
||||
$$ = NewSimplePropertyDefinition($4 as method_name, $5 as property_interface, null, proc_attribute.attr_none, null, @$);
|
||||
($$ as simple_property).is_auto = true;
|
||||
($$ as simple_property).attr = definition_attribute.Static;
|
||||
($$ as simple_property).initial_value = $6;
|
||||
}
|
||||
;
|
||||
|
||||
optional_property_initialization
|
||||
: tkAssign expr { $$ = $2; }
|
||||
| { $$ = null; }
|
||||
;
|
||||
|
||||
array_defaultproperty
|
||||
:
|
||||
{ $$ = null; }
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -2547,6 +2547,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
visit(simple_property.accessors);
|
||||
visit(simple_property.array_default);
|
||||
visit(simple_property.parameter_list);
|
||||
visit(simple_property.initial_value);
|
||||
post_do_visit(_simple_property);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1691,6 +1691,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
_simple_property.attr = (definition_attribute)br.ReadByte();
|
||||
_simple_property.virt_over_none_attr = (proc_attribute)br.ReadByte();
|
||||
_simple_property.is_auto = br.ReadBoolean();
|
||||
_simple_property.initial_value = _read_node() as expression;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2222,6 +2222,15 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
bw.Write((byte)_simple_property.attr);
|
||||
bw.Write((byte)_simple_property.virt_over_none_attr);
|
||||
bw.Write(_simple_property.is_auto);
|
||||
if (_simple_property.initial_value == null)
|
||||
{
|
||||
bw.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
bw.Write((byte)1);
|
||||
_simple_property.initial_value.visit(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16294,7 +16294,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
///<summary>
|
||||
///Конструктор с параметрами.
|
||||
///</summary>
|
||||
public simple_property(ident _property_name,type_definition _property_type,expression _index_expression,property_accessors _accessors,property_array_default _array_default,property_parameter_list _parameter_list,definition_attribute _attr,proc_attribute _virt_over_none_attr,bool _is_auto)
|
||||
public simple_property(ident _property_name,type_definition _property_type,expression _index_expression,property_accessors _accessors,property_array_default _array_default,property_parameter_list _parameter_list,definition_attribute _attr,proc_attribute _virt_over_none_attr,bool _is_auto,expression _initial_value)
|
||||
{
|
||||
this._property_name=_property_name;
|
||||
this._property_type=_property_type;
|
||||
|
|
@ -16305,13 +16305,14 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
this._attr=_attr;
|
||||
this._virt_over_none_attr=_virt_over_none_attr;
|
||||
this._is_auto=_is_auto;
|
||||
this._initial_value=_initial_value;
|
||||
FillParentsInDirectChilds();
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Конструктор с параметрами.
|
||||
///</summary>
|
||||
public simple_property(ident _property_name,type_definition _property_type,expression _index_expression,property_accessors _accessors,property_array_default _array_default,property_parameter_list _parameter_list,definition_attribute _attr,proc_attribute _virt_over_none_attr,bool _is_auto,SourceContext sc)
|
||||
public simple_property(ident _property_name,type_definition _property_type,expression _index_expression,property_accessors _accessors,property_array_default _array_default,property_parameter_list _parameter_list,definition_attribute _attr,proc_attribute _virt_over_none_attr,bool _is_auto,expression _initial_value,SourceContext sc)
|
||||
{
|
||||
this._property_name=_property_name;
|
||||
this._property_type=_property_type;
|
||||
|
|
@ -16322,6 +16323,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
this._attr=_attr;
|
||||
this._virt_over_none_attr=_virt_over_none_attr;
|
||||
this._is_auto=_is_auto;
|
||||
this._initial_value=_initial_value;
|
||||
source_context = sc;
|
||||
FillParentsInDirectChilds();
|
||||
}
|
||||
|
|
@ -16334,6 +16336,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
protected definition_attribute _attr;
|
||||
protected proc_attribute _virt_over_none_attr;
|
||||
protected bool _is_auto;
|
||||
protected expression _initial_value;
|
||||
|
||||
///<summary>
|
||||
///
|
||||
|
|
@ -16482,6 +16485,23 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
public expression initial_value
|
||||
{
|
||||
get
|
||||
{
|
||||
return _initial_value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_initial_value=value;
|
||||
if (_initial_value != null)
|
||||
_initial_value.Parent = this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Создает копию узла </summary>
|
||||
public override syntax_tree_node Clone()
|
||||
|
|
@ -16528,6 +16548,11 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
copy.attr = attr;
|
||||
copy.virt_over_none_attr = virt_over_none_attr;
|
||||
copy.is_auto = is_auto;
|
||||
if (initial_value != null)
|
||||
{
|
||||
copy.initial_value = (expression)initial_value.Clone();
|
||||
copy.initial_value.Parent = copy;
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
|
@ -16554,6 +16579,8 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
array_default.Parent = this;
|
||||
if (parameter_list != null)
|
||||
parameter_list.Parent = this;
|
||||
if (initial_value != null)
|
||||
initial_value.Parent = this;
|
||||
}
|
||||
|
||||
///<summary> Заполняет поля Parent во всем поддереве </summary>
|
||||
|
|
@ -16567,6 +16594,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
accessors?.FillParentsInAllChilds();
|
||||
array_default?.FillParentsInAllChilds();
|
||||
parameter_list?.FillParentsInAllChilds();
|
||||
initial_value?.FillParentsInAllChilds();
|
||||
}
|
||||
|
||||
///<summary>
|
||||
|
|
@ -16576,7 +16604,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
{
|
||||
get
|
||||
{
|
||||
return 6;
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
///<summary>
|
||||
|
|
@ -16586,7 +16614,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
{
|
||||
get
|
||||
{
|
||||
return 6;
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
///<summary>
|
||||
|
|
@ -16612,6 +16640,8 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
return array_default;
|
||||
case 5:
|
||||
return parameter_list;
|
||||
case 6:
|
||||
return initial_value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -16639,6 +16669,9 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
case 5:
|
||||
parameter_list = (property_parameter_list)value;
|
||||
break;
|
||||
case 6:
|
||||
initial_value = (expression)value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16694,7 +16727,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
///<summary>
|
||||
///Конструктор с параметрами.
|
||||
///</summary>
|
||||
public index_property(ident _property_name,type_definition _property_type,expression _index_expression,property_accessors _accessors,property_array_default _array_default,property_parameter_list _parameter_list,definition_attribute _attr,proc_attribute _virt_over_none_attr,bool _is_auto,formal_parameters _property_parametres,default_indexer_property_node _is_default)
|
||||
public index_property(ident _property_name,type_definition _property_type,expression _index_expression,property_accessors _accessors,property_array_default _array_default,property_parameter_list _parameter_list,definition_attribute _attr,proc_attribute _virt_over_none_attr,bool _is_auto,expression _initial_value,formal_parameters _property_parametres,default_indexer_property_node _is_default)
|
||||
{
|
||||
this._property_name=_property_name;
|
||||
this._property_type=_property_type;
|
||||
|
|
@ -16705,6 +16738,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
this._attr=_attr;
|
||||
this._virt_over_none_attr=_virt_over_none_attr;
|
||||
this._is_auto=_is_auto;
|
||||
this._initial_value=_initial_value;
|
||||
this._property_parametres=_property_parametres;
|
||||
this._is_default=_is_default;
|
||||
FillParentsInDirectChilds();
|
||||
|
|
@ -16713,7 +16747,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
///<summary>
|
||||
///Конструктор с параметрами.
|
||||
///</summary>
|
||||
public index_property(ident _property_name,type_definition _property_type,expression _index_expression,property_accessors _accessors,property_array_default _array_default,property_parameter_list _parameter_list,definition_attribute _attr,proc_attribute _virt_over_none_attr,bool _is_auto,formal_parameters _property_parametres,default_indexer_property_node _is_default,SourceContext sc)
|
||||
public index_property(ident _property_name,type_definition _property_type,expression _index_expression,property_accessors _accessors,property_array_default _array_default,property_parameter_list _parameter_list,definition_attribute _attr,proc_attribute _virt_over_none_attr,bool _is_auto,expression _initial_value,formal_parameters _property_parametres,default_indexer_property_node _is_default,SourceContext sc)
|
||||
{
|
||||
this._property_name=_property_name;
|
||||
this._property_type=_property_type;
|
||||
|
|
@ -16724,6 +16758,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
this._attr=_attr;
|
||||
this._virt_over_none_attr=_virt_over_none_attr;
|
||||
this._is_auto=_is_auto;
|
||||
this._initial_value=_initial_value;
|
||||
this._property_parametres=_property_parametres;
|
||||
this._is_default=_is_default;
|
||||
source_context = sc;
|
||||
|
|
@ -16812,6 +16847,11 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
copy.attr = attr;
|
||||
copy.virt_over_none_attr = virt_over_none_attr;
|
||||
copy.is_auto = is_auto;
|
||||
if (initial_value != null)
|
||||
{
|
||||
copy.initial_value = (expression)initial_value.Clone();
|
||||
copy.initial_value.Parent = copy;
|
||||
}
|
||||
if (property_parametres != null)
|
||||
{
|
||||
copy.property_parametres = (formal_parameters)property_parametres.Clone();
|
||||
|
|
@ -16848,6 +16888,8 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
array_default.Parent = this;
|
||||
if (parameter_list != null)
|
||||
parameter_list.Parent = this;
|
||||
if (initial_value != null)
|
||||
initial_value.Parent = this;
|
||||
if (property_parametres != null)
|
||||
property_parametres.Parent = this;
|
||||
if (is_default != null)
|
||||
|
|
@ -16865,6 +16907,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
accessors?.FillParentsInAllChilds();
|
||||
array_default?.FillParentsInAllChilds();
|
||||
parameter_list?.FillParentsInAllChilds();
|
||||
initial_value?.FillParentsInAllChilds();
|
||||
property_parametres?.FillParentsInAllChilds();
|
||||
is_default?.FillParentsInAllChilds();
|
||||
}
|
||||
|
|
@ -16876,7 +16919,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
{
|
||||
get
|
||||
{
|
||||
return 8;
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
///<summary>
|
||||
|
|
@ -16886,7 +16929,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
{
|
||||
get
|
||||
{
|
||||
return 8;
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
///<summary>
|
||||
|
|
@ -16913,8 +16956,10 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
case 5:
|
||||
return parameter_list;
|
||||
case 6:
|
||||
return property_parametres;
|
||||
return initial_value;
|
||||
case 7:
|
||||
return property_parametres;
|
||||
case 8:
|
||||
return is_default;
|
||||
}
|
||||
return null;
|
||||
|
|
@ -16944,9 +16989,12 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
parameter_list = (property_parameter_list)value;
|
||||
break;
|
||||
case 6:
|
||||
property_parametres = (formal_parameters)value;
|
||||
initial_value = (expression)value;
|
||||
break;
|
||||
case 7:
|
||||
property_parametres = (formal_parameters)value;
|
||||
break;
|
||||
case 8:
|
||||
is_default = (default_indexer_property_node)value;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1094,7 +1094,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
public partial class simple_property
|
||||
{
|
||||
public simple_property(ident name, type_definition type, property_accessors accessors, SourceContext sc = null)
|
||||
: this(name, type, null, accessors, null, null, definition_attribute.None,proc_attribute.attr_none,false,sc)
|
||||
: this(name, type, null, accessors, null, null, definition_attribute.None,proc_attribute.attr_none,false, null, sc)
|
||||
{ }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1022,6 +1022,7 @@
|
|||
<ExtendedField Name="attr" Type="definition_attribute" CreateVariable="false" DeleteVariable="false" />
|
||||
<ExtendedField Name="virt_over_none_attr" Type="proc_attribute" CreateVariable="false" DeleteVariable="false" />
|
||||
<ExtendedField Name="is_auto" Type="bool" CreateVariable="false" DeleteVariable="false" />
|
||||
<SyntaxField Name="initial_value" SyntaxType="expression" />
|
||||
</Fields>
|
||||
<Methods />
|
||||
<Tags>
|
||||
|
|
@ -4153,6 +4154,7 @@
|
|||
<HelpData Key="simple_property.array_default" Value="" />
|
||||
<HelpData Key="simple_property.attr" Value="" />
|
||||
<HelpData Key="simple_property.index_expression" Value="" />
|
||||
<HelpData Key="simple_property.initial_value" Value="" />
|
||||
<HelpData Key="simple_property.is_auto" Value="" />
|
||||
<HelpData Key="simple_property.parameter_list" Value="" />
|
||||
<HelpData Key="simple_property.property_name" Value="" />
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ namespace SyntaxVisitors.SugarVisitors
|
|||
var var_def_statement = new var_def_statement(
|
||||
new ident_list(l, simple_property.source_context),
|
||||
simple_property.property_type,
|
||||
null,
|
||||
simple_property.initial_value,
|
||||
def_attribute,
|
||||
false,
|
||||
simple_property.source_context);
|
||||
|
|
|
|||
20
TestSuite/autoproperty6.pas
Normal file
20
TestSuite/autoproperty6.pas
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
type
|
||||
TClass = class
|
||||
auto property X: integer := 1;
|
||||
auto property Y: string := 'abc';
|
||||
static auto property Z: double := 3.14;
|
||||
end;
|
||||
|
||||
begin
|
||||
var a := new TClass();
|
||||
assert(a.X = 1);
|
||||
assert(a.Y.Equals('abc'));
|
||||
assert(TClass.Z = 3.14);
|
||||
|
||||
TCLass.Z := 1.3;
|
||||
a.X := 2;
|
||||
a.Y := '';
|
||||
assert(a.X = 2);
|
||||
assert(a.Y.Equals(''));
|
||||
assert(TClass.Z = 1.3);
|
||||
end.
|
||||
Loading…
Reference in a new issue