use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.
the class TypeParameter method appendSignature.
@Override
public void appendSignature(StringBuilder buffer) {
buffer.append(this.name).append(':');
if (this.upperBounds == null) {
buffer.append("Ljava/lang/Object;");
return;
}
final IClass theClass = this.upperBounds[0].getTheClass();
if (theClass != null && theClass.isInterface()) {
// If the first type is not an interface type, we append two colons
buffer.append(':');
}
this.upperBounds[0].appendSignature(buffer, false);
for (int i = 1, count = this.upperBounds.length; i < count; i++) {
buffer.append(':');
this.upperBounds[i].appendSignature(buffer, false);
}
}
use of dyvilx.tools.compiler.ast.classes.IClass 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.classes.IClass in project Dyvil by Dyvil.
the class SpecialIntrinsicData method visitMethodInsn.
private static void visitMethodInsn(MethodWriter writer, int opcode, String owner, String name, String desc) {
final boolean isInterface;
switch(opcode) {
case // invokeINTERFACE -> definitely an interface
Opcodes.INVOKEINTERFACE:
isInterface = true;
break;
case Opcodes.INVOKESPECIAL:
case // private or virtual -> can't be an interface
Opcodes.INVOKEVIRTUAL:
isInterface = false;
break;
// check the class
case Opcodes.INVOKESTATIC:
default:
final IClass iclass = Package.rootPackage.resolveInternalClass(owner);
isInterface = iclass != null && iclass.isInterface();
break;
}
writer.visitMethodInsn(opcode, owner, name, desc, isInterface);
}
use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.
the class TupleSurrogate method writeJumpOnMismatch.
@Override
public void writeJumpOnMismatch(MethodWriter writer, int varIndex, Label target) throws BytecodeException {
varIndex = Pattern.ensureVar(writer, varIndex);
final int lineNumber = this.lineNumber();
final IType tupleType = this.getType();
final IClass tupleClass = tupleType.getTheClass();
final TypeParameterList typeParameters = tupleClass.getTypeParameters();
final String internalTupleClassName = tupleType.getInternalName();
for (int i = 0; i < this.patternCount; i++) {
if (this.patterns[i].isWildcard()) {
// Skip wildcard patterns
continue;
}
writer.visitVarInsn(Opcodes.ALOAD, varIndex);
writer.visitFieldInsn(Opcodes.GETFIELD, internalTupleClassName, "_" + (i + 1), "Ljava/lang/Object;");
final IType targetType = Types.resolveTypeSafely(tupleType, typeParameters.get(i));
Types.OBJECT.writeCast(writer, targetType, lineNumber);
this.patterns[i].writeJumpOnMismatch(writer, -1, target);
}
}
use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.
the class UnapplyPattern method withType.
@Override
public Pattern withType(IType type, MarkerList markers) {
// PatternType.unapply(_ : MatchedType)
final IClass matchClass = this.type.getTheClass();
if (matchClass == null) {
return null;
}
final MethodCall methodCall = new MethodCall(this.position, new ClassAccess(this.type), Names.unapply, new ArgumentList(new DummyValue(type)));
final IValue resolvedCall = methodCall.resolveCall(MarkerList.BLACKHOLE, matchClass, false);
return resolvedCall != null && this.withMethod(type, resolvedCall, markers) ? this : null;
}
Aggregations