diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 577b8a545..1f8cd86ef 100644 --- a/Configuration/GlobalAssemblyInfo.cs +++ b/Configuration/GlobalAssemblyInfo.cs @@ -15,7 +15,7 @@ internal static class RevisionClass public const string Major = "3"; public const string Minor = "2"; public const string Build = "0"; - public const string Revision = "1359"; + public const string Revision = "1360"; public const string MainVersion = Major + "." + Minor; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; diff --git a/Configuration/Version.defs b/Configuration/Version.defs index 4de738cc7..fb89369b6 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%COREVERSION%=0 -%REVISION%=1359 %MINOR%=2 +%REVISION%=1360 +%COREVERSION%=0 %MAJOR%=3 diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs index 0ee5d44e7..6e725320d 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs @@ -2,7 +2,7 @@ // This CSharp output file generated by Gardens Point LEX // Version: 1.1.3.301 // Machine: DESKTOP-8EAQPI9 -// DateTime: 04.12.2016 9:22:22 +// DateTime: 12.12.2016 11:36:35 // UserName: ????????? // GPLEX input file // GPLEX frame file diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs index cd2a91c25..d02d6aab6 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs @@ -2,7 +2,7 @@ // GPPG version 1.3.6 // Machine: DESKTOP-8EAQPI9 -// DateTime: 04.12.2016 9:22:23 +// DateTime: 12.12.2016 11:36:36 // UserName: ????????? // Input file diff --git a/Parsers/PascalABCParserNewSaushkin/PABC.ymc b/Parsers/PascalABCParserNewSaushkin/PABC.ymc index 622647de3..bb01f75fb 100644 --- a/Parsers/PascalABCParserNewSaushkin/PABC.ymc +++ b/Parsers/PascalABCParserNewSaushkin/PABC.ymc @@ -152,5 +152,6 @@ script= + diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 54c491ca8..7af35f82b 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.2.0.1359' +!define VERSION '3.2.0.1360' diff --git a/TestSuite/CompilationSamples/LambdaIf.pas b/TestSuite/CompilationSamples/LambdaIf.pas new file mode 100644 index 000000000..a17623dc2 --- /dev/null +++ b/TestSuite/CompilationSamples/LambdaIf.pas @@ -0,0 +1,5 @@ +begin + var p: procedure(x: integer); + p := x -> if True then Print(x); + p(666); +end. \ No newline at end of file diff --git a/TestSuite/CompilationSamples/LambdaInForeachHeader.pas b/TestSuite/CompilationSamples/LambdaInForeachHeader.pas new file mode 100644 index 000000000..47041e0fd --- /dev/null +++ b/TestSuite/CompilationSamples/LambdaInForeachHeader.pas @@ -0,0 +1,4 @@ +begin + foreach var x in ArrGen(5,i->i) do + Print(x); +end. \ No newline at end of file diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index 01ee64c58..df5be1c42 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -1500,12 +1500,12 @@ function Length(a: System.Array; dim: integer): integer; function Copy(a: System.Array): System.Array; /// Сортирует динамический массив по возрастанию procedure Sort(a: array of T); -/// Сортирует динамический массив по критерию сортировки, задаваемому функцией сравнения less -procedure Sort(a: array of T; less: (T,T)->boolean); +/// Сортирует динамический массив по критерию сортировки, задаваемому функцией сравнения cmp +procedure Sort(a: array of T; cmp: (T,T)->integer); /// Сортирует список по возрастанию procedure Sort(l: List); -/// Сортирует список по критерию сортировки, задаваемому функцией сравнения less -procedure Sort(l: List; less: (T,T)->boolean); +/// Сортирует список по критерию сортировки, задаваемому функцией сравнения cmp +procedure Sort(l: List; cmp: (T,T)->integer); /// Изменяет порядок элементов в динамическом массиве на противоположный procedure Reverse(a: array of T); /// Изменяет порядок элементов на противоположный в диапазоне динамического массива длины length начиная с индекса index @@ -6999,9 +6999,9 @@ begin System.Array.Sort(a); end; -procedure Sort(a: array of T; less: (T,T)->boolean); +procedure Sort(a: array of T; cmp: (T,T)->integer); begin - System.Array.Sort(a,(x,y)->less(y,x)?1:-1); + System.Array.Sort(a,cmp); end; procedure Sort(l: List); @@ -7009,9 +7009,9 @@ begin l.Sort(); end; -procedure Sort(l: List; less: (T,T)->boolean); +procedure Sort(l: List; cmp: (T,T)->integer); begin - l.Sort((x,y)->less(y,x)?1:-1); + l.Sort(cmp); end; procedure Reverse(a: array of T); @@ -9241,7 +9241,7 @@ end; /// Генерирует последовательность целых от текущего значения до n в убывающем порядке function &Downto(Self: integer; n: integer): sequence of integer; extensionmethod; begin - Result := Range(n, Self, -1); // неверно - исправить + Result := Range(Self, n, -1); end; /// Возвращает последовательность целых 0,1,...n-1 diff --git a/TreeConverter/TreeConversion/LambdaHelper.cs b/TreeConverter/TreeConversion/LambdaHelper.cs index 3b6645917..67d8470bf 100644 --- a/TreeConverter/TreeConversion/LambdaHelper.cs +++ b/TreeConverter/TreeConversion/LambdaHelper.cs @@ -211,10 +211,13 @@ namespace PascalABCCompiler.TreeConverter /// public static bool TryConvertFuncLambdaBodyWithMethodCallToProcLambdaBody(function_lambda_definition lambdaDef) { + // SSM 12/12/16 - сделал чтобы всегда эта функция возвращала true. + // Посмотрю далее на её поведение. Мне кажется, что если мы попали сюда, то мы хотим присвоить процедурному типу, + // и в любом случае это надо интерпретировать как процедуру var stl = lambdaDef.proc_body as SyntaxTree.statement_list; if (stl.expr_lambda_body) { - // Очищаем от Result := + // Очищаем от Result := , который мы создали на предыдущем этапе var ass = stl.list[0] as assign; if (ass != null && ass.to is ident && (ass.to as ident).name.ToLower() == "result") @@ -227,10 +230,14 @@ namespace PascalABCCompiler.TreeConverter lambdaDef.return_type = null; return true; } + else + return false; } } - return false; + lambdaDef.return_type = null; + return true; +// return false; } /// diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index 3cd8965fe..76fa70ee2 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -19207,11 +19207,30 @@ namespace PascalABCCompiler.TreeConverter var el = new SyntaxTree.expression_list(); el.Add(new int32_const(situation)); - el.Add(sl.from); + + var semfrom = convert_strong(sl.from); + var b = convertion_data_and_alghoritms.can_convert_type(semfrom, SystemLibrary.SystemLibrary.integer_type); + if (!b) + AddError(get_location(sl.from), "INTEGER_VALUE_EXPECTED"); + + el.Add(sl.from); // Это плохо - считается 2 раза. Надо делать semantic_expr_node !!! + + var semto = convert_strong(sl.to); + b = convertion_data_and_alghoritms.can_convert_type(semto, SystemLibrary.SystemLibrary.integer_type); + if (!b) + AddError(get_location(sl.to), "INTEGER_VALUE_EXPECTED"); + el.Add(sl.to); if (sl.step != null) + { + var semstep = convert_strong(sl.step); + b = convertion_data_and_alghoritms.can_convert_type(semstep, SystemLibrary.SystemLibrary.integer_type); + if (!b) + AddError(get_location(sl.step), "INTEGER_VALUE_EXPECTED"); + el.Add(sl.step); + } var mc = new method_call(new dot_node(sl.v, new ident("SystemSlice", sl.v.source_context), sl.v.source_context), el, sl.source_context); visit(mc); diff --git a/bin/Lib/PABCRtl.dll b/bin/Lib/PABCRtl.dll index 5f4395ac6..225ae653f 100644 Binary files a/bin/Lib/PABCRtl.dll and b/bin/Lib/PABCRtl.dll differ