auto properties + extended indexed properties
This commit is contained in:
parent
4a96058739
commit
6f9c2b726d
|
|
@ -1853,11 +1853,30 @@ namespace CodeFormatters
|
|||
public override void visit(simple_property _simple_property)
|
||||
{
|
||||
multiline_stack_push(_simple_property);
|
||||
|
||||
string keyword_with_spaces = "property";
|
||||
var property_keyword = "property";
|
||||
if (_simple_property.is_auto)
|
||||
{
|
||||
property_keyword = property_keyword.Insert(0, "auto ");
|
||||
var name_pos = GetPosition(
|
||||
_simple_property.property_name.source_context.begin_position.line_num,
|
||||
_simple_property.property_name.source_context.begin_position.column_num);
|
||||
var property_start_pos = GetPosition(
|
||||
_simple_property.source_context.begin_position.line_num,
|
||||
_simple_property.source_context.begin_position.column_num);
|
||||
|
||||
keyword_with_spaces = Text.Substring(
|
||||
property_start_pos, name_pos - property_start_pos - 1);
|
||||
keyword_with_spaces.Trim();
|
||||
}
|
||||
|
||||
if (_simple_property.attr != definition_attribute.Static)
|
||||
{
|
||||
sb.Append("property");
|
||||
SetKeywordOffset("property");
|
||||
sb.Append(property_keyword);
|
||||
SetKeywordOffset(keyword_with_spaces);
|
||||
}
|
||||
|
||||
visit_node(_simple_property.property_name);
|
||||
if (_simple_property.parameter_list != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
//
|
||||
// This CSharp output file generated by Gardens Point LEX
|
||||
// Version: 1.1.3.301
|
||||
// Machine: DESKTOP-G8V08V4
|
||||
// DateTime: 01.12.2018 12:55:41
|
||||
// UserName: ?????????
|
||||
// Machine: DESKTOP-LFNDRFO
|
||||
// DateTime: 12/5/2018 9:39:16 AM
|
||||
// UserName: wowit
|
||||
// GPLEX input file <ABCPascal.lex>
|
||||
// GPLEX frame file <embedded resource>
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1552,55 +1552,6 @@ object_type
|
|||
: class_attributes class_or_interface_keyword optional_base_classes optional_where_section optional_component_list_seq_end
|
||||
{
|
||||
$$ = NewObjectType((class_attribute)$1, $2, $3 as named_type_reference_list, $4 as where_definition_list, $5 as class_body_list, @$);
|
||||
class_definition cd = $$ as class_definition;
|
||||
if (cd == null || cd.body == null)
|
||||
break;
|
||||
var ccnt = cd.body.DescendantNodes().OfType<simple_property>().ToArray();
|
||||
var cm = new class_members(access_modifer.private_modifer);
|
||||
foreach (var prop in ccnt)
|
||||
{
|
||||
var td = prop.property_type;
|
||||
var ra = prop.accessors?.read_accessor;
|
||||
if ($2.text.ToLower() == "interface" && ra != null && (ra.pr != null || ra.accessor_name != null))
|
||||
parsertools.AddErrorFromResource("INVALID_INTERFACE_MEMBER",ra.source_context);
|
||||
|
||||
if (ra != null && ra.pr != null)
|
||||
{
|
||||
if (prop.parameter_list != null)
|
||||
parsertools.AddErrorFromResource("EXTENDED_INDEXED_PROPERTIES",ra.source_context);
|
||||
var rapr = ra.pr as procedure_definition;
|
||||
(rapr.proc_header as function_header).return_type = td;
|
||||
cm.Add(rapr);
|
||||
if (prop.attr == definition_attribute.Static)
|
||||
{
|
||||
rapr.proc_header.class_keyword = true;
|
||||
procedure_attribute pa = new procedure_attribute(proc_attribute.attr_static);
|
||||
pa.source_context = rapr.proc_header.source_context;
|
||||
rapr.proc_header.proc_attributes = new procedure_attributes_list(pa);
|
||||
}
|
||||
}
|
||||
var wa = prop.accessors?.write_accessor;
|
||||
if ($2.text.ToLower() == "interface" && wa != null && (wa.pr != null || wa.accessor_name != null))
|
||||
parsertools.AddErrorFromResource("INVALID_INTERFACE_MEMBER",wa.source_context);
|
||||
|
||||
if (wa != null && wa.pr != null)
|
||||
{
|
||||
if (prop.parameter_list != null)
|
||||
parsertools.AddErrorFromResource("EXTENDED_INDEXED_PROPERTIES",ra.source_context);
|
||||
var wapr = wa.pr as procedure_definition;
|
||||
wapr.proc_header.parameters.params_list[0].vars_type = td;
|
||||
cm.Add(wapr);
|
||||
if (prop.attr == definition_attribute.Static)
|
||||
{
|
||||
wapr.proc_header.class_keyword = true;
|
||||
procedure_attribute pa = new procedure_attribute(proc_attribute.attr_static);
|
||||
pa.source_context = wapr.proc_header.source_context;
|
||||
wapr.proc_header.proc_attributes = new procedure_attributes_list(pa);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cm.Count>0)
|
||||
cd.body.Insert(0, cm);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -1608,51 +1559,6 @@ record_type
|
|||
: tkRecord optional_base_classes optional_where_section member_list_section tkEnd
|
||||
{
|
||||
$$ = NewRecordType($2 as named_type_reference_list, $3 as where_definition_list, $4 as class_body_list, @$);
|
||||
class_definition cd = $$ as class_definition;
|
||||
if (cd == null || cd.body == null)
|
||||
break;
|
||||
var ccnt = cd.body.DescendantNodes().OfType<simple_property>().ToArray();
|
||||
var cm = new class_members(access_modifer.private_modifer);
|
||||
foreach (var prop in ccnt)
|
||||
{
|
||||
var td = prop.property_type;
|
||||
var ra = prop.accessors?.read_accessor;
|
||||
|
||||
if (ra != null && ra.pr != null)
|
||||
{
|
||||
if (prop.parameter_list != null)
|
||||
parsertools.AddErrorFromResource("EXTENDED_INDEXED_PROPERTIES",ra.source_context);
|
||||
var rapr = ra.pr as procedure_definition;
|
||||
(rapr.proc_header as function_header).return_type = td;
|
||||
cm.Add(rapr);
|
||||
if (prop.attr == definition_attribute.Static)
|
||||
{
|
||||
rapr.proc_header.class_keyword = true;
|
||||
procedure_attribute pa = new procedure_attribute(proc_attribute.attr_static);
|
||||
pa.source_context = rapr.proc_header.source_context;
|
||||
rapr.proc_header.proc_attributes = new procedure_attributes_list(pa);
|
||||
}
|
||||
}
|
||||
var wa = prop.accessors?.write_accessor;
|
||||
|
||||
if (wa != null && wa.pr != null && prop.parameter_list == null)
|
||||
{
|
||||
if (prop.parameter_list != null)
|
||||
parsertools.AddErrorFromResource("EXTENDED_INDEXED_PROPERTIES",ra.source_context);
|
||||
var wapr = wa.pr as procedure_definition;
|
||||
wapr.proc_header.parameters.params_list[0].vars_type = td;
|
||||
cm.Add(wapr);
|
||||
if (prop.attr == definition_attribute.Static)
|
||||
{
|
||||
wapr.proc_header.class_keyword = true;
|
||||
procedure_attribute pa = new procedure_attribute(proc_attribute.attr_static);
|
||||
pa.source_context = wapr.proc_header.source_context;
|
||||
wapr.proc_header.proc_attributes = new procedure_attributes_list(pa);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cm.Count>0)
|
||||
cd.body.Insert(0, cm);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -2068,12 +1974,17 @@ simple_property_definition
|
|||
{
|
||||
parsertools.AddErrorFromResource("STATIC_PROPERTIES_CANNOT_HAVE_ATTRBUTE_{0}",@7,$7.name);
|
||||
}
|
||||
| tkAuto tkProperty qualified_identifier property_interface tkSemiColon
|
||||
{
|
||||
$$ = NewSimplePropertyDefinition($3 as method_name, $4 as property_interface, null, proc_attribute.attr_none, null, @$);
|
||||
($$ as simple_property).is_auto = true;
|
||||
}
|
||||
;
|
||||
|
||||
array_defaultproperty
|
||||
:
|
||||
{ $$ = null; }
|
||||
| tkDefault tkSemiColon
|
||||
| tkDefault tkSemiColon
|
||||
{
|
||||
$$ = new property_array_default();
|
||||
$$.source_context = @$;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -57,6 +57,9 @@ namespace PascalABCCompiler.SyntaxTreeConverters
|
|||
// SingleDeconstructChecker.New.ProcessNode(root); // SSM 21.10.18 - пока разрешил множественные деконструкторы. Если будут проблемы - запретить
|
||||
PatternsDesugaringVisitor.New.ProcessNode(root);
|
||||
|
||||
// simple_property
|
||||
PropertyDesugarVisitor.New.ProcessNode(root);
|
||||
|
||||
// Всё, связанное с yield
|
||||
CapturedNamesHelper.Reset();
|
||||
MarkMethodHasYieldAndCheckSomeErrorsVisitor.New.ProcessNode(root);
|
||||
|
|
|
|||
196
SyntaxVisitors/SugarVisitors/PropertyDesugarVisitor.cs
Normal file
196
SyntaxVisitors/SugarVisitors/PropertyDesugarVisitor.cs
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
using PascalABCCompiler.SyntaxTree;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace SyntaxVisitors.SugarVisitors
|
||||
{
|
||||
public class PropertyDesugarVisitor : BaseChangeVisitor
|
||||
{
|
||||
public static PropertyDesugarVisitor New
|
||||
{
|
||||
get { return new PropertyDesugarVisitor(); }
|
||||
}
|
||||
|
||||
public override void visit(simple_property _simple_property)
|
||||
{
|
||||
var property_parent_node = _simple_property.Parent;
|
||||
while (property_parent_node != null && property_parent_node.GetType() != typeof(class_members))
|
||||
{
|
||||
property_parent_node = property_parent_node.Parent;
|
||||
}
|
||||
class_members property_class_members = property_parent_node as class_members;
|
||||
|
||||
while (property_parent_node != null && property_parent_node.GetType() != typeof(class_body_list))
|
||||
{
|
||||
property_parent_node = property_parent_node.Parent;
|
||||
}
|
||||
class_body_list class_body = property_parent_node as class_body_list;
|
||||
|
||||
while (property_parent_node != null && property_parent_node.GetType() != typeof(class_definition))
|
||||
{
|
||||
property_parent_node = property_parent_node.Parent;
|
||||
}
|
||||
class_definition class_def = property_parent_node as class_definition;
|
||||
|
||||
var property_type = _simple_property.property_type;
|
||||
var read_accessor = _simple_property.accessors?.read_accessor;
|
||||
var write_accessor = _simple_property.accessors?.write_accessor;
|
||||
var new_class_members = new class_members(access_modifer.private_modifer);
|
||||
|
||||
if (class_def.keyword == class_keyword.Interface && _simple_property.is_auto)
|
||||
{
|
||||
throw new SyntaxVisitorError(
|
||||
"INVALID_INTERFACE_MEMBER", _simple_property.source_context);
|
||||
}
|
||||
|
||||
if (class_def.keyword == class_keyword.Interface &&
|
||||
read_accessor != null &&
|
||||
(read_accessor.pr != null || read_accessor.accessor_name != null))
|
||||
{
|
||||
throw new SyntaxVisitorError(
|
||||
"INVALID_INTERFACE_MEMBER", read_accessor.source_context);
|
||||
}
|
||||
|
||||
if (class_def.keyword == class_keyword.Interface &&
|
||||
write_accessor != null &&
|
||||
(write_accessor.pr != null || write_accessor.accessor_name != null))
|
||||
{
|
||||
throw new SyntaxVisitorError(
|
||||
"INVALID_INTERFACE_MEMBER", write_accessor.source_context);
|
||||
}
|
||||
|
||||
if (_simple_property.is_auto)
|
||||
{
|
||||
AutoPropertyDesugaring(_simple_property, new_class_members);
|
||||
}
|
||||
|
||||
// pr != null => extended read accessor
|
||||
if (read_accessor != null && read_accessor.pr != null)
|
||||
{
|
||||
ExtendedReadAccessorDesugaring(read_accessor, _simple_property, new_class_members);
|
||||
}
|
||||
|
||||
// pr != null => extended write accessor
|
||||
if (write_accessor != null && write_accessor.pr != null)
|
||||
{
|
||||
ExtendedWriteAccessorDesugaring(write_accessor, _simple_property, new_class_members);
|
||||
}
|
||||
|
||||
if (new_class_members.Count > 0)
|
||||
{
|
||||
class_body.InsertBefore(property_class_members, new_class_members);
|
||||
}
|
||||
}
|
||||
|
||||
private void AutoPropertyDesugaring(simple_property simple_property,
|
||||
class_members members)
|
||||
{
|
||||
var id = NewId("#PField", simple_property.source_context);
|
||||
var accessors = new property_accessors();
|
||||
accessors.write_accessor = new write_accessor_name(id, null, null, simple_property.source_context);
|
||||
accessors.read_accessor = new read_accessor_name(id, null, null, simple_property.source_context);
|
||||
simple_property.accessors = accessors;
|
||||
|
||||
List<ident> l = new List<ident>() { id };
|
||||
var var_def_statement = new var_def_statement(
|
||||
new ident_list(l, simple_property.source_context),
|
||||
simple_property.property_type,
|
||||
null,
|
||||
definition_attribute.None,
|
||||
false,
|
||||
simple_property.source_context);
|
||||
members.Add(var_def_statement);
|
||||
}
|
||||
|
||||
private void ExtendedReadAccessorDesugaring(read_accessor_name read_accessor,
|
||||
simple_property simple_property,
|
||||
class_members members)
|
||||
{
|
||||
var read_accessor_procedure = read_accessor.pr as procedure_definition;
|
||||
var func_header = (read_accessor_procedure.proc_header as function_header);
|
||||
func_header.return_type = simple_property.property_type;
|
||||
|
||||
//extended indexed property
|
||||
if (simple_property.parameter_list != null)
|
||||
{
|
||||
var func_header_params = new List<ident>();
|
||||
var func_header_types = new List<type_definition>();
|
||||
foreach (var param in simple_property.parameter_list.parameters)
|
||||
{
|
||||
foreach (var ident in param.names.idents)
|
||||
{
|
||||
func_header_params.Add(ident);
|
||||
func_header_types.Add(param.type);
|
||||
}
|
||||
}
|
||||
func_header.parameters =
|
||||
SyntaxTreeBuilder.BuildFormalParameters(
|
||||
func_header_params,
|
||||
func_header_types);
|
||||
}
|
||||
|
||||
members.Add(read_accessor_procedure);
|
||||
if (simple_property.attr == definition_attribute.Static)
|
||||
{
|
||||
read_accessor_procedure.proc_header.class_keyword = true;
|
||||
var proc_attr = new procedure_attribute(proc_attribute.attr_static);
|
||||
proc_attr.source_context = read_accessor_procedure.proc_header.source_context;
|
||||
read_accessor_procedure.proc_header.proc_attributes = new procedure_attributes_list(proc_attr);
|
||||
}
|
||||
}
|
||||
|
||||
private void ExtendedWriteAccessorDesugaring(write_accessor_name write_accessor,
|
||||
simple_property simple_property,
|
||||
class_members members)
|
||||
{
|
||||
var write_accessor_procedure = write_accessor.pr as procedure_definition;
|
||||
|
||||
//extended indexed property
|
||||
if (simple_property.parameter_list != null)
|
||||
{
|
||||
var proc_header_params = new List<ident>();
|
||||
var proc_header_types = new List<type_definition>();
|
||||
|
||||
foreach (var param in simple_property.parameter_list.parameters)
|
||||
{
|
||||
foreach (var ident in param.names.idents)
|
||||
{
|
||||
proc_header_params.Add(ident);
|
||||
proc_header_types.Add(param.type);
|
||||
}
|
||||
}
|
||||
proc_header_params.Add(new ident("value"));
|
||||
proc_header_types.Add(simple_property.property_type);
|
||||
|
||||
write_accessor_procedure.proc_header.parameters =
|
||||
SyntaxTreeBuilder.BuildFormalParameters(
|
||||
proc_header_params,
|
||||
proc_header_types);
|
||||
}
|
||||
else
|
||||
{
|
||||
write_accessor_procedure.proc_header.parameters.params_list[0].vars_type = simple_property.property_type;
|
||||
}
|
||||
|
||||
members.Add(write_accessor_procedure);
|
||||
if (simple_property.attr == definition_attribute.Static)
|
||||
{
|
||||
write_accessor_procedure.proc_header.class_keyword = true;
|
||||
var proc_attr = new procedure_attribute(proc_attribute.attr_static);
|
||||
proc_attr.source_context = write_accessor_procedure.proc_header.source_context;
|
||||
write_accessor_procedure.proc_header.proc_attributes = new procedure_attributes_list(proc_attr);
|
||||
}
|
||||
}
|
||||
|
||||
//random id generator
|
||||
private int postfix = 0;
|
||||
public ident NewId(string prefix, SourceContext sc = null)
|
||||
{
|
||||
postfix++;
|
||||
return new ident(prefix + postfix.ToString(), sc);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ namespace SyntaxVisitors.SugarVisitors
|
|||
|
||||
public override void visit(read_accessor_name wn)
|
||||
{
|
||||
|
||||
DefaultVisit(wn);
|
||||
}
|
||||
|
||||
public override void visit(unnamed_type_object u)
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
<Compile Include="SugarVisitors\AssignTuplesDesugarVisitor.cs" />
|
||||
<Compile Include="SugarVisitors\DoubleQuestionDesugarVisitor.cs" />
|
||||
<Compile Include="SugarVisitors\LoopDesugarVisitor.cs" />
|
||||
<Compile Include="SugarVisitors\PropertyDesugarVisitor.cs" />
|
||||
<Compile Include="SugarVisitors\QuestionPointDesugarVisitor.cs" />
|
||||
<Compile Include="SugarVisitors\PatternsDesugaringVisitor.cs" />
|
||||
<Compile Include="SugarVisitors\SliceDesugarVisitor.cs" />
|
||||
|
|
|
|||
16
TestSuite/autoproperty1.pas
Normal file
16
TestSuite/autoproperty1.pas
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
type
|
||||
TBaseClass = class
|
||||
auto property p1: byte;
|
||||
end;
|
||||
|
||||
TClass = class(TBaseClass)
|
||||
end;
|
||||
|
||||
begin
|
||||
var o: TBaseClass := new TClass;
|
||||
var o1: TBaseClass := new TBaseClass;
|
||||
o.p1 := 2;
|
||||
o1.p1 := 3;
|
||||
assert(o.p1 = 2);
|
||||
assert(o1.p1 = 3);
|
||||
end.
|
||||
19
TestSuite/autoproperty2.pas
Normal file
19
TestSuite/autoproperty2.pas
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
type
|
||||
TBaseClass = class
|
||||
auto property p1: byte;
|
||||
auto property p2: integer;
|
||||
auto property p3: sequence of integer;
|
||||
end;
|
||||
|
||||
TClass = class(TBaseClass)
|
||||
end;
|
||||
|
||||
begin
|
||||
var o: TBaseClass := new TClass;
|
||||
o.p1 := 2;
|
||||
o.p2 := 398;
|
||||
o.p3 := Seq(1,2,3);
|
||||
assert(o.p1 = 2);
|
||||
assert(o.p2 = 398);
|
||||
assert(o.p3.SequenceEqual(Seq(1,2,3)));
|
||||
end.
|
||||
22
TestSuite/autoproperty3.pas
Normal file
22
TestSuite/autoproperty3.pas
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
type
|
||||
TBaseClass = abstract class
|
||||
auto property p1: byte;
|
||||
end;
|
||||
|
||||
TClass1 = class(TBaseClass)
|
||||
auto property p2: integer;
|
||||
end;
|
||||
|
||||
TClass2 = class(TClass1)
|
||||
auto property p3: sequence of integer;
|
||||
end;
|
||||
|
||||
begin
|
||||
var o: TClass2 := new TClass2;
|
||||
o.p1 := 2;
|
||||
o.p2 := 398;
|
||||
o.p3 := Seq(1, 2, 3);
|
||||
assert(o.p1 = 2);
|
||||
assert(o.p2 = 398);
|
||||
assert(o.p3.SequenceEqual(Seq(1, 2, 3)));
|
||||
end.
|
||||
24
TestSuite/autoproperty4.pas
Normal file
24
TestSuite/autoproperty4.pas
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
type
|
||||
TClass0 = record
|
||||
protected auto property p1: byte;
|
||||
end;
|
||||
|
||||
TClass1 = record
|
||||
public auto property p2: integer;
|
||||
end;
|
||||
|
||||
TClass2 = record
|
||||
public auto property p3: sequence of integer;
|
||||
end;
|
||||
|
||||
begin
|
||||
var o1 := new TClass0();
|
||||
var o2 := new TClass1();
|
||||
var o3 := new TClass2();
|
||||
o1.p1 := 123;
|
||||
o2.p2 := 398;
|
||||
o3.p3 := Seq(1, 2, 3);
|
||||
assert(o1.p1 = 123);
|
||||
assert(o2.p2 = 398);
|
||||
assert(o3.p3.SequenceEqual(Seq(1, 2, 3)));
|
||||
end.
|
||||
0
TestSuite/errors/err0259.exe
Normal file
0
TestSuite/errors/err0259.exe
Normal file
16
TestSuite/extendedindexedproperty1.pas
Normal file
16
TestSuite/extendedindexedproperty1.pas
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
type
|
||||
TExample = class
|
||||
private a := new integer[10,10];
|
||||
|
||||
property p[i, j: integer]: integer read a[i, j] write begin a[i,j] := value; end;
|
||||
end;
|
||||
|
||||
begin
|
||||
var c := new TExample();
|
||||
c.p[3,2] := 10;
|
||||
c.p[0,0] := -2;
|
||||
assert(c.p[3,2] = 10);
|
||||
assert(c.p[0,0] = -2);
|
||||
assert(c.p[1,3] = 0);
|
||||
assert(c.p[9,9] = 0);
|
||||
end.
|
||||
17
TestSuite/extendedindexedproperty2.pas
Normal file
17
TestSuite/extendedindexedproperty2.pas
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
type
|
||||
TExample = record
|
||||
private a := new integer[10,10];
|
||||
|
||||
property p[i, j: integer]: integer read a[i, j] write begin a[i,j] := value; end;
|
||||
end;
|
||||
|
||||
begin
|
||||
var c := new TExample();
|
||||
for var i:=0 to 9 do
|
||||
for var j:=0 to 9 do
|
||||
c.p[j, i] := i+j*j;
|
||||
|
||||
for var i:=0 to 9 do
|
||||
for var j:=0 to 9 do
|
||||
assert(c.p[j, i] = i+j*j);
|
||||
end.
|
||||
26
TestSuite/extendedindexedproperty3.pas
Normal file
26
TestSuite/extendedindexedproperty3.pas
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
type
|
||||
TBase = abstract class
|
||||
protected a := new integer[10,10,10];
|
||||
end;
|
||||
|
||||
TExample = class(TBase)
|
||||
public property p[i, j: integer; k: integer]: integer
|
||||
read a[i, j, k] write begin a[i,j,value] := k*k+i+j; end;
|
||||
end;
|
||||
|
||||
begin
|
||||
var c := new TExample();
|
||||
var k := 5;
|
||||
for var i:=0 to 9 do
|
||||
for var j:=0 to 9 do
|
||||
c.p[i, j, k] := 0;
|
||||
|
||||
for var i:=0 to 9 do
|
||||
for var j:=0 to 9 do
|
||||
assert(c.p[i, j, 0] = 25 + i + j);
|
||||
|
||||
for var i:=0 to 9 do
|
||||
for var j:=0 to 9 do
|
||||
for var d:=1 to 9 do
|
||||
assert(c.p[i, j, d] = 0);
|
||||
end.
|
||||
14
TestSuite/formatter_tests/input/autoproperty1.pas
Normal file
14
TestSuite/formatter_tests/input/autoproperty1.pas
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
type
|
||||
TBaseClass = class
|
||||
auto property p1: byte;
|
||||
end;
|
||||
TClass = class(TBaseClass)
|
||||
end;
|
||||
begin
|
||||
var o: TBaseClass := new TClass;
|
||||
var o1: TBaseClass := new TBaseClass;
|
||||
o.p1 := 2;
|
||||
o1.p1 := 3;
|
||||
assert(o.p1 = 2);
|
||||
assert(o1.p1 = 3);
|
||||
end.
|
||||
24
TestSuite/formatter_tests/input/extendedindexedproperty3.pas
Normal file
24
TestSuite/formatter_tests/input/extendedindexedproperty3.pas
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
type
|
||||
TBase = abstract class
|
||||
protected a := new integer[10,10,10];
|
||||
end;
|
||||
TExample = class(TBase)
|
||||
public property p[i, j: integer; k: integer]: integer
|
||||
read a[i, j, k] write begin a[i,j,value] := k*k+i+j; end;
|
||||
end;
|
||||
|
||||
begin
|
||||
var c := new TExample();
|
||||
var k := 5;
|
||||
for var i:=0 to 9 do
|
||||
for var j:=0 to 9 do
|
||||
c.p[i, j, k] := 0;
|
||||
|
||||
for var i:=0 to 9 do
|
||||
for var j:=0 to 9 do
|
||||
assert(c.p[i, j, 0] = 25 + i + j);
|
||||
for var i:=0 to 9 do
|
||||
for var j:=0 to 9 do
|
||||
for var d:=1 to 9 do
|
||||
assert(c.p[i, j, d] = 0);
|
||||
end.
|
||||
15
TestSuite/formatter_tests/should/autoproperty1.pas
Normal file
15
TestSuite/formatter_tests/should/autoproperty1.pas
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
type
|
||||
TBaseClass = class
|
||||
auto property p1: byte;
|
||||
end;
|
||||
TClass = class(TBaseClass)
|
||||
end;
|
||||
|
||||
begin
|
||||
var o: TBaseClass := new TClass;
|
||||
var o1: TBaseClass := new TBaseClass;
|
||||
o.p1 := 2;
|
||||
o1.p1 := 3;
|
||||
assert(o.p1 = 2);
|
||||
assert(o1.p1 = 3);
|
||||
end.
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
type
|
||||
TBase = abstract class
|
||||
protected a := new integer[10, 10, 10];
|
||||
end;
|
||||
TExample = class(TBase)
|
||||
public property p[i, j: integer; k: integer]: integer
|
||||
read a[i, j, k] write begin a[i, j, value] := k * k + i + j; end;
|
||||
end;
|
||||
|
||||
begin
|
||||
var c := new TExample();
|
||||
var k := 5;
|
||||
for var i := 0 to 9 do
|
||||
for var j := 0 to 9 do
|
||||
c.p[i, j, k] := 0;
|
||||
|
||||
for var i := 0 to 9 do
|
||||
for var j := 0 to 9 do
|
||||
assert(c.p[i, j, 0] = 25 + i + j);
|
||||
for var i := 0 to 9 do
|
||||
for var j := 0 to 9 do
|
||||
for var d := 1 to 9 do
|
||||
assert(c.p[i, j, d] = 0);
|
||||
end.
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" (
|
||||
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" PascalABCNET.sln
|
||||
) else if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe" (
|
||||
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe" PascalABCNET.sln
|
||||
) else (
|
||||
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" PascalABCNET.sln
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" (
|
||||
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" /t:clean PascalABCNET.sln
|
||||
) else if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe" (
|
||||
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe" /t:clean PascalABCNET.sln
|
||||
) else (
|
||||
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" /t:clean PascalABCNET.sln
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" (
|
||||
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" /t:rebuild PascalABCNET.sln
|
||||
) else if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe" (
|
||||
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe" /t:rebuild PascalABCNET.sln
|
||||
) else (
|
||||
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" /t:rebuild PascalABCNET.sln
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" (
|
||||
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" /t:rebuild /property:Configuration=Release /p:Platform="Any CPU" PascalABCNET.sln
|
||||
) else if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe" (
|
||||
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe" /t:rebuild /property:Configuration=Release /p:Platform="Any CPU" PascalABCNET.sln
|
||||
) else (
|
||||
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" /t:rebuild /property:Configuration=Release /p:Platform="Any CPU" PascalABCNET.sln
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue