This commit is contained in:
Mikhalkovich Stanislav 2019-06-21 20:32:01 +03:00
parent fe19dfabee
commit 75ef577703
8 changed files with 71 additions and 7 deletions

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "5";
public const string Build = "0";
public const string Revision = "2134";
public const string Revision = "2135";
public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%COREVERSION%=0
%REVISION%=2134
%MINOR%=5
%REVISION%=2135
%COREVERSION%=0
%MAJOR%=3

Binary file not shown.

View file

@ -1 +1 @@
!define VERSION '3.5.0.2134'
!define VERSION '3.5.0.2135'

View file

@ -30,7 +30,38 @@ namespace SyntaxVisitors
{
if (node is T)
foundT = true;
else
else
base.DefaultVisit(node);
}
}
public class HasStatementWithBarrierVisitor<T,Barrier> : BaseEnterExitVisitor
where T : statement
where Barrier: syntax_tree_node
{
private bool foundT = false;
public static bool Has(syntax_tree_node node)
{
HasStatementWithBarrierVisitor<T, Barrier> vis = new HasStatementWithBarrierVisitor<T, Barrier>();
vis.ProcessNode(node);
return vis.foundT;
}
public override void Enter(syntax_tree_node sn) // Искать всюду, но не заходить в узлы Barrier и вложенные
{
if (sn is Barrier)
{
visitNode = false;
}
}
public override void DefaultVisit(syntax_tree_node node)
{
if (node is T)
foundT = true;
else
base.DefaultVisit(node);
}
}

View file

@ -100,12 +100,14 @@ namespace SyntaxVisitors
throw new SyntaxVisitorError("FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_NESTED_SUBROUTINES", pd.source_context);
}
if (pd.has_yield && pd.DescendantNodes().OfType<try_stmt>().Count() > 0)
if (pd.has_yield && HasStatementWithBarrierVisitor<try_stmt,function_lambda_definition>.Has(pd))
//pd.DescendantNodes().OfType<try_stmt>().Count() > 0)
{
throw new SyntaxVisitorError("FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_TRY_EXCEPT_FINALLY", pd.source_context);
}
if (pd.has_yield && pd.DescendantNodes().OfType<lock_stmt>().Count() > 0)
if (pd.has_yield && HasStatementWithBarrierVisitor<lock_stmt,function_lambda_definition>.Has(pd))
//pd.DescendantNodes().OfType<lock_stmt>().Count() > 0)
{
throw new SyntaxVisitorError("FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_LOCK", pd.source_context);
}

View file

@ -0,0 +1,16 @@
function f1: sequence of byte; //Ошибка: Функции с yield не могут содержать блоков try..except и try..finally
begin
yield 0;
var p: procedure := ()->
begin
lock(new object) do
begin
end;
end;
end;
begin
end.

View file

@ -0,0 +1,15 @@
function f1: sequence of byte; //Ошибка: Функции с yield не могут содержать блоков try..except и try..finally
begin
yield 0;
var p: procedure := ()->
begin
try
except
end
end;
end;
begin
end.