parent
356e185bef
commit
8bdad9b717
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
||||||
public const string Major = "3";
|
public const string Major = "3";
|
||||||
public const string Minor = "5";
|
public const string Minor = "5";
|
||||||
public const string Build = "0";
|
public const string Build = "0";
|
||||||
public const string Revision = "2150";
|
public const string Revision = "2151";
|
||||||
|
|
||||||
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%=0
|
|
||||||
%REVISION%=2150
|
|
||||||
%MINOR%=5
|
%MINOR%=5
|
||||||
|
%REVISION%=2151
|
||||||
|
%COREVERSION%=0
|
||||||
%MAJOR%=3
|
%MAJOR%=3
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
!define VERSION '3.5.0.2150'
|
!define VERSION '3.5.0.2151'
|
||||||
|
|
|
||||||
|
|
@ -332,6 +332,11 @@ namespace PascalABCCompiler.SyntaxTree
|
||||||
{
|
{
|
||||||
get { return new statement_list(); }
|
get { return new statement_list(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return "begin " + list.Select(st=>st is empty_statement ? "" : st.ToString()+"; ").Aggregate((s,x)=>s+x)+ "end";
|
||||||
|
}
|
||||||
//-- List members end
|
//-- List members end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -564,7 +569,7 @@ namespace PascalABCCompiler.SyntaxTree
|
||||||
sb.Append(" := ");
|
sb.Append(" := ");
|
||||||
sb.Append(inital_value.ToString());
|
sb.Append(inital_value.ToString());
|
||||||
}
|
}
|
||||||
sb.Append("; ");
|
//sb.Append("; ");
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -761,14 +766,15 @@ namespace PascalABCCompiler.SyntaxTree
|
||||||
if (name != null)
|
if (name != null)
|
||||||
sb.Append(name.ToString());
|
sb.Append(name.ToString());
|
||||||
else
|
else
|
||||||
sb.Append("NONAME");
|
sb.Append("");
|
||||||
|
|
||||||
if (template_args != null)
|
if (template_args != null)
|
||||||
sb.Append("<" + template_args.ToString() + ">");
|
sb.Append("<" + template_args.ToString() + ">");
|
||||||
|
|
||||||
if (parameters != null)
|
if (parameters != null)
|
||||||
sb.Append("(" + parameters.ToString() + ")");
|
sb.Append("(" + parameters.ToString() + ")");
|
||||||
sb.Append(";");
|
if (name != null)
|
||||||
|
sb.Append(";");
|
||||||
if (this.proc_attributes != null)
|
if (this.proc_attributes != null)
|
||||||
foreach (var pa in this.proc_attributes.proc_attributes)
|
foreach (var pa in this.proc_attributes.proc_attributes)
|
||||||
sb.Append(" " + pa.ToString() + " ");
|
sb.Append(" " + pa.ToString() + " ");
|
||||||
|
|
@ -1669,7 +1675,11 @@ namespace PascalABCCompiler.SyntaxTree
|
||||||
{
|
{
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return "" + this._ident_list.ToString() + " -> lambda_body";
|
var s = this._ident_list.ToString();
|
||||||
|
if (_ident_list.Count != 1)
|
||||||
|
s = "(" + s + ")";
|
||||||
|
var b = this.proc_body.ToString();
|
||||||
|
return "" + s + " -> "+b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1893,5 +1903,14 @@ namespace PascalABCCompiler.SyntaxTree
|
||||||
this.source_context = sc;
|
this.source_context = sc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public partial class empty_statement
|
||||||
|
{
|
||||||
|
public override string ToString() => "<>";
|
||||||
|
}
|
||||||
|
public partial class modern_proc_type
|
||||||
|
{
|
||||||
|
public override string ToString() => "<proc_type>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
19
TestSuite/lambda_3_levels_a.pas
Normal file
19
TestSuite/lambda_3_levels_a.pas
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
begin
|
||||||
|
var a := 1;
|
||||||
|
|
||||||
|
var l0: procedure :=
|
||||||
|
()->
|
||||||
|
begin
|
||||||
|
var l1: procedure := ()->Assert(777=777);
|
||||||
|
|
||||||
|
var l2: integer->()->() :=
|
||||||
|
i->
|
||||||
|
begin
|
||||||
|
Assert(666=666);
|
||||||
|
Result := ()-> Assert(a+i=8);
|
||||||
|
end;
|
||||||
|
l1;
|
||||||
|
l2(7)();
|
||||||
|
end;
|
||||||
|
l0();
|
||||||
|
end.
|
||||||
|
|
@ -544,6 +544,14 @@ namespace TreeConverter.LambdaExpressions.Closure
|
||||||
|
|
||||||
private void AddReferencesToIdentInLambda(type_declaration upperScopeWhereVarsAreCapturedClass, CapturedVariablesTreeNode scope, string varName, syntax_tree_node syntaxTreeNodeWithVarDeclaration, dot_node substDotNode, bool nestedLambda)
|
private void AddReferencesToIdentInLambda(type_declaration upperScopeWhereVarsAreCapturedClass, CapturedVariablesTreeNode scope, string varName, syntax_tree_node syntaxTreeNodeWithVarDeclaration, dot_node substDotNode, bool nestedLambda)
|
||||||
{
|
{
|
||||||
|
/*#if DEBUG
|
||||||
|
var pp = scope.ToString().IndexOf("TreeNode");
|
||||||
|
var ss = scope.ToString().Remove(0, pp + 8).Replace("Scope"," ");
|
||||||
|
var cn = "";
|
||||||
|
if (scope.ChildNodes.Count>0)
|
||||||
|
cn = "Childs: "+ scope.ChildNodes.Aggregate("",(s, x) => s + x.ScopeIndex.ToString() + " ");
|
||||||
|
System.IO.File.AppendAllText("d:\\w.txt", "AddR enter: " + ss + scope.ScopeIndex + " " + cn + "" +scope.CorrespondingSyntaxTreeNode + "\n");
|
||||||
|
#endif*/
|
||||||
for (var i = 0; i < scope.ChildNodes.Count; i++)
|
for (var i = 0; i < scope.ChildNodes.Count; i++)
|
||||||
{
|
{
|
||||||
if (!(scope.ChildNodes[i] is CapturedVariablesTreeNodeLambdaScope))
|
if (!(scope.ChildNodes[i] is CapturedVariablesTreeNodeLambdaScope))
|
||||||
|
|
@ -579,6 +587,10 @@ namespace TreeConverter.LambdaExpressions.Closure
|
||||||
|
|
||||||
if (!_substitutions.ContainsKey(substKey))
|
if (!_substitutions.ContainsKey(substKey))
|
||||||
{
|
{
|
||||||
|
/*#if DEBUG
|
||||||
|
System.IO.File.AppendAllText("d:\\w.txt", "1 substitutions.Add: " + substKey + " " + substDotNode + "\n");
|
||||||
|
#endif*/
|
||||||
|
|
||||||
_substitutions.Add(substKey, substDotNode);
|
_substitutions.Add(substKey, substDotNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -634,19 +646,26 @@ namespace TreeConverter.LambdaExpressions.Closure
|
||||||
scope.ChildNodes[0].CorrespondingSyntaxTreeNode);
|
scope.ChildNodes[0].CorrespondingSyntaxTreeNode);
|
||||||
if (!_substitutions.ContainsKey(substKey))
|
if (!_substitutions.ContainsKey(substKey))
|
||||||
{
|
{
|
||||||
|
/*#if DEBUG
|
||||||
|
System.IO.File.AppendAllText("d:\\w.txt", "2 substitutions.Add: " + substKey + " " + substDotNode + "\n");
|
||||||
|
#endif*/
|
||||||
|
|
||||||
_substitutions.Add(substKey, substDotNode1);
|
_substitutions.Add(substKey, substDotNode1);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddReferencesToIdentInLambda(_capturedVarsClassDefs[scopeAsLambda.ScopeIndexOfClassWhereLambdaWillBeAddedAsMethod.Value].ClassDeclaration, scopeAsLambda.ChildNodes[0], varName, syntaxTreeNodeWithVarDeclaration, substDotNode1, true);
|
AddReferencesToIdentInLambda(_capturedVarsClassDefs[scopeAsLambda.ScopeIndexOfClassWhereLambdaWillBeAddedAsMethod.Value].ClassDeclaration, scopeAsLambda.ChildNodes[0], varName, syntaxTreeNodeWithVarDeclaration, substDotNode1, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddReferencesToIdentInLambda(upperScopeWhereVarsAreCapturedClass, scope.ChildNodes[0], varName, syntaxTreeNodeWithVarDeclaration, substDotNode, nestedLambda);
|
// SSM 25.06.19 fix #1988 - заменил ошибочное scope.ChildNodes[0] на scope.ChildNodes[i]
|
||||||
|
AddReferencesToIdentInLambda(upperScopeWhereVarsAreCapturedClass, scope.ChildNodes[i], varName, syntaxTreeNodeWithVarDeclaration, substDotNode, nestedLambda);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*#if DEBUG
|
||||||
|
System.IO.File.AppendAllText("d:\\w.txt", "AddR exit: " + scope.ScopeIndex+"\n");
|
||||||
|
#endif*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void VisitTreeAndBuildClassDefinitions(CapturedVariablesTreeNode currentNode)
|
private void VisitTreeAndBuildClassDefinitions(CapturedVariablesTreeNode currentNode)
|
||||||
{
|
{
|
||||||
var variablesFromThisScopeWhichWereCaptured = currentNode
|
var variablesFromThisScopeWhichWereCaptured = currentNode
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue