Ejemplo n.º 1
0
        public override void EnterNormalClassDeclaration(Java9Parser.NormalClassDeclarationContext context)
        {
            int i;

            for (i = 0; i < context.ChildCount; ++i)
            {
                if (context.GetChild(i) as Java9Parser.IdentifierContext != null)
                {
                    break;
                }
            }
            var node              = context.GetChild(i) as Java9Parser.IdentifierContext;
            var id_name           = node.GetText();
            TerminalNodeImpl term = null;
            IParseTree       t    = node;

            for (; t != null; t = t.GetChild(0))
            {
                if (t is TerminalNodeImpl)
                {
                    term = t as TerminalNodeImpl;
                    break;
                }
                else if (t.ChildCount == 0)
                {
                    term = null;
                    break;
                }
            }
            ISymbol cs    = new Symtab.ClassSymbol(id_name, term?.Symbol);
            var     scope = GetScope(NearestScope(context));

            scope.define(ref cs);
            _pd.Attributes[node] = new List <CombinedScopeSymbol>()
            {
                (CombinedScopeSymbol)cs
            };
            IScope s = (IScope)cs;

            _pd.Attributes[context.GetChild(0)] = new List <CombinedScopeSymbol>()
            {
                (CombinedScopeSymbol)s
            };
            _pd.Attributes[context] = new List <CombinedScopeSymbol>()
            {
                (CombinedScopeSymbol)s
            };
        }