Захват en.ii в yield где en - поле класса

This commit is contained in:
miks1965 2016-08-18 20:58:15 +03:00
parent 272ea816e2
commit f6d267305d
12 changed files with 302 additions and 25 deletions

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "1";
public const string Build = "0";
public const string Revision = "1297";
public const string Revision = "1305";
public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%COREVERSION%=0
%REVISION%=1297
%REVISION%=1305
%MINOR%=1
%MAJOR%=3

View file

@ -1299,7 +1299,7 @@
</i>
</OCtx>
</Node>
<Node Name="AddStandardSyntaxConverters">
<Node Name="StandardSyntaxConverters">
<FileName>\SyntaxTreeConverters\AddStandardSyntaxConverters.cs</FileName>
<Text>static class AddStandardSyntaxConverters</Text>
<OCtx>
@ -1309,6 +1309,21 @@
</i>
</OCtx>
</Node>
<Node Name="StandardSyntaxTreeConverter">
<FileName>\StandardSyntaxTreeConverter\StandardSyntaxConverters.cs</FileName>
<Text>class StandardSyntaxTreeConverter: ISyntaxTreeConverter</Text>
<OCtx>
<i Type="ClassOrNamespace">class StandardSyntaxTreeConverter : ISyntaxTreeConverter</i>
<i Type="ClassOrNamespace">namespace PascalABCCompiler . SyntaxTreeConverters</i>
<i Type="CS_TreeNode">
</i>
</OCtx>
<ICtx>
<i Type="Method">public string Name</i>
<i Type="Field">=</i>
<i Type="Method">public syntax_tree_node Convert ( syntax_tree_node root )</i>
</ICtx>
</Node>
</Items>
</Node>
</Items>

View file

@ -1 +1 @@
!define VERSION '3.1.0.1297'
!define VERSION '3.1.0.1305'

View file

@ -73,18 +73,15 @@ type
protected
b := new System.Windows.Forms.Button;
procedure BClick(sender: Object; e: EventArgs);
function GetW(): integer;
begin
Result := b.Width
end;
procedure SetW(w: integer);
begin
b.Width := w;
end;
function GetW := b.Width;
procedure SetW(w: integer) := b.Width := w;
function GetText := b.Text;
procedure SetText(t: string) := b.Text := t;
public
event Click: procedure;
constructor Create(text: string);
property Width: integer read GetW write SetW;
property Text: string read GetText write SetText;
end;
/// Текстовая метка

View file

@ -1046,6 +1046,10 @@ function Sign(x: real): integer;
/// Возвращает модуль числа x
function Abs(x: integer): integer;
///--
function Abs(x: shortint): shortint;
///--
function Abs(x: smallint): smallint;
///--
function Abs(x: BigInteger): BigInteger;
///--
function Abs(x: longword): longword;
@ -1090,6 +1094,10 @@ function Sqrt(x: real): real;
/// Возвращает квадрат числа x
function Sqr(x: integer): int64;
///--
function Sqr(x: shortint): integer;
///--
function Sqr(x: smallint): integer;
///--
function Sqr(x: BigInteger): BigInteger;
///--
function Sqr(x: longword): uint64;
@ -3995,7 +4003,10 @@ end;}
function ArrFill<T>(count: integer; x: T): array of T;
begin
Result := System.Linq.Enumerable.Repeat(x,count).ToArray();
Result := new T[count];
for var i:=0 to Result.Length-1 do
Result[i] := x;
//Result := System.Linq.Enumerable.Repeat(x,count).ToArray();
end;
function ArrGen<T>(count: integer; f: integer -> T; from: integer): array of T;
@ -6623,6 +6634,16 @@ begin
Result := Math.Sign(x);
end;
function Abs(x: shortint): shortint;
begin
Result := Math.Abs(x);
end;
function Abs(x: smallint): smallint;
begin
Result := Math.Abs(x);
end;
function Abs(x: integer): integer;
begin
Result := Math.Abs(x);
@ -6733,6 +6754,16 @@ begin
Result := x * x;
end;
function Sqr(x: shortint): integer;
begin
Result := x * x;
end;
function Sqr(x: smallint): integer;
begin
Result := x * x;
end;
function Sqr(x: BigInteger): BigInteger;
begin
Result := x * x;
@ -8693,6 +8724,102 @@ begin
end;
end;
type
AdjGroupClass<T> = class
private
cur: T;
enm: IEnumerator<T>;
fin: boolean;
public
constructor Create(a: sequence of T);
begin
enm := a.GetEnumerator();
fin := enm.MoveNext;
if fin then
cur := enm.Current;
end;
function TakeGroup: sequence of T;
begin
yield cur;
fin := enm.movenext;
while fin do
begin
if enm.current = cur then
yield enm.current
else
begin
cur := enm.Current;
break;
end;
fin := enm.movenext;
end;
end;
end;
/// Группирует одинаковые подряд идущие элементы, получая последовательность последовательностей
function AdjacentGroup<T>(Self: sequence of T): sequence of sequence of T; extensionmethod;
begin
var c := new AdjGroupClass<T>(Self);
while c.fin do
yield c.TakeGroup();
end;
/// Возвращает минимальный элемент
function Min<T>(Self: array of T): T; extensionmethod; where T: System.IComparable<T>;
begin
Result := Self[0];
for var i:=1 to Self.Length-1 do
if Self[i].CompareTo(Result)<0 then
Result := Self[i];
end;
/// Возвращает максинимальный элемент
function Max<T>(Self: array of T): T; extensionmethod; where T: System.IComparable<T>;
begin
Result := Self[0];
for var i:=1 to Self.Length-1 do
if Self[i].CompareTo(Result)>0 then
Result := Self[i];
end;
/// Возвращает минимальный элемент
function Min(Self: array of integer): integer; extensionmethod;
begin
Result := Self[0];
for var i:=1 to Self.Length-1 do
if Self[i] < Result then
Result := Self[i];
end;
/// Возвращает минимальный элемент
function Min(Self: array of real): real; extensionmethod;
begin
Result := Self[0];
for var i:=1 to Self.Length-1 do
if Self[i] < Result then
Result := Self[i];
end;
/// Возвращает максимальный элемент
function Max(Self: array of integer): integer; extensionmethod;
begin
Result := Self[0];
for var i:=1 to Self.Length-1 do
if Self[i] > Result then
Result := Self[i];
end;
/// Возвращает максимальный элемент
function Max(Self: array of real): real; extensionmethod;
begin
Result := Self[0];
for var i:=1 to Self.Length-1 do
if Self[i] > Result then
Result := Self[i];
end;
/// Возвращает индекс первого минимального элемента начиная с позиции start
function IndexMin<T>(Self: array of T; start: integer := 0): integer; extensionmethod; where T: System.IComparable<T>;
begin

View file

@ -9242,11 +9242,24 @@ namespace PascalABCCompiler.TreeConverter
public override void visit(SyntaxTree.dot_node _dot_node)
{
var mot = motivation_keeper.motivation;
var mot = motivation_keeper.motivation;
SyntaxTree.ident id_left = _dot_node.left as SyntaxTree.ident;
SyntaxTree.ident id_right = _dot_node.right as SyntaxTree.ident;
if (_dot_node.right is ident_with_templateparams)
id_right = (_dot_node.right as ident_with_templateparams).name as ident;
// SSM 18.08.16 - пробуем обработать захват enn.ii в yieldах где enn - поле класса и нуждается в переименовании
// Так же ниже делает lroman
if (_dot_node.left is yield_unknown_ident)
{
var yui = (yield_unknown_ident)_dot_node.left;
var av = ProcessUnknownIdent(yui);
var dn = new dot_node(av, _dot_node.right,yui.source_context);
visit(dn);
return;
}
//lroman
if (_dot_node.left is closure_substituting_node)
{
@ -19221,7 +19234,8 @@ namespace PascalABCCompiler.TreeConverter
bool isStaticIdent;
if (CheckUnknownIdentNeedsClassCapture(unk, out isStaticIdent))
{
return CaptureUnknownIdent(unk, isStaticIdent);
var uid = CaptureUnknownIdent(unk, isStaticIdent);
return uid;
}
else
{

View file

@ -30,7 +30,7 @@ namespace YieldDesugarSyntaxTreeConverter
#if DEBUG
try
{
//root.visit(new SimplePrettyPrinterVisitor(@"d:\\zzz1.txt"));
//root.visit(new SimplePrettyPrinterVisitor(@"d:\\zzz1.txt"));
}
catch
{

View file

@ -73,18 +73,15 @@ type
protected
b := new System.Windows.Forms.Button;
procedure BClick(sender: Object; e: EventArgs);
function GetW(): integer;
begin
Result := b.Width
end;
procedure SetW(w: integer);
begin
b.Width := w;
end;
function GetW := b.Width;
procedure SetW(w: integer) := b.Width := w;
function GetText := b.Text;
procedure SetText(t: string) := b.Text := t;
public
event Click: procedure;
constructor Create(text: string);
property Width: integer read GetW write SetW;
property Text: string read GetText write SetText;
end;
/// Текстовая метка

Binary file not shown.

View file

@ -1046,6 +1046,10 @@ function Sign(x: real): integer;
/// Возвращает модуль числа x
function Abs(x: integer): integer;
///--
function Abs(x: shortint): shortint;
///--
function Abs(x: smallint): smallint;
///--
function Abs(x: BigInteger): BigInteger;
///--
function Abs(x: longword): longword;
@ -1090,6 +1094,10 @@ function Sqrt(x: real): real;
/// Возвращает квадрат числа x
function Sqr(x: integer): int64;
///--
function Sqr(x: shortint): integer;
///--
function Sqr(x: smallint): integer;
///--
function Sqr(x: BigInteger): BigInteger;
///--
function Sqr(x: longword): uint64;
@ -3995,7 +4003,10 @@ end;}
function ArrFill<T>(count: integer; x: T): array of T;
begin
Result := System.Linq.Enumerable.Repeat(x,count).ToArray();
Result := new T[count];
for var i:=0 to Result.Length-1 do
Result[i] := x;
//Result := System.Linq.Enumerable.Repeat(x,count).ToArray();
end;
function ArrGen<T>(count: integer; f: integer -> T; from: integer): array of T;
@ -6623,6 +6634,16 @@ begin
Result := Math.Sign(x);
end;
function Abs(x: shortint): shortint;
begin
Result := Math.Abs(x);
end;
function Abs(x: smallint): smallint;
begin
Result := Math.Abs(x);
end;
function Abs(x: integer): integer;
begin
Result := Math.Abs(x);
@ -6733,6 +6754,16 @@ begin
Result := x * x;
end;
function Sqr(x: shortint): integer;
begin
Result := x * x;
end;
function Sqr(x: smallint): integer;
begin
Result := x * x;
end;
function Sqr(x: BigInteger): BigInteger;
begin
Result := x * x;
@ -8693,6 +8724,102 @@ begin
end;
end;
type
AdjGroupClass<T> = class
private
cur: T;
enm: IEnumerator<T>;
fin: boolean;
public
constructor Create(a: sequence of T);
begin
enm := a.GetEnumerator();
fin := enm.MoveNext;
if fin then
cur := enm.Current;
end;
function TakeGroup: sequence of T;
begin
yield cur;
fin := enm.movenext;
while fin do
begin
if enm.current = cur then
yield enm.current
else
begin
cur := enm.Current;
break;
end;
fin := enm.movenext;
end;
end;
end;
/// Группирует одинаковые подряд идущие элементы, получая последовательность последовательностей
function AdjacentGroup<T>(Self: sequence of T): sequence of sequence of T; extensionmethod;
begin
var c := new AdjGroupClass<T>(Self);
while c.fin do
yield c.TakeGroup();
end;
/// Возвращает минимальный элемент
function Min<T>(Self: array of T): T; extensionmethod; where T: System.IComparable<T>;
begin
Result := Self[0];
for var i:=1 to Self.Length-1 do
if Self[i].CompareTo(Result)<0 then
Result := Self[i];
end;
/// Возвращает максинимальный элемент
function Max<T>(Self: array of T): T; extensionmethod; where T: System.IComparable<T>;
begin
Result := Self[0];
for var i:=1 to Self.Length-1 do
if Self[i].CompareTo(Result)>0 then
Result := Self[i];
end;
/// Возвращает минимальный элемент
function Min(Self: array of integer): integer; extensionmethod;
begin
Result := Self[0];
for var i:=1 to Self.Length-1 do
if Self[i] < Result then
Result := Self[i];
end;
/// Возвращает минимальный элемент
function Min(Self: array of real): real; extensionmethod;
begin
Result := Self[0];
for var i:=1 to Self.Length-1 do
if Self[i] < Result then
Result := Self[i];
end;
/// Возвращает максимальный элемент
function Max(Self: array of integer): integer; extensionmethod;
begin
Result := Self[0];
for var i:=1 to Self.Length-1 do
if Self[i] > Result then
Result := Self[i];
end;
/// Возвращает максимальный элемент
function Max(Self: array of real): real; extensionmethod;
begin
Result := Self[0];
for var i:=1 to Self.Length-1 do
if Self[i] > Result then
Result := Self[i];
end;
/// Возвращает индекс первого минимального элемента начиная с позиции start
function IndexMin<T>(Self: array of T; start: integer := 0): integer; extensionmethod; where T: System.IComparable<T>;
begin

Binary file not shown.