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;
}
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;
}
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;
}
Aggregations