Search in sources :

Example 46 with IType

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

the class CaptureVariable method writeSetCopy.

@Override
public void writeSetCopy(@NonNull MethodWriter writer, WriteableExpression receiver, @NonNull WriteableExpression value, int lineNumber) throws BytecodeException {
    final IType referenceType = this.variable.getReferenceType();
    assert referenceType != null;
    referenceType.resolveField(Names.value).writeSetCopy(writer, this.asWriteableExpression(), value, lineNumber);
}
Also used : IType(dyvilx.tools.compiler.ast.type.IType)

Example 47 with IType

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

the class CodeTypeParameter method resolveTypes.

@Override
public void resolveTypes(MarkerList markers, IContext context) {
    this.attributes.resolveTypes(markers, context, this);
    if (this.lowerBound != null) {
        this.lowerBound = this.lowerBound.resolveType(markers, context);
    }
    this.upperBound = this.upperBound.resolveType(markers, context);
    this.upperBounds = getUpperBounds(this.upperBound);
    // The first upper bound is meant to be a class bound.
    IType type = this.upperBounds[0];
    IClass typeClass = type.getTheClass();
    if (typeClass != null && !typeClass.isInterface()) {
        // If the first type is a class type (not an interface), it becomes the erasure type.
        this.erasure = type;
    }
    // Check if the remaining upper bounds are interfaces
    for (int i = 1, count = this.upperBounds.length; i < count; i++) {
        type = this.upperBounds[i];
        typeClass = type.getTheClass();
        if (typeClass != null && !typeClass.isInterface()) {
            final Marker marker = Markers.semanticError(type.getPosition(), "type_parameter.bound.class");
            marker.addInfo(Markers.getSemantic("class.declaration", Util.classSignatureToString(typeClass)));
            markers.add(marker);
        }
    }
}
Also used : IClass(dyvilx.tools.compiler.ast.classes.IClass) Marker(dyvilx.tools.parsing.marker.Marker) IType(dyvilx.tools.compiler.ast.type.IType)

Example 48 with IType

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

the class CombiningTypeContext method resolveType.

@Override
public IType resolveType(ITypeParameter typeParameter) {
    final IType type1 = this.context1.resolveType(typeParameter);
    final IType type2 = this.context2.resolveType(typeParameter);
    if (type1 == null) {
        return type2;
    }
    if (type2 == null) {
        return type1;
    }
    return Types.combine(type1, type2);
}
Also used : IType(dyvilx.tools.compiler.ast.type.IType)

Example 49 with IType

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

the class GenericData method addMapping.

@Override
public void addMapping(ITypeParameter typeParameter, IType type) {
    if (!this.isMethodTypeVariable(typeParameter)) {
        return;
    }
    final int index = typeParameter.getIndex();
    final IType current = this.generics.get(index);
    if (current == null) {
        this.generics.set(index, type);
        return;
    }
    if (index < this.lockedCount) {
        return;
    }
    this.generics.set(index, Types.combine(current, type));
}
Also used : IType(dyvilx.tools.compiler.ast.type.IType)

Example 50 with IType

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

the class PopExpr method writeExpression.

@Override
public void writeExpression(MethodWriter writer, IType type) throws BytecodeException {
    final IType valueType = this.value.getType();
    this.value.writeExpression(writer, null);
    if (!Types.isVoid(valueType)) {
        writer.visitInsn(Opcodes.AUTO_POP);
    }
}
Also used : IType(dyvilx.tools.compiler.ast.type.IType)

Aggregations

IType (dyvilx.tools.compiler.ast.type.IType)159 IClass (dyvilx.tools.compiler.ast.classes.IClass)26 Marker (dyvilx.tools.parsing.marker.Marker)23 IValue (dyvilx.tools.compiler.ast.expression.IValue)21 TypeParameterList (dyvilx.tools.compiler.ast.generic.TypeParameterList)13 ParameterList (dyvilx.tools.compiler.ast.parameter.ParameterList)11 IParameter (dyvilx.tools.compiler.ast.parameter.IParameter)10 SourcePosition (dyvil.source.position.SourcePosition)9 Annotation (dyvilx.tools.compiler.ast.attribute.annotation.Annotation)9 ITypeParameter (dyvilx.tools.compiler.ast.generic.ITypeParameter)9 ArgumentList (dyvilx.tools.compiler.ast.parameter.ArgumentList)9 TypeList (dyvilx.tools.compiler.ast.type.TypeList)7 AttributeList (dyvilx.tools.compiler.ast.attribute.AttributeList)6 FieldAccess (dyvilx.tools.compiler.ast.expression.access.FieldAccess)6 IVariable (dyvilx.tools.compiler.ast.field.IVariable)6 ArrayType (dyvilx.tools.compiler.ast.type.compound.ArrayType)6 MethodWriter (dyvilx.tools.compiler.backend.MethodWriter)6 CodeMethod (dyvilx.tools.compiler.ast.method.CodeMethod)5 CodeParameter (dyvilx.tools.compiler.ast.parameter.CodeParameter)5 Name (dyvil.lang.Name)4