Search in sources :

Example 1 with ExternalClass

use of dyvilx.tools.compiler.ast.external.ExternalClass in project Dyvil by Dyvil.

the class AbstractClass method getVisibility.

@Override
public byte getVisibility(IClassMember member) {
    final IClass enclosingClass = member.getEnclosingClass();
    if (enclosingClass == this) {
        return VISIBLE;
    }
    int level = member.getAccessLevel();
    if ((level & Modifiers.INTERNAL) != 0) {
        if (enclosingClass instanceof ExternalClass) {
            return INTERNAL;
        }
        level &= ~Modifiers.INTERNAL;
    }
    if (level == Modifiers.PUBLIC) {
        return VISIBLE;
    }
    if (level == Modifiers.PROTECTED || level == Modifiers.PRIVATE_PROTECTED) {
        if (Types.isSuperClass(enclosingClass, this)) {
            // The enclosing class of the member is a super class of this
            return VISIBLE;
        }
    }
    if (level == Modifiers.PROTECTED || level == Modifiers.PACKAGE) {
        final IHeaderUnit thisUnit = this.getHeader();
        final IHeaderUnit memberUnit = enclosingClass.getHeader();
        if (thisUnit != null && memberUnit != null && thisUnit.getPackage() == memberUnit.getPackage()) {
            // The two units are in the same package
            return VISIBLE;
        }
    }
    return INVISIBLE;
}
Also used : ExternalClass(dyvilx.tools.compiler.ast.external.ExternalClass) IHeaderUnit(dyvilx.tools.compiler.ast.header.IHeaderUnit)

Example 2 with ExternalClass

use of dyvilx.tools.compiler.ast.external.ExternalClass in project Dyvil by Dyvil.

the class HeaderContext method getVisibility.

@Override
public byte getVisibility(IClassMember member) {
    IClass iclass = member.getEnclosingClass();
    int access = member.getAccessLevel();
    if ((access & Modifiers.INTERNAL) != 0) {
        if (iclass instanceof ExternalClass) {
            return INTERNAL;
        }
        // Clear the INTERNAL bit by ANDing with 0b1111
        access &= 0b1111;
    }
    switch(access) {
        case Modifiers.PUBLIC:
            return VISIBLE;
        case Modifiers.PROTECTED:
        case Modifiers.PACKAGE:
            IHeaderUnit header = iclass.getHeader();
            if (header != null && (header == this || this.pack == header.getPackage())) {
                return VISIBLE;
            }
        // Fallthrough
        case Modifiers.PRIVATE:
        case Modifiers.PRIVATE_PROTECTED:
        default:
            return INVISIBLE;
    }
}
Also used : IClass(dyvilx.tools.compiler.ast.classes.IClass) ExternalClass(dyvilx.tools.compiler.ast.external.ExternalClass)

Example 3 with ExternalClass

use of dyvilx.tools.compiler.ast.external.ExternalClass in project Dyvil by Dyvil.

the class Package method loadClass.

public static IClass loadClass(String fileName, Name name, IClassConsumer consumer) {
    final DyvilCompiler compiler = rootPackage.compiler;
    for (Library library : compiler.config.libraries) {
        final InputStream inputStream = library.getInputStream(fileName);
        if (inputStream != null) {
            final ExternalClass externalClass = new ExternalClass(name);
            consumer.addClass(externalClass);
            return ClassReader.loadClass(compiler, externalClass, inputStream);
        }
    }
    return null;
}
Also used : InputStream(java.io.InputStream) DyvilCompiler(dyvilx.tools.compiler.DyvilCompiler) Library(dyvilx.tools.compiler.library.Library) ExternalClass(dyvilx.tools.compiler.ast.external.ExternalClass)

Aggregations

ExternalClass (dyvilx.tools.compiler.ast.external.ExternalClass)3 DyvilCompiler (dyvilx.tools.compiler.DyvilCompiler)1 IClass (dyvilx.tools.compiler.ast.classes.IClass)1 IHeaderUnit (dyvilx.tools.compiler.ast.header.IHeaderUnit)1 Library (dyvilx.tools.compiler.library.Library)1 InputStream (java.io.InputStream)1