com.sun.tools.javac.util.Filter Java Examples

The following examples show how to use com.sun.tools.javac.util.Filter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Scope.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Iterable<Symbol> getSymbols(final Filter<Symbol> sf, final LookupKind lookupKind) {
    if (filterName != null)
        return getSymbolsByName(filterName, sf, lookupKind);
    try {
        SymbolImporter si = new SymbolImporter(imp.staticImport) {
            @Override
            Iterable<Symbol> doLookup(TypeSymbol tsym) {
                return tsym.members().getSymbols(sf, lookupKind);
            }
        };
        List<Iterable<Symbol>> results =
                si.importFrom((TypeSymbol) origin.owner, List.nil());
        return () -> createFilterIterator(createCompoundIterator(results,
                                                                 Iterable::iterator),
                                          s -> filter.accepts(origin, s));
    } catch (CompletionFailure cf) {
        cfHandler.accept(imp, cf);
        return Collections.emptyList();
    }
}
 
Example #2
Source File: Scope.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Iterable<Symbol> getSymbolsByName(final Name name,
                                         final Filter<Symbol> sf,
                                         final LookupKind lookupKind) {
    if (filterName != null && filterName != name)
        return Collections.emptyList();
    try {
        SymbolImporter si = new SymbolImporter(imp.staticImport) {
            @Override
            Iterable<Symbol> doLookup(TypeSymbol tsym) {
                return tsym.members().getSymbolsByName(name, sf, lookupKind);
            }
        };
        List<Iterable<Symbol>> results =
                si.importFrom((TypeSymbol) origin.owner, List.nil());
        return () -> createFilterIterator(createCompoundIterator(results,
                                                                 Iterable::iterator),
                                          s -> filter.accepts(origin, s));
    } catch (CompletionFailure cf) {
        cfHandler.accept(imp, cf);
        return Collections.emptyList();
    }
}
 
Example #3
Source File: Types.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
MethodSymbol get(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter) {
    SoftReference<Map<TypeSymbol, Entry>> ref_cache = _map.get(ms);
    Map<TypeSymbol, Entry> cache = ref_cache != null ? ref_cache.get() : null;
    if (cache == null) {
        cache = new HashMap<TypeSymbol, Entry>();
        _map.put(ms, new SoftReference<Map<TypeSymbol, Entry>>(cache));
    }
    Entry e = cache.get(origin);
    CompoundScope members = membersClosure(origin.type, true);
    if (e == null ||
            !e.matches(implFilter, checkResult, members.getMark())) {
        MethodSymbol impl = implementationInternal(ms, origin, checkResult, implFilter);
        cache.put(origin, new Entry(impl, implFilter, checkResult, members.getMark()));
        return impl;
    }
    else {
        return e.cachedImpl;
    }
}
 
Example #4
Source File: Check.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/** Check that single-type import is not already imported or top-level defined,
 *  but make an exception for two single-type imports which denote the same type.
 *  @param pos                     Position for error reporting.
 *  @param ordinallyImportedSoFar  A Scope containing types imported so far through
 *                                 ordinary imports.
 *  @param staticallyImportedSoFar A Scope containing types imported so far through
 *                                 static imports.
 *  @param topLevelScope           The current file's top-level Scope
 *  @param sym                     The symbol.
 *  @param staticImport            Whether or not this was a static import
 */
private boolean checkUniqueImport(DiagnosticPosition pos, Scope ordinallyImportedSoFar,
                                  Scope staticallyImportedSoFar, Scope topLevelScope,
                                  Symbol sym, boolean staticImport) {
    Filter<Symbol> duplicates = candidate -> candidate != sym && !candidate.type.isErroneous();
    Symbol clashing = ordinallyImportedSoFar.findFirst(sym.name, duplicates);
    if (clashing == null && !staticImport) {
        clashing = staticallyImportedSoFar.findFirst(sym.name, duplicates);
    }
    if (clashing != null) {
        if (staticImport)
            log.error(pos, Errors.AlreadyDefinedStaticSingleImport(clashing));
        else
            log.error(pos, Errors.AlreadyDefinedSingleImport(clashing));
        return false;
    }
    clashing = topLevelScope.findFirst(sym.name, duplicates);
    if (clashing != null) {
        log.error(pos, Errors.AlreadyDefinedThisUnit(clashing));
        return false;
    }
    return true;
}
 
Example #5
Source File: Types.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
MethodSymbol get(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter) {
    SoftReference<Map<TypeSymbol, Entry>> ref_cache = _map.get(ms);
    Map<TypeSymbol, Entry> cache = ref_cache != null ? ref_cache.get() : null;
    if (cache == null) {
        cache = new HashMap<TypeSymbol, Entry>();
        _map.put(ms, new SoftReference<Map<TypeSymbol, Entry>>(cache));
    }
    Entry e = cache.get(origin);
    CompoundScope members = membersClosure(origin.type, true);
    if (e == null ||
            !e.matches(implFilter, checkResult, members.getMark())) {
        MethodSymbol impl = implementationInternal(ms, origin, checkResult, implFilter);
        cache.put(origin, new Entry(impl, implFilter, checkResult, members.getMark()));
        return impl;
    }
    else {
        return e.cachedImpl;
    }
}
 
Example #6
Source File: Pool.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check consistency of reference kind and symbol (see JVMS 4.4.8)
 */
@SuppressWarnings("fallthrough")
private void checkConsistent() {
    boolean staticOk = false;
    int expectedKind = -1;
    Filter<Name> nameFilter = nonInitFilter;
    boolean interfaceOwner = false;
    switch (refKind) {
        case ClassFile.REF_getStatic:
        case ClassFile.REF_putStatic:
            staticOk = true;
        case ClassFile.REF_getField:
        case ClassFile.REF_putField:
            expectedKind = Kinds.VAR;
            break;
        case ClassFile.REF_newInvokeSpecial:
            nameFilter = initFilter;
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeInterface:
            interfaceOwner = true;
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeStatic:
            interfaceOwner = true;
            staticOk = true;
        case ClassFile.REF_invokeVirtual:
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeSpecial:
            interfaceOwner = true;
            expectedKind = Kinds.MTH;
            break;
    }
    Assert.check(!refSym.isStatic() || staticOk);
    Assert.check(refSym.kind == expectedKind);
    Assert.check(nameFilter.accepts(refSym.name));
    Assert.check(!refSym.owner.isInterface() || interfaceOwner);
}
 
Example #7
Source File: Scope.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Iterable<Symbol> getSymbolsByName(Name name,
                                         Filter<Symbol> sf,
                                         LookupKind lookupKind) {
    return sym.name == name &&
           (sf == null || sf.accepts(sym)) ? content : Collections.emptyList();
}
 
Example #8
Source File: Scope.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Iterable<Symbol> getSymbols(final Filter<Symbol> sf,
                                   final LookupKind lookupKind) {
    return () -> Iterators.createCompoundIterator(subScopes,
                                                  scope -> scope.getSymbols(sf,
                                                                            lookupKind)
                                                                .iterator());
}
 
Example #9
Source File: Scope.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Iterable<Symbol> getSymbolsByName(final Name name,
                                         final Filter<Symbol> sf,
                                         final LookupKind lookupKind) {
    return () -> Iterators.createCompoundIterator(subScopes,
                                                  scope -> scope.getSymbolsByName(name,
                                                                                  sf,
                                                                                  lookupKind)
                                                                .iterator());
}
 
Example #10
Source File: InferenceContext.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private List<Type> filterVars(Filter<UndetVar> fu) {
    ListBuffer<Type> res = new ListBuffer<>();
    for (Type t : undetvars) {
        UndetVar uv = (UndetVar)t;
        if (fu.accepts(uv)) {
            res.append(uv.qtype);
        }
    }
    return res.toList();
}
 
Example #11
Source File: Pool.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check consistency of reference kind and symbol (see JVMS 4.4.8)
 */
@SuppressWarnings("fallthrough")
private void checkConsistent() {
    boolean staticOk = false;
    int expectedKind = -1;
    Filter<Name> nameFilter = nonInitFilter;
    boolean interfaceOwner = false;
    switch (refKind) {
        case ClassFile.REF_getStatic:
        case ClassFile.REF_putStatic:
            staticOk = true;
        case ClassFile.REF_getField:
        case ClassFile.REF_putField:
            expectedKind = Kinds.VAR;
            break;
        case ClassFile.REF_newInvokeSpecial:
            nameFilter = initFilter;
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeInterface:
            interfaceOwner = true;
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeStatic:
            interfaceOwner = true;
            staticOk = true;
        case ClassFile.REF_invokeVirtual:
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeSpecial:
            interfaceOwner = true;
            expectedKind = Kinds.MTH;
            break;
    }
    Assert.check(!refSym.isStatic() || staticOk);
    Assert.check(refSym.kind == expectedKind);
    Assert.check(nameFilter.accepts(refSym.name));
    Assert.check(!refSym.owner.isInterface() || interfaceOwner);
}
 
Example #12
Source File: Types.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public Entry(MethodSymbol cachedImpl,
        Filter<Symbol> scopeFilter,
        boolean checkResult,
        int prevMark) {
    this.cachedImpl = cachedImpl;
    this.implFilter = scopeFilter;
    this.checkResult = checkResult;
    this.prevMark = prevMark;
}
 
Example #13
Source File: Types.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private MethodSymbol implementationInternal(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter) {
    for (Type t = origin.type; t.tag == CLASS || t.tag == TYPEVAR; t = supertype(t)) {
        while (t.tag == TYPEVAR)
            t = t.getUpperBound();
        TypeSymbol c = t.tsym;
        for (Scope.Entry e = c.members().lookup(ms.name, implFilter);
             e.scope != null;
             e = e.next(implFilter)) {
            if (e.sym != null &&
                     e.sym.overrides(ms, origin, Types.this, checkResult))
                return (MethodSymbol)e.sym;
        }
    }
    return null;
}
 
Example #14
Source File: Type.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public static List<Type> filter(List<Type> ts, Filter<Type> tf) {
    ListBuffer<Type> buf = ListBuffer.lb();
    for (Type t : ts) {
        if (tf.accepts(t)) {
            buf.append(t);
        }
    }
    return buf.toList();
}
 
Example #15
Source File: Pool.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check consistency of reference kind and symbol (see JVMS 4.4.8)
 */
@SuppressWarnings("fallthrough")
private void checkConsistent() {
    boolean staticOk = false;
    Kind expectedKind = null;
    Filter<Name> nameFilter = nonInitFilter;
    boolean interfaceOwner = false;
    switch (refKind) {
        case ClassFile.REF_getStatic:
        case ClassFile.REF_putStatic:
            staticOk = true;
        case ClassFile.REF_getField:
        case ClassFile.REF_putField:
            expectedKind = VAR;
            break;
        case ClassFile.REF_newInvokeSpecial:
            nameFilter = initFilter;
            expectedKind = MTH;
            break;
        case ClassFile.REF_invokeInterface:
            interfaceOwner = true;
            expectedKind = MTH;
            break;
        case ClassFile.REF_invokeStatic:
            interfaceOwner = true;
            staticOk = true;
        case ClassFile.REF_invokeVirtual:
            expectedKind = MTH;
            break;
        case ClassFile.REF_invokeSpecial:
            interfaceOwner = true;
            expectedKind = MTH;
            break;
    }
    Assert.check(!refSym.isStatic() || staticOk);
    Assert.check(refSym.kind == expectedKind);
    Assert.check(nameFilter.accepts(refSym.name));
    Assert.check(!refSym.owner.isInterface() || interfaceOwner);
}
 
Example #16
Source File: InferenceContext.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private List<Type> filterVars(Filter<UndetVar> fu) {
    ListBuffer<Type> res = new ListBuffer<>();
    for (Type t : undetvars) {
        UndetVar uv = (UndetVar)t;
        if (fu.accepts(uv)) {
            res.append(uv.qtype);
        }
    }
    return res.toList();
}
 
Example #17
Source File: ManTypes.java    From manifold with Apache License 2.0 5 votes vote down vote up
/**
 * Override to keep track of when/if implemetation() is in scope, if ManTypes#memberType() should not try to
 * substitute the qualifier type for @Self because the qualifier is not really a call site, rather it is the
 * declaring class of the method being checked for override etc.  Thus we need to let the normal signature flow
 * through.
 */
@Override
public Symbol.MethodSymbol implementation( Symbol.MethodSymbol ms, Symbol.TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter )
{
  _overrideCount++;
  try
  {
    return super.implementation( ms, origin, checkResult, implFilter );
  }
  finally
  {
    _overrideCount--;
  }
}
 
Example #18
Source File: Pool.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check consistency of reference kind and symbol (see JVMS 4.4.8)
 */
@SuppressWarnings("fallthrough")
private void checkConsistent() {
    boolean staticOk = false;
    int expectedKind = -1;
    Filter<Name> nameFilter = nonInitFilter;
    boolean interfaceOwner = false;
    switch (refKind) {
        case ClassFile.REF_getStatic:
        case ClassFile.REF_putStatic:
            staticOk = true;
        case ClassFile.REF_getField:
        case ClassFile.REF_putField:
            expectedKind = Kinds.VAR;
            break;
        case ClassFile.REF_newInvokeSpecial:
            nameFilter = initFilter;
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeInterface:
            interfaceOwner = true;
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeStatic:
            interfaceOwner = true;
            staticOk = true;
        case ClassFile.REF_invokeVirtual:
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeSpecial:
            interfaceOwner = true;
            expectedKind = Kinds.MTH;
            break;
    }
    Assert.check(!refSym.isStatic() || staticOk);
    Assert.check(refSym.kind == expectedKind);
    Assert.check(nameFilter.accepts(refSym.name));
    Assert.check(!refSym.owner.isInterface() || interfaceOwner);
}
 
Example #19
Source File: Pool.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check consistency of reference kind and symbol (see JVMS 4.4.8)
 */
@SuppressWarnings("fallthrough")
private void checkConsistent() {
    boolean staticOk = false;
    int expectedKind = -1;
    Filter<Name> nameFilter = nonInitFilter;
    boolean interfaceOwner = false;
    switch (refKind) {
        case ClassFile.REF_getStatic:
        case ClassFile.REF_putStatic:
            staticOk = true;
        case ClassFile.REF_getField:
        case ClassFile.REF_putField:
            expectedKind = Kinds.VAR;
            break;
        case ClassFile.REF_newInvokeSpecial:
            nameFilter = initFilter;
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeInterface:
            interfaceOwner = true;
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeStatic:
            interfaceOwner = true;
            staticOk = true;
        case ClassFile.REF_invokeVirtual:
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeSpecial:
            interfaceOwner = true;
            expectedKind = Kinds.MTH;
            break;
    }
    Assert.check(!refSym.isStatic() || staticOk);
    Assert.check(refSym.kind == expectedKind);
    Assert.check(nameFilter.accepts(refSym.name));
    Assert.check(!refSym.owner.isInterface() || interfaceOwner);
}
 
Example #20
Source File: Pool.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check consistency of reference kind and symbol (see JVMS 4.4.8)
 */
@SuppressWarnings("fallthrough")
private void checkConsistent() {
    boolean staticOk = false;
    int expectedKind = -1;
    Filter<Name> nameFilter = nonInitFilter;
    boolean interfaceOwner = false;
    switch (refKind) {
        case ClassFile.REF_getStatic:
        case ClassFile.REF_putStatic:
            staticOk = true;
        case ClassFile.REF_getField:
        case ClassFile.REF_putField:
            expectedKind = Kinds.VAR;
            break;
        case ClassFile.REF_newInvokeSpecial:
            nameFilter = initFilter;
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeInterface:
            interfaceOwner = true;
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeStatic:
            interfaceOwner = true;
            staticOk = true;
        case ClassFile.REF_invokeVirtual:
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeSpecial:
            interfaceOwner = true;
            expectedKind = Kinds.MTH;
            break;
    }
    Assert.check(!refSym.isStatic() || staticOk);
    Assert.check(refSym.kind == expectedKind);
    Assert.check(nameFilter.accepts(refSym.name));
    Assert.check(!refSym.owner.isInterface() || interfaceOwner);
}
 
Example #21
Source File: Pool.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check consistency of reference kind and symbol (see JVMS 4.4.8)
 */
@SuppressWarnings("fallthrough")
private void checkConsistent() {
    boolean staticOk = false;
    int expectedKind = -1;
    Filter<Name> nameFilter = nonInitFilter;
    boolean interfaceOwner = false;
    switch (refKind) {
        case ClassFile.REF_getStatic:
        case ClassFile.REF_putStatic:
            staticOk = true;
        case ClassFile.REF_getField:
        case ClassFile.REF_putField:
            expectedKind = Kinds.VAR;
            break;
        case ClassFile.REF_newInvokeSpecial:
            nameFilter = initFilter;
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeInterface:
            interfaceOwner = true;
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeStatic:
            interfaceOwner = true;
            staticOk = true;
        case ClassFile.REF_invokeVirtual:
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeSpecial:
            interfaceOwner = true;
            expectedKind = Kinds.MTH;
            break;
    }
    Assert.check(!refSym.isStatic() || staticOk);
    Assert.check(refSym.kind == expectedKind);
    Assert.check(nameFilter.accepts(refSym.name));
    Assert.check(!refSym.owner.isInterface() || interfaceOwner);
}
 
Example #22
Source File: Scope.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Iterable<Symbol> getSymbolsByName(final Name name,
                                         final Filter<Symbol> sf,
                                         final LookupKind lookupKind) {
    return () -> new Iterator<Symbol>() {
       Entry currentEntry = lookup(name, sf);
       int seenRemoveCount = currentEntry.scope != null ?
               currentEntry.scope.removeCount : -1;

       public boolean hasNext() {
           if (currentEntry.scope != null &&
               seenRemoveCount != currentEntry.scope.removeCount &&
               !currentEntry.scope.includes(currentEntry.sym)) {
               doNext(); //skip entry that is no longer in the Scope
           }
           return currentEntry.scope != null &&
                   (lookupKind == RECURSIVE ||
                    currentEntry.scope == ScopeImpl.this);
       }
       public Symbol next() {
           if (!hasNext()) {
               throw new NoSuchElementException();
           }
           return doNext();
       }
       private Symbol doNext() {
           Entry prevEntry = currentEntry;
           currentEntry = currentEntry.next(sf);
           return prevEntry.sym;
       }
       public void remove() {
           throw new UnsupportedOperationException();
       }
   };
}
 
Example #23
Source File: Types.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public Entry(MethodSymbol cachedImpl,
        Filter<Symbol> scopeFilter,
        boolean checkResult,
        int prevMark) {
    this.cachedImpl = cachedImpl;
    this.implFilter = scopeFilter;
    this.checkResult = checkResult;
    this.prevMark = prevMark;
}
 
Example #24
Source File: Scope.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected Entry lookup(Name name, Filter<Symbol> sf) {
    Entry e = table[getIndex(name)];
    if (e == null || e == sentinel)
        return sentinel;
    while (e.scope != null && (e.sym.name != name || (sf != null && !sf.accepts(e.sym))))
        e = e.shadowed;
    return e;
}
 
Example #25
Source File: Types.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private MethodSymbol implementationInternal(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter) {
    for (Type t = origin.type; t.tag == CLASS || t.tag == TYPEVAR; t = supertype(t)) {
        while (t.tag == TYPEVAR)
            t = t.getUpperBound();
        TypeSymbol c = t.tsym;
        for (Scope.Entry e = c.members().lookup(ms.name, implFilter);
             e.scope != null;
             e = e.next(implFilter)) {
            if (e.sym != null &&
                     e.sym.overrides(ms, origin, Types.this, checkResult))
                return (MethodSymbol)e.sym;
        }
    }
    return null;
}
 
Example #26
Source File: Type.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public static List<Type> filter(List<Type> ts, Filter<Type> tf) {
    ListBuffer<Type> buf = ListBuffer.lb();
    for (Type t : ts) {
        if (tf.accepts(t)) {
            buf.append(t);
        }
    }
    return buf.toList();
}
 
Example #27
Source File: Pool.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check consistency of reference kind and symbol (see JVMS 4.4.8)
 */
@SuppressWarnings("fallthrough")
private void checkConsistent() {
    boolean staticOk = false;
    int expectedKind = -1;
    Filter<Name> nameFilter = nonInitFilter;
    boolean interfaceOwner = false;
    switch (refKind) {
        case ClassFile.REF_getStatic:
        case ClassFile.REF_putStatic:
            staticOk = true;
        case ClassFile.REF_getField:
        case ClassFile.REF_putField:
            expectedKind = Kinds.VAR;
            break;
        case ClassFile.REF_newInvokeSpecial:
            nameFilter = initFilter;
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeInterface:
            interfaceOwner = true;
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeStatic:
            interfaceOwner = true;
            staticOk = true;
        case ClassFile.REF_invokeVirtual:
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeSpecial:
            interfaceOwner = true;
            expectedKind = Kinds.MTH;
            break;
    }
    Assert.check(!refSym.isStatic() || staticOk);
    Assert.check(refSym.kind == expectedKind);
    Assert.check(nameFilter.accepts(refSym.name));
    Assert.check(!refSym.owner.isInterface() || interfaceOwner);
}
 
Example #28
Source File: Pool.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Check consistency of reference kind and symbol (see JVMS 4.4.8)
 */
@SuppressWarnings("fallthrough")
private void checkConsistent() {
    boolean staticOk = false;
    Kind expectedKind = null;
    Filter<Name> nameFilter = nonInitFilter;
    boolean interfaceOwner = false;
    switch (refKind) {
        case ClassFile.REF_getStatic:
        case ClassFile.REF_putStatic:
            staticOk = true;
        case ClassFile.REF_getField:
        case ClassFile.REF_putField:
            expectedKind = VAR;
            break;
        case ClassFile.REF_newInvokeSpecial:
            nameFilter = initFilter;
            expectedKind = MTH;
            break;
        case ClassFile.REF_invokeInterface:
            interfaceOwner = true;
            expectedKind = MTH;
            break;
        case ClassFile.REF_invokeStatic:
            interfaceOwner = true;
            staticOk = true;
        case ClassFile.REF_invokeVirtual:
            expectedKind = MTH;
            break;
        case ClassFile.REF_invokeSpecial:
            interfaceOwner = true;
            expectedKind = MTH;
            break;
    }
    Assert.check(!refSym.isStatic() || staticOk);
    Assert.check(refSym.kind == expectedKind);
    Assert.check(nameFilter.accepts(refSym.name));
    Assert.check(!refSym.owner.isInterface() || interfaceOwner);
}
 
Example #29
Source File: Scope.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**Returns Symbols that match the given filter. Symbols from outward Scopes are included.
 */
public final Iterable<Symbol> getSymbols(Filter<Symbol> sf) {
    return getSymbols(sf, RECURSIVE);
}
 
Example #30
Source File: Types.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
boolean matches(Filter<Symbol> scopeFilter, boolean checkResult, int mark) {
    return this.implFilter == scopeFilter &&
            this.checkResult == checkResult &&
            this.prevMark == mark;
}