a[:][:]
This commit is contained in:
parent
6dd106d950
commit
9967adf5ee
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%COREVERSION%=0
|
||||
%REVISION%=1381
|
||||
%MINOR%=2
|
||||
%REVISION%=1382
|
||||
%COREVERSION%=0
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.2.0.1381'
|
||||
!define VERSION '3.2.0.1382'
|
||||
|
|
|
|||
|
|
@ -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); // обойти заменённое на предмет наличия такого же синтаксического сахара
|
||||
|
|
|
|||
6
TestSuite/CompilationSamples/NestedSlices.pas
Normal file
6
TestSuite/CompilationSamples/NestedSlices.pas
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
begin
|
||||
var a := Arr(1,2,3);
|
||||
a := a[:][:2];
|
||||
a := a?[:]?[:2];
|
||||
Print(a);
|
||||
end.
|
||||
|
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in a new issue