diff --git a/SyntaxTree/tree/TreeHelper.cs b/SyntaxTree/tree/TreeHelper.cs
index 38d5d804f..4600b1468 100644
--- a/SyntaxTree/tree/TreeHelper.cs
+++ b/SyntaxTree/tree/TreeHelper.cs
@@ -662,7 +662,10 @@ namespace PascalABCCompiler.SyntaxTree
{
var sb = new System.Text.StringBuilder();
sb.Append("procedure ");
- sb.Append(name.ToString());
+ if (name != null)
+ sb.Append(name.ToString());
+ else
+ sb.Append("NONAME");
if (template_args != null)
sb.Append("<" + template_args.ToString() + ">");
@@ -1175,7 +1178,7 @@ namespace PascalABCCompiler.SyntaxTree
{ }
public override string ToString()
{
- return "new "+this.type.ToString()+"("+this.params_list.ToString()+")";
+ return "new "+ (this.type != null ? this.type.ToString() : "NOTYPE") + "(" +(this.params_list != null ? this.params_list.ToString() : "NOPARAMS") + ")";
}
}
@@ -1459,6 +1462,7 @@ namespace PascalABCCompiler.SyntaxTree
{
protected ident _UnknownID;
protected ident _ClassName;
+ protected bool _IsYieldInStaticMethod;
public ident UnknownID
{
@@ -1472,24 +1476,32 @@ namespace PascalABCCompiler.SyntaxTree
set { _ClassName = value; }
}
- ///
- ///Конструктор с параметрами.
- ///
- public yield_unknown_ident(ident _UnknownID, ident _ClassName)
+ public bool IsYieldInStaticMethod
{
- this._name = _UnknownID.name;
- this._UnknownID = _UnknownID;
- this._ClassName = _ClassName;
+ get { return _IsYieldInStaticMethod; }
+ set { _IsYieldInStaticMethod = value; }
}
///
///Конструктор с параметрами.
///
- public yield_unknown_ident(ident _UnknownID, ident _ClassName, SourceContext sc)
+ public yield_unknown_ident(ident _UnknownID, ident _ClassName, bool isYieldInStaticMethod = false)
{
this._name = _UnknownID.name;
this._UnknownID = _UnknownID;
this._ClassName = _ClassName;
+ this._IsYieldInStaticMethod = isYieldInStaticMethod;
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public yield_unknown_ident(ident _UnknownID, ident _ClassName, bool isYieldInStaticMethod, SourceContext sc)
+ {
+ this._name = _UnknownID.name;
+ this._UnknownID = _UnknownID;
+ this._ClassName = _ClassName;
+ this._IsYieldInStaticMethod = isYieldInStaticMethod;
source_context = sc;
}
}
diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs
index afe4ef679..80039fc4c 100644
--- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs
+++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs
@@ -18998,6 +18998,7 @@ namespace PascalABCCompiler.TreeConverter
private bool CheckUnknownIdentNeedsClassCapture(SyntaxTree.yield_unknown_ident _unk, out bool isStaticIdent)
{
+
string Consts__Self = YieldHelpers.YieldConsts.Self;
// Find semantic class containing iterator (yield-method) with unknown ident
@@ -19031,6 +19032,9 @@ namespace PascalABCCompiler.TreeConverter
|| found.sym_info is compiled_function_node
|| found.sym_info is compiled_property_node)
{
+ if (!isStaticIdent && _unk.IsYieldInStaticMethod)
+ return false;
+
// frninja 06/06/16 - фиксим private того же модуля
if ((iteratorContainingClass is common_type_node)
&& this.GetUnknownIdentUnit(found.sym_info) ==
diff --git a/Yield/SyntaxVisitors/YieldVisitors/ProcessYieldsCapturedVars.cs b/Yield/SyntaxVisitors/YieldVisitors/ProcessYieldsCapturedVars.cs
index 16c66db8e..c23c3b964 100644
--- a/Yield/SyntaxVisitors/YieldVisitors/ProcessYieldsCapturedVars.cs
+++ b/Yield/SyntaxVisitors/YieldVisitors/ProcessYieldsCapturedVars.cs
@@ -755,6 +755,7 @@ namespace SyntaxVisitors
capturedLocalsNamesMap,
capturedFormalParamsNamesMap,
IsClassMethod(pd),
+ pd.proc_header.class_keyword,
GetClassName(pd)
);
// Replace
diff --git a/Yield/SyntaxVisitors/YieldVisitors/ReplaceCapturedVariablesVisitor.cs b/Yield/SyntaxVisitors/YieldVisitors/ReplaceCapturedVariablesVisitor.cs
index 76d287883..31af3a855 100644
--- a/Yield/SyntaxVisitors/YieldVisitors/ReplaceCapturedVariablesVisitor.cs
+++ b/Yield/SyntaxVisitors/YieldVisitors/ReplaceCapturedVariablesVisitor.cs
@@ -23,6 +23,7 @@ namespace SyntaxVisitors
private IDictionary CapturedFormalParamsMap = new Dictionary();
private bool IsInClassMethod = true;
+ private bool IsStaticMethod = false;
private ident ClassName;
@@ -35,7 +36,7 @@ namespace SyntaxVisitors
IEnumerable unitGlobals,
IDictionary localsMap,
IDictionary formalParamsMap,
- bool isInClassMethod, ident className)
+ bool isInClassMethod, bool isStaticMethod, ident className)
{
CollectedLocals = new HashSet(locals);
CollectedFormalParams = new HashSet(formalParams);
@@ -120,7 +121,7 @@ namespace SyntaxVisitors
if (!id.name.StartsWith("<")) // Check for already captured
{
- Replace(id, new yield_unknown_ident(id, ClassName));
+ Replace(id, new yield_unknown_ident(id, ClassName, this.IsStaticMethod));
}
}
}