Search in sources :

Example 41 with IType

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

the class FieldAccess method resolveAsType.

@Override
protected IValue resolveAsType(IContext context) {
    final IType parentType;
    if (this.receiver == null) {
        parentType = null;
    } else if (this.receiver.isClassAccess()) {
        parentType = this.receiver.getType();
    } else {
        return null;
    }
    final IType type = new NamedType(this.position, this.name, parentType).resolveType(null, context);
    return type != null ? new ClassAccess(this.position, type) : null;
}
Also used : NamedType(dyvilx.tools.compiler.ast.type.raw.NamedType) IType(dyvilx.tools.compiler.ast.type.IType)

Example 42 with IType

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

the class CaptureField method writeGet.

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

Example 43 with IType

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

the class CaptureField method writeSet.

@Override
public void writeSet(@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).writeSet(writer, this.asWriteableExpression(receiver), value, lineNumber);
}
Also used : IType(dyvilx.tools.compiler.ast.type.IType)

Example 44 with IType

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

the class CaptureParameter method getDefaultValue.

@Override
public IValue getDefaultValue(IContext context) {
    final IValue access = new FieldAccess(this.variable) {

        @Override
        public void writeExpression(MethodWriter writer, IType type) throws BytecodeException {
            this.field.writeGetRaw(writer, this.receiver, this.lineNumber());
        }
    }.resolve(MarkerList.BLACKHOLE, context);
    // ensures proper capture
    access.checkTypes(MarkerList.BLACKHOLE, context);
    return access;
}
Also used : IValue(dyvilx.tools.compiler.ast.expression.IValue) BytecodeException(dyvilx.tools.compiler.backend.exception.BytecodeException) MethodWriter(dyvilx.tools.compiler.backend.MethodWriter) FieldAccess(dyvilx.tools.compiler.ast.expression.access.FieldAccess) IType(dyvilx.tools.compiler.ast.type.IType)

Example 45 with IType

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

the class CaptureVariable method writeSet.

@Override
public void writeSet(@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).writeSet(writer, this.asWriteableExpression(), value, lineNumber);
}
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