use of dyvilx.tools.compiler.ast.type.TypeList in project Dyvil by Dyvil.
the class CaseClassMetadata method getUnapplyReturnType.
private TupleType getUnapplyReturnType() {
final TupleType returnType = new TupleType();
final TypeList typeArgs = returnType.getArguments();
for (IParameter param : this.theClass.getParameters()) {
typeArgs.add(param.getType());
}
return returnType;
}
use of dyvilx.tools.compiler.ast.type.TypeList in project Dyvil by Dyvil.
the class TupleSurrogate method getType.
@Override
public IType getType() {
if (this.tupleType != null) {
return this.tupleType;
}
final TupleType tupleType = new TupleType(this.patternCount);
final TypeList arguments = tupleType.getArguments();
for (int i = 0; i < this.patternCount; i++) {
arguments.add(this.patterns[i].getType());
}
return this.tupleType = tupleType;
}
use of dyvilx.tools.compiler.ast.type.TypeList in project Dyvil by Dyvil.
the class AbstractClass method getThisType.
@Override
public IType getThisType() {
if (this.thisType != null) {
return this.thisType;
}
if (this.typeParameters == null) {
return this.thisType = this.classType;
}
final ClassGenericType type = new ClassGenericType(this);
final TypeList arguments = type.getArguments();
for (int i = 0; i < this.typeParameters.size(); i++) {
arguments.add(new TypeVarType(this.typeParameters.get(i)));
}
return this.thisType = type;
}
use of dyvilx.tools.compiler.ast.type.TypeList in project Dyvil by Dyvil.
the class CodeClass method fillTraitClasses.
/**
* Fills the list of traits and returns a status. If {@code top} is true, the returned value represents whether or
* not the super type of the given class has traits
*
* @param currentClass
* the current class to process
* @param traitClasses
* the list of trait classes
* @param top
* {@code true} if this is the top call
*/
private static boolean fillTraitClasses(IClass currentClass, Set<IClass> traitClasses, boolean top) {
boolean traits = false;
final TypeList interfaces = currentClass.getInterfaces();
if (interfaces != null) {
for (IType type : interfaces) {
final IClass interfaceClass = type.getTheClass();
if (interfaceClass == null) {
continue;
}
if (interfaceClass.hasModifier(Modifiers.TRAIT_CLASS)) {
traitClasses.add(interfaceClass);
traits = true;
}
fillTraitClasses(interfaceClass, traitClasses, false);
}
}
final IType superType = currentClass.getSuperType();
final IClass superClass;
if (superType == null || (superClass = superType.getTheClass()) == null) {
return traits && !top;
}
return top ? fillTraitClasses(superClass, traitClasses, false) : traits || fillTraitClasses(superClass, traitClasses, false);
}
use of dyvilx.tools.compiler.ast.type.TypeList in project Dyvil by Dyvil.
the class ClassFormat method readReferenceType.
@NonNull
private static IType readReferenceType(String desc, int start, int end) {
int index = desc.indexOf('<', start);
if (index >= 0 && index < end) {
final GenericType type = new InternalGenericType(desc.substring(start, index));
final TypeList arguments = type.getArguments();
index++;
while (desc.charAt(index) != '>') {
index = readTyped(desc, index, arguments, true);
}
return type;
}
return new InternalType(desc.substring(start, end));
}
Aggregations