diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 3e03bba4d..c040056b8 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 = "1319"; + public const string Revision = "1323"; 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 62591d18e..099b27087 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %COREVERSION%=0 -%REVISION%=1319 +%REVISION%=1323 %MINOR%=2 %MAJOR%=3 diff --git a/Localization/DefaultLang.resources b/Localization/DefaultLang.resources index 56017ee1e..fcdecbba3 100644 Binary files a/Localization/DefaultLang.resources and b/Localization/DefaultLang.resources differ diff --git a/PascalABCNET.axml b/PascalABCNET.axml index 4fd7689e3..f36a2caa7 100644 --- a/PascalABCNET.axml +++ b/PascalABCNET.axml @@ -1207,6 +1207,17 @@ + + \syntaxvisitors\yieldvisitors\processyieldscapturedvars.cs + var pdCloned = ObjectCopier.Clone(pd); + + private void CreateErrorCheckerHelper ( procedure_definition pd ) + public class ProcessYieldCapturedVarsVisitor : BaseChangeVisitor + namespace SyntaxVisitors + + + + diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 2ab7be0f5..c80b6908d 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.2.0.1319' +!define VERSION '3.2.0.1323' diff --git a/StandardSyntaxTreeConverter/StandardSyntaxConverters.cs b/StandardSyntaxTreeConverter/StandardSyntaxConverters.cs index ef491d09a..9bac78c71 100644 --- a/StandardSyntaxTreeConverter/StandardSyntaxConverters.cs +++ b/StandardSyntaxTreeConverter/StandardSyntaxConverters.cs @@ -11,7 +11,7 @@ namespace PascalABCCompiler.SyntaxTreeConverters public string Name { get; } = "Standard"; public syntax_tree_node Convert(syntax_tree_node root) { - //FillParentNodeVisitor.New.ProcessNode(root); // прошивание ссылками на Parent nodes + FillParentNodeVisitor.New.ProcessNode(root); // прошивание ссылками на Parent nodes // Пока нельзя вызывать - если это делать, то ObjectCopier.Clone провоцирует катастрофически долгое время работы!!! return root; } diff --git a/SyntaxTree/tree/FillParentNodeVisitor.cs b/SyntaxTree/tree/FillParentNodeVisitor.cs index c4a5b679e..2a1682bd0 100644 --- a/SyntaxTree/tree/FillParentNodeVisitor.cs +++ b/SyntaxTree/tree/FillParentNodeVisitor.cs @@ -17,7 +17,7 @@ namespace PascalABCCompiler.SyntaxTree public override void Enter(syntax_tree_node st) { base.Enter(st); - //st.Parent = UpperNode(); + st.Parent = UpperNode(); } } } diff --git a/SyntaxVisitors/ObjectCopier.cs b/SyntaxVisitors/ObjectCopier.cs index 822ad3bfc..d740c41a8 100644 --- a/SyntaxVisitors/ObjectCopier.cs +++ b/SyntaxVisitors/ObjectCopier.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using PascalABCCompiler.SyntaxTree; namespace SyntaxVisitors { @@ -25,18 +26,18 @@ namespace SyntaxVisitors /// The object instance to copy. /// The copied object. public static T Clone(T source) + where T: syntax_tree_node { - if (!typeof(T).IsSerializable) - { - throw new ArgumentException("The type must be serializable.", "source"); - } - - // Don't serialize a null object, simply return the default for that object if (Object.ReferenceEquals(source, null)) { return default(T); } + /*if (!typeof(T).IsSerializable) + { + throw new ArgumentException("The type must be serializable.", "source"); + } + IFormatter formatter = new BinaryFormatter(); Stream stream = new MemoryStream(); using (stream) @@ -44,7 +45,8 @@ namespace SyntaxVisitors formatter.Serialize(stream, source); stream.Seek(0, SeekOrigin.Begin); return (T)formatter.Deserialize(stream); - } + }*/ + return (T)source.Clone(); } } } diff --git a/SyntaxVisitors/YieldVisitors/ProcessYieldsCapturedVars.cs b/SyntaxVisitors/YieldVisitors/ProcessYieldsCapturedVars.cs index c85e51914..57ffa58ad 100644 --- a/SyntaxVisitors/YieldVisitors/ProcessYieldsCapturedVars.cs +++ b/SyntaxVisitors/YieldVisitors/ProcessYieldsCapturedVars.cs @@ -213,7 +213,10 @@ namespace SyntaxVisitors if (decls != null) { // frninja 12/05/16 - забыли копировать return - function_header nfh = ObjectCopier.Clone(fh); + //function_header nfh = ObjectCopier.Clone(fh); + + function_header nfh = fh.TypedClone(); + //function_header nfh = new function_header(); //nfh.name = new method_name(fh.name.meth_name.name); @@ -415,6 +418,7 @@ namespace SyntaxVisitors if (pd.proc_header.where_defs != null) { return ObjectCopier.Clone(pd.proc_header.where_defs); + //return pd.proc_header.where_defs.TypedClone(); } else { @@ -426,6 +430,7 @@ namespace SyntaxVisitors if (pdPredefs.Count() > 0) { return ObjectCopier.Clone(pdPredefs.First().proc_header.where_defs); + //return pdPredefs.First().proc_header.where_defs.TypedClone(); } } } @@ -587,7 +592,8 @@ namespace SyntaxVisitors private void CreateErrorCheckerHelper(procedure_definition pd) { // Клонируем исходный метод для проверок ошибок бэкендом - var pdCloned = ObjectCopier.Clone(pd); + //var pdCloned = ObjectCopier.Clone(pd); + var pdCloned = (procedure_definition)pd.Clone(); pdCloned.has_yield = false; @@ -613,7 +619,8 @@ namespace SyntaxVisitors // Клонируем исходный метод для вставки оберток-хелперов для локальных переменных и дальнейшей обработки на семантике var pdCloned = ObjectCopier.Clone(pd); - //var pdCloned = pd; + //pd. + //var pdCloned = (procedure_definition)pd.Clone(); pdCloned.has_yield = false; diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index 252320e00..36f7338e2 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -3755,17 +3755,20 @@ end; function SeqRandom(n: integer; a: integer; b: integer): sequence of integer; begin - Result := Range(1,n).Select(i->Random(a,b)) + for var i:=1 to n do + yield Random(a,b) end; function SeqRandomInteger(n: integer; a: integer; b: integer): sequence of integer; begin - Result := Range(1,n).Select(i->Random(a,b)) + for var i:=1 to n do + yield Random(a,b) end; function SeqRandomReal(n: integer; a: real; b: real): sequence of real; begin - Result := Range(1,n).Select(i->Random()*(b-a)+a) + for var i:=1 to n do + yield Random()*(b-a)+a end; function Arr(params a: array of T): array of T; diff --git a/bin/Lib/PABCRtl.dll b/bin/Lib/PABCRtl.dll index 7f8688f74..a776211a8 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 252320e00..36f7338e2 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -3755,17 +3755,20 @@ end; function SeqRandom(n: integer; a: integer; b: integer): sequence of integer; begin - Result := Range(1,n).Select(i->Random(a,b)) + for var i:=1 to n do + yield Random(a,b) end; function SeqRandomInteger(n: integer; a: integer; b: integer): sequence of integer; begin - Result := Range(1,n).Select(i->Random(a,b)) + for var i:=1 to n do + yield Random(a,b) end; function SeqRandomReal(n: integer; a: real; b: real): sequence of real; begin - Result := Range(1,n).Select(i->Random()*(b-a)+a) + for var i:=1 to n do + yield Random()*(b-a)+a end; function Arr(params a: array of T): array of T; diff --git a/bin/Lng/Eng/SemanticErrors_ms.dat b/bin/Lng/Eng/SemanticErrors_ms.dat index 6ea29f665..bab27bee1 100644 --- a/bin/Lng/Eng/SemanticErrors_ms.dat +++ b/bin/Lng/Eng/SemanticErrors_ms.dat @@ -7,3 +7,4 @@ TUPLE_TYPE_ERROR=Bad element in Tuple type INTEGER_VALUE_EXPECTED=Integer value expected BAD_SLICE_OBJECT=Slices are allowed for strings, dynamic arrays and lists only ONLY_IN_SHORT_FUNC_DEFS_RETURN_TYPE_CANBE_OMITTED=Only in short function definitions you can omit the return type +ONE_TKIDENTIFIER=Type here must be identifier diff --git a/bin/Lng/Rus/SemanticErrors_ms.dat b/bin/Lng/Rus/SemanticErrors_ms.dat index 7246e9599..925281c3b 100644 --- a/bin/Lng/Rus/SemanticErrors_ms.dat +++ b/bin/Lng/Rus/SemanticErrors_ms.dat @@ -7,3 +7,4 @@ TUPLE_TYPE_ERROR=Ошибочная конструкция при построе INTEGER_VALUE_EXPECTED=Ожидалось значение целого типа BAD_SLICE_OBJECT=Срезы допустимы только для строк, динамических массивов и списков ONLY_IN_SHORT_FUNC_DEFS_RETURN_TYPE_CANBE_OMITTED=Только в коротких определениях функций можно не указывать тип возвращаемого значения +ONE_TKIDENTIFIER=В качестве типа ожидался идентификатор diff --git a/bin/template.pct b/bin/template.pct index 5963f3d9e..c7e6e1701 100644 --- a/bin/template.pct +++ b/bin/template.pct @@ -18,19 +18,19 @@ string boolean [f] -for |:= to do +for var |:= to do [fb] -for |:= to do +for var |:= to do begin end; [fore] -foreach |: in do +foreach var |: in do [foreb] -foreach |: in do +foreach var |: in do begin end; @@ -91,7 +91,7 @@ begin end; [ar] -array[1..|] of ; +array of |; [try] try