use of dyvilx.tools.compiler.ast.classes.IClass 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.classes.IClass 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.classes.IClass in project Dyvil by Dyvil.
the class Types method addSuperClasses.
private static void addSuperClasses(IType type, Collection<IClass> types) {
final IClass theClass = type.getTheClass();
if (theClass == null) {
return;
}
types.add(theClass);
final IType superType = theClass.getSuperType();
if (superType != null) {
addSuperClasses(superType, types);
}
final TypeList interfaces = theClass.getInterfaces();
if (interfaces == null) {
return;
}
for (int i = 0, count = interfaces.size(); i < count; i++) {
addSuperClasses(interfaces.get(i), types);
}
}
use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.
the class NamedType method resolveTopLevelWith.
private IType resolveTopLevelWith(@SuppressWarnings("UnusedParameters") MarkerList markers, IContext context) {
final MatchList<ITypeAlias> typeAliases = IContext.resolveTypeAlias(context, null, this.name, TypeList.EMPTY);
if (typeAliases.hasCandidate()) {
final ITypeAlias typeAlias = typeAliases.getBestMember();
final IType type = typeAlias.getType();
if (!type.isResolved() && markers != null) {
markers.add(Markers.semanticError(this.position, "type.alias.unresolved", this.name));
return type.atPosition(this.position);
}
return type.getConcreteType(ITypeContext.DEFAULT).atPosition(this.position);
}
final IClass theClass = context.resolveClass(this.name);
if (theClass != null) {
return new ResolvedClassType(theClass, this.position);
}
final ITypeParameter typeParameter = context.resolveTypeParameter(this.name);
if (typeParameter != null) {
return new ResolvedTypeVarType(typeParameter, this.position);
}
final Package thePackage = context.resolvePackage(this.name);
if (thePackage != null) {
return new PackageType(thePackage).atPosition(this.position);
}
return null;
}
use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.
the class Package method resolveClass.
@Override
public IClass resolveClass(Name name) {
for (IHeaderUnit c : this.headers) {
if (c.getName() == name) {
return c.getClass(name);
}
}
for (IClass c : this.classes) {
if (c.getName() == name) {
return c;
}
}
String qualifiedName = name.qualified;
// Check for inner / nested / anonymous classes
final int cashIndex = qualifiedName.lastIndexOf('$');
if (cashIndex < 0) {
return this.loadClass(name, qualifiedName);
}
final Name outerName = Name.fromRaw(qualifiedName.substring(0, cashIndex));
final Name innerName = Name.fromRaw(qualifiedName.substring(cashIndex + 1));
final IClass outerClass = this.resolveClass(outerName);
if (outerClass != null) {
return outerClass.resolveClass(innerName);
}
return this.loadClass(name, qualifiedName);
}
Aggregations