pascalabcnet/SyntaxVisitors/LightSymInfoVisitors/CollectFullLightSymInfoVisitor.cs
nevermind322 a8b1e9035b
LightSymInfo rework (#2994)
* LightSymInfo rework

* add rebuildDebug and build units

* enable VarNamesInMethodsWithSameNameAsClassGenericParamsReplacer

* remove CollectFullLightSymInfo call

* fix

fix

remove CollectFullLightSymInfo call
2023-12-31 12:54:49 +03:00

60 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PascalABCCompiler.SyntaxTree
{
public class CollectFullLightSymInfoVisitor : CollectLightSymInfoVisitor
{
protected override AbstractScopeCreator scopeCreator => _scopeCreator;
private CachingScopeCreator _scopeCreator = new CachingScopeCreator();
public CollectFullLightSymInfoVisitor(compilation_unit root) : base(root)
{
}
public override void Enter(syntax_tree_node st)
{
var scope = scopeCreator.GetScope(st);
if (scope != null)
{
scope.Parent = Current;
Current = scope;
}
}
public override void Exit(syntax_tree_node st)
{
if (AbstractScopeCreator.IsScopeCreator(st))
{
PreExitScope(st);
if (Current != null)
Current = Current.Parent;
}
}
public override void visit(procedure_definition node)
{
var name = node.proc_header?.name?.meth_name;
var attr = node.proc_header.class_keyword ? SymbolAttributes.class_attr : 0;
if (name != null)
if (node.proc_header is function_header)
Current.Parent.AddSymbol(name, SymKind.funcname, null, attr);
else
Current.Parent.AddSymbol(name, SymKind.procname, null, attr);
base.visit(node);
}
public override void PreExitScope(syntax_tree_node st)
{
}
}
}