Search in sources :

Example 1 with PackageType

use of dyvilx.tools.compiler.ast.type.raw.PackageType in project Dyvil by Dyvil.

the class NamedGenericType method resolveWithParent.

private IType resolveWithParent(MarkerList markers) {
    final IClass theClass = this.parent.resolveClass(this.name);
    if (theClass != null) {
        final IType classType = theClass.getThisType();
        return this.checkCount(markers, theClass, "class", classType);
    }
    final Package thePackage = this.parent.resolvePackage(this.name);
    if (thePackage != null) {
        markers.add(Markers.semanticError(this.position, "type.generic.package.not_generic", thePackage.getName()));
        return new PackageType(thePackage).atPosition(this.position);
    }
    markers.add(Markers.semanticError(this.position, "resolve.type.package", this.name, this.parent));
    return this;
}
Also used : PackageType(dyvilx.tools.compiler.ast.type.raw.PackageType) IClass(dyvilx.tools.compiler.ast.classes.IClass) Package(dyvilx.tools.compiler.ast.structure.Package) IType(dyvilx.tools.compiler.ast.type.IType)

Example 2 with PackageType

use of dyvilx.tools.compiler.ast.type.raw.PackageType in project Dyvil by Dyvil.

the class NamedGenericType method resolveTopLevelWith.

private IType resolveTopLevelWith(MarkerList markers, IContext context) {
    final MatchList<ITypeAlias> typeAliases = IContext.resolveTypeAlias(context, null, this.name, this.arguments);
    if (typeAliases.hasCandidate()) {
        final ITypeAlias typeAlias = typeAliases.getBestMember();
        final IType aliasType = typeAlias.getType();
        if (!aliasType.isResolved()) {
            markers.add(Markers.semanticError(this.position, "type.alias.unresolved", this.name));
            return aliasType.atPosition(this.position);
        }
        return this.checkCount(markers, typeAlias, "type_alias", aliasType);
    }
    final IClass theClass = context.resolveClass(this.name);
    if (theClass != null) {
        final IType classType = theClass.getThisType();
        return this.checkCount(markers, theClass, "class", classType);
    }
    final ITypeParameter typeParameter = context.resolveTypeParameter(this.name);
    if (typeParameter != null) {
        markers.add(Markers.semanticError(this.position, "type.generic.type_parameter.not_generic", typeParameter.getName()));
        return new ResolvedTypeVarType(typeParameter, this.position);
    }
    final Package thePackage = context.resolvePackage(this.name);
    if (thePackage != null) {
        markers.add(Markers.semanticError(this.position, "type.generic.package.not_generic", thePackage.getName()));
        return new PackageType(thePackage).atPosition(this.position);
    }
    return null;
}
Also used : ITypeAlias(dyvilx.tools.compiler.ast.type.alias.ITypeAlias) PackageType(dyvilx.tools.compiler.ast.type.raw.PackageType) ResolvedTypeVarType(dyvilx.tools.compiler.ast.type.typevar.ResolvedTypeVarType) ITypeParameter(dyvilx.tools.compiler.ast.generic.ITypeParameter) IClass(dyvilx.tools.compiler.ast.classes.IClass) Package(dyvilx.tools.compiler.ast.structure.Package) IType(dyvilx.tools.compiler.ast.type.IType)

Example 3 with PackageType

use of dyvilx.tools.compiler.ast.type.raw.PackageType 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)

Aggregations

PackageType (dyvilx.tools.compiler.ast.type.raw.PackageType)3 IClass (dyvilx.tools.compiler.ast.classes.IClass)2 Package (dyvilx.tools.compiler.ast.structure.Package)2 IType (dyvilx.tools.compiler.ast.type.IType)2 ITypeParameter (dyvilx.tools.compiler.ast.generic.ITypeParameter)1 ReferenceType (dyvilx.tools.compiler.ast.reference.ReferenceType)1 ITypeAlias (dyvilx.tools.compiler.ast.type.alias.ITypeAlias)1 ClassGenericType (dyvilx.tools.compiler.ast.type.generic.ClassGenericType)1 ClassType (dyvilx.tools.compiler.ast.type.raw.ClassType)1 NamedType (dyvilx.tools.compiler.ast.type.raw.NamedType)1 ResolvedTypeVarType (dyvilx.tools.compiler.ast.type.typevar.ResolvedTypeVarType)1