diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 3e19a7342..c4550a120 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 = "1379"; + public const string Revision = "1381"; 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 b67b1c9f9..82927b619 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %COREVERSION%=0 -%REVISION%=1379 +%REVISION%=1381 %MINOR%=2 %MAJOR%=3 diff --git a/InstallerSamples/LanguageFeatures/Tuples/MySqrt.pas b/InstallerSamples/LanguageFeatures/Tuples/MySqrt.pas new file mode 100644 index 000000000..a976c51ff --- /dev/null +++ b/InstallerSamples/LanguageFeatures/Tuples/MySqrt.pas @@ -0,0 +1,14 @@ +function MySqrt(x: real): real; +begin + var eps := 1e-15; + (var a, var b) := (x, real.MaxValue); + while abs(b-a) >= eps do + (a,b) := (b,(a + x / a) / 2); + Result := b; +end; + +begin + Println(MySqrt(2)); + Println(MySqrt(3)); + Println(MySqrt(4)); +end. \ No newline at end of file diff --git a/ReleaseGenerators/PascalABCNETConsoleZIP.bat b/ReleaseGenerators/PascalABCNETConsoleZIP.bat index f8903b37f..773922da7 100644 --- a/ReleaseGenerators/PascalABCNETConsoleZIP.bat +++ b/ReleaseGenerators/PascalABCNETConsoleZIP.bat @@ -1,6 +1,6 @@ cd ..\bin del ..\Release\PACNETConsole.zip -..\utils\pkzipc\pkzipc.exe -add ..\Release\PABCNETC.zip pabcnetc.exe pabcnetcclear.exe Compiler.dll CompilerTools.dll Errors.dll Localization.dll NETGenerator.dll ParserTools.dll ICSharpCode.NRefactory.dll SemanticTree.dll SyntaxTree.dll TreeConverter.dll OptimizerConversion.dll PascalABCParser.dll licence.txt PascalABCNET.chm System.Threading.dll SyntaxTreeConverters.dll YieldHelpers.dll +..\utils\pkzipc\pkzipc.exe -add ..\Release\PABCNETC.zip pabcnetc.exe pabcnetcclear.exe Compiler.dll CompilerTools.dll Errors.dll Localization.dll NETGenerator.dll ParserTools.dll ICSharpCode.NRefactory.dll SemanticTree.dll SyntaxTree.dll TreeConverter.dll OptimizerConversion.dll PascalABCParser.dll licence.txt PascalABCNET.chm System.Threading.dll SyntaxTreeConverters.dll YieldHelpers.dll SyntaxVisitors.dll ..\utils\pkzipc\pkzipc.exe -add -nozip -dir ..\Release\PABCNETC.zip Lib\*.pcu ..\utils\pkzipc\pkzipc.exe -add -nozip -dir ..\Release\PABCNETC.zip Lng\*.dat ..\utils\pkzipc\pkzipc.exe -add -nozip -dir ..\Release\PABCNETC.zip Lng\*.LanguageName diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 8c86c8cc4..e9d214e50 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.2.0.1379' +!define VERSION '3.2.0.1381' diff --git a/ReleaseGenerators/sect_Core.nsh b/ReleaseGenerators/sect_Core.nsh index 6568e08dc..d6b6398c4 100644 --- a/ReleaseGenerators/sect_Core.nsh +++ b/ReleaseGenerators/sect_Core.nsh @@ -11,7 +11,6 @@ File "..\bin\SemanticTree.dll" File "..\bin\SyntaxTree.dll" File "..\bin\SyntaxTreeConverters.dll" - File "..\bin\StandardSyntaxTreeConverter.dll" File "..\bin\SyntaxVisitors.dll" File "..\bin\YieldConversionSyntax.dll" File "..\bin\YieldHelpers.dll" @@ -49,7 +48,6 @@ ${AddFile} "SemanticTree.dll" ${AddFile} "SyntaxTree.dll" ${AddFile} "SyntaxTreeConverters.dll" - ${AddFile} "StandardSyntaxTreeConverter.dll" ${AddFile} "YieldHelpers.dll" ${AddFile} "SyntaxVisitors.dll" ${AddFile} "YieldConversionSyntax.dll" @@ -255,8 +253,6 @@ Call NGEN Push "YieldConversionSyntax.dll" Call NGEN - Push "StandardSyntaxTreeConverter.dll" - Call NGEN ; SetOutPath "$INSTDIR\Output" SectionEnd diff --git a/SyntaxTree/tree/TreeHelper.cs b/SyntaxTree/tree/TreeHelper.cs index 92d1d7f0a..452578b90 100644 --- a/SyntaxTree/tree/TreeHelper.cs +++ b/SyntaxTree/tree/TreeHelper.cs @@ -948,8 +948,28 @@ namespace PascalABCCompiler.SyntaxTree } } + public partial class dot_node + { + public static dot_node NewP(addressed_value avl, addressed_value avr, SourceContext sc) + { + var dn = new dot_node(avl, avr, sc); + if (avl != null) avl.Parent = dn; + if (avr != null) avr.Parent = dn; + return dn; + } + } + + public partial class method_call { + public static method_call NewP(addressed_value av, expression_list el, SourceContext sc) + { + var mc = new method_call(av, el, sc); + if (av != null) av.Parent = mc; + if (el != null) el.Parent = mc; + return mc; + } + /// /// Простое имя метода. Возвращает null, если не удалось такое получить. /// @@ -1640,6 +1660,11 @@ namespace PascalABCCompiler.SyntaxTree } } + public partial class slice_expr + { + public override string ToString() => this.v + "[" + this.from + ":" + this.to + ":" + this.step + "]"; + } + public partial class slice_expr_question { public slice_expr_question(addressed_value v, expression from, expression to, expression step) : base(v, from, to, step) @@ -1648,5 +1673,21 @@ namespace PascalABCCompiler.SyntaxTree { } } + public partial class sugared_addressed_value + { + public static sugared_addressed_value NewP(object sug, addressed_value av, SourceContext sc) + { + var res = new sugared_addressed_value(sug, av, sc); + av.Parent = res; + return res; + } + public override string ToString() + { + return "{sug}" + this.new_addr_value; + } + + } + + } diff --git a/SyntaxTree/tree/WalkingVisitorNew.cs b/SyntaxTree/tree/WalkingVisitorNew.cs index 9b178157f..dd59ce50e 100644 --- a/SyntaxTree/tree/WalkingVisitorNew.cs +++ b/SyntaxTree/tree/WalkingVisitorNew.cs @@ -47,6 +47,7 @@ namespace PascalABCCompiler.SyntaxTree // Можно перенести сюда поскольку замена 1 на 1 позволяет пользоваться текущим DefaultVisit public void ReplaceUsingParent(syntax_tree_node from, syntax_tree_node to) { + to.Parent = from.Parent; if (from.Parent == null) throw new Exception("У корневого элемента нельзя получить Parent"); from.Parent.ReplaceDescendant(from, to); diff --git a/SyntaxVisitors/SugarVisitors/SliceDesugarVisitor.cs b/SyntaxVisitors/SugarVisitors/SliceDesugarVisitor.cs index 9344e1313..9486caf50 100644 --- a/SyntaxVisitors/SugarVisitors/SliceDesugarVisitor.cs +++ b/SyntaxVisitors/SugarVisitors/SliceDesugarVisitor.cs @@ -45,9 +45,10 @@ namespace SyntaxVisitors.SugarVisitors public override void visit(slice_expr sl) { var el = construct_expression_list_for_slice_expr(sl); - 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); + // Проблема в том, что тут тоже надо перепрошивать Parent! + var mc = method_call.NewP(dot_node.NewP(sl.v, new ident("SystemSlice", sl.v.source_context), sl.v.source_context), el, sl.source_context); - var sug = new sugared_addressed_value(sl, mc, sl.source_context); + var sug = sugared_addressed_value.NewP(sl, mc, sl.source_context); ReplaceUsingParent(sl, sug); visit(mc); // обойти заменённое на предмет наличия такого же синтаксического сахара diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index 0c83fbdb1..f2912fc37 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -1205,8 +1205,14 @@ function Odd(i: longword): boolean; function Odd(i: int64): boolean; ///-- function Odd(i: uint64): boolean; + +// ----------------------------------------------------- +//>> Функции для работы с комплексными числами # Functions for Complex numbers +// ----------------------------------------------------- /// Конструирует комплексное число с вещественной частью re и мнимой частью im function Cplx(re,im: real): Complex; +/// Вычисляет квадратный корень из комплексного числа +function Sqrt(c: Complex): Complex; // ----------------------------------------------------- //>> Процедуры для работы со стандартными множествами # Subroutines for set of T @@ -6971,6 +6977,12 @@ begin Result := new Complex(re,im); end; +function Sqrt(c: Complex): Complex; +begin + Result := Complex.Sqrt(c); +end; + + // ----------------------------------------------------- // Dynamic arrays: implementation // ----------------------------------------------------- diff --git a/bin/Lib/PABCRtl.dll b/bin/Lib/PABCRtl.dll index 474d4b5ac..65e5b8cb8 100644 Binary files a/bin/Lib/PABCRtl.dll and b/bin/Lib/PABCRtl.dll differ diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index 0c83fbdb1..f2912fc37 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -1205,8 +1205,14 @@ function Odd(i: longword): boolean; function Odd(i: int64): boolean; ///-- function Odd(i: uint64): boolean; + +// ----------------------------------------------------- +//>> Функции для работы с комплексными числами # Functions for Complex numbers +// ----------------------------------------------------- /// Конструирует комплексное число с вещественной частью re и мнимой частью im function Cplx(re,im: real): Complex; +/// Вычисляет квадратный корень из комплексного числа +function Sqrt(c: Complex): Complex; // ----------------------------------------------------- //>> Процедуры для работы со стандартными множествами # Subroutines for set of T @@ -6971,6 +6977,12 @@ begin Result := new Complex(re,im); end; +function Sqrt(c: Complex): Complex; +begin + Result := Complex.Sqrt(c); +end; + + // ----------------------------------------------------- // Dynamic arrays: implementation // -----------------------------------------------------