Search in sources :

Example 6 with IContext

use of dyvilx.tools.compiler.ast.context.IContext in project Dyvil by Dyvil.

the class ExternalMethod method resolveExceptions.

private void resolveExceptions() {
    if (this.exceptions == null || (this.resolved & EXCEPTIONS) != 0) {
        return;
    }
    this.resolved |= EXCEPTIONS;
    if (this.exceptions != null) {
        final IContext context = this.getExternalContext();
        this.exceptions.resolveTypes(null, context);
    }
}
Also used : IContext(dyvilx.tools.compiler.ast.context.IContext)

Example 7 with IContext

use of dyvilx.tools.compiler.ast.context.IContext in project Dyvil by Dyvil.

the class ClassUnit method check.

@Override
public void check() {
    this.pack.check(this.packageDeclaration, this.markers);
    if (this.headerDeclaration != null) {
        this.headerDeclaration.check(this.markers);
    }
    final IContext context = this.getContext();
    for (int i = 0; i < this.classCount; i++) {
        this.classes[i].check(this.markers, context);
    }
}
Also used : IContext(dyvilx.tools.compiler.ast.context.IContext)

Example 8 with IContext

use of dyvilx.tools.compiler.ast.context.IContext in project Dyvil by Dyvil.

the class Initializer method resolve.

@Override
public void resolve(MarkerList markers, IContext context) {
    super.resolve(markers, context);
    if (this.value != null) {
        final IContext context1 = new CombiningContext(this, context);
        final IValue resolved = this.value.resolve(markers, context1);
        this.value = TypeChecker.convertValue(resolved, Types.VOID, Types.VOID, markers, context1, TypeChecker.markerSupplier("initializer.type"));
    }
}
Also used : IContext(dyvilx.tools.compiler.ast.context.IContext) IValue(dyvilx.tools.compiler.ast.expression.IValue) CombiningContext(dyvilx.tools.compiler.ast.context.CombiningContext)

Example 9 with IContext

use of dyvilx.tools.compiler.ast.context.IContext in project Dyvil by Dyvil.

the class IDataMember method checkAssign.

default IValue checkAssign(MarkerList markers, IContext context, SourcePosition position, IValue receiver, IValue newValue) {
    if (this.hasModifier(Modifiers.FINAL) && !context.isConstructor()) {
        markers.add(Markers.semanticError(position, this.getKind().getName() + ".assign.final", this.getName()));
    }
    final IType type = this.getType();
    final ITypeContext typeContext = receiver == null ? ITypeContext.NULL : receiver.getType();
    final TypeChecker.MarkerSupplier markerSupplier = (errorPosition, expected, actual) -> {
        final String kindName = this.getKind().getName();
        final Marker marker = Markers.semanticError(errorPosition, kindName + ".assign.type", this.getName());
        marker.addInfo(Markers.getSemantic(kindName + ".type", expected));
        marker.addInfo(Markers.getSemantic("value.type", actual));
        return marker;
    };
    return TypeChecker.convertValue(newValue, type, typeContext, markers, context, markerSupplier);
}
Also used : IValue(dyvilx.tools.compiler.ast.expression.IValue) ITypeContext(dyvilx.tools.compiler.ast.generic.ITypeContext) IValueConsumer(dyvilx.tools.compiler.ast.consumer.IValueConsumer) IContext(dyvilx.tools.compiler.ast.context.IContext) TypeChecker(dyvilx.tools.compiler.transform.TypeChecker) IType(dyvilx.tools.compiler.ast.type.IType) MemberKind(dyvilx.tools.compiler.ast.member.MemberKind) WriteableExpression(dyvilx.tools.compiler.ast.expression.WriteableExpression) IMember(dyvilx.tools.compiler.ast.member.IMember) Types(dyvilx.tools.compiler.ast.type.builtin.Types) Formatting(dyvilx.tools.compiler.config.Formatting) Marker(dyvilx.tools.parsing.marker.Marker) SourcePosition(dyvil.source.position.SourcePosition) Markers(dyvilx.tools.compiler.util.Markers) BytecodeException(dyvilx.tools.compiler.backend.exception.BytecodeException) MarkerList(dyvilx.tools.parsing.marker.MarkerList) NonNull(dyvil.annotation.internal.NonNull) Modifiers(dyvil.reflect.Modifiers) MethodWriter(dyvilx.tools.compiler.backend.MethodWriter) IClass(dyvilx.tools.compiler.ast.classes.IClass) TypeChecker(dyvilx.tools.compiler.transform.TypeChecker) Marker(dyvilx.tools.parsing.marker.Marker) ITypeContext(dyvilx.tools.compiler.ast.generic.ITypeContext) IType(dyvilx.tools.compiler.ast.type.IType)

Example 10 with IContext

use of dyvilx.tools.compiler.ast.context.IContext in project Dyvil by Dyvil.

the class Property method resolve.

@Override
public void resolve(MarkerList markers, IContext context) {
    super.resolve(markers, context);
    if (this.getter != null) {
        this.getter.resolve(markers, context);
        // Infer Type if necessary
        if (this.type == Types.UNKNOWN) {
            this.type = this.getter.getType();
            if (this.setterParameter != null) {
                this.setterParameter.setType(this.type);
            }
        }
    }
    if (this.type == Types.UNKNOWN) {
        markers.add(Markers.semanticError(this.position, "property.type.infer", this.name));
    }
    if (this.setter != null) {
        this.setter.resolve(markers, context);
    }
    if (this.initializer != null) {
        final IContext context1 = new CombiningContext(this, context);
        final IValue resolved = this.initializer.resolve(markers, context1);
        this.initializer = TypeChecker.convertValue(resolved, Types.VOID, Types.VOID, markers, context1, TypeChecker.markerSupplier("property.initializer.type"));
    }
}
Also used : IContext(dyvilx.tools.compiler.ast.context.IContext) IValue(dyvilx.tools.compiler.ast.expression.IValue) CombiningContext(dyvilx.tools.compiler.ast.context.CombiningContext)

Aggregations

IContext (dyvilx.tools.compiler.ast.context.IContext)16 IValue (dyvilx.tools.compiler.ast.expression.IValue)5 CombiningContext (dyvilx.tools.compiler.ast.context.CombiningContext)3 SourcePosition (dyvil.source.position.SourcePosition)2 IMember (dyvilx.tools.compiler.ast.member.IMember)2 IMethod (dyvilx.tools.compiler.ast.method.IMethod)2 IType (dyvilx.tools.compiler.ast.type.IType)2 TypeChecker (dyvilx.tools.compiler.transform.TypeChecker)2 MarkerList (dyvilx.tools.parsing.marker.MarkerList)2 NonNull (dyvil.annotation.internal.NonNull)1 TreeSet (dyvil.collection.mutable.TreeSet)1 Modifiers (dyvil.reflect.Modifiers)1 LineSource (dyvil.source.LineSource)1 IClass (dyvilx.tools.compiler.ast.classes.IClass)1 IValueConsumer (dyvilx.tools.compiler.ast.consumer.IValueConsumer)1 ThisExpr (dyvilx.tools.compiler.ast.expression.ThisExpr)1 WriteableExpression (dyvilx.tools.compiler.ast.expression.WriteableExpression)1 FieldAccess (dyvilx.tools.compiler.ast.expression.access.FieldAccess)1 FieldAssignment (dyvilx.tools.compiler.ast.expression.access.FieldAssignment)1 VoidValue (dyvilx.tools.compiler.ast.expression.constant.VoidValue)1