.chm правки
This commit is contained in:
parent
c98642aabb
commit
38d2bab6f5
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "1";
|
||||
public const string Build = "0";
|
||||
public const string Revision = "1282";
|
||||
public const string Revision = "1284";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%MINOR%=1
|
||||
%REVISION%=1282
|
||||
%REVISION%=1284
|
||||
%COREVERSION%=0
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
|
|
@ -540,6 +540,21 @@
|
|||
</i>
|
||||
</OCtx>
|
||||
</Node>
|
||||
<Node Name="В параметрах">
|
||||
<Items>
|
||||
<Node Name="create_not_static_method_call">
|
||||
<FileName>\TreeConverter\TreeConversion\syntax_tree_visitor.cs</FileName>
|
||||
<Text>private base_function_call create_not_static_method_call(function_node fn, expression_node en, location loc, bool procedure_allowed)</Text>
|
||||
<OCtx>
|
||||
<i Type="Method">private base_function_call create_not_static_method_call ( function_node fn , expression_node en , location loc , bool procedure_allowed )</i>
|
||||
<i Type="ClassOrNamespace">public class syntax_tree_visitor : SyntaxTree . AbstractVisitor</i>
|
||||
<i Type="ClassOrNamespace">namespace PascalABCCompiler . TreeConverter</i>
|
||||
<i Type="CS_TreeNode">
|
||||
</i>
|
||||
</OCtx>
|
||||
</Node>
|
||||
</Items>
|
||||
</Node>
|
||||
</Items>
|
||||
</Node>
|
||||
<Node Name="Преобразование синт дерева">
|
||||
|
|
@ -1138,6 +1153,30 @@
|
|||
</Node>
|
||||
</Items>
|
||||
</Node>
|
||||
<Node Name="a.Sort((row1, row2) -> 1)">
|
||||
<FileName>\TreeConverter\TreeConversion\syntax_tree_visitor.cs</FileName>
|
||||
<Text>return;</Text>
|
||||
<OCtx>
|
||||
<i Type="Method">internal void visit_method_call ( SyntaxTree . method_call _method_call )</i>
|
||||
<i Type="ClassOrNamespace">public class syntax_tree_visitor : SyntaxTree . AbstractVisitor</i>
|
||||
<i Type="ClassOrNamespace">namespace PascalABCCompiler . TreeConverter</i>
|
||||
<i Type="CS_TreeNode">
|
||||
</i>
|
||||
</OCtx>
|
||||
<Items>
|
||||
<Node Name="visit_method_call">
|
||||
<FileName>\TreeConverter\TreeConversion\syntax_tree_visitor.cs</FileName>
|
||||
<Text>internal void visit_method_call(SyntaxTree.method_call _method_call)</Text>
|
||||
<OCtx>
|
||||
<i Type="Method">internal void visit_method_call ( SyntaxTree . method_call _method_call )</i>
|
||||
<i Type="ClassOrNamespace">public class syntax_tree_visitor : SyntaxTree . AbstractVisitor</i>
|
||||
<i Type="ClassOrNamespace">namespace PascalABCCompiler . TreeConverter</i>
|
||||
<i Type="CS_TreeNode">
|
||||
</i>
|
||||
</OCtx>
|
||||
</Node>
|
||||
</Items>
|
||||
</Node>
|
||||
</Items>
|
||||
</Node>
|
||||
</AspectFile>
|
||||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.1.0.1282'
|
||||
!define VERSION '3.1.0.1284'
|
||||
|
|
|
|||
|
|
@ -8080,17 +8080,14 @@ end;
|
|||
/// Возвращает последние count элементов последовательности
|
||||
function TakeLast<T>(Self: sequence of T; count: integer): sequence of T; extensionmethod;
|
||||
begin
|
||||
var q := new Queue<T>;
|
||||
foreach var x in Self do
|
||||
begin
|
||||
if q.Count = count then
|
||||
q.Dequeue();
|
||||
q.Enqueue(x);
|
||||
end;
|
||||
Result := q;
|
||||
Result := Self.Reverse.Take(count).Reverse;
|
||||
end;
|
||||
|
||||
// ToDo: SkipLast
|
||||
/// Возвращает последовательность без последних count элементов
|
||||
function SkipLast<T>(self: sequence of T; count: integer): sequence of T; extensionmethod;
|
||||
begin
|
||||
Result := Self.Reverse.Skip(count).Reverse;
|
||||
end;
|
||||
|
||||
/// Декартово произведение последовательностей
|
||||
function Cartesian<T,T1>(Self: sequence of T; b: sequence of T1): sequence of (T,T1); extensionmethod;
|
||||
|
|
|
|||
|
|
@ -205,6 +205,34 @@ namespace PascalABCCompiler.TreeConverter
|
|||
retType.real_type = new LambdaResultTypeInferrer(funcHeader, procBody, visitor).InferResultType();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Заменяет x -> begin result := x.Print end; на x -> begin x.Print end в случае если это один оператор и вызов метода
|
||||
///
|
||||
/// </summary>
|
||||
public static bool TryConvertFuncLambdaBodyWithMethodCallToProcLambdaBody(function_lambda_definition lambdaDef)
|
||||
{
|
||||
var stl = lambdaDef.proc_body as SyntaxTree.statement_list;
|
||||
if (stl.expr_lambda_body)
|
||||
{
|
||||
// Очищаем от Result :=
|
||||
|
||||
var ass = stl.list[0] as assign;
|
||||
if (ass != null && ass.to is ident && (ass.to as ident).name.ToLower() == "result")
|
||||
{
|
||||
var f = ass.from;
|
||||
if (f is method_call)
|
||||
{
|
||||
var ff = f as method_call;
|
||||
stl.list[0] = new procedure_call(ff, ff.source_context); // заменить result := Print(x) на Print(x)
|
||||
lambdaDef.return_type = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Вывод типа параметров лямбд и типа возвращаемого значения при присваивании лямбды переменной
|
||||
/// </summary>
|
||||
|
|
@ -263,27 +291,10 @@ namespace PascalABCCompiler.TreeConverter
|
|||
(lambdaDef.return_type as lambda_inferred_type).real_type = dii_left.return_value_type;
|
||||
else // SSM 23/07/16 - попытка бороться с var p: Shape->() := a->a.Print()
|
||||
{
|
||||
var stl = lambdaDef.proc_body as SyntaxTree.statement_list;
|
||||
if (stl.expr_lambda_body)
|
||||
{
|
||||
// Очищаем от Result :=
|
||||
|
||||
var ass = stl.list[0] as assign;
|
||||
if (ass != null && ass.to is ident && (ass.to as ident).name.ToLower() == "result")
|
||||
{
|
||||
var f = ass.from;
|
||||
if (f is method_call)
|
||||
{
|
||||
var ff = f as method_call;
|
||||
stl.list[0] = new procedure_call(ff, ff.source_context); // заменить result := Print(x) на Print(x)
|
||||
lambdaDef.return_type = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new SimpleSemanticError(visitor.get_location(lambdaDef), "UNABLE_TO_CONVERT_FUNCTIONAL_TYPE_TO_PROCEDURAL_TYPE");
|
||||
var b = TryConvertFuncLambdaBodyWithMethodCallToProcLambdaBody(lambdaDef);
|
||||
if (!b)
|
||||
throw new SimpleSemanticError(visitor.get_location(lambdaDef), "UNABLE_TO_CONVERT_FUNCTIONAL_TYPE_TO_PROCEDURAL_TYPE");
|
||||
}
|
||||
//throw new SimpleSemanticError(visitor.get_location(lambdaDef), "UNABLE_TO_CONVERT_FUNCTIONAL_TYPE_TO_PROCEDURAL_TYPE");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -8864,7 +8864,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
try_convert_typed_expression_to_function_call(ref en);
|
||||
if ((!procedure_allowed) && (fn.return_value_type == null))
|
||||
{
|
||||
AddError(loc, "FUNCTION_EXPECTED_PROCEDURE_{0}_MEET", fn);
|
||||
AddError(loc, "FUNCTION_EXPECTED_PROCEDURE_{0}_MEET", fn.name);
|
||||
}
|
||||
if (fn.semantic_node_type == semantic_node_type.common_method_node)
|
||||
{
|
||||
|
|
@ -15726,7 +15726,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
var fld1 = _assign.from as SyntaxTree.function_lambda_definition;
|
||||
if (fld1 != null)
|
||||
{
|
||||
MaybeConvertFunctionLambdaDefinitionToProcedureLambdaDefinition(fld1);
|
||||
//MaybeConvertFunctionLambdaDefinitionToProcedureLambdaDefinition(fld1);
|
||||
LambdaHelper.InferTypesFromVarStmt(to.type, fld1, this); //lroman//
|
||||
}
|
||||
|
||||
|
|
@ -18223,6 +18223,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
public void MaybeConvertFunctionLambdaDefinitionToProcedureLambdaDefinition(function_lambda_definition _function_lambda_definition)
|
||||
{
|
||||
// SSM 23/07/16 - вроде сделал лучше в LambdaHelper.InferTypesFromVarStmt, но пока везде удалять вызов этой функции не решаюсь - лень тестировать
|
||||
// SSM 18/04/16 попытка разрешить x->Print(x)
|
||||
var stl = _function_lambda_definition.proc_body as SyntaxTree.statement_list;
|
||||
if (_function_lambda_definition.return_type is lambda_inferred_type && stl != null && stl.list.Count == 1 && _function_lambda_definition.usedkeyword == 0)
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -8080,17 +8080,14 @@ end;
|
|||
/// Возвращает последние count элементов последовательности
|
||||
function TakeLast<T>(Self: sequence of T; count: integer): sequence of T; extensionmethod;
|
||||
begin
|
||||
var q := new Queue<T>;
|
||||
foreach var x in Self do
|
||||
begin
|
||||
if q.Count = count then
|
||||
q.Dequeue();
|
||||
q.Enqueue(x);
|
||||
end;
|
||||
Result := q;
|
||||
Result := Self.Reverse.Take(count).Reverse;
|
||||
end;
|
||||
|
||||
// ToDo: SkipLast
|
||||
/// Возвращает последовательность без последних count элементов
|
||||
function SkipLast<T>(self: sequence of T; count: integer): sequence of T; extensionmethod;
|
||||
begin
|
||||
Result := Self.Reverse.Skip(count).Reverse;
|
||||
end;
|
||||
|
||||
/// Декартово произведение последовательностей
|
||||
function Cartesian<T,T1>(Self: sequence of T; b: sequence of T1): sequence of (T,T1); extensionmethod;
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in a new issue