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;
}
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;
}
}
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;
}
Aggregations