Исправление s[^1] в zerobasedstrings
This commit is contained in:
parent
c70063db15
commit
3396fddd6b
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "8";
|
||||
public const string Build = "1";
|
||||
public const string Revision = "2979";
|
||||
public const string Revision = "2980";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%MINOR%=8
|
||||
%REVISION%=2979
|
||||
%COREVERSION%=1
|
||||
%REVISION%=2980
|
||||
%MINOR%=8
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
3.8.1.2979
|
||||
3.8.1.2980
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.8.1.2979'
|
||||
!define VERSION '3.8.1.2980'
|
||||
|
|
|
|||
|
|
@ -820,6 +820,11 @@ type
|
|||
Result := str.Length - IndexValue + 1;
|
||||
end;
|
||||
|
||||
function Reverse0(str: string): integer;
|
||||
begin
|
||||
Result := str.Length - IndexValue;
|
||||
end;
|
||||
|
||||
function Reverse(arr: System.Array; dim: integer): integer;
|
||||
begin
|
||||
Result := arr.GetLength(dim) - IndexValue;
|
||||
|
|
|
|||
8
TestSuite/zerobased_with_index_fromend.pas
Normal file
8
TestSuite/zerobased_with_index_fromend.pas
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{$zerobasedstrings}
|
||||
begin
|
||||
var s := 'ABCD';
|
||||
Assert(s[^1]='D');
|
||||
Assert(s[^2]='C');
|
||||
Assert(s[^3]='B');
|
||||
Assert(s[^4]='A');
|
||||
end.
|
||||
|
|
@ -5417,7 +5417,6 @@ namespace PascalABCCompiler.TreeConverter
|
|||
semantic_node sn = convert_semantic_strong(_dot_node.left);
|
||||
|
||||
// SSM 17/07/21 учёт ZeroBasedStrings в семантике срезов строк
|
||||
// Пока не получилось
|
||||
if (SemanticRules.ZeroBasedStrings
|
||||
&& (sn as expression_node)?.type is compiled_type_node ctn && ctn.compiled_type == typeof(string)
|
||||
&& _dot_node.right is ident id0
|
||||
|
|
@ -5427,11 +5426,25 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|| id0.name.ToLower() == "systemslicequestion"
|
||||
|| id0.name.ToLower() == "systemsliceassignment"
|
||||
)
|
||||
id0.name += "0";
|
||||
id0.name += "0"; // SystemSlice0
|
||||
}
|
||||
|
||||
// SSM 04/09/21 учёт ZeroBasedStrings в s[^1]
|
||||
if (SemanticRules.ZeroBasedStrings
|
||||
&& (sn as expression_node)?.type.BaseFullName == "PABCSystem.SystemIndex"
|
||||
&& _dot_node.right is ident id1
|
||||
&& id1.name.ToLower() == "reverse"
|
||||
&& _method_call.parameters.Count == 1)
|
||||
{
|
||||
var strtn = convert_strong(_method_call.parameters.expressions[0]);
|
||||
if (strtn.type is compiled_type_node strtnc && strtnc.compiled_type == typeof(string)) // Уф
|
||||
{
|
||||
id1.name += "0"; // Reverse0
|
||||
}
|
||||
}
|
||||
|
||||
//SyntaxTree.ident id_right = ConvertOperatorNameToIdent(_dot_node.right as SyntaxTree.ident);
|
||||
SyntaxTree.ident id_right = _dot_node.right as SyntaxTree.ident;
|
||||
SyntaxTree.ident id_right = _dot_node.right as SyntaxTree.ident;
|
||||
switch (sn.general_node_type)
|
||||
{
|
||||
case general_node_type.expression:
|
||||
|
|
|
|||
|
|
@ -820,6 +820,11 @@ type
|
|||
Result := str.Length - IndexValue + 1;
|
||||
end;
|
||||
|
||||
function Reverse0(str: string): integer;
|
||||
begin
|
||||
Result := str.Length - IndexValue;
|
||||
end;
|
||||
|
||||
function Reverse(arr: System.Array; dim: integer): integer;
|
||||
begin
|
||||
Result := arr.GetLength(dim) - IndexValue;
|
||||
|
|
|
|||
Loading…
Reference in a new issue