Search in sources :

Example 41 with IClass

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

the class MethodWriterImpl method visitEnd.

@Override
public void visitEnd(IType type) {
    IClass iclass = type.getTheClass();
    if (iclass != null) {
        iclass.writeInnerClassInfo(this.cw);
    }
    if (!this.hasReturn) {
        int opcode = type.getReturnOpcode();
        if (opcode == RETURN || this.frame.actualStackCount > 0) {
            this.insnCallback();
            this.mv.visitInsn(opcode);
        }
    }
    this.mv.visitMaxs(this.frame.maxStack, this.frame.maxLocals);
    this.mv.visitEnd();
}
Also used : IClass(dyvilx.tools.compiler.ast.classes.IClass)

Example 42 with IClass

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

the class NamedType method resolveWithParent.

private IType resolveWithParent(MarkerList markers) {
    final IClass theClass = this.parent.resolveClass(this.name);
    if (theClass != null) {
        return new ResolvedClassType(theClass, this.position);
    }
    final Package thePackage = this.parent.resolvePackage(this.name);
    if (thePackage != null) {
        return new PackageType(thePackage).atPosition(this.position);
    }
    if (markers == null) {
        // FieldAccess support
        return null;
    }
    markers.add(Markers.semanticError(this.position, "resolve.type.package", this.name, this.parent));
    return this;
}
Also used : IClass(dyvilx.tools.compiler.ast.classes.IClass) Package(dyvilx.tools.compiler.ast.structure.Package)

Example 43 with IClass

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

the class ResolvedClassType method checkType.

@Override
public void checkType(MarkerList markers, IContext context, int position) {
    final IClass iclass = this.theClass;
    if (iclass != null) {
        ModifierUtil.checkVisibility(iclass, this.position, markers, context);
    }
    super.checkType(markers, context, position);
}
Also used : IClass(dyvilx.tools.compiler.ast.classes.IClass)

Example 44 with IClass

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

the class ClassAccess method check.

@Override
public void check(MarkerList markers, IContext context) {
    this.type.check(markers, context);
    if (!this.withTyped) {
        // Don't need an additional error
        return;
    }
    if (!this.type.isResolved()) {
        // Already reported this in CHECK_TYPES
        return;
    }
    final IClass iclass = this.type.getTheClass();
    if (iclass != null && iclass.hasModifier(Modifiers.OBJECT_CLASS)) {
        // Object type, we can safely use it's instance field.
        return;
    }
    markers.add(Markers.semantic(this.position, "type.access.invalid", this.type.toString()));
}
Also used : IClass(dyvilx.tools.compiler.ast.classes.IClass)

Example 45 with IClass

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

the class ConstructorCall method resolveCall.

@Override
public IValue resolveCall(MarkerList markers, IContext context, boolean report) {
    if (!this.type.isResolved()) {
        return this;
    }
    final ArrayType arrayType = this.type.extract(ArrayType.class);
    if (arrayType != null) {
        this.resolveArrayConstructor(markers, context, arrayType);
        return this;
    }
    final IClass theClass = this.type.getTheClass();
    if (theClass != null && theClass.isInterface()) {
        if (!report) {
            return null;
        }
        markers.add(Markers.semanticError(this.position, "constructor.access.interface", this.type));
        return this;
    }
    final MatchList<IConstructor> candidates = this.resolveCandidates(context, this.type);
    if (candidates.hasCandidate()) {
        this.checkArguments(markers, context, candidates.getBestMember());
        return this;
    }
    if (report) {
        reportResolve(markers, candidates, this.position, this.type, this.arguments);
        return this;
    }
    return null;
}
Also used : ArrayType(dyvilx.tools.compiler.ast.type.compound.ArrayType) IConstructor(dyvilx.tools.compiler.ast.constructor.IConstructor) IClass(dyvilx.tools.compiler.ast.classes.IClass)

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