Merge branch 'master' into uses-in-new
This commit is contained in:
commit
8c4c5e2d8f
|
|
@ -3441,9 +3441,28 @@ namespace CodeFormatters
|
||||||
}
|
}
|
||||||
public override void visit(bigint_const bi)
|
public override void visit(bigint_const bi)
|
||||||
{
|
{
|
||||||
visit(new uint64_const(bi.val,bi.source_context));
|
visit(new uint64_const(bi.val, bi.source_context));
|
||||||
//sb.Append("bi");
|
//sb.Append("bi");
|
||||||
}
|
}
|
||||||
|
public override void visit(foreach_stmt_formatting fe)
|
||||||
|
{
|
||||||
|
WriteKeyword("foreach");
|
||||||
|
SetKeywordOffset("foreach");
|
||||||
|
sb.Append(" var (");
|
||||||
|
visit_node(fe.il);
|
||||||
|
add_space_after = true;
|
||||||
|
add_space_before = true;
|
||||||
|
visit_node(fe.in_what);
|
||||||
|
if (!in_one_row(fe.stmt))
|
||||||
|
add_newline_after = true;
|
||||||
|
add_space_before = true;
|
||||||
|
bool need_off = !(fe.stmt is statement_list);
|
||||||
|
if (need_off)
|
||||||
|
IncOffset();
|
||||||
|
visit_node(fe.stmt);
|
||||||
|
if (need_off)
|
||||||
|
DecOffset();
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1292,6 +1292,8 @@ namespace PascalABCCompiler.PCU
|
||||||
return GetGenericParameterOfFunction();
|
return GetGenericParameterOfFunction();
|
||||||
case 11:
|
case 11:
|
||||||
return GetGenericParameterOfMethod();
|
return GetGenericParameterOfMethod();
|
||||||
|
case 12:
|
||||||
|
return new lambda_any_type_node();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,8 @@ namespace PascalABCCompiler.PCU
|
||||||
ShortString = 8,
|
ShortString = 8,
|
||||||
GenericParameterOfType = 9,
|
GenericParameterOfType = 9,
|
||||||
GenericParameterOfFunction = 10,
|
GenericParameterOfFunction = 10,
|
||||||
GenericParameterOfMethod = 11
|
GenericParameterOfMethod = 11,
|
||||||
|
LambdaAnyType = 12
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum GenericParamKind
|
public enum GenericParamKind
|
||||||
|
|
@ -1395,6 +1396,12 @@ namespace PascalABCCompiler.PCU
|
||||||
WriteTemplateInstance(c_t_n);
|
WriteTemplateInstance(c_t_n);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type is lambda_any_type_node)
|
||||||
|
{
|
||||||
|
bw.Write((byte)TypeKind.LambdaAnyType);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
byte is_def = 0;
|
byte is_def = 0;
|
||||||
int offset = GetTypeReference(type, ref is_def);
|
int offset = GetTypeReference(type, ref is_def);
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
||||||
public const string Major = "3";
|
public const string Major = "3";
|
||||||
public const string Minor = "7";
|
public const string Minor = "7";
|
||||||
public const string Build = "1";
|
public const string Build = "1";
|
||||||
public const string Revision = "2746";
|
public const string Revision = "2768";
|
||||||
|
|
||||||
public const string MainVersion = Major + "." + Minor;
|
public const string MainVersion = Major + "." + Minor;
|
||||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
%COREVERSION%=1
|
%COREVERSION%=1
|
||||||
%REVISION%=2746
|
%REVISION%=2768
|
||||||
%MINOR%=7
|
%MINOR%=7
|
||||||
%MAJOR%=3
|
%MAJOR%=3
|
||||||
|
|
|
||||||
6
InstallerSamples/Algorithms/Combinatorics/NextPerm.pas
Normal file
6
InstallerSamples/Algorithms/Combinatorics/NextPerm.pas
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
begin
|
||||||
|
var a := Arr(1..4);
|
||||||
|
repeat
|
||||||
|
a.Println;
|
||||||
|
until not NextPermutation(a);
|
||||||
|
end.
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
// Сериализация объектов
|
||||||
|
// Можно сериализовать только объекты, помеченные атрибутом [Serializable]
|
||||||
|
// Внешние Serialize, Deserialize позволяют сохранить в файле - восстановить
|
||||||
|
// один объект (один граф объектов с данным корнем)
|
||||||
|
type
|
||||||
|
[Serializable]
|
||||||
|
Node = auto class
|
||||||
|
x: integer;
|
||||||
|
next: Node;
|
||||||
|
end;
|
||||||
|
|
||||||
|
const fname = 'a.dat';
|
||||||
|
|
||||||
|
begin
|
||||||
|
var m := new Node(5,new Node(3,new Node(4,nil)));
|
||||||
|
Serialize(fname,m); // Сериализуем объект в файл
|
||||||
|
var m1 := Deserialize(fname) as Node; // Десериализуем из файла
|
||||||
|
Print(m1);
|
||||||
|
end.
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
// Сериализация объектов
|
||||||
|
// Можно сериализовать только объекты, помеченные атрибутом [Serializable]
|
||||||
|
// Внешние Serialize, Deserialize позволяют сохранить в файле - восстановить
|
||||||
|
// один объект (один граф объектов с данным корнем)
|
||||||
|
type
|
||||||
|
[Serializable]
|
||||||
|
My = auto class
|
||||||
|
x,y: integer;
|
||||||
|
end;
|
||||||
|
IntArray = array of integer;
|
||||||
|
|
||||||
|
const fname = 'a.dat';
|
||||||
|
|
||||||
|
begin
|
||||||
|
var f := CreateBinary(fname);
|
||||||
|
f.Serialize(new My(444,555));
|
||||||
|
f.Serialize(|1,2,3|);
|
||||||
|
f.Serialize(Lst(1..9));
|
||||||
|
f.Close;
|
||||||
|
|
||||||
|
f := OpenBinary(fname);
|
||||||
|
var m: My := f.Deserialize as My;
|
||||||
|
var a: array of integer := f.Deserialize as IntArray;
|
||||||
|
var l: List<integer> := f.Deserialize as List<integer>;
|
||||||
|
f.Close;
|
||||||
|
|
||||||
|
Print(m,a,l);
|
||||||
|
end.
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
// Сериализация объектов
|
||||||
|
// Можно сериализовать только объекты, помеченные атрибутом [Serializable]
|
||||||
|
// Внешние Serialize, Deserialize позволяют сохранить в файле - восстановить
|
||||||
|
// один объект (один граф объектов с данным корнем)
|
||||||
|
type
|
||||||
|
[Serializable]
|
||||||
|
My = auto class
|
||||||
|
x,y: integer;
|
||||||
|
end;
|
||||||
|
|
||||||
|
const fname = 'a.dat';
|
||||||
|
|
||||||
|
begin
|
||||||
|
var m := new My(2,3);
|
||||||
|
Serialize(fname,m); // Сериализуем объект в файл
|
||||||
|
var m1 := Deserialize(fname) as My; // Десериализуем из файла
|
||||||
|
Print(m1);
|
||||||
|
end.
|
||||||
Binary file not shown.
|
|
@ -2,7 +2,7 @@
|
||||||
// This CSharp output file generated by Gardens Point LEX
|
// This CSharp output file generated by Gardens Point LEX
|
||||||
// Version: 1.1.3.301
|
// Version: 1.1.3.301
|
||||||
// Machine: DESKTOP-G8V08V4
|
// Machine: DESKTOP-G8V08V4
|
||||||
// DateTime: 19.11.2020 11:17:32
|
// DateTime: 03.12.2020 22:26:21
|
||||||
// UserName: ?????????
|
// UserName: ?????????
|
||||||
// GPLEX input file <ABCPascal.lex>
|
// GPLEX input file <ABCPascal.lex>
|
||||||
// GPLEX frame file <embedded resource>
|
// GPLEX frame file <embedded resource>
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@
|
||||||
%type <stn> typed_const_list1 typed_const_list optional_expr_list elem_list optional_expr_list_with_bracket expr_list const_elem_list1 /*const_expr_list*/ case_label_list const_elem_list optional_const_func_expr_list elem_list1
|
%type <stn> typed_const_list1 typed_const_list optional_expr_list elem_list optional_expr_list_with_bracket expr_list const_elem_list1 /*const_expr_list*/ case_label_list const_elem_list optional_const_func_expr_list elem_list1
|
||||||
%type <stn> enumeration_id expr_l1_list
|
%type <stn> enumeration_id expr_l1_list
|
||||||
%type <stn> enumeration_id_list
|
%type <stn> enumeration_id_list
|
||||||
%type <ex> const_simple_expr term term1 typed_const typed_const_plus typed_var_init_expression expr expr_with_func_decl_lambda const_expr elem range_expr const_elem array_const factor factor_without_unary_op relop_expr expr_dq expr_l1 expr_l1_func_decl_lambda expr_l1_for_lambda simple_expr range_term range_factor
|
%type <ex> const_simple_expr term term1 typed_const typed_const_plus typed_var_init_expression expr expr_with_func_decl_lambda const_expr const_relop_expr elem range_expr const_elem array_const factor factor_without_unary_op relop_expr expr_dq expr_l1 expr_l1_func_decl_lambda expr_l1_for_lambda simple_expr range_term range_factor
|
||||||
%type <ex> external_directive_ident init_const_expr case_label variable var_reference /*optional_write_expr*/ optional_read_expr simple_expr_or_nothing var_question_point expr_l1_for_question_expr expr_l1_for_new_question_expr
|
%type <ex> external_directive_ident init_const_expr case_label variable var_reference /*optional_write_expr*/ optional_read_expr simple_expr_or_nothing var_question_point expr_l1_for_question_expr expr_l1_for_new_question_expr
|
||||||
%type <ob> for_cycle_type
|
%type <ob> for_cycle_type
|
||||||
%type <ex> format_expr format_const_expr const_expr_or_nothing /* simple_expr_with_deref_or_nothing simple_expr_with_deref expr_l1_for_indexer*/
|
%type <ex> format_expr format_const_expr const_expr_or_nothing /* simple_expr_with_deref_or_nothing simple_expr_with_deref expr_l1_for_indexer*/
|
||||||
|
|
@ -744,19 +744,28 @@ expr_l1_list
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
const_expr
|
const_relop_expr
|
||||||
: const_simple_expr
|
: const_simple_expr
|
||||||
{
|
{
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
| const_simple_expr const_relop const_simple_expr
|
| const_relop_expr const_relop const_simple_expr
|
||||||
{
|
{
|
||||||
$$ = new bin_expr($1, $3, $2.type, @$);
|
$$ = new bin_expr($1, $3, $2.type, @$);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
const_expr
|
||||||
|
: const_relop_expr
|
||||||
|
{
|
||||||
|
$$ = $1;
|
||||||
|
}
|
||||||
| question_constexpr
|
| question_constexpr
|
||||||
{
|
{
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
|
| const_expr tkDoubleQuestion const_relop_expr
|
||||||
|
{ $$ = new double_question_node($1 as expression, $3 as expression, @$);}
|
||||||
;
|
;
|
||||||
|
|
||||||
question_constexpr
|
question_constexpr
|
||||||
|
|
@ -2971,6 +2980,28 @@ foreach_stmt
|
||||||
{
|
{
|
||||||
$$ = new foreach_stmt($3, new no_type_foreach(), $5, (statement)$7, @$);
|
$$ = new foreach_stmt($3, new no_type_foreach(), $5, (statement)$7, @$);
|
||||||
}
|
}
|
||||||
|
| tkForeach tkVar tkRoundOpen ident_list tkRoundClose tkIn expr_l1 tkDo unlabelled_stmt // ñàõàðíîå ïðàâèëî
|
||||||
|
{
|
||||||
|
if (parsertools.build_tree_for_formatter)
|
||||||
|
{
|
||||||
|
var il = $4 as ident_list;
|
||||||
|
il.source_context = LexLocation.MergeAll(@4,@5); // íóæíî äëÿ ôîðìàòèðîâàíèÿ
|
||||||
|
$$ = new foreach_stmt_formatting(il,$7,$9 as statement,@$);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Åñòü ïðîáëåìà - íåïîíÿòíî, ãäå çäåñü ñäåëàòü ñåìàíò÷åñêèé óçåä äëÿ ïðîâåðêè
|
||||||
|
// Ïðîâåðèòü ìîæíî è â foreach, íî ãäå-òî äîëæåí áûòü ìàðêåð, ÷òî ýòî ñàõàðíûé óçåë
|
||||||
|
// Íàïðèìåð, èäåíòèôèêàòîð #fe - íî ýòî ïëîõàÿ èäåÿ
|
||||||
|
var id = NewId("#fe",@4);
|
||||||
|
var tttt = new assign_var_tuple($4 as ident_list, id, @$);
|
||||||
|
statement_list nine = $9 is statement_list ? $9 as statement_list : new statement_list($9 as statement,@9);
|
||||||
|
nine.Insert(0,tttt);
|
||||||
|
var fe = new foreach_stmt(id, new no_type_foreach(), $7, nine, @$);
|
||||||
|
fe.ext = $4 as ident_list;
|
||||||
|
$$ = fe;
|
||||||
|
}
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
foreach_stmt_ident_dype_opt
|
foreach_stmt_ident_dype_opt
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -2,7 +2,6 @@
|
||||||
<tags>
|
<tags>
|
||||||
<tag value="Выражения">
|
<tag value="Выражения">
|
||||||
<name value="stmt_or_expression" />
|
<name value="stmt_or_expression" />
|
||||||
<name value="const_expr" />
|
|
||||||
<name value="question_constexpr" />
|
<name value="question_constexpr" />
|
||||||
<name value="const_simple_expr" />
|
<name value="const_simple_expr" />
|
||||||
<name value="as_is_constexpr" />
|
<name value="as_is_constexpr" />
|
||||||
|
|
@ -130,7 +129,6 @@
|
||||||
<name value="array_const" />
|
<name value="array_const" />
|
||||||
<name value="question_constexpr" />
|
<name value="question_constexpr" />
|
||||||
<name value="init_const_expr" />
|
<name value="init_const_expr" />
|
||||||
<name value="const_expr" />
|
|
||||||
<name value="const_elem" />
|
<name value="const_elem" />
|
||||||
<name value="record_const" />
|
<name value="record_const" />
|
||||||
<name value="const_simple_expr" />
|
<name value="const_simple_expr" />
|
||||||
|
|
@ -150,7 +148,6 @@
|
||||||
<name value="question_constexpr" />
|
<name value="question_constexpr" />
|
||||||
<name value="init_const_expr" />
|
<name value="init_const_expr" />
|
||||||
<name value="const_name" />
|
<name value="const_name" />
|
||||||
<name value="const_expr" />
|
|
||||||
<name value="const_elem" />
|
<name value="const_elem" />
|
||||||
<name value="literal_or_number" />
|
<name value="literal_or_number" />
|
||||||
<name value="const_simple_expr" />
|
<name value="const_simple_expr" />
|
||||||
|
|
@ -322,7 +319,6 @@
|
||||||
<name value="var_decl_part" />
|
<name value="var_decl_part" />
|
||||||
<name value="typed_const" />
|
<name value="typed_const" />
|
||||||
<name value="var_stmt" />
|
<name value="var_stmt" />
|
||||||
<name value="const_expr" />
|
|
||||||
<name value="func_decl_lambda" />
|
<name value="func_decl_lambda" />
|
||||||
</tag>
|
</tag>
|
||||||
</tags>
|
</tags>
|
||||||
|
|
@ -283,6 +283,14 @@ script=
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ _ReBuildRelease.bat builds the project in Release-mode.
|
||||||
|
|
||||||
_ReBuildDebug.bat builds the project in Debug-mode.
|
_ReBuildDebug.bat builds the project in Debug-mode.
|
||||||
|
|
||||||
PascalABC is being developed in Visual Studio Community 2017.
|
PascalABC is being developed in Visual Studio Community 2019.
|
||||||
|
|
||||||
## Building PascalABC.NET in Linux (Ubuntu)
|
## Building PascalABC.NET in Linux (Ubuntu)
|
||||||
Install Mono (http://www.mono-project.com/docs/getting-started/install/linux/)
|
Install Mono (http://www.mono-project.com/docs/getting-started/install/linux/)
|
||||||
|
|
@ -60,7 +60,7 @@ _ReBuildRelease.bat собирает проект в Release-режиме.
|
||||||
_ReBuildDebug.bat собирает проект в Debug-режиме.
|
_ReBuildDebug.bat собирает проект в Debug-режиме.
|
||||||
|
|
||||||
|
|
||||||
Разработка ведется в Visual Studio Community 2017.
|
Разработка ведется в Visual Studio Community 2019.
|
||||||
|
|
||||||
## Сборка проекта в Linux (Ubuntu)
|
## Сборка проекта в Linux (Ubuntu)
|
||||||
Установка Mono (http://www.mono-project.com/docs/getting-started/install/linux/)
|
Установка Mono (http://www.mono-project.com/docs/getting-started/install/linux/)
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
3.7.1.2746
|
3.7.1.2768
|
||||||
|
|
|
||||||
BIN
ReleaseGenerators/1049/IlDasmrc.dll
Normal file
BIN
ReleaseGenerators/1049/IlDasmrc.dll
Normal file
Binary file not shown.
BIN
ReleaseGenerators/1049/TrackerUI.dll
Normal file
BIN
ReleaseGenerators/1049/TrackerUI.dll
Normal file
Binary file not shown.
BIN
ReleaseGenerators/1049/flogvwrc.dll
Normal file
BIN
ReleaseGenerators/1049/flogvwrc.dll
Normal file
Binary file not shown.
BIN
ReleaseGenerators/1049/gacutlrc.dll
Normal file
BIN
ReleaseGenerators/1049/gacutlrc.dll
Normal file
Binary file not shown.
BIN
ReleaseGenerators/1049/pevrfyrc.dll
Normal file
BIN
ReleaseGenerators/1049/pevrfyrc.dll
Normal file
Binary file not shown.
BIN
ReleaseGenerators/1049/snrc.dll
Normal file
BIN
ReleaseGenerators/1049/snrc.dll
Normal file
Binary file not shown.
|
|
@ -5,7 +5,7 @@ uses
|
||||||
ABCSprites, CRT, DMCollect, DMTaskMaker, DMZadan, Drawman,
|
ABCSprites, CRT, DMCollect, DMTaskMaker, DMZadan, Drawman,
|
||||||
DrawManField, Events, FilesOperations, GraphABC,
|
DrawManField, Events, FilesOperations, GraphABC,
|
||||||
GraphABCHelper, IniFile, PointerTools, PointRect, Robot, RobotField,
|
GraphABCHelper, IniFile, PointerTools, PointRect, Robot, RobotField,
|
||||||
RobotTaskMaker, RobotZadan, Sockets, Utils, VCL, Timers, PT4TaskMakerNET, RBDMUtils, SF, School, BlockFileOfT,
|
RobotTaskMaker, RobotZadan, Sockets, Utils, VCL, Timers, PT4TaskMakerNET, RBDMUtils,
|
||||||
FormsABC, Collections, Arrays, ClientServer, WPFObjects, Controls, Graph3D, GraphWPF, __RedirectIOMode, __RunMode, __RtlUtils;
|
FormsABC, Collections, Arrays, ClientServer, WPFObjects, Controls, Graph3D, GraphWPF, __RedirectIOMode, __RunMode, __RtlUtils;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
@ -5,7 +5,7 @@ uses
|
||||||
ABCSprites, CRT, DMCollect, DMTaskMaker, DMZadan, Drawman,
|
ABCSprites, CRT, DMCollect, DMTaskMaker, DMZadan, Drawman,
|
||||||
DrawManField, Events, FilesOperations, GraphABC,
|
DrawManField, Events, FilesOperations, GraphABC,
|
||||||
GraphABCHelper, IniFile, PointerTools, PointRect, Robot, RobotField,
|
GraphABCHelper, IniFile, PointerTools, PointRect, Robot, RobotField,
|
||||||
RobotTaskMaker, RobotZadan, Sockets, Utils, VCL, Timers, PT4, PT4TaskMakerNET, RBDMUtils, SF, School, BlockFileOfT,
|
RobotTaskMaker, RobotZadan, Sockets, Utils, VCL, Timers, PT4, PT4TaskMakerNET, RBDMUtils,
|
||||||
FormsABC, Collections, Arrays, ClientServer, Graph3D, GraphWPF, WPFObjects, Controls, __RedirectIOMode, __RunMode, __RtlUtils;
|
FormsABC, Collections, Arrays, ClientServer, Graph3D, GraphWPF, WPFObjects, Controls, __RedirectIOMode, __RunMode, __RtlUtils;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
@ -1 +1 @@
|
||||||
!define VERSION '3.7.1.2746'
|
!define VERSION '3.7.1.2768'
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1287,6 +1287,11 @@ namespace PascalABCCompiler.SyntaxTree
|
||||||
{
|
{
|
||||||
DefaultVisit(_bigint_const);
|
DefaultVisit(_bigint_const);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void visit(foreach_stmt_formatting _foreach_stmt_formatting)
|
||||||
|
{
|
||||||
|
DefaultVisit(_foreach_stmt_formatting);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2053,6 +2053,14 @@ namespace PascalABCCompiler.SyntaxTree
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void pre_do_visit(foreach_stmt_formatting _foreach_stmt_formatting)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void post_do_visit(foreach_stmt_formatting _foreach_stmt_formatting)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public override void visit(expression _expression)
|
public override void visit(expression _expression)
|
||||||
{
|
{
|
||||||
DefaultVisit(_expression);
|
DefaultVisit(_expression);
|
||||||
|
|
@ -4238,6 +4246,16 @@ namespace PascalABCCompiler.SyntaxTree
|
||||||
pre_do_visit(_bigint_const);
|
pre_do_visit(_bigint_const);
|
||||||
post_do_visit(_bigint_const);
|
post_do_visit(_bigint_const);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void visit(foreach_stmt_formatting _foreach_stmt_formatting)
|
||||||
|
{
|
||||||
|
DefaultVisit(_foreach_stmt_formatting);
|
||||||
|
pre_do_visit(_foreach_stmt_formatting);
|
||||||
|
visit(foreach_stmt_formatting.il);
|
||||||
|
visit(foreach_stmt_formatting.in_what);
|
||||||
|
visit(foreach_stmt_formatting.stmt);
|
||||||
|
post_do_visit(_foreach_stmt_formatting);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -532,6 +532,8 @@ namespace PascalABCCompiler.SyntaxTree
|
||||||
return new semantic_ith_element_of();
|
return new semantic_ith_element_of();
|
||||||
case 255:
|
case 255:
|
||||||
return new bigint_const();
|
return new bigint_const();
|
||||||
|
case 256:
|
||||||
|
return new foreach_stmt_formatting();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -4459,6 +4461,20 @@ namespace PascalABCCompiler.SyntaxTree
|
||||||
_bigint_const.val = br.ReadUInt64();
|
_bigint_const.val = br.ReadUInt64();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void visit(foreach_stmt_formatting _foreach_stmt_formatting)
|
||||||
|
{
|
||||||
|
read_foreach_stmt_formatting(_foreach_stmt_formatting);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void read_foreach_stmt_formatting(foreach_stmt_formatting _foreach_stmt_formatting)
|
||||||
|
{
|
||||||
|
read_statement(_foreach_stmt_formatting);
|
||||||
|
_foreach_stmt_formatting.il = _read_node() as ident_list;
|
||||||
|
_foreach_stmt_formatting.in_what = _read_node() as expression;
|
||||||
|
_foreach_stmt_formatting.stmt = _read_node() as statement;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6972,6 +6972,45 @@ namespace PascalABCCompiler.SyntaxTree
|
||||||
bw.Write(_bigint_const.val);
|
bw.Write(_bigint_const.val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void visit(foreach_stmt_formatting _foreach_stmt_formatting)
|
||||||
|
{
|
||||||
|
bw.Write((Int16)256);
|
||||||
|
write_foreach_stmt_formatting(_foreach_stmt_formatting);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write_foreach_stmt_formatting(foreach_stmt_formatting _foreach_stmt_formatting)
|
||||||
|
{
|
||||||
|
write_statement(_foreach_stmt_formatting);
|
||||||
|
if (_foreach_stmt_formatting.il == null)
|
||||||
|
{
|
||||||
|
bw.Write((byte)0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bw.Write((byte)1);
|
||||||
|
_foreach_stmt_formatting.il.visit(this);
|
||||||
|
}
|
||||||
|
if (_foreach_stmt_formatting.in_what == null)
|
||||||
|
{
|
||||||
|
bw.Write((byte)0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bw.Write((byte)1);
|
||||||
|
_foreach_stmt_formatting.in_what.visit(this);
|
||||||
|
}
|
||||||
|
if (_foreach_stmt_formatting.stmt == null)
|
||||||
|
{
|
||||||
|
bw.Write((byte)0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bw.Write((byte)1);
|
||||||
|
_foreach_stmt_formatting.stmt.visit(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54521,6 +54521,229 @@ namespace PascalABCCompiler.SyntaxTree
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
///// для форматирования только
|
||||||
|
///</summary>
|
||||||
|
[Serializable]
|
||||||
|
public partial class foreach_stmt_formatting : statement
|
||||||
|
{
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
///Конструктор без параметров.
|
||||||
|
///</summary>
|
||||||
|
public foreach_stmt_formatting()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
///Конструктор с параметрами.
|
||||||
|
///</summary>
|
||||||
|
public foreach_stmt_formatting(ident_list _il,expression _in_what,statement _stmt)
|
||||||
|
{
|
||||||
|
this._il=_il;
|
||||||
|
this._in_what=_in_what;
|
||||||
|
this._stmt=_stmt;
|
||||||
|
FillParentsInDirectChilds();
|
||||||
|
}
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
///Конструктор с параметрами.
|
||||||
|
///</summary>
|
||||||
|
public foreach_stmt_formatting(ident_list _il,expression _in_what,statement _stmt,SourceContext sc)
|
||||||
|
{
|
||||||
|
this._il=_il;
|
||||||
|
this._in_what=_in_what;
|
||||||
|
this._stmt=_stmt;
|
||||||
|
source_context = sc;
|
||||||
|
FillParentsInDirectChilds();
|
||||||
|
}
|
||||||
|
protected ident_list _il;
|
||||||
|
protected expression _in_what;
|
||||||
|
protected statement _stmt;
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
///
|
||||||
|
///</summary>
|
||||||
|
public ident_list il
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _il;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_il=value;
|
||||||
|
if (_il != null)
|
||||||
|
_il.Parent = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
///
|
||||||
|
///</summary>
|
||||||
|
public expression in_what
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _in_what;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_in_what=value;
|
||||||
|
if (_in_what != null)
|
||||||
|
_in_what.Parent = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
///
|
||||||
|
///</summary>
|
||||||
|
public statement stmt
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _stmt;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_stmt=value;
|
||||||
|
if (_stmt != null)
|
||||||
|
_stmt.Parent = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary> Создает копию узла </summary>
|
||||||
|
public override syntax_tree_node Clone()
|
||||||
|
{
|
||||||
|
foreach_stmt_formatting copy = new foreach_stmt_formatting();
|
||||||
|
copy.Parent = this.Parent;
|
||||||
|
if (source_context != null)
|
||||||
|
copy.source_context = new SourceContext(source_context);
|
||||||
|
if (attributes != null)
|
||||||
|
{
|
||||||
|
copy.attributes = (attribute_list)attributes.Clone();
|
||||||
|
copy.attributes.Parent = copy;
|
||||||
|
}
|
||||||
|
if (il != null)
|
||||||
|
{
|
||||||
|
copy.il = (ident_list)il.Clone();
|
||||||
|
copy.il.Parent = copy;
|
||||||
|
}
|
||||||
|
if (in_what != null)
|
||||||
|
{
|
||||||
|
copy.in_what = (expression)in_what.Clone();
|
||||||
|
copy.in_what.Parent = copy;
|
||||||
|
}
|
||||||
|
if (stmt != null)
|
||||||
|
{
|
||||||
|
copy.stmt = (statement)stmt.Clone();
|
||||||
|
copy.stmt.Parent = copy;
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Получает копию данного узла корректного типа </summary>
|
||||||
|
public new foreach_stmt_formatting TypedClone()
|
||||||
|
{
|
||||||
|
return Clone() as foreach_stmt_formatting;
|
||||||
|
}
|
||||||
|
|
||||||
|
///<summary> Заполняет поля Parent в непосредственных дочерних узлах </summary>
|
||||||
|
public override void FillParentsInDirectChilds()
|
||||||
|
{
|
||||||
|
if (attributes != null)
|
||||||
|
attributes.Parent = this;
|
||||||
|
if (il != null)
|
||||||
|
il.Parent = this;
|
||||||
|
if (in_what != null)
|
||||||
|
in_what.Parent = this;
|
||||||
|
if (stmt != null)
|
||||||
|
stmt.Parent = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
///<summary> Заполняет поля Parent во всем поддереве </summary>
|
||||||
|
public override void FillParentsInAllChilds()
|
||||||
|
{
|
||||||
|
FillParentsInDirectChilds();
|
||||||
|
attributes?.FillParentsInAllChilds();
|
||||||
|
il?.FillParentsInAllChilds();
|
||||||
|
in_what?.FillParentsInAllChilds();
|
||||||
|
stmt?.FillParentsInAllChilds();
|
||||||
|
}
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
///Свойство для получения количества всех подузлов без элементов поля типа List
|
||||||
|
///</summary>
|
||||||
|
public override Int32 subnodes_without_list_elements_count
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
///<summary>
|
||||||
|
///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
|
||||||
|
///</summary>
|
||||||
|
public override Int32 subnodes_count
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
///<summary>
|
||||||
|
///Индексатор для получения всех подузлов
|
||||||
|
///</summary>
|
||||||
|
public override syntax_tree_node this[Int32 ind]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
switch(ind)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return il;
|
||||||
|
case 1:
|
||||||
|
return in_what;
|
||||||
|
case 2:
|
||||||
|
return stmt;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
|
||||||
|
throw new IndexOutOfRangeException();
|
||||||
|
switch(ind)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
il = (ident_list)value;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
in_what = (expression)value;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
stmt = (statement)value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
///<summary>
|
||||||
|
///Метод для обхода дерева посетителем
|
||||||
|
///</summary>
|
||||||
|
///<param name="visitor">Объект-посетитель.</param>
|
||||||
|
///<returns>Return value is void</returns>
|
||||||
|
public override void visit(IVisitor visitor)
|
||||||
|
{
|
||||||
|
visitor.visit(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2025,4 +2025,10 @@ namespace PascalABCCompiler.SyntaxTree
|
||||||
{
|
{
|
||||||
public object sl = null;
|
public object sl = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public partial class foreach_stmt
|
||||||
|
{
|
||||||
|
public object ext = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1540,6 +1540,12 @@ namespace PascalABCCompiler.SyntaxTree
|
||||||
///<param name="_bigint_const">Node to visit</param>
|
///<param name="_bigint_const">Node to visit</param>
|
||||||
///<returns> Return value is void </returns>
|
///<returns> Return value is void </returns>
|
||||||
void visit(bigint_const _bigint_const);
|
void visit(bigint_const _bigint_const);
|
||||||
|
///<summary>
|
||||||
|
///Method to visit foreach_stmt_formatting.
|
||||||
|
///</summary>
|
||||||
|
///<param name="_foreach_stmt_formatting">Node to visit</param>
|
||||||
|
///<returns> Return value is void </returns>
|
||||||
|
void visit(foreach_stmt_formatting _foreach_stmt_formatting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3301,6 +3301,18 @@
|
||||||
<TagIndices />
|
<TagIndices />
|
||||||
</Tags>
|
</Tags>
|
||||||
</SyntaxNode>
|
</SyntaxNode>
|
||||||
|
<SyntaxNode Name="foreach_stmt_formatting" BaseName="statement">
|
||||||
|
<Fields>
|
||||||
|
<SyntaxField Name="il" SyntaxType="ident_list" />
|
||||||
|
<SyntaxField Name="in_what" SyntaxType="expression" />
|
||||||
|
<SyntaxField Name="stmt" SyntaxType="statement" />
|
||||||
|
</Fields>
|
||||||
|
<Methods />
|
||||||
|
<Tags>
|
||||||
|
<CategoryIndices />
|
||||||
|
<TagIndices />
|
||||||
|
</Tags>
|
||||||
|
</SyntaxNode>
|
||||||
</SyntaxNodes>
|
</SyntaxNodes>
|
||||||
<Settings>
|
<Settings>
|
||||||
<FileName>Tree.cs</FileName>
|
<FileName>Tree.cs</FileName>
|
||||||
|
|
@ -3370,6 +3382,8 @@
|
||||||
<HelpData Key=".i" Value="" />
|
<HelpData Key=".i" Value="" />
|
||||||
<HelpData Key=".if_false" Value="" />
|
<HelpData Key=".if_false" Value="" />
|
||||||
<HelpData Key=".if_true" Value="" />
|
<HelpData Key=".if_true" Value="" />
|
||||||
|
<HelpData Key=".il" Value="" />
|
||||||
|
<HelpData Key=".in_what" Value="" />
|
||||||
<HelpData Key=".index" Value="" />
|
<HelpData Key=".index" Value="" />
|
||||||
<HelpData Key=".index_expr" Value="" />
|
<HelpData Key=".index_expr" Value="" />
|
||||||
<HelpData Key=".inverted" Value="" />
|
<HelpData Key=".inverted" Value="" />
|
||||||
|
|
@ -3400,6 +3414,7 @@
|
||||||
<HelpData Key=".stat" Value="" />
|
<HelpData Key=".stat" Value="" />
|
||||||
<HelpData Key=".statements" Value="" />
|
<HelpData Key=".statements" Value="" />
|
||||||
<HelpData Key=".step" Value="" />
|
<HelpData Key=".step" Value="" />
|
||||||
|
<HelpData Key=".stmt" Value="" />
|
||||||
<HelpData Key=".string" Value="" />
|
<HelpData Key=".string" Value="" />
|
||||||
<HelpData Key=".subprogram_definitions" Value="" />
|
<HelpData Key=".subprogram_definitions" Value="" />
|
||||||
<HelpData Key=".substitution" Value="" />
|
<HelpData Key=".substitution" Value="" />
|
||||||
|
|
@ -3411,6 +3426,7 @@
|
||||||
<HelpData Key=".to" Value="" />
|
<HelpData Key=".to" Value="" />
|
||||||
<HelpData Key=".typ" Value="" />
|
<HelpData Key=".typ" Value="" />
|
||||||
<HelpData Key=".type" Value="" />
|
<HelpData Key=".type" Value="" />
|
||||||
|
<HelpData Key=".type_name" Value="" />
|
||||||
<HelpData Key=".types" Value="" />
|
<HelpData Key=".types" Value="" />
|
||||||
<HelpData Key=".unknown_foreach" Value="" />
|
<HelpData Key=".unknown_foreach" Value="" />
|
||||||
<HelpData Key=".usings" Value="" />
|
<HelpData Key=".usings" Value="" />
|
||||||
|
|
@ -3842,10 +3858,16 @@
|
||||||
<HelpData Key="for_node.type_name" Value="" />
|
<HelpData Key="for_node.type_name" Value="" />
|
||||||
<HelpData Key="foreach_stmt" Value="" />
|
<HelpData Key="foreach_stmt" Value="" />
|
||||||
<HelpData Key="foreach_stmt." Value="" />
|
<HelpData Key="foreach_stmt." Value="" />
|
||||||
|
<HelpData Key="foreach_stmt.ext" Value="" />
|
||||||
<HelpData Key="foreach_stmt.identifier" Value="" />
|
<HelpData Key="foreach_stmt.identifier" Value="" />
|
||||||
<HelpData Key="foreach_stmt.in_what" Value="" />
|
<HelpData Key="foreach_stmt.in_what" Value="" />
|
||||||
<HelpData Key="foreach_stmt.stmt" Value="" />
|
<HelpData Key="foreach_stmt.stmt" Value="" />
|
||||||
<HelpData Key="foreach_stmt.type_name" Value="" />
|
<HelpData Key="foreach_stmt.type_name" Value="" />
|
||||||
|
<HelpData Key="foreach_stmt_formatting" Value="// для форматирования только" />
|
||||||
|
<HelpData Key="foreach_stmt_formatting.il" Value="" />
|
||||||
|
<HelpData Key="foreach_stmt_formatting.in_what" Value="" />
|
||||||
|
<HelpData Key="foreach_stmt_formatting.stmt" Value="" />
|
||||||
|
<HelpData Key="foreach_stmt_formatting.type_name" Value="" />
|
||||||
<HelpData Key="formal_parameters" Value="" />
|
<HelpData Key="formal_parameters" Value="" />
|
||||||
<HelpData Key="formal_parameters.formal_parameters Add(typed_parameters _typed_parameters)" Value="" />
|
<HelpData Key="formal_parameters.formal_parameters Add(typed_parameters _typed_parameters)" Value="" />
|
||||||
<HelpData Key="formal_parameters.formal_parameters Add(typed_parameters _typed_parameters, SourceContext sc)" Value="" />
|
<HelpData Key="formal_parameters.formal_parameters Add(typed_parameters _typed_parameters, SourceContext sc)" Value="" />
|
||||||
|
|
|
||||||
|
|
@ -28,14 +28,16 @@ namespace SyntaxVisitors.SugarVisitors
|
||||||
while (!(st is statement))
|
while (!(st is statement))
|
||||||
st = st.Parent;
|
st = st.Parent;
|
||||||
var tname = "#temp" + UniqueNumStr();
|
var tname = "#temp" + UniqueNumStr();
|
||||||
var tt = new var_statement(new ident(tname), dqn.left);
|
var tt = new var_statement(new ident(tname, dqn.source_context), dqn.left, dqn.source_context);
|
||||||
tt.var_def.Parent = tt;
|
tt.var_def.Parent = tt;
|
||||||
var l = new List<statement>();
|
var l = new List<statement>();
|
||||||
l.Add(tt);
|
l.Add(tt);
|
||||||
l.Add(st as statement);
|
l.Add(st as statement);
|
||||||
expression right = dqn.right;
|
expression right = dqn.right;
|
||||||
var eq = new bin_expr(new ident(tname), new nil_const(), Operators.NotEqual, dqn.left.source_context);
|
var ni = new nil_const();
|
||||||
var qce = new question_colon_expression(eq, new ident(tname), right, dqn.source_context);
|
ni.source_context = dqn.source_context;
|
||||||
|
var eq = new bin_expr(new ident(tname, dqn.source_context), ni, Operators.NotEqual, dqn.left.source_context);
|
||||||
|
var qce = new question_colon_expression(eq, new ident(tname, dqn.source_context), right, dqn.source_context);
|
||||||
ReplaceUsingParent(dqn, qce);
|
ReplaceUsingParent(dqn, qce);
|
||||||
visit(qce);
|
visit(qce);
|
||||||
ReplaceStatementUsingParent(st as statement, l);
|
ReplaceStatementUsingParent(st as statement, l);
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,15 @@ namespace SyntaxVisitors.SugarVisitors
|
||||||
DefaultVisit(ne);
|
DefaultVisit(ne);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void visit(labeled_statement ls)
|
||||||
|
{
|
||||||
|
var sl = new List<statement>();
|
||||||
|
sl.Add(new labeled_statement(ls.label_name, new empty_statement(), ls.source_context));
|
||||||
|
sl.Add(ls.to_statement);
|
||||||
|
ReplaceStatementUsingParent(ls, sl);
|
||||||
|
ProcessNode(ls.to_statement);
|
||||||
|
}
|
||||||
|
|
||||||
public override void visit(assign_var_tuple assvartup)
|
public override void visit(assign_var_tuple assvartup)
|
||||||
{
|
{
|
||||||
if (assvartup.expr is tuple_node tn && tn.el.expressions.All(ex => ex is const_node) && !tn.el.expressions.Any(ex => ex is nil_const))
|
if (assvartup.expr is tuple_node tn && tn.el.expressions.All(ex => ex is const_node) && !tn.el.expressions.Any(ex => ex is nil_const))
|
||||||
|
|
|
||||||
|
|
@ -295,9 +295,10 @@ namespace SyntaxVisitors
|
||||||
stl1.Add(new assign("Result", "$res"));
|
stl1.Add(new assign("Result", "$res"));
|
||||||
|
|
||||||
|
|
||||||
GetEnumeratorBody.Add(new if_node(new bin_expr(new ident(YieldConsts.State), new int32_const(0), Operators.Equal),
|
/*GetEnumeratorBody.Add(new if_node(new bin_expr(new ident(YieldConsts.State), new int32_const(0), Operators.Equal),
|
||||||
new assign("Result", "Self"),
|
new assign("Result", "Self"),
|
||||||
stl1));
|
stl1));*/ // SSM 06.12.20 - исправление неработающего Batch. Нужно по хорошему вводить доп. состояние - как в C#: -2. Так медленнее, но правильно
|
||||||
|
GetEnumeratorBody.Add(stl1);
|
||||||
|
|
||||||
var cct = new type_declarations(/*td*/);
|
var cct = new type_declarations(/*td*/);
|
||||||
cct.Add(td1);
|
cct.Add(td1);
|
||||||
|
|
|
||||||
14
TestSuite/2363.pas
Normal file
14
TestSuite/2363.pas
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
procedure p0<T>(o: T);
|
||||||
|
begin
|
||||||
|
//Print(1);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure p1<T>; where T: record;
|
||||||
|
begin
|
||||||
|
//Ошибка: Возможны два преобразования типов
|
||||||
|
p0&<T?>(nil);
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Assert(1=1)
|
||||||
|
end.
|
||||||
7
TestSuite/BigIntSeqSumProduct.pas
Normal file
7
TestSuite/BigIntSeqSumProduct.pas
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
begin
|
||||||
|
var a := Arr(1bi,2bi,4bi);
|
||||||
|
Assert(a.Sum = 7bi);
|
||||||
|
Assert(a.Product = 8bi);
|
||||||
|
var lst := new List<integer>();
|
||||||
|
lst.Sum;
|
||||||
|
end.
|
||||||
|
|
@ -264,6 +264,7 @@ PupilMark = auto class
|
||||||
|
|
||||||
function ЗаполнитьМассивСтран: array of Страна;
|
function ЗаполнитьМассивСтран: array of Страна;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
var fname := 'c:\Program files (x86)\PascalABC.NET\Files\Databases\Страны.csv';
|
var fname := 'c:\Program files (x86)\PascalABC.NET\Files\Databases\Страны.csv';
|
||||||
if fname = '' then
|
if fname = '' then
|
||||||
raise new System.ApplicationException('Не найден массив стран Databases\Страны.csv');
|
raise new System.ApplicationException('Не найден массив стран Databases\Страны.csv');
|
||||||
|
|
|
||||||
|
|
@ -253,6 +253,9 @@ type
|
||||||
/// Предоставляет методы для точного измерения затраченного времени
|
/// Предоставляет методы для точного измерения затраченного времени
|
||||||
Stopwatch = System.Diagnostics.Stopwatch;
|
Stopwatch = System.Diagnostics.Stopwatch;
|
||||||
|
|
||||||
|
/// Указывает на возможность сериализации класса
|
||||||
|
Serializable = System.SerializableAttribute;
|
||||||
|
|
||||||
/// Представляет тип короткой строки фиксированной длины 255 символов
|
/// Представляет тип короткой строки фиксированной длины 255 символов
|
||||||
ShortString = string[255];
|
ShortString = string[255];
|
||||||
|
|
||||||
|
|
@ -586,6 +589,10 @@ type
|
||||||
function ReadReal: real;
|
function ReadReal: real;
|
||||||
/// Считывает строку из бестипового файла
|
/// Считывает строку из бестипового файла
|
||||||
function ReadString: string;
|
function ReadString: string;
|
||||||
|
/// Сериализует объект в файл (объект должен иметь атрибут [Serializable])
|
||||||
|
procedure Serialize(obj: object);
|
||||||
|
/// Десериализует объект из файла
|
||||||
|
function Deserialize: object;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
@ -628,7 +635,7 @@ type
|
||||||
Result := (l = r2.l) and (h = r2.h);
|
Result := (l = r2.l) and (h = r2.h);
|
||||||
end;
|
end;
|
||||||
function GetHashCode: integer; override := l.GetHashCode xor h.GetHashCode;
|
function GetHashCode: integer; override := l.GetHashCode xor h.GetHashCode;
|
||||||
function ToArray: array of integer;
|
{function ToArray: array of integer;
|
||||||
begin
|
begin
|
||||||
Result := new integer[Count];
|
Result := new integer[Count];
|
||||||
var x := l;
|
var x := l;
|
||||||
|
|
@ -640,14 +647,14 @@ type
|
||||||
end;
|
end;
|
||||||
function ToList: List<integer>;
|
function ToList: List<integer>;
|
||||||
begin
|
begin
|
||||||
Result := new List<integer>;
|
Result := new List<integer>(Count);
|
||||||
var x := l;
|
var x := l;
|
||||||
loop Count do
|
loop Count do
|
||||||
begin
|
begin
|
||||||
Result.Add(x);
|
Result.Add(x);
|
||||||
x += 1;
|
x += 1;
|
||||||
end;
|
end;
|
||||||
end;
|
end;}
|
||||||
function ToLinkedList: LinkedList<integer>;
|
function ToLinkedList: LinkedList<integer>;
|
||||||
begin
|
begin
|
||||||
Result := new LinkedList<integer>(System.Linq.Enumerable.Range(l,Count));
|
Result := new LinkedList<integer>(System.Linq.Enumerable.Range(l,Count));
|
||||||
|
|
@ -701,7 +708,7 @@ type
|
||||||
end;
|
end;
|
||||||
function GetHashCode: integer; override := l.GetHashCode xor h.GetHashCode;
|
function GetHashCode: integer; override := l.GetHashCode xor h.GetHashCode;
|
||||||
|
|
||||||
function ToArray: array of char;
|
{function ToArray: array of char;
|
||||||
begin
|
begin
|
||||||
Result := new char[Count];
|
Result := new char[Count];
|
||||||
var x := l;
|
var x := l;
|
||||||
|
|
@ -720,7 +727,7 @@ type
|
||||||
Result.Add(x);
|
Result.Add(x);
|
||||||
x := char(integer(x) + 1);
|
x := char(integer(x) + 1);
|
||||||
end;
|
end;
|
||||||
end;
|
end;}
|
||||||
function ToLinkedList: LinkedList<char>;
|
function ToLinkedList: LinkedList<char>;
|
||||||
begin
|
begin
|
||||||
Result := new LinkedList<char>(System.Linq.Enumerable.Range(integer(l),Count).Select(i -> char(i)));
|
Result := new LinkedList<char>(System.Linq.Enumerable.Range(integer(l),Count).Select(i -> char(i)));
|
||||||
|
|
@ -1183,6 +1190,12 @@ procedure Println(params args: array of object);
|
||||||
/// Выводит значения a,b,... в текстовый файл f, после каждого значения выводит пробел и переходит на новую строку
|
/// Выводит значения a,b,... в текстовый файл f, после каждого значения выводит пробел и переходит на новую строку
|
||||||
procedure Println(f: Text; params args: array of object);
|
procedure Println(f: Text; params args: array of object);
|
||||||
|
|
||||||
|
/// Сериализует объект в файл (объект должен иметь атрибут [Serializable])
|
||||||
|
procedure Serialize(filename: string; obj: object);
|
||||||
|
/// Десериализует объект из файла
|
||||||
|
function Deserialize(filename: string): object;
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
//>> Общие подпрограммы для работы с файлами # Common subroutines for files
|
//>> Общие подпрограммы для работы с файлами # Common subroutines for files
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
|
|
@ -2142,6 +2155,10 @@ function NextPermutation(a: array of integer): boolean;
|
||||||
function Range(a, b: integer): sequence of integer;
|
function Range(a, b: integer): sequence of integer;
|
||||||
/// Возвращает последовательность целых от a до b с шагом step
|
/// Возвращает последовательность целых от a до b с шагом step
|
||||||
function Range(a, b, step: integer): sequence of integer;
|
function Range(a, b, step: integer): sequence of integer;
|
||||||
|
/// Возвращает последовательность длинных целых от a до b
|
||||||
|
function Range(a, b: BigInteger): sequence of BigInteger;
|
||||||
|
/// Возвращает последовательность длинных целых от a до b с шагом step
|
||||||
|
function Range(a, b, step: BigInteger): sequence of BigInteger;
|
||||||
/// Возвращает последовательность символов от c1 до c2
|
/// Возвращает последовательность символов от c1 до c2
|
||||||
function Range(c1, c2: char): sequence of char;
|
function Range(c1, c2: char): sequence of char;
|
||||||
/// Возвращает последовательность символов от c1 до c2 с шагом step
|
/// Возвращает последовательность символов от c1 до c2 с шагом step
|
||||||
|
|
@ -2814,6 +2831,9 @@ function WINAPI_AllocConsole: longword; external 'kernel32.dll' name 'AllocConso
|
||||||
|
|
||||||
var
|
var
|
||||||
console_alloc: boolean := false;
|
console_alloc: boolean := false;
|
||||||
|
|
||||||
|
type
|
||||||
|
BinaryFormatter = System.Runtime.Serialization.Formatters.Binary.BinaryFormatter;
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
// Internal functions
|
// Internal functions
|
||||||
|
|
@ -4557,7 +4577,7 @@ begin
|
||||||
else Result := System.Linq.Enumerable.Range(a, b - a + 1);
|
else Result := System.Linq.Enumerable.Range(a, b - a + 1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function Range(a, b: real; n: integer): sequence of real;
|
function PartitionPoints(a, b: real; n: integer): sequence of real;
|
||||||
begin
|
begin
|
||||||
if n = 0 then
|
if n = 0 then
|
||||||
raise new System.ArgumentException('Range: n=0');
|
raise new System.ArgumentException('Range: n=0');
|
||||||
|
|
@ -4582,11 +4602,26 @@ begin
|
||||||
Result := Range(integer(c1), integer(c2), step).Select(x -> Chr(x));
|
Result := Range(integer(c1), integer(c2), step).Select(x -> Chr(x));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function PartitionPoints(a, b: real; n: integer): sequence of real;
|
function Range(a, b, step: BigInteger): sequence of BigInteger;
|
||||||
begin
|
begin
|
||||||
Result := Range(a, b, n)
|
if step = 0 then
|
||||||
|
raise new System.ArgumentException('step=0');
|
||||||
|
if step > 0 then
|
||||||
|
while a<=b do
|
||||||
|
begin
|
||||||
|
yield a;
|
||||||
|
a += step;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
while a>=b do
|
||||||
|
begin
|
||||||
|
yield a;
|
||||||
|
a += step;
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function Range(a, b: BigInteger): sequence of BigInteger := Range(a,b,1);
|
||||||
|
|
||||||
type
|
type
|
||||||
ArithmSeq = auto class
|
ArithmSeq = auto class
|
||||||
a, step: integer;
|
a, step: integer;
|
||||||
|
|
@ -6658,6 +6693,18 @@ begin
|
||||||
Result := Self.br.ReadString;
|
Result := Self.br.ReadString;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure BinaryFile.Serialize(obj: object);
|
||||||
|
begin
|
||||||
|
var formatter := new BinaryFormatter;
|
||||||
|
formatter.Serialize(fs,obj);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function BinaryFile.Deserialize: object;
|
||||||
|
begin
|
||||||
|
var formatter := new BinaryFormatter;
|
||||||
|
Result := formatter.Deserialize(fs);
|
||||||
|
end;
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
// Eoln - Eof
|
// Eoln - Eof
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
|
|
@ -6978,6 +7025,23 @@ begin
|
||||||
Print(f, args);
|
Print(f, args);
|
||||||
Writeln(f);
|
Writeln(f);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure Serialize(filename: string; obj: object);
|
||||||
|
begin
|
||||||
|
var fs := new System.IO.FileStream(filename,System.IO.FileMode.Create);
|
||||||
|
var formatter := new BinaryFormatter;
|
||||||
|
formatter.Serialize(fs,obj);
|
||||||
|
fs.Close;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Deserialize(filename: string): object;
|
||||||
|
begin
|
||||||
|
var fs := new System.IO.FileStream(filename,System.IO.FileMode.Open);
|
||||||
|
var formatter := new BinaryFormatter;
|
||||||
|
Result := formatter.Deserialize(fs);
|
||||||
|
fs.Close;
|
||||||
|
end;
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
// Text files
|
// Text files
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
|
|
@ -9745,6 +9809,39 @@ begin
|
||||||
Result += f(x);
|
Result += f(x);
|
||||||
end;}
|
end;}
|
||||||
|
|
||||||
|
// SSM 23/11/2020 - Sum Average Product for sequence of BigInteger
|
||||||
|
|
||||||
|
/// Возвращает сумму элементов последовательности
|
||||||
|
function Sum(Self: sequence of BigInteger): BigInteger; extensionmethod;
|
||||||
|
begin
|
||||||
|
Result := 0bi;
|
||||||
|
foreach var a in Self do
|
||||||
|
Result += a
|
||||||
|
end;
|
||||||
|
|
||||||
|
/// Возвращает среднее элементов последовательности
|
||||||
|
function Average(Self: sequence of BigInteger): real; extensionmethod;
|
||||||
|
begin
|
||||||
|
var cnt := 0;
|
||||||
|
var sum := 0bi;
|
||||||
|
foreach var a in Self do
|
||||||
|
begin
|
||||||
|
sum += a;
|
||||||
|
cnt += 1;
|
||||||
|
end;
|
||||||
|
if cnt <> 0 then
|
||||||
|
Result := sum/cnt
|
||||||
|
else Result := 0
|
||||||
|
end;
|
||||||
|
|
||||||
|
/// Возвращает произведение элементов последовательности
|
||||||
|
function Product(Self: sequence of BigInteger): BigInteger; extensionmethod;
|
||||||
|
begin
|
||||||
|
Result := 1bi;
|
||||||
|
foreach var a in Self do
|
||||||
|
Result *= a
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
/// Возвращает отсортированную по возрастанию последовательность
|
/// Возвращает отсортированную по возрастанию последовательность
|
||||||
function Sorted<T>(Self: sequence of T): sequence of T; extensionmethod;
|
function Sorted<T>(Self: sequence of T): sequence of T; extensionmethod;
|
||||||
|
|
@ -10261,6 +10358,15 @@ end;
|
||||||
|
|
||||||
// ToDo Сделать AdjacentGroup с функцией сравнения
|
// ToDo Сделать AdjacentGroup с функцией сравнения
|
||||||
|
|
||||||
|
/// Возвращает количество элементов, равных указанному значению
|
||||||
|
function CountOf<T>(Self: sequence of T; x: T): integer; extensionmethod;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
foreach var y in Self do
|
||||||
|
if y = x then
|
||||||
|
Result += 1;
|
||||||
|
end;
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
//>> Методы расширения списков # Extension methods for List T
|
//>> Методы расширения списков # Extension methods for List T
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
|
|
@ -12243,6 +12349,14 @@ begin
|
||||||
Result := Self.Split(delim, System.StringSplitOptions.RemoveEmptyEntries);
|
Result := Self.Split(delim, System.StringSplitOptions.RemoveEmptyEntries);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
const AllWordDelimiters = ' <>=^`|~$№§!"#%&''()*,+-./:;?@[\]_{}«·»'#9#10#13;
|
||||||
|
|
||||||
|
/// Преобразует строку в массив слов, используя в качестве разделителей символы из строки delim
|
||||||
|
function ToWords(Self: string; delim: string := AllWordDelimiters): array of string; extensionmethod;
|
||||||
|
begin
|
||||||
|
Result := Self.Split(delim.ToCharArray, System.StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure PassSpaces(var s: string; var from: integer);
|
procedure PassSpaces(var s: string; var from: integer);
|
||||||
begin
|
begin
|
||||||
while (from <= s.Length) and (s[from]=' ') do
|
while (from <= s.Length) and (s[from]=' ') do
|
||||||
|
|
|
||||||
|
|
@ -38,19 +38,25 @@ function MinMax(s: sequence of int64): (int64, int64);
|
||||||
/// Возвращает кортеж из минимума и максимума последовательности s
|
/// Возвращает кортеж из минимума и максимума последовательности s
|
||||||
function MinMax(s: sequence of integer): (integer, integer);
|
function MinMax(s: sequence of integer): (integer, integer);
|
||||||
|
|
||||||
/// Ввозвращает НОД
|
/// Возвращает кортеж из минимума и максимума последовательности s
|
||||||
|
function MinMax(s: sequence of real): (real, real);
|
||||||
|
|
||||||
|
/// Возвращает кортеж из минимума и максимума последовательности s
|
||||||
|
function MinMax(s: sequence of BigInteger): (BigInteger, BigInteger);
|
||||||
|
|
||||||
|
/// Возвращает НОД
|
||||||
function НОД(a, b: int64): int64;
|
function НОД(a, b: int64): int64;
|
||||||
|
|
||||||
/// Ввозвращает НОК пары чисел
|
/// Возвращает НОК пары чисел
|
||||||
function НОК(a, b: int64): int64;
|
function НОК(a, b: int64): int64;
|
||||||
|
|
||||||
/// Ввозвращает НОД и НОК пары чисел
|
/// Возвращает НОД и НОК пары чисел
|
||||||
function НОДНОК(a, b: int64): (int64, int64);
|
function НОДНОК(a, b: int64): (int64, int64);
|
||||||
|
|
||||||
/// Разложение числа на простые множители
|
/// Разложение числа на простые множители
|
||||||
function Factorize(n: int64): List<int64>;
|
function Factorize(n: int64): List<int64>;
|
||||||
|
|
||||||
/// Рразложение числа на простые множители
|
/// Разложение числа на простые множители
|
||||||
function Factorize(n: integer): List<integer>;
|
function Factorize(n: integer): List<integer>;
|
||||||
|
|
||||||
/// Простые числа на интервале [2;n]
|
/// Простые числа на интервале [2;n]
|
||||||
|
|
@ -62,10 +68,10 @@ function FirstPrimes(n: integer): List<integer>;
|
||||||
/// Возвращает список, содержащий цифры числа
|
/// Возвращает список, содержащий цифры числа
|
||||||
function Digits(n: int64): List<integer>;
|
function Digits(n: int64): List<integer>;
|
||||||
|
|
||||||
/// возвращает список делителей натурального числа
|
/// Возвращает список делителей натурального числа
|
||||||
function Divizors(n: int64): List<int64>;
|
function Divizors(n: int64): List<int64>;
|
||||||
|
|
||||||
/// возвращает список делителей натурального числа
|
/// Возвращает список делителей натурального числа
|
||||||
function Divizors(n: integer): List<integer>;
|
function Divizors(n: integer): List<integer>;
|
||||||
|
|
||||||
/// Возвращает Sin угла, заданного в градусах
|
/// Возвращает Sin угла, заданного в градусах
|
||||||
|
|
@ -236,6 +242,9 @@ end;
|
||||||
/// Перевод BigInteger в систему счисления по основанию base (2..36)
|
/// Перевод BigInteger в систему счисления по основанию base (2..36)
|
||||||
function ToBase(BI: BigInteger; base: integer): string;
|
function ToBase(BI: BigInteger; base: integer): string;
|
||||||
begin
|
begin
|
||||||
|
if not (base in 2..36) then
|
||||||
|
raise new School_InvalidBase
|
||||||
|
($'ToDecimal: Недопустимое основание {base}');
|
||||||
var s := new System.Text.StringBuilder('');
|
var s := new System.Text.StringBuilder('');
|
||||||
while BI > 0 do
|
while BI > 0 do
|
||||||
begin
|
begin
|
||||||
|
|
@ -252,6 +261,9 @@ function ToBase(Self: BigInteger; base: integer): string; extensionmethod :=
|
||||||
/// Перевод десятичного числа в систему счисления по основанию base (2..36)
|
/// Перевод десятичного числа в систему счисления по основанию base (2..36)
|
||||||
function ToBase(sDec: string; base: integer): string;
|
function ToBase(sDec: string; base: integer): string;
|
||||||
begin
|
begin
|
||||||
|
if not (base in 2..36) then
|
||||||
|
raise new School_InvalidBase
|
||||||
|
($'ToDecimal: Недопустимое основание {base}');
|
||||||
var n: BigInteger;
|
var n: BigInteger;
|
||||||
if BigInteger.TryParse(sDec, n) then
|
if BigInteger.TryParse(sDec, n) then
|
||||||
Result := ToBase(n, base)
|
Result := ToBase(n, base)
|
||||||
|
|
@ -270,10 +282,12 @@ function MinMax(s: sequence of int64): (int64, int64);
|
||||||
begin
|
begin
|
||||||
var (min, max) := (int64.MaxValue, int64.MinValue);
|
var (min, max) := (int64.MaxValue, int64.MinValue);
|
||||||
foreach var m in s do
|
foreach var m in s do
|
||||||
|
begin
|
||||||
if m < min then
|
if m < min then
|
||||||
min := m
|
min := m;
|
||||||
else if m > max then
|
if m > max then
|
||||||
max := m;
|
max := m
|
||||||
|
end;
|
||||||
Result := (min, max)
|
Result := (min, max)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
@ -282,10 +296,44 @@ function MinMax(s: sequence of integer): (integer, integer);
|
||||||
begin
|
begin
|
||||||
var (min, max) := (integer.MaxValue, integer.MinValue);
|
var (min, max) := (integer.MaxValue, integer.MinValue);
|
||||||
foreach var m in s do
|
foreach var m in s do
|
||||||
|
begin
|
||||||
if m < min then
|
if m < min then
|
||||||
min := m
|
min := m;
|
||||||
else if m > max then
|
if m > max then
|
||||||
max := m;
|
max := m
|
||||||
|
end;
|
||||||
|
Result := (min, max)
|
||||||
|
end;
|
||||||
|
|
||||||
|
/// Возвращает кортеж из минимума и максимума последовательности s
|
||||||
|
function MinMax(s: sequence of real): (real, real);
|
||||||
|
begin
|
||||||
|
var (min, max) := (real.MaxValue, -real.MaxValue);
|
||||||
|
foreach var m in s do
|
||||||
|
begin
|
||||||
|
if m < min then
|
||||||
|
min := m;
|
||||||
|
if m > max then
|
||||||
|
max := m
|
||||||
|
end;
|
||||||
|
Result := (min, max)
|
||||||
|
end;
|
||||||
|
|
||||||
|
/// Возвращает кортеж из минимума и максимума последовательности s
|
||||||
|
function MinMax(s: sequence of BigInteger): (BigInteger, BigInteger);
|
||||||
|
begin
|
||||||
|
var min, max: BigInteger;
|
||||||
|
var FirstValue := True;
|
||||||
|
foreach var m in s do
|
||||||
|
if FirstValue then
|
||||||
|
(min, max, FirstValue) := (m, m, False)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
if m < min then
|
||||||
|
min := m;
|
||||||
|
if m > max then
|
||||||
|
max := m
|
||||||
|
end;
|
||||||
Result := (min, max)
|
Result := (min, max)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
@ -296,7 +344,15 @@ MinMax(Self);
|
||||||
/// Возвращает кортеж из минимума и максимума последовательности
|
/// Возвращает кортеж из минимума и максимума последовательности
|
||||||
function MinMax(Self: sequence of integer): (integer, integer);
|
function MinMax(Self: sequence of integer): (integer, integer);
|
||||||
extensionmethod :=
|
extensionmethod :=
|
||||||
MinMax(Self);
|
MinMax(Self);
|
||||||
|
|
||||||
|
/// Возвращает кортеж из минимума и максимума последовательности
|
||||||
|
function MinMax(Self: sequence of real): (real, real); extensionmethod :=
|
||||||
|
MinMax(Self);
|
||||||
|
|
||||||
|
/// Возвращает кортеж из минимума и максимума последовательности
|
||||||
|
function MinMax(Self: sequence of BigInteger): (BigInteger, BigInteger);
|
||||||
|
extensionmethod := MinMax(Self);
|
||||||
|
|
||||||
{$endregion}
|
{$endregion}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
begin
|
begin
|
||||||
var Floors := new Dictionary<(cardinal, cardinal), List<integer>>;
|
var Floors := new Dictionary<(cardinal, cardinal), List<integer>>;
|
||||||
var sz := (1, 2);
|
var sz := (1, 2);
|
||||||
foreach var a{@var a: (cardinal,cardinal);@} in Floors.Keys do
|
foreach var a{@var a: (cardinal,cardinal);@} in Floors.Keys do
|
||||||
|
|
|
||||||
8
TestSuite/label_ass_var_tuple.pas
Normal file
8
TestSuite/label_ass_var_tuple.pas
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
label 1;
|
||||||
|
begin
|
||||||
|
var c := 1;
|
||||||
|
1:
|
||||||
|
var (a,b) := (1,1);
|
||||||
|
b := 1;
|
||||||
|
Assert(b=1);
|
||||||
|
end.
|
||||||
14
TestSuite/units/u_lambda_any.pas
Normal file
14
TestSuite/units/u_lambda_any.pas
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
unit u_lambda_any;
|
||||||
|
{$reference WindowsBase.dll}
|
||||||
|
|
||||||
|
function f: integer;
|
||||||
|
begin
|
||||||
|
var d := System.Windows.Threading.Dispatcher.CurrentDispatcher;
|
||||||
|
var res := d.Invoke(()->
|
||||||
|
begin
|
||||||
|
Result := 1;
|
||||||
|
end);
|
||||||
|
Result := res;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
5
TestSuite/usesunits/use_lambda_any.pas
Normal file
5
TestSuite/usesunits/use_lambda_any.pas
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
uses u_lambda_any;
|
||||||
|
|
||||||
|
begin
|
||||||
|
assert(f = 1);
|
||||||
|
end.
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using PascalABCCompiler.SyntaxTree;
|
using PascalABCCompiler.SyntaxTree;
|
||||||
using PascalABCCompiler.TreeRealization;
|
using PascalABCCompiler.TreeRealization;
|
||||||
using TreeConverter.LambdaExpressions;
|
using TreeConverter.LambdaExpressions;
|
||||||
|
using System.Linq;
|
||||||
using for_node = PascalABCCompiler.SyntaxTree.for_node;
|
using for_node = PascalABCCompiler.SyntaxTree.for_node;
|
||||||
|
|
||||||
namespace PascalABCCompiler.TreeConverter
|
namespace PascalABCCompiler.TreeConverter
|
||||||
|
|
@ -70,6 +71,34 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void semantic_check_extended_foreach(ident_list vars, type_node elem_type, location inwhatloc)
|
||||||
|
{
|
||||||
|
var t = ConvertSemanticTypeNodeToNETType(elem_type);
|
||||||
|
if (t == null)
|
||||||
|
AddError(inwhatloc, "TUPLE_OR_SEQUENCE_EXPECTED_FOREACH");
|
||||||
|
|
||||||
|
var IsTuple = false;
|
||||||
|
var IsSequence = false;
|
||||||
|
if (t.FullName.StartsWith("System.Tuple"))
|
||||||
|
IsTuple = true;
|
||||||
|
if (!IsTuple)
|
||||||
|
{
|
||||||
|
if (t.Name.Equals("IEnumerable`1") || t.GetInterface("IEnumerable`1") != null)
|
||||||
|
IsSequence = true;
|
||||||
|
}
|
||||||
|
if (!IsTuple && !IsSequence)
|
||||||
|
{
|
||||||
|
AddError(inwhatloc, "TUPLE_OR_SEQUENCE_EXPECTED_FOREACH");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsTuple)
|
||||||
|
{
|
||||||
|
var n = vars.idents.Count();
|
||||||
|
if (n > t.GetGenericArguments().Count())
|
||||||
|
AddError(get_location(vars), "TOO_MANY_ELEMENTS_ON_LEFT_SIDE_OF_TUPLE_ASSIGNMRNT");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ForeachCheckAndConvert(foreach_stmt _foreach_stmt, out expression_node foreachCollection,
|
private void ForeachCheckAndConvert(foreach_stmt _foreach_stmt, out expression_node foreachCollection,
|
||||||
out var_definition_node foreachVariable)
|
out var_definition_node foreachVariable)
|
||||||
|
|
@ -91,6 +120,12 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
if (!FindIEnumerableElementType(foreachCollection.type, ref elem_type, out sys_coll_ienum))
|
if (!FindIEnumerableElementType(foreachCollection.type, ref elem_type, out sys_coll_ienum))
|
||||||
AddError(foreachCollection.location, "CAN_NOT_EXECUTE_FOREACH_BY_EXPR_OF_TYPE_{0}", foreachCollection.type.name);
|
AddError(foreachCollection.location, "CAN_NOT_EXECUTE_FOREACH_BY_EXPR_OF_TYPE_{0}", foreachCollection.type.name);
|
||||||
|
|
||||||
|
var vars = _foreach_stmt.ext as ident_list;
|
||||||
|
if (vars != null)
|
||||||
|
{
|
||||||
|
semantic_check_extended_foreach(vars, elem_type, foreachCollection.location);
|
||||||
|
}
|
||||||
|
|
||||||
CheckToEmbeddedStatementCannotBeADeclaration(_foreach_stmt.stmt);
|
CheckToEmbeddedStatementCannotBeADeclaration(_foreach_stmt.stmt);
|
||||||
|
|
||||||
foreachVariable = FindForeachVariable(_foreach_stmt, elem_type, sys_coll_ienum);
|
foreachVariable = FindForeachVariable(_foreach_stmt, elem_type, sys_coll_ienum);
|
||||||
|
|
|
||||||
|
|
@ -1667,6 +1667,8 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
{
|
{
|
||||||
if (ptc.second!=null)
|
if (ptc.second!=null)
|
||||||
{
|
{
|
||||||
|
if (ptc.first.from is null_type_node || ptc.second.from is null_type_node)
|
||||||
|
continue; // SSM 9/12/20 fix 2363
|
||||||
AddError(new PossibleTwoTypeConversionsInFunctionCall(loc,ptc.first,ptc.second));
|
AddError(new PossibleTwoTypeConversionsInFunctionCall(loc,ptc.first,ptc.second));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3582,7 +3582,7 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
start = ext.GetRange(cur_index, ext.Count() - cur_index);
|
start = ext.GetRange(cur_index, ext.Count() - cur_index);
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
result.RemoveRange(1, result.Count() - 1);
|
//result.RemoveRange(1, result.Count() - 1);
|
||||||
result.AddRange(start);
|
result.AddRange(start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -264,6 +264,7 @@ PupilMark = auto class
|
||||||
|
|
||||||
function ЗаполнитьМассивСтран: array of Страна;
|
function ЗаполнитьМассивСтран: array of Страна;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
var fname := 'c:\Program files (x86)\PascalABC.NET\Files\Databases\Страны.csv';
|
var fname := 'c:\Program files (x86)\PascalABC.NET\Files\Databases\Страны.csv';
|
||||||
if fname = '' then
|
if fname = '' then
|
||||||
raise new System.ApplicationException('Не найден массив стран Databases\Страны.csv');
|
raise new System.ApplicationException('Не найден массив стран Databases\Страны.csv');
|
||||||
|
|
|
||||||
|
|
@ -253,6 +253,9 @@ type
|
||||||
/// Предоставляет методы для точного измерения затраченного времени
|
/// Предоставляет методы для точного измерения затраченного времени
|
||||||
Stopwatch = System.Diagnostics.Stopwatch;
|
Stopwatch = System.Diagnostics.Stopwatch;
|
||||||
|
|
||||||
|
/// Указывает на возможность сериализации класса
|
||||||
|
Serializable = System.SerializableAttribute;
|
||||||
|
|
||||||
/// Представляет тип короткой строки фиксированной длины 255 символов
|
/// Представляет тип короткой строки фиксированной длины 255 символов
|
||||||
ShortString = string[255];
|
ShortString = string[255];
|
||||||
|
|
||||||
|
|
@ -586,6 +589,10 @@ type
|
||||||
function ReadReal: real;
|
function ReadReal: real;
|
||||||
/// Считывает строку из бестипового файла
|
/// Считывает строку из бестипового файла
|
||||||
function ReadString: string;
|
function ReadString: string;
|
||||||
|
/// Сериализует объект в файл (объект должен иметь атрибут [Serializable])
|
||||||
|
procedure Serialize(obj: object);
|
||||||
|
/// Десериализует объект из файла
|
||||||
|
function Deserialize: object;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
@ -628,7 +635,7 @@ type
|
||||||
Result := (l = r2.l) and (h = r2.h);
|
Result := (l = r2.l) and (h = r2.h);
|
||||||
end;
|
end;
|
||||||
function GetHashCode: integer; override := l.GetHashCode xor h.GetHashCode;
|
function GetHashCode: integer; override := l.GetHashCode xor h.GetHashCode;
|
||||||
function ToArray: array of integer;
|
{function ToArray: array of integer;
|
||||||
begin
|
begin
|
||||||
Result := new integer[Count];
|
Result := new integer[Count];
|
||||||
var x := l;
|
var x := l;
|
||||||
|
|
@ -640,14 +647,14 @@ type
|
||||||
end;
|
end;
|
||||||
function ToList: List<integer>;
|
function ToList: List<integer>;
|
||||||
begin
|
begin
|
||||||
Result := new List<integer>;
|
Result := new List<integer>(Count);
|
||||||
var x := l;
|
var x := l;
|
||||||
loop Count do
|
loop Count do
|
||||||
begin
|
begin
|
||||||
Result.Add(x);
|
Result.Add(x);
|
||||||
x += 1;
|
x += 1;
|
||||||
end;
|
end;
|
||||||
end;
|
end;}
|
||||||
function ToLinkedList: LinkedList<integer>;
|
function ToLinkedList: LinkedList<integer>;
|
||||||
begin
|
begin
|
||||||
Result := new LinkedList<integer>(System.Linq.Enumerable.Range(l,Count));
|
Result := new LinkedList<integer>(System.Linq.Enumerable.Range(l,Count));
|
||||||
|
|
@ -701,7 +708,7 @@ type
|
||||||
end;
|
end;
|
||||||
function GetHashCode: integer; override := l.GetHashCode xor h.GetHashCode;
|
function GetHashCode: integer; override := l.GetHashCode xor h.GetHashCode;
|
||||||
|
|
||||||
function ToArray: array of char;
|
{function ToArray: array of char;
|
||||||
begin
|
begin
|
||||||
Result := new char[Count];
|
Result := new char[Count];
|
||||||
var x := l;
|
var x := l;
|
||||||
|
|
@ -720,7 +727,7 @@ type
|
||||||
Result.Add(x);
|
Result.Add(x);
|
||||||
x := char(integer(x) + 1);
|
x := char(integer(x) + 1);
|
||||||
end;
|
end;
|
||||||
end;
|
end;}
|
||||||
function ToLinkedList: LinkedList<char>;
|
function ToLinkedList: LinkedList<char>;
|
||||||
begin
|
begin
|
||||||
Result := new LinkedList<char>(System.Linq.Enumerable.Range(integer(l),Count).Select(i -> char(i)));
|
Result := new LinkedList<char>(System.Linq.Enumerable.Range(integer(l),Count).Select(i -> char(i)));
|
||||||
|
|
@ -1183,6 +1190,12 @@ procedure Println(params args: array of object);
|
||||||
/// Выводит значения a,b,... в текстовый файл f, после каждого значения выводит пробел и переходит на новую строку
|
/// Выводит значения a,b,... в текстовый файл f, после каждого значения выводит пробел и переходит на новую строку
|
||||||
procedure Println(f: Text; params args: array of object);
|
procedure Println(f: Text; params args: array of object);
|
||||||
|
|
||||||
|
/// Сериализует объект в файл (объект должен иметь атрибут [Serializable])
|
||||||
|
procedure Serialize(filename: string; obj: object);
|
||||||
|
/// Десериализует объект из файла
|
||||||
|
function Deserialize(filename: string): object;
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
//>> Общие подпрограммы для работы с файлами # Common subroutines for files
|
//>> Общие подпрограммы для работы с файлами # Common subroutines for files
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
|
|
@ -2142,6 +2155,10 @@ function NextPermutation(a: array of integer): boolean;
|
||||||
function Range(a, b: integer): sequence of integer;
|
function Range(a, b: integer): sequence of integer;
|
||||||
/// Возвращает последовательность целых от a до b с шагом step
|
/// Возвращает последовательность целых от a до b с шагом step
|
||||||
function Range(a, b, step: integer): sequence of integer;
|
function Range(a, b, step: integer): sequence of integer;
|
||||||
|
/// Возвращает последовательность длинных целых от a до b
|
||||||
|
function Range(a, b: BigInteger): sequence of BigInteger;
|
||||||
|
/// Возвращает последовательность длинных целых от a до b с шагом step
|
||||||
|
function Range(a, b, step: BigInteger): sequence of BigInteger;
|
||||||
/// Возвращает последовательность символов от c1 до c2
|
/// Возвращает последовательность символов от c1 до c2
|
||||||
function Range(c1, c2: char): sequence of char;
|
function Range(c1, c2: char): sequence of char;
|
||||||
/// Возвращает последовательность символов от c1 до c2 с шагом step
|
/// Возвращает последовательность символов от c1 до c2 с шагом step
|
||||||
|
|
@ -2814,6 +2831,9 @@ function WINAPI_AllocConsole: longword; external 'kernel32.dll' name 'AllocConso
|
||||||
|
|
||||||
var
|
var
|
||||||
console_alloc: boolean := false;
|
console_alloc: boolean := false;
|
||||||
|
|
||||||
|
type
|
||||||
|
BinaryFormatter = System.Runtime.Serialization.Formatters.Binary.BinaryFormatter;
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
// Internal functions
|
// Internal functions
|
||||||
|
|
@ -4557,7 +4577,7 @@ begin
|
||||||
else Result := System.Linq.Enumerable.Range(a, b - a + 1);
|
else Result := System.Linq.Enumerable.Range(a, b - a + 1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function Range(a, b: real; n: integer): sequence of real;
|
function PartitionPoints(a, b: real; n: integer): sequence of real;
|
||||||
begin
|
begin
|
||||||
if n = 0 then
|
if n = 0 then
|
||||||
raise new System.ArgumentException('Range: n=0');
|
raise new System.ArgumentException('Range: n=0');
|
||||||
|
|
@ -4582,11 +4602,26 @@ begin
|
||||||
Result := Range(integer(c1), integer(c2), step).Select(x -> Chr(x));
|
Result := Range(integer(c1), integer(c2), step).Select(x -> Chr(x));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function PartitionPoints(a, b: real; n: integer): sequence of real;
|
function Range(a, b, step: BigInteger): sequence of BigInteger;
|
||||||
begin
|
begin
|
||||||
Result := Range(a, b, n)
|
if step = 0 then
|
||||||
|
raise new System.ArgumentException('step=0');
|
||||||
|
if step > 0 then
|
||||||
|
while a<=b do
|
||||||
|
begin
|
||||||
|
yield a;
|
||||||
|
a += step;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
while a>=b do
|
||||||
|
begin
|
||||||
|
yield a;
|
||||||
|
a += step;
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function Range(a, b: BigInteger): sequence of BigInteger := Range(a,b,1);
|
||||||
|
|
||||||
type
|
type
|
||||||
ArithmSeq = auto class
|
ArithmSeq = auto class
|
||||||
a, step: integer;
|
a, step: integer;
|
||||||
|
|
@ -6658,6 +6693,18 @@ begin
|
||||||
Result := Self.br.ReadString;
|
Result := Self.br.ReadString;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure BinaryFile.Serialize(obj: object);
|
||||||
|
begin
|
||||||
|
var formatter := new BinaryFormatter;
|
||||||
|
formatter.Serialize(fs,obj);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function BinaryFile.Deserialize: object;
|
||||||
|
begin
|
||||||
|
var formatter := new BinaryFormatter;
|
||||||
|
Result := formatter.Deserialize(fs);
|
||||||
|
end;
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
// Eoln - Eof
|
// Eoln - Eof
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
|
|
@ -6978,6 +7025,23 @@ begin
|
||||||
Print(f, args);
|
Print(f, args);
|
||||||
Writeln(f);
|
Writeln(f);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure Serialize(filename: string; obj: object);
|
||||||
|
begin
|
||||||
|
var fs := new System.IO.FileStream(filename,System.IO.FileMode.Create);
|
||||||
|
var formatter := new BinaryFormatter;
|
||||||
|
formatter.Serialize(fs,obj);
|
||||||
|
fs.Close;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Deserialize(filename: string): object;
|
||||||
|
begin
|
||||||
|
var fs := new System.IO.FileStream(filename,System.IO.FileMode.Open);
|
||||||
|
var formatter := new BinaryFormatter;
|
||||||
|
Result := formatter.Deserialize(fs);
|
||||||
|
fs.Close;
|
||||||
|
end;
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
// Text files
|
// Text files
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
|
|
@ -9745,6 +9809,39 @@ begin
|
||||||
Result += f(x);
|
Result += f(x);
|
||||||
end;}
|
end;}
|
||||||
|
|
||||||
|
// SSM 23/11/2020 - Sum Average Product for sequence of BigInteger
|
||||||
|
|
||||||
|
/// Возвращает сумму элементов последовательности
|
||||||
|
function Sum(Self: sequence of BigInteger): BigInteger; extensionmethod;
|
||||||
|
begin
|
||||||
|
Result := 0bi;
|
||||||
|
foreach var a in Self do
|
||||||
|
Result += a
|
||||||
|
end;
|
||||||
|
|
||||||
|
/// Возвращает среднее элементов последовательности
|
||||||
|
function Average(Self: sequence of BigInteger): real; extensionmethod;
|
||||||
|
begin
|
||||||
|
var cnt := 0;
|
||||||
|
var sum := 0bi;
|
||||||
|
foreach var a in Self do
|
||||||
|
begin
|
||||||
|
sum += a;
|
||||||
|
cnt += 1;
|
||||||
|
end;
|
||||||
|
if cnt <> 0 then
|
||||||
|
Result := sum/cnt
|
||||||
|
else Result := 0
|
||||||
|
end;
|
||||||
|
|
||||||
|
/// Возвращает произведение элементов последовательности
|
||||||
|
function Product(Self: sequence of BigInteger): BigInteger; extensionmethod;
|
||||||
|
begin
|
||||||
|
Result := 1bi;
|
||||||
|
foreach var a in Self do
|
||||||
|
Result *= a
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
/// Возвращает отсортированную по возрастанию последовательность
|
/// Возвращает отсортированную по возрастанию последовательность
|
||||||
function Sorted<T>(Self: sequence of T): sequence of T; extensionmethod;
|
function Sorted<T>(Self: sequence of T): sequence of T; extensionmethod;
|
||||||
|
|
@ -10261,6 +10358,15 @@ end;
|
||||||
|
|
||||||
// ToDo Сделать AdjacentGroup с функцией сравнения
|
// ToDo Сделать AdjacentGroup с функцией сравнения
|
||||||
|
|
||||||
|
/// Возвращает количество элементов, равных указанному значению
|
||||||
|
function CountOf<T>(Self: sequence of T; x: T): integer; extensionmethod;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
foreach var y in Self do
|
||||||
|
if y = x then
|
||||||
|
Result += 1;
|
||||||
|
end;
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
//>> Методы расширения списков # Extension methods for List T
|
//>> Методы расширения списков # Extension methods for List T
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
|
|
@ -12243,6 +12349,14 @@ begin
|
||||||
Result := Self.Split(delim, System.StringSplitOptions.RemoveEmptyEntries);
|
Result := Self.Split(delim, System.StringSplitOptions.RemoveEmptyEntries);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
const AllWordDelimiters = ' <>=^`|~$№§!"#%&''()*,+-./:;?@[\]_{}«·»'#9#10#13;
|
||||||
|
|
||||||
|
/// Преобразует строку в массив слов, используя в качестве разделителей символы из строки delim
|
||||||
|
function ToWords(Self: string; delim: string := AllWordDelimiters): array of string; extensionmethod;
|
||||||
|
begin
|
||||||
|
Result := Self.Split(delim.ToCharArray, System.StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure PassSpaces(var s: string; var from: integer);
|
procedure PassSpaces(var s: string; var from: integer);
|
||||||
begin
|
begin
|
||||||
while (from <= s.Length) and (s[from]=' ') do
|
while (from <= s.Length) and (s[from]=' ') do
|
||||||
|
|
|
||||||
|
|
@ -38,19 +38,25 @@ function MinMax(s: sequence of int64): (int64, int64);
|
||||||
/// Возвращает кортеж из минимума и максимума последовательности s
|
/// Возвращает кортеж из минимума и максимума последовательности s
|
||||||
function MinMax(s: sequence of integer): (integer, integer);
|
function MinMax(s: sequence of integer): (integer, integer);
|
||||||
|
|
||||||
/// Ввозвращает НОД
|
/// Возвращает кортеж из минимума и максимума последовательности s
|
||||||
|
function MinMax(s: sequence of real): (real, real);
|
||||||
|
|
||||||
|
/// Возвращает кортеж из минимума и максимума последовательности s
|
||||||
|
function MinMax(s: sequence of BigInteger): (BigInteger, BigInteger);
|
||||||
|
|
||||||
|
/// Возвращает НОД
|
||||||
function НОД(a, b: int64): int64;
|
function НОД(a, b: int64): int64;
|
||||||
|
|
||||||
/// Ввозвращает НОК пары чисел
|
/// Возвращает НОК пары чисел
|
||||||
function НОК(a, b: int64): int64;
|
function НОК(a, b: int64): int64;
|
||||||
|
|
||||||
/// Ввозвращает НОД и НОК пары чисел
|
/// Возвращает НОД и НОК пары чисел
|
||||||
function НОДНОК(a, b: int64): (int64, int64);
|
function НОДНОК(a, b: int64): (int64, int64);
|
||||||
|
|
||||||
/// Разложение числа на простые множители
|
/// Разложение числа на простые множители
|
||||||
function Factorize(n: int64): List<int64>;
|
function Factorize(n: int64): List<int64>;
|
||||||
|
|
||||||
/// Рразложение числа на простые множители
|
/// Разложение числа на простые множители
|
||||||
function Factorize(n: integer): List<integer>;
|
function Factorize(n: integer): List<integer>;
|
||||||
|
|
||||||
/// Простые числа на интервале [2;n]
|
/// Простые числа на интервале [2;n]
|
||||||
|
|
@ -62,10 +68,10 @@ function FirstPrimes(n: integer): List<integer>;
|
||||||
/// Возвращает список, содержащий цифры числа
|
/// Возвращает список, содержащий цифры числа
|
||||||
function Digits(n: int64): List<integer>;
|
function Digits(n: int64): List<integer>;
|
||||||
|
|
||||||
/// возвращает список делителей натурального числа
|
/// Возвращает список делителей натурального числа
|
||||||
function Divizors(n: int64): List<int64>;
|
function Divizors(n: int64): List<int64>;
|
||||||
|
|
||||||
/// возвращает список делителей натурального числа
|
/// Возвращает список делителей натурального числа
|
||||||
function Divizors(n: integer): List<integer>;
|
function Divizors(n: integer): List<integer>;
|
||||||
|
|
||||||
/// Возвращает Sin угла, заданного в градусах
|
/// Возвращает Sin угла, заданного в градусах
|
||||||
|
|
@ -236,6 +242,9 @@ end;
|
||||||
/// Перевод BigInteger в систему счисления по основанию base (2..36)
|
/// Перевод BigInteger в систему счисления по основанию base (2..36)
|
||||||
function ToBase(BI: BigInteger; base: integer): string;
|
function ToBase(BI: BigInteger; base: integer): string;
|
||||||
begin
|
begin
|
||||||
|
if not (base in 2..36) then
|
||||||
|
raise new School_InvalidBase
|
||||||
|
($'ToDecimal: Недопустимое основание {base}');
|
||||||
var s := new System.Text.StringBuilder('');
|
var s := new System.Text.StringBuilder('');
|
||||||
while BI > 0 do
|
while BI > 0 do
|
||||||
begin
|
begin
|
||||||
|
|
@ -252,6 +261,9 @@ function ToBase(Self: BigInteger; base: integer): string; extensionmethod :=
|
||||||
/// Перевод десятичного числа в систему счисления по основанию base (2..36)
|
/// Перевод десятичного числа в систему счисления по основанию base (2..36)
|
||||||
function ToBase(sDec: string; base: integer): string;
|
function ToBase(sDec: string; base: integer): string;
|
||||||
begin
|
begin
|
||||||
|
if not (base in 2..36) then
|
||||||
|
raise new School_InvalidBase
|
||||||
|
($'ToDecimal: Недопустимое основание {base}');
|
||||||
var n: BigInteger;
|
var n: BigInteger;
|
||||||
if BigInteger.TryParse(sDec, n) then
|
if BigInteger.TryParse(sDec, n) then
|
||||||
Result := ToBase(n, base)
|
Result := ToBase(n, base)
|
||||||
|
|
@ -270,10 +282,12 @@ function MinMax(s: sequence of int64): (int64, int64);
|
||||||
begin
|
begin
|
||||||
var (min, max) := (int64.MaxValue, int64.MinValue);
|
var (min, max) := (int64.MaxValue, int64.MinValue);
|
||||||
foreach var m in s do
|
foreach var m in s do
|
||||||
|
begin
|
||||||
if m < min then
|
if m < min then
|
||||||
min := m
|
min := m;
|
||||||
else if m > max then
|
if m > max then
|
||||||
max := m;
|
max := m
|
||||||
|
end;
|
||||||
Result := (min, max)
|
Result := (min, max)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
@ -282,10 +296,44 @@ function MinMax(s: sequence of integer): (integer, integer);
|
||||||
begin
|
begin
|
||||||
var (min, max) := (integer.MaxValue, integer.MinValue);
|
var (min, max) := (integer.MaxValue, integer.MinValue);
|
||||||
foreach var m in s do
|
foreach var m in s do
|
||||||
|
begin
|
||||||
if m < min then
|
if m < min then
|
||||||
min := m
|
min := m;
|
||||||
else if m > max then
|
if m > max then
|
||||||
max := m;
|
max := m
|
||||||
|
end;
|
||||||
|
Result := (min, max)
|
||||||
|
end;
|
||||||
|
|
||||||
|
/// Возвращает кортеж из минимума и максимума последовательности s
|
||||||
|
function MinMax(s: sequence of real): (real, real);
|
||||||
|
begin
|
||||||
|
var (min, max) := (real.MaxValue, -real.MaxValue);
|
||||||
|
foreach var m in s do
|
||||||
|
begin
|
||||||
|
if m < min then
|
||||||
|
min := m;
|
||||||
|
if m > max then
|
||||||
|
max := m
|
||||||
|
end;
|
||||||
|
Result := (min, max)
|
||||||
|
end;
|
||||||
|
|
||||||
|
/// Возвращает кортеж из минимума и максимума последовательности s
|
||||||
|
function MinMax(s: sequence of BigInteger): (BigInteger, BigInteger);
|
||||||
|
begin
|
||||||
|
var min, max: BigInteger;
|
||||||
|
var FirstValue := True;
|
||||||
|
foreach var m in s do
|
||||||
|
if FirstValue then
|
||||||
|
(min, max, FirstValue) := (m, m, False)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
if m < min then
|
||||||
|
min := m;
|
||||||
|
if m > max then
|
||||||
|
max := m
|
||||||
|
end;
|
||||||
Result := (min, max)
|
Result := (min, max)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
@ -296,7 +344,15 @@ MinMax(Self);
|
||||||
/// Возвращает кортеж из минимума и максимума последовательности
|
/// Возвращает кортеж из минимума и максимума последовательности
|
||||||
function MinMax(Self: sequence of integer): (integer, integer);
|
function MinMax(Self: sequence of integer): (integer, integer);
|
||||||
extensionmethod :=
|
extensionmethod :=
|
||||||
MinMax(Self);
|
MinMax(Self);
|
||||||
|
|
||||||
|
/// Возвращает кортеж из минимума и максимума последовательности
|
||||||
|
function MinMax(Self: sequence of real): (real, real); extensionmethod :=
|
||||||
|
MinMax(Self);
|
||||||
|
|
||||||
|
/// Возвращает кортеж из минимума и максимума последовательности
|
||||||
|
function MinMax(Self: sequence of BigInteger): (BigInteger, BigInteger);
|
||||||
|
extensionmethod := MinMax(Self);
|
||||||
|
|
||||||
{$endregion}
|
{$endregion}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
CAN_NOT_READ=Can not read data of this type
|
CAN_NOT_READ=Can not read data of this type
|
||||||
TUPLE_EXPECTED=Tuple expected
|
TUPLE_EXPECTED=Tuple expected
|
||||||
TUPLE_OR_SEQUENCE_EXPECTED=Tuple or sequence expected
|
TUPLE_OR_SEQUENCE_EXPECTED=Tuple or sequence expected
|
||||||
|
TUPLE_OR_SEQUENCE_EXPECTED_FOREACH=Sequence of tuple or sequence expected
|
||||||
TOO_MANY_ELEMENTS_ON_LEFT_SIDE_OF_TUPLE_ASSIGNMRNT=Too many elements on the left side of tuple assignment
|
TOO_MANY_ELEMENTS_ON_LEFT_SIDE_OF_TUPLE_ASSIGNMRNT=Too many elements on the left side of tuple assignment
|
||||||
ONLY_BASE_ASSIGNMENT_FOR_TUPLE=Tuple allows only base assignment :=
|
ONLY_BASE_ASSIGNMENT_FOR_TUPLE=Tuple allows only base assignment :=
|
||||||
TUPLE_TYPE_ERROR=Bad element in Tuple type
|
TUPLE_TYPE_ERROR=Bad element in Tuple type
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
CAN_NOT_READ=Нельзя считывать данные этого типа
|
CAN_NOT_READ=Нельзя считывать данные этого типа
|
||||||
TUPLE_EXPECTED=Ожидался кортеж
|
TUPLE_EXPECTED=Ожидался кортеж
|
||||||
TUPLE_OR_SEQUENCE_EXPECTED=Ожидался кортеж или последовательность
|
TUPLE_OR_SEQUENCE_EXPECTED=Ожидался кортеж или последовательность
|
||||||
TOO_MANY_ELEMENTS_ON_LEFT_SIDE_OF_TUPLE_ASSIGNMRNT=Слишком много элементов в левой части при присваивании кортежа
|
TUPLE_OR_SEQUENCE_EXPECTED_FOREACH=Ожидалась последовательность кортежей или последовательностей
|
||||||
|
TOO_MANY_ELEMENTS_ON_LEFT_SIDE_OF_TUPLE_ASSIGNMRNT=Слишком много переменных при распаковке кортежа
|
||||||
ONLY_BASE_ASSIGNMENT_FOR_TUPLE=Для кортежа допустимо только обычное присваивание :=
|
ONLY_BASE_ASSIGNMENT_FOR_TUPLE=Для кортежа допустимо только обычное присваивание :=
|
||||||
TUPLE_TYPE_ERROR=Ошибочная конструкция при построении типа кортежа
|
TUPLE_TYPE_ERROR=Ошибочная конструкция при построении типа кортежа
|
||||||
INTEGER_VALUE_EXPECTED=Ожидалось значение целого типа
|
INTEGER_VALUE_EXPECTED=Ожидалось значение целого типа
|
||||||
|
|
@ -11,7 +12,7 @@ INTEGER_OR_CHAR_VALUE_EXPECTED=Ожидалось значение целого
|
||||||
INCOMPATIBLE_DIAPASON_BOUNDS_TYPES=Несовместимые типы границ диапазона
|
INCOMPATIBLE_DIAPASON_BOUNDS_TYPES=Несовместимые типы границ диапазона
|
||||||
INCOMPATIBLE_TYPES_OF_ELEMENT_AND_DIAPASON=Тип элемента несовместим с типом диапазона
|
INCOMPATIBLE_TYPES_OF_ELEMENT_AND_DIAPASON=Тип элемента несовместим с типом диапазона
|
||||||
BAD_SLICE_OBJECT=Срезы допустимы только для строк, динамических массивов и списков
|
BAD_SLICE_OBJECT=Срезы допустимы только для строк, динамических массивов и списков
|
||||||
ONLY_IN_SHORT_FUNC_DEFS_RETURN_TYPE_CANBE_OMITTED=Только в коротких определениях функций можно не указывать тип возвращаемого значения
|
ONLY_IN_SHORT_FUNC_DEFS_RETURN_TYPE_CANBE_OMITTED=Тип возвращаемого значения следует указать явно
|
||||||
ONE_TKIDENTIFIER=В качестве типа ожидался идентификатор
|
ONE_TKIDENTIFIER=В качестве типа ожидался идентификатор
|
||||||
SUGARED_NODE_{0}_IN_SYNTAX_TREE_VISITOR=Сахарный узел {0} не должен обходиться в syntax_tree_visitor. Обратитесь к разработчикам PascalABC.NET
|
SUGARED_NODE_{0}_IN_SYNTAX_TREE_VISITOR=Сахарный узел {0} не должен обходиться в syntax_tree_visitor. Обратитесь к разработчикам PascalABC.NET
|
||||||
MISSED_SEMANTIC_CHECK_FOR_SUGARED_NODE_{0}=Отсутствует семантическая проверка для сахарного узла {0}
|
MISSED_SEMANTIC_CHECK_FOR_SUGARED_NODE_{0}=Отсутствует семантическая проверка для сахарного узла {0}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue