Example #1
0
        public override void EnterNormalInterfaceDeclaration(Java9Parser.NormalInterfaceDeclarationContext 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.InterfaceSymbol(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
            };
        }
Example #2
0
 public override void setSlotNumber(ISymbol sym)
 {
     {
         if (sym is MethodSymbol)
         {
             MethodSymbol msym = (MethodSymbol)sym;
             // handle inheritance. If not found in this scope, check superclass
             // if any.
             IList <InterfaceSymbol> list = SuperClassScope;
             if (list.Count == 1)
             {
                 InterfaceSymbol superClass = list[0];
                 if (superClass != null)
                 {
                     IList <MethodSymbol> list_methods = superClass.resolveMethod(sym.Name);
                     if (list_methods.Count > 0)
                     {
                         MethodSymbol superMethodSym = list_methods[0];
                         if (superMethodSym != null)
                         {
                             msym.slot = superMethodSym.slot;
                         }
                     }
                 }
                 if (msym.slot == -1)
                 {
                     msym.slot = nextFreeMethodSlot++;
                 }
             }
         }
         else
         {
             base.setSlotNumber(sym);
         }
     }
 }