pascalabcnet/SyntaxVisitors/YieldVisitors/CollectUnitGlobalsVisitor.cs
Бондарев Иван 65a2566223 bug fix #347
add missing copyrights
change year in copyright
2017-02-19 14:29:24 +01:00

46 lines
1.5 KiB
C#

// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PascalABCCompiler;
using PascalABCCompiler.SyntaxTree;
namespace SyntaxVisitors
{
public class CollectUnitGlobalsVisitor : CollectUpperNodesVisitor
{
public ISet<ident> CollectedGlobals { get; private set; }
public CollectUnitGlobalsVisitor()
{
CollectedGlobals = new HashSet<ident>();
}
/*public override void visit(interface_node node)
{
var globals = node.interface_definitions.defs
.Select(def => def as variable_definitions)
.Where(varDefsObj => (object)varDefsObj != null)
.SelectMany(varDefs => varDefs.var_definitions)
.SelectMany(v => v.vars.idents);
CollectedGlobals.UnionWith(globals);
}*/
public override void visit(declarations node)
{
var globals = node.defs
.Select(def => def as variable_definitions)
.Where(varDefsObj => (object)varDefsObj != null)
.SelectMany(varDefs => varDefs.var_definitions)
.SelectMany(v => v.vars.idents);
CollectedGlobals.UnionWith(globals);
}
}
}