Search in sources :

Example 1 with ClassGenericType

use of dyvilx.tools.compiler.ast.type.generic.ClassGenericType 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 2 with ClassGenericType

use of dyvilx.tools.compiler.ast.type.generic.ClassGenericType in project Dyvil by Dyvil.

the class EnumClassMetadata method resolveTypesPre.

@Override
public void resolveTypesPre(MarkerList markers, IContext context) {
    super.resolveTypesPre(markers, context);
    this.theClass.getAttributes().addFlag(Modifiers.FINAL);
    // Ensure the super type is Enum<TYPE>
    final IType classType = this.theClass.getClassType();
    final IType superType = this.theClass.getSuperType();
    if (// default
    superType != Types.OBJECT) {
        markers.add(Markers.semanticError(superType.getPosition(), "enum.super_class"));
    }
    this.theClass.setSuperType(new ClassGenericType(Types.ENUM_CLASS, classType));
}
Also used : ClassGenericType(dyvilx.tools.compiler.ast.type.generic.ClassGenericType) IType(dyvilx.tools.compiler.ast.type.IType)

Example 3 with ClassGenericType

use of dyvilx.tools.compiler.ast.type.generic.ClassGenericType in project Dyvil by Dyvil.

the class ClassOperator method resolveTypes.

// Phases
@Override
public void resolveTypes(MarkerList markers, IContext context) {
    if (this.type == null) {
        this.type = dyvilx.tools.compiler.ast.type.builtin.Types.UNKNOWN;
        markers.add(Markers.semantic(this.position, "classoperator.invalid"));
        return;
    }
    this.type = this.type.resolveType(markers, context);
    this.genericType = new ClassGenericType(LazyFields.CLASS_CLASS, this.type);
}
Also used : ClassGenericType(dyvilx.tools.compiler.ast.type.generic.ClassGenericType)

Example 4 with ClassGenericType

use of dyvilx.tools.compiler.ast.type.generic.ClassGenericType in project Dyvil by Dyvil.

the class IType method readType.

static IType readType(DataInput dis) throws IOException {
    int tag = dis.readUnsignedByte();
    IType type;
    switch(tag) {
        case UNKNOWN:
            return Types.UNKNOWN;
        case NULL:
            return Types.NULL;
        case NONE:
            return Types.NONE;
        case ANY:
            return Types.ANY;
        case PRIMITIVE:
            return PrimitiveType.fromTypecode(dis.readByte());
        case CLASS:
            type = new ClassType();
            break;
        case PACKAGE:
            type = new PackageType();
            break;
        case GENERIC:
            type = new ClassGenericType();
            break;
        case TUPLE:
            type = new TupleType();
            break;
        case LAMBDA:
            type = new LambdaType();
            break;
        case ARRAY:
            type = new ArrayType();
            break;
        case MAP:
            type = new MapType();
            break;
        case OPTIONAL:
            type = new NullableType();
            break;
        case IMPLICIT_OPTIONAL:
            type = new ImplicitNullableType();
            break;
        case REFERENCE:
            type = new ReferenceType();
            break;
        case ANNOTATED:
            type = new AnnotatedType();
            break;
        case TYPE_VAR:
            type = new NamedType();
            break;
        case WILDCARD_TYPE:
            type = new WildcardType();
            break;
        case MISSING_TAG:
            return null;
        default:
            throw new Error("Cannot decode TypeTag " + tag);
    }
    type.read(dis);
    return type;
}
Also used : NamedType(dyvilx.tools.compiler.ast.type.raw.NamedType) ClassType(dyvilx.tools.compiler.ast.type.raw.ClassType) ReferenceType(dyvilx.tools.compiler.ast.reference.ReferenceType) PackageType(dyvilx.tools.compiler.ast.type.raw.PackageType) ClassGenericType(dyvilx.tools.compiler.ast.type.generic.ClassGenericType)

Example 5 with ClassGenericType

use of dyvilx.tools.compiler.ast.type.generic.ClassGenericType in project Dyvil by Dyvil.

the class TypeOperator method resolveTypes.

@Override
public void resolveTypes(MarkerList markers, IContext context) {
    if (this.type == null) {
        this.type = dyvilx.tools.compiler.ast.type.builtin.Types.UNKNOWN;
        markers.add(Markers.semantic(this.position, "typeoperator.invalid"));
        return;
    }
    this.type = this.type.resolveType(markers, context);
    this.genericType = new ClassGenericType(LazyFields.TYPE_CLASS, this.type);
}
Also used : ClassGenericType(dyvilx.tools.compiler.ast.type.generic.ClassGenericType)

Aggregations

ClassGenericType (dyvilx.tools.compiler.ast.type.generic.ClassGenericType)5 ReferenceType (dyvilx.tools.compiler.ast.reference.ReferenceType)1 IType (dyvilx.tools.compiler.ast.type.IType)1 TypeList (dyvilx.tools.compiler.ast.type.TypeList)1 ClassType (dyvilx.tools.compiler.ast.type.raw.ClassType)1 NamedType (dyvilx.tools.compiler.ast.type.raw.NamedType)1 PackageType (dyvilx.tools.compiler.ast.type.raw.PackageType)1 TypeVarType (dyvilx.tools.compiler.ast.type.typevar.TypeVarType)1