From 9967adf5ee6747b7d63c292e8c1427c62c1d6ac2 Mon Sep 17 00:00:00 2001 From: miks1965 Date: Mon, 6 Feb 2017 11:02:42 +0300 Subject: [PATCH] a[:][:] --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 4 +-- ReleaseGenerators/PascalABCNET_version.nsh | 2 +- .../SugarVisitors/SliceDesugarVisitor.cs | 4 +-- TestSuite/CompilationSamples/NestedSlices.pas | 6 +++++ .../semantic_checks_for_sugar.cs | 25 +++++++++++------- .../TreeConversion/syntax_tree_visitor.cs | 2 +- bin/Lib/PABCRtl.dll | Bin 546816 -> 546816 bytes 8 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 TestSuite/CompilationSamples/NestedSlices.pas diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index c4550a120..5a444f974 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 = "1381"; + public const string Revision = "1382"; 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 82927b619..31fbcfe28 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%COREVERSION%=0 -%REVISION%=1381 %MINOR%=2 +%REVISION%=1382 +%COREVERSION%=0 %MAJOR%=3 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index e9d214e50..d3b710f36 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.2.0.1381' +!define VERSION '3.2.0.1382' diff --git a/SyntaxVisitors/SugarVisitors/SliceDesugarVisitor.cs b/SyntaxVisitors/SugarVisitors/SliceDesugarVisitor.cs index 9486caf50..110f36758 100644 --- a/SyntaxVisitors/SugarVisitors/SliceDesugarVisitor.cs +++ b/SyntaxVisitors/SugarVisitors/SliceDesugarVisitor.cs @@ -57,9 +57,9 @@ namespace SyntaxVisitors.SugarVisitors public override void visit(slice_expr_question sl) { var el = construct_expression_list_for_slice_expr(sl); - var mc = new method_call(new dot_node(sl.v, new ident("SystemSliceQuestion", sl.v.source_context), sl.v.source_context), el, sl.source_context); + var mc = method_call.NewP(dot_node.NewP(sl.v, new ident("SystemSliceQuestion", 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/NestedSlices.pas b/TestSuite/CompilationSamples/NestedSlices.pas new file mode 100644 index 000000000..e1e72fc39 --- /dev/null +++ b/TestSuite/CompilationSamples/NestedSlices.pas @@ -0,0 +1,6 @@ +begin + var a := Arr(1,2,3); + a := a[:][:2]; + a := a?[:]?[:2]; + Print(a); +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/semantic_checks_for_sugar.cs b/TreeConverter/TreeConversion/semantic_checks_for_sugar.cs index 17d247343..61c12a969 100644 --- a/TreeConverter/TreeConversion/semantic_checks_for_sugar.cs +++ b/TreeConverter/TreeConversion/semantic_checks_for_sugar.cs @@ -28,9 +28,14 @@ namespace PascalABCCompiler.TreeConverter AddError(get_location(asstup.vars), "TOO_MANY_ELEMENTS_ON_LEFT_SIDE_OF_TUPLE_ASSIGNMRNT"); } - void semantic_check_slice_expr(SyntaxTree.slice_expr sl) + void semantic_check_method_call_as_slice_expr(SyntaxTree.method_call mc) { - var semvar = convert_strong(sl.v); + var v = (mc.dereferencing_value as dot_node).left; + var from = mc.parameters.expressions[1]; + var to = mc.parameters.expressions[2]; + expression step = mc.parameters.expressions.Count > 3 ? mc.parameters.expressions[3] : null; + + var semvar = convert_strong(v); if (semvar is typed_expression) semvar = convert_typed_expression_to_function_call(semvar as typed_expression); @@ -54,24 +59,24 @@ namespace PascalABCCompiler.TreeConverter } if (IsSlicedType == 0) - AddError(get_location(sl.v), "BAD_SLICE_OBJECT"); + AddError(get_location(v), "BAD_SLICE_OBJECT"); - var semfrom = convert_strong(sl.from); + var semfrom = convert_strong(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"); + AddError(get_location(from), "INTEGER_VALUE_EXPECTED"); - var semto = convert_strong(sl.to); + var semto = convert_strong(to); b = convertion_data_and_alghoritms.can_convert_type(semto, SystemLibrary.SystemLibrary.integer_type); if (!b) - AddError(get_location(sl.to), "INTEGER_VALUE_EXPECTED"); + AddError(get_location(to), "INTEGER_VALUE_EXPECTED"); - if (sl.step != null) + if (step != null) { - var semstep = convert_strong(sl.step); + var semstep = convert_strong(step); b = convertion_data_and_alghoritms.can_convert_type(semstep, SystemLibrary.SystemLibrary.integer_type); if (!b) - AddError(get_location(sl.step), "INTEGER_VALUE_EXPECTED"); + AddError(get_location(step), "INTEGER_VALUE_EXPECTED"); } } diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index 16744d8f9..eeb5455f4 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -19377,7 +19377,7 @@ namespace PascalABCCompiler.TreeConverter { if (av.sugared_expr is SyntaxTree.slice_expr) // и slice_expr_question { - semantic_check_slice_expr(av.sugared_expr as SyntaxTree.slice_expr); + semantic_check_method_call_as_slice_expr(av.new_addr_value as SyntaxTree.method_call); } else { diff --git a/bin/Lib/PABCRtl.dll b/bin/Lib/PABCRtl.dll index 65e5b8cb8edc321fa3a0d3a868c3fcc6ce34d5bc..0d135b58a9d7b04c7a6f3ee324f6a1e3426c46fe 100644 GIT binary patch delta 234 zcmVITW`{s|rA%Jri69OjBRC=u`+81HNHwxBvhE delta 234 zcmV9zfaw}3<{s?JjkkMS zheVZD9}Ry64LyfPF1?@i?}P?EBi~2#!3yOmM2vEZ5;cZNQ`b+g