Search in sources :

Example 11 with IClass

use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.

the class ThisExpr method resolveTypes.

@Override
public void resolveTypes(MarkerList markers, IContext context) {
    if (this.type != Types.UNKNOWN) {
        this.type = this.type.resolveType(markers, context);
        // Replace e.g. this<List> with this<List<T>> in class List<type T>
        final IClass iclass = this.type.getTheClass();
        if (iclass != null) {
            this.type = iclass.getThisType();
        }
        return;
    }
    final IType thisType = context.getThisType();
    if (thisType != null) {
        this.type = thisType;
    } else {
        markers.add(Markers.semanticError(this.position, "this.access.unresolved"));
    }
}
Also used : IClass(dyvilx.tools.compiler.ast.classes.IClass) IType(dyvilx.tools.compiler.ast.type.IType)

Example 12 with IClass

use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.

the class ExternalClass method resolveClass.

@Override
public IClass resolveClass(Name name) {
    final IClass bodyClass = this.body.getClass(name);
    if (bodyClass != null) {
        return bodyClass;
    }
    if (this.innerTypes == null) {
        return null;
    }
    final String internal = this.innerTypes.get(name.qualified);
    if (internal == null) {
        return null;
    }
    // Resolve the class name and add it to the body
    final String fileName = internal + DyvilFileType.CLASS_EXTENSION;
    return Package.loadClass(fileName, name, this.body);
}
Also used : IClass(dyvilx.tools.compiler.ast.classes.IClass)

Example 13 with IClass

use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.

the class ClassConstructorCall method resolveCall.

@Override
public IValue resolveCall(MarkerList markers, IContext context, boolean report) {
    if (!this.type.isResolved()) {
        return this;
    }
    final IClass theClass = this.type.getTheClass();
    if (theClass == null) {
        return this;
    }
    final IType type = theClass.isInterface() ? Types.OBJECT : this.type;
    final MatchList<IConstructor> candidates = this.resolveCandidates(context, type);
    if (candidates.hasCandidate()) {
        this.checkArguments(markers, context, candidates.getBestMember());
        return this;
    }
    if (report) {
        reportResolve(markers, candidates, this.position, type, this.arguments);
        return this;
    }
    return null;
}
Also used : IConstructor(dyvilx.tools.compiler.ast.constructor.IConstructor) IClass(dyvilx.tools.compiler.ast.classes.IClass) IType(dyvilx.tools.compiler.ast.type.IType)

Example 14 with IClass

use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.

the class ClassConstructorCall method resolveTypes.

@Override
public void resolveTypes(MarkerList markers, IContext context) {
    super.resolveTypes(markers, context);
    final IClass theClass = this.type.getTheClass();
    if (theClass != null) {
        if (theClass.isInterface()) {
            this.nestedClass.getInterfaces().add(this.type);
        } else {
            this.nestedClass.setSuperType(this.type);
        }
    }
    this.nestedClass.resolveTypes(markers, context);
}
Also used : IClass(dyvilx.tools.compiler.ast.classes.IClass)

Example 15 with IClass

use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.

the class ClassConstructorCall method resolve.

@Override
public IValue resolve(MarkerList markers, IContext context) {
    this.type.resolve(markers, context);
    this.arguments.resolve(markers, context);
    this.resolveCall(markers, context, true);
    final IClass enclosingClass = context.getThisClass();
    assert enclosingClass != null;
    this.nestedClass.setConstructor(this.constructor);
    this.nestedClass.setEnclosingClass(enclosingClass);
    final IHeaderUnit header = enclosingClass.getHeader();
    assert header != null;
    this.nestedClass.setHeader(header);
    header.addCompilable(this.nestedClass);
    this.nestedClass.resolve(markers, context);
    return this;
}
Also used : IClass(dyvilx.tools.compiler.ast.classes.IClass) IHeaderUnit(dyvilx.tools.compiler.ast.header.IHeaderUnit)

Aggregations

IClass (dyvilx.tools.compiler.ast.classes.IClass)57 IType (dyvilx.tools.compiler.ast.type.IType)23 Marker (dyvilx.tools.parsing.marker.Marker)9 TypeParameterList (dyvilx.tools.compiler.ast.generic.TypeParameterList)6 ParameterList (dyvilx.tools.compiler.ast.parameter.ParameterList)5 Package (dyvilx.tools.compiler.ast.structure.Package)5 IParameter (dyvilx.tools.compiler.ast.parameter.IParameter)4 Name (dyvil.lang.Name)3 IValue (dyvilx.tools.compiler.ast.expression.IValue)3 ITypeParameter (dyvilx.tools.compiler.ast.generic.ITypeParameter)3 IHeaderUnit (dyvilx.tools.compiler.ast.header.IHeaderUnit)3 ClassBody (dyvilx.tools.compiler.ast.classes.ClassBody)2 IConstructor (dyvilx.tools.compiler.ast.constructor.IConstructor)2 ArgumentList (dyvilx.tools.compiler.ast.parameter.ArgumentList)2 TypeList (dyvilx.tools.compiler.ast.type.TypeList)2 ITypeAlias (dyvilx.tools.compiler.ast.type.alias.ITypeAlias)2 PackageType (dyvilx.tools.compiler.ast.type.raw.PackageType)2 ResolvedTypeVarType (dyvilx.tools.compiler.ast.type.typevar.ResolvedTypeVarType)2 Handle (dyvilx.tools.asm.Handle)1 Annotation (dyvilx.tools.compiler.ast.attribute.annotation.Annotation)1