parent
68627c6908
commit
a2c16c54cb
|
|
@ -59,7 +59,7 @@ namespace SyntaxVisitors
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Нескольких переменных тут всё равно не будет - это ошибка
|
// Нескольких переменных тут всё равно не будет - это ошибка
|
||||||
ReplaceStatement(vs, SeqStatements(vs.var_def.vars.idents.Select(id => new assign(id, vs.var_def.inital_value)).ToArray()));
|
ReplaceStatement(vs, SeqStatements(vs.var_def.vars.idents.Select(id => new assign(id, vs.var_def.inital_value, vs.source_context)).ToArray()));
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalDeletedDefsNames.UnionWith(vs.var_def.vars.idents.Select(id => id.name));
|
LocalDeletedDefsNames.UnionWith(vs.var_def.vars.idents.Select(id => id.name));
|
||||||
|
|
|
||||||
14
TestSuite/yieldnil2.pas
Normal file
14
TestSuite/yieldnil2.pas
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
type
|
||||||
|
t1 = class end;
|
||||||
|
t2 = class
|
||||||
|
function f1: sequence of t1;//должен быть какой то класс, sequence of object не вызывает ошибку
|
||||||
|
begin
|
||||||
|
yield nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
var o := new t2;
|
||||||
|
var o2 := o.f1.ToArray()[0];
|
||||||
|
assert(o2 = nil);
|
||||||
|
end.
|
||||||
|
|
@ -172,7 +172,10 @@ namespace TreeConverter.LambdaExpressions.Closure
|
||||||
var varName = ((IVAriableDefinitionNode)symbolInfo.SymbolInfo.sym_info).name.ToLower();
|
var varName = ((IVAriableDefinitionNode)symbolInfo.SymbolInfo.sym_info).name.ToLower();
|
||||||
var ff = symbolInfo.SymbolInfo.sym_info.GetType();
|
var ff = symbolInfo.SymbolInfo.sym_info.GetType();
|
||||||
var isSelfWordInClass = scope is CapturedVariablesTreeNodeClassScope && varName == compiler_string_consts.self_word;
|
var isSelfWordInClass = scope is CapturedVariablesTreeNodeClassScope && varName == compiler_string_consts.self_word;
|
||||||
|
SourceContext sourceCtxt = null;
|
||||||
|
if (symbolInfo.SymbolInfo.sym_info.location != null)
|
||||||
|
sourceCtxt = new SourceContext(symbolInfo.SymbolInfo.sym_info.location.begin_line_num, symbolInfo.SymbolInfo.sym_info.location.begin_column_num,
|
||||||
|
symbolInfo.SymbolInfo.sym_info.location.end_line_num, symbolInfo.SymbolInfo.sym_info.location.end_column_num);
|
||||||
foreach (var referencingLambda in symbolInfo.ReferencingLambdas.OrderByDescending(rl => rl.ScopeIndex))
|
foreach (var referencingLambda in symbolInfo.ReferencingLambdas.OrderByDescending(rl => rl.ScopeIndex))
|
||||||
{
|
{
|
||||||
if (scope != referencingLambda.ParentNode)
|
if (scope != referencingLambda.ParentNode)
|
||||||
|
|
@ -211,7 +214,7 @@ namespace TreeConverter.LambdaExpressions.Closure
|
||||||
new dot_node(
|
new dot_node(
|
||||||
new ident(
|
new ident(
|
||||||
_capturedVarsClassDefs[upperScopeWhereVarsAreCaptured.ScopeIndex]
|
_capturedVarsClassDefs[upperScopeWhereVarsAreCaptured.ScopeIndex]
|
||||||
.GeneratedSubstitutingFieldName), new ident(varName)));
|
.GeneratedSubstitutingFieldName, sourceCtxt), new ident(varName, sourceCtxt), sourceCtxt));
|
||||||
}
|
}
|
||||||
|
|
||||||
while (upperScopesStack.Count != 0)
|
while (upperScopesStack.Count != 0)
|
||||||
|
|
@ -246,10 +249,10 @@ namespace TreeConverter.LambdaExpressions.Closure
|
||||||
new dot_node(
|
new dot_node(
|
||||||
new ident(
|
new ident(
|
||||||
_capturedVarsClassDefs[upperScopeWhereVarsAreCaptured.ScopeIndex]
|
_capturedVarsClassDefs[upperScopeWhereVarsAreCaptured.ScopeIndex]
|
||||||
.GeneratedSubstitutingFieldName),
|
.GeneratedSubstitutingFieldName, sourceCtxt),
|
||||||
new ident(
|
new ident(
|
||||||
_capturedVarsClassDefs[upperScopeWhereVarsAreCaptured.ScopeIndex]
|
_capturedVarsClassDefs[upperScopeWhereVarsAreCaptured.ScopeIndex]
|
||||||
.GeneratedUpperClassFieldName));
|
.GeneratedUpperClassFieldName, sourceCtxt), sourceCtxt);
|
||||||
|
|
||||||
var nodeForDotNodeCalc = upperScopeWhereVarsAreCaptured.ParentNode;
|
var nodeForDotNodeCalc = upperScopeWhereVarsAreCaptured.ParentNode;
|
||||||
while (nodeForDotNodeCalc != scope)
|
while (nodeForDotNodeCalc != scope)
|
||||||
|
|
@ -269,7 +272,7 @@ namespace TreeConverter.LambdaExpressions.Closure
|
||||||
}
|
}
|
||||||
if (!isSelfWordInClass)
|
if (!isSelfWordInClass)
|
||||||
{
|
{
|
||||||
dotnode = new dot_node(dotnode, new ident(varName));
|
dotnode = new dot_node(dotnode, new ident(varName, sourceCtxt), sourceCtxt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -277,8 +280,8 @@ namespace TreeConverter.LambdaExpressions.Closure
|
||||||
dotnode = new dot_node(new ident(
|
dotnode = new dot_node(new ident(
|
||||||
_capturedVarsClassDefs[
|
_capturedVarsClassDefs[
|
||||||
upperScopeWhereVarsAreCaptured.ScopeIndex]
|
upperScopeWhereVarsAreCaptured.ScopeIndex]
|
||||||
.GeneratedSubstitutingFieldName),
|
.GeneratedSubstitutingFieldName, sourceCtxt),
|
||||||
new ident(varName));
|
new ident(varName, sourceCtxt), sourceCtxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_substitutions.ContainsKey(substKey))
|
if (!_substitutions.ContainsKey(substKey))
|
||||||
|
|
@ -319,7 +322,7 @@ namespace TreeConverter.LambdaExpressions.Closure
|
||||||
{
|
{
|
||||||
new ident(
|
new ident(
|
||||||
_capturedVarsClassDefs[nextNodeWhereVarsAreCaptured.ScopeIndex]
|
_capturedVarsClassDefs[nextNodeWhereVarsAreCaptured.ScopeIndex]
|
||||||
.GeneratedUpperClassFieldName)
|
.GeneratedUpperClassFieldName, sourceCtxt)
|
||||||
},
|
},
|
||||||
new List<type_definition> {fieldType});
|
new List<type_definition> {fieldType});
|
||||||
|
|
||||||
|
|
@ -331,13 +334,14 @@ namespace TreeConverter.LambdaExpressions.Closure
|
||||||
new dot_node(
|
new dot_node(
|
||||||
new ident(
|
new ident(
|
||||||
_capturedVarsClassDefs[nextNodeWhereVarsAreCaptured.ScopeIndex]
|
_capturedVarsClassDefs[nextNodeWhereVarsAreCaptured.ScopeIndex]
|
||||||
.GeneratedSubstitutingFieldName),
|
.GeneratedSubstitutingFieldName, sourceCtxt),
|
||||||
new ident(
|
new ident(
|
||||||
_capturedVarsClassDefs[nextNodeWhereVarsAreCaptured.ScopeIndex]
|
_capturedVarsClassDefs[nextNodeWhereVarsAreCaptured.ScopeIndex]
|
||||||
.GeneratedUpperClassFieldName)),
|
.GeneratedUpperClassFieldName), sourceCtxt),
|
||||||
new ident(
|
new ident(
|
||||||
_capturedVarsClassDefs[upperScopeWhereVarsAreCaptured.ScopeIndex]
|
_capturedVarsClassDefs[upperScopeWhereVarsAreCaptured.ScopeIndex]
|
||||||
.GeneratedSubstitutingFieldName));
|
.GeneratedSubstitutingFieldName, sourceCtxt),
|
||||||
|
sourceCtxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
substKey = new SubstitutionKey(varName, symbolInfo.SyntaxTreeNodeWithVarDeclaration,
|
substKey = new SubstitutionKey(varName, symbolInfo.SyntaxTreeNodeWithVarDeclaration,
|
||||||
|
|
@ -362,7 +366,7 @@ namespace TreeConverter.LambdaExpressions.Closure
|
||||||
dot = new dot_node(dot,
|
dot = new dot_node(dot,
|
||||||
new ident(
|
new ident(
|
||||||
_capturedVarsClassDefs[nodeForDotNodeCalculation.ScopeIndex]
|
_capturedVarsClassDefs[nodeForDotNodeCalculation.ScopeIndex]
|
||||||
.GeneratedUpperClassFieldName));
|
.GeneratedUpperClassFieldName, sourceCtxt), sourceCtxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeForDotNodeCalculation = nodeForDotNodeCalculation.ParentNode;
|
nodeForDotNodeCalculation = nodeForDotNodeCalculation.ParentNode;
|
||||||
|
|
@ -370,13 +374,13 @@ namespace TreeConverter.LambdaExpressions.Closure
|
||||||
|
|
||||||
if (!isSelfWordInClass)
|
if (!isSelfWordInClass)
|
||||||
{
|
{
|
||||||
dot = new dot_node(dot, new ident(varName));
|
dot = new dot_node(dot, new ident(varName, sourceCtxt), sourceCtxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_substitutions.ContainsKey(substKey))
|
if (!_substitutions.ContainsKey(substKey))
|
||||||
{
|
{
|
||||||
if (ClassField != null && ClassField.IsStatic)
|
if (ClassField != null && ClassField.IsStatic)
|
||||||
_substitutions.Add(substKey, new dot_node(ClassName, new ident(varName)));// sc не заполнен, что плохо!
|
_substitutions.Add(substKey, new dot_node(ClassName, new ident(varName, sourceCtxt), sourceCtxt));// sc не заполнен, что плохо!
|
||||||
else
|
else
|
||||||
_substitutions.Add(substKey, dot);
|
_substitutions.Add(substKey, dot);
|
||||||
}
|
}
|
||||||
|
|
@ -397,10 +401,10 @@ namespace TreeConverter.LambdaExpressions.Closure
|
||||||
dotnode1 = new dot_node(ClassName, new ident(varName));
|
dotnode1 = new dot_node(ClassName, new ident(varName));
|
||||||
else
|
else
|
||||||
dotnode1 = new dot_node(
|
dotnode1 = new dot_node(
|
||||||
new ident(compiler_string_consts.self_word),
|
new ident(compiler_string_consts.self_word, sourceCtxt),
|
||||||
new ident(
|
new ident(
|
||||||
_capturedVarsClassDefs[upperScopeWhereVarsAreCaptured.ScopeIndex]
|
_capturedVarsClassDefs[upperScopeWhereVarsAreCaptured.ScopeIndex]
|
||||||
.GeneratedUpperClassFieldName));
|
.GeneratedUpperClassFieldName, sourceCtxt), sourceCtxt);
|
||||||
|
|
||||||
if (upperScopeWhereVarsAreCaptured != scope)
|
if (upperScopeWhereVarsAreCaptured != scope)
|
||||||
{
|
{
|
||||||
|
|
@ -414,7 +418,7 @@ namespace TreeConverter.LambdaExpressions.Closure
|
||||||
dotnode1 = new dot_node(dotnode1,
|
dotnode1 = new dot_node(dotnode1,
|
||||||
new ident(
|
new ident(
|
||||||
_capturedVarsClassDefs[nodeForDotNodeCalc.ScopeIndex]
|
_capturedVarsClassDefs[nodeForDotNodeCalc.ScopeIndex]
|
||||||
.GeneratedUpperClassFieldName));
|
.GeneratedUpperClassFieldName, sourceCtxt), sourceCtxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeForDotNodeCalc = nodeForDotNodeCalc.ParentNode;
|
nodeForDotNodeCalc = nodeForDotNodeCalc.ParentNode;
|
||||||
|
|
@ -429,17 +433,17 @@ namespace TreeConverter.LambdaExpressions.Closure
|
||||||
Tuple<string, class_field, semantic_node> publicProperty;
|
Tuple<string, class_field, semantic_node> publicProperty;
|
||||||
if (classScope.NonPublicMembersNamesMapping.TryGetValue(varName, out publicProperty))
|
if (classScope.NonPublicMembersNamesMapping.TryGetValue(varName, out publicProperty))
|
||||||
{
|
{
|
||||||
dotnode1 = new dot_node(dotnode1, new ident(publicProperty.Item1));
|
dotnode1 = new dot_node(dotnode1, new ident(publicProperty.Item1, sourceCtxt), sourceCtxt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!(ClassField != null && ClassField.IsStatic))
|
if (!(ClassField != null && ClassField.IsStatic))
|
||||||
dotnode1 = new dot_node(dotnode1, new ident(varName));
|
dotnode1 = new dot_node(dotnode1, new ident(varName, sourceCtxt), sourceCtxt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dotnode1 = new dot_node(dotnode1, new ident(varName));
|
dotnode1 = new dot_node(dotnode1, new ident(varName, sourceCtxt), sourceCtxt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_lambdaIdReferences.Add(new LambdaReferencesSubstitutionInfo
|
_lambdaIdReferences.Add(new LambdaReferencesSubstitutionInfo
|
||||||
|
|
@ -453,8 +457,8 @@ namespace TreeConverter.LambdaExpressions.Closure
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var dotnode1 = new dot_node(
|
var dotnode1 = new dot_node(
|
||||||
new ident(compiler_string_consts.self_word),
|
new ident(compiler_string_consts.self_word, sourceCtxt),
|
||||||
new ident(varName));
|
new ident(varName, sourceCtxt), sourceCtxt);
|
||||||
|
|
||||||
_lambdaIdReferences.Add(new LambdaReferencesSubstitutionInfo
|
_lambdaIdReferences.Add(new LambdaReferencesSubstitutionInfo
|
||||||
{
|
{
|
||||||
|
|
@ -508,13 +512,13 @@ namespace TreeConverter.LambdaExpressions.Closure
|
||||||
new dot_node(
|
new dot_node(
|
||||||
new ident(
|
new ident(
|
||||||
_capturedVarsClassDefs[scope.ScopeIndex]
|
_capturedVarsClassDefs[scope.ScopeIndex]
|
||||||
.GeneratedSubstitutingFieldName), new ident(propertyName ?? varName)));
|
.GeneratedSubstitutingFieldName, sourceCtxt), new ident(propertyName ?? varName, sourceCtxt), sourceCtxt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var dotnode1 = new dot_node(
|
var dotnode1 = new dot_node(
|
||||||
new ident(compiler_string_consts.self_word),
|
new ident(compiler_string_consts.self_word, sourceCtxt),
|
||||||
new ident(varName));
|
new ident(varName, sourceCtxt), sourceCtxt);
|
||||||
|
|
||||||
_lambdaIdReferences.Add(new LambdaReferencesSubstitutionInfo
|
_lambdaIdReferences.Add(new LambdaReferencesSubstitutionInfo
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2141,7 +2141,7 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
type_node tn = converted_type.ImplementingInterfaces.Find(x=>(x as type_node).full_name.StartsWith("System.Collections.Generic.IEnumerable")) as type_node;
|
type_node tn = converted_type.ImplementingInterfaces.Find(x=>(x as type_node).BaseFullName.StartsWith("System.Collections.Generic.IEnumerable")) as type_node;
|
||||||
return new List<SymbolInfo> { new SymbolInfo(tn.instance_params[0]) };
|
return new List<SymbolInfo> { new SymbolInfo(tn.instance_params[0]) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,14 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual location location
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual semantic_node find_by_location(int line, int col)
|
public virtual semantic_node find_by_location(int line, int col)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -857,6 +857,14 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override location location
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Расположение имени функции в программе.
|
/// Расположение имени функции в программе.
|
||||||
/// Используется при обходе дерева посетителем.
|
/// Используется при обходе дерева посетителем.
|
||||||
|
|
|
||||||
|
|
@ -861,6 +861,14 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
set { _loc = value; }
|
set { _loc = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override location location
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ref_type_node(type_node pointed_type)
|
public ref_type_node(type_node pointed_type)
|
||||||
{
|
{
|
||||||
_pointed_type = pointed_type;
|
_pointed_type = pointed_type;
|
||||||
|
|
@ -1116,6 +1124,14 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
_loc = loc;
|
_loc = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override location location
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string name
|
public string name
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -1659,6 +1675,14 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override location location
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public SemanticTree.ILocation Location
|
public SemanticTree.ILocation Location
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -2374,6 +2398,13 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
set { _loc = value; }
|
set { _loc = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override location location
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
/*public short_string_type_node(SemanticTree.type_access_level type_access_level,
|
/*public short_string_type_node(SemanticTree.type_access_level type_access_level,
|
||||||
common_namespace_node comprehensive_namespace, SymbolTable.ClassScope cs, location loc, int length)
|
common_namespace_node comprehensive_namespace, SymbolTable.ClassScope cs, location loc, int length)
|
||||||
:base(null,type_access_level,comprehensive_namespace,cs,loc)
|
:base(null,type_access_level,comprehensive_namespace,cs,loc)
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,14 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override location location
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool is_used_as_unlocal
|
public bool is_used_as_unlocal
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -292,7 +300,13 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override location location
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public SemanticTree.ILocation Location
|
public SemanticTree.ILocation Location
|
||||||
{
|
{
|
||||||
|
|
@ -378,6 +392,14 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override location location
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public SemanticTree.ILocation Location
|
public SemanticTree.ILocation Location
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -474,6 +496,14 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override location location
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public SemanticTree.ILocation Location
|
public SemanticTree.ILocation Location
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -891,6 +921,14 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override location location
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public SemanticTree.ILocation Location
|
public SemanticTree.ILocation Location
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue