Search in sources :

Example 6 with TypeList

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;
}
Also used : IParameter(dyvilx.tools.compiler.ast.parameter.IParameter) TupleType(dyvilx.tools.compiler.ast.type.compound.TupleType) TypeList(dyvilx.tools.compiler.ast.type.TypeList)

Example 7 with TypeList

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;
}
Also used : TupleType(dyvilx.tools.compiler.ast.type.compound.TupleType) TypeList(dyvilx.tools.compiler.ast.type.TypeList)

Example 8 with TypeList

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;
}
Also used : TypeVarType(dyvilx.tools.compiler.ast.type.typevar.TypeVarType) ClassGenericType(dyvilx.tools.compiler.ast.type.generic.ClassGenericType) TypeList(dyvilx.tools.compiler.ast.type.TypeList)

Example 9 with TypeList

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);
}
Also used : TypeList(dyvilx.tools.compiler.ast.type.TypeList) IType(dyvilx.tools.compiler.ast.type.IType)

Example 10 with TypeList

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));
}
Also used : InternalType(dyvilx.tools.compiler.ast.type.raw.InternalType) GenericType(dyvilx.tools.compiler.ast.type.generic.GenericType) InternalGenericType(dyvilx.tools.compiler.ast.type.generic.InternalGenericType) InternalGenericType(dyvilx.tools.compiler.ast.type.generic.InternalGenericType) TypeList(dyvilx.tools.compiler.ast.type.TypeList) NonNull(dyvil.annotation.internal.NonNull)

Aggregations

TypeList (dyvilx.tools.compiler.ast.type.TypeList)14 IType (dyvilx.tools.compiler.ast.type.IType)6 TupleType (dyvilx.tools.compiler.ast.type.compound.TupleType)5 NonNull (dyvil.annotation.internal.NonNull)2 IClass (dyvilx.tools.compiler.ast.classes.IClass)2 Marker (dyvilx.tools.parsing.marker.Marker)2 Name (dyvil.lang.Name)1 Annotation (dyvilx.tools.compiler.ast.attribute.annotation.Annotation)1 CodeAnnotation (dyvilx.tools.compiler.ast.attribute.annotation.CodeAnnotation)1 ClassBody (dyvilx.tools.compiler.ast.classes.ClassBody)1 IParameter (dyvilx.tools.compiler.ast.parameter.IParameter)1 AbstractPattern (dyvilx.tools.compiler.ast.pattern.AbstractPattern)1 Pattern (dyvilx.tools.compiler.ast.pattern.Pattern)1 ITyped (dyvilx.tools.compiler.ast.type.ITyped)1 LambdaType (dyvilx.tools.compiler.ast.type.compound.LambdaType)1 ClassGenericType (dyvilx.tools.compiler.ast.type.generic.ClassGenericType)1 GenericType (dyvilx.tools.compiler.ast.type.generic.GenericType)1 InternalGenericType (dyvilx.tools.compiler.ast.type.generic.InternalGenericType)1 InternalType (dyvilx.tools.compiler.ast.type.raw.InternalType)1 NamedType (dyvilx.tools.compiler.ast.type.raw.NamedType)1