This commit is contained in:
Бондарев Иван 2017-12-31 14:37:37 +01:00
parent 4a9f3171bd
commit 6e177e0c90
3 changed files with 43 additions and 13 deletions

19
TestSuite/lambdas5.pas Normal file
View file

@ -0,0 +1,19 @@
type
t1=class
function f1(aX,aY:Single):=byte(2);
constructor;
begin
var MAng := 0;
var NP2 := new byte[1];
NP2.Fill(i->self.f1(i,MAng));
assert(NP2[0] = 2);
end;
end;
begin
new t1;
end.

View file

@ -287,7 +287,8 @@ namespace PascalABCCompiler.TreeConverter
if (lst.statements[0] is basic_function_call) if (lst.statements[0] is basic_function_call)
{ {
base_function_call bfc = lst.statements[0] as basic_function_call; base_function_call bfc = lst.statements[0] as basic_function_call;
if (bfc.type != null && bfc.type.name.Contains("<>local_variables_class"))
return true;
} }
return false; return false;
} }

View file

@ -16649,12 +16649,12 @@ namespace PascalABCCompiler.TreeConverter
} }
else //уже генерируем одну из веток else //уже генерируем одну из веток
if (CurrentParallelPosition == ParallelPosition.InsideParallel) if (CurrentParallelPosition == ParallelPosition.InsideParallel)
{ {
isGenerateParallel = true; isGenerateParallel = true;
isGenerateSequential = false; isGenerateSequential = false;
} }
//else //else
//флаг isGenerateParallel не установлен, параллельная ветка не сгенерируется //флаг isGenerateParallel не установлен, параллельная ветка не сгенерируется
} }
#endregion #endregion
@ -16662,17 +16662,27 @@ namespace PascalABCCompiler.TreeConverter
statements_list stl = new statements_list(get_location(_statement_list), get_location_with_check(_statement_list.left_logical_bracket), get_location_with_check(_statement_list.right_logical_bracket)); statements_list stl = new statements_list(get_location(_statement_list), get_location_with_check(_statement_list.left_logical_bracket), get_location_with_check(_statement_list.right_logical_bracket));
convertion_data_and_alghoritms.statement_list_stack_push(stl); convertion_data_and_alghoritms.statement_list_stack_push(stl);
for (var i=0; i< _statement_list.subnodes.Count; i++) // SSM 13.10.16 - поменял т.к. собираюсь менять узлы в процессе обхода for (var i = 0; i < _statement_list.subnodes.Count; i++) // SSM 13.10.16 - поменял т.к. собираюсь менять узлы в процессе обхода
{ {
statement syntax_statement = _statement_list.subnodes[i]; statement syntax_statement = _statement_list.subnodes[i];
try try
{ {
statement_node semantic_statement = convert_strong(syntax_statement); statement_node semantic_statement = convert_strong(syntax_statement);
if (semantic_statement != null) bool lambda_init_code = false;
{ if (semantic_statement is basic_function_call)
{
base_function_call bfc = semantic_statement as basic_function_call;
if (bfc.type != null && bfc.type.name.Contains("<>local_variables_class"))
lambda_init_code = true;
}
if (semantic_statement != null)
{
if (context.allow_inherited_ctor_call && !lambda_init_code)
stl.statements.AddElementFirst(semantic_statement);
else
stl.statements.AddElement(semantic_statement); stl.statements.AddElement(semantic_statement);
} }
if (!lambda_init_code)
context.allow_inherited_ctor_call = false; context.allow_inherited_ctor_call = false;
} }
catch (Errors.Error ex) catch (Errors.Error ex)