Search in sources :

Example 6 with Marker

use of dyvilx.tools.parsing.marker.Marker in project Dyvil by Dyvil.

the class MatchCase method resolve.

public void resolve(MarkerList markers, IType type, IContext context) {
    if (this.pattern != null) {
        this.pattern = this.pattern.resolve(markers, context);
        final Pattern typedPattern = this.pattern.withType(type, markers);
        if (typedPattern == null) {
            Marker marker = Markers.semanticError(this.pattern.getPosition(), "pattern.type.incompatible");
            marker.addInfo(Markers.getSemantic("pattern.type", this.pattern.getType()));
            marker.addInfo(Markers.getSemantic("value.type", type));
            markers.add(marker);
        } else {
            this.pattern = typedPattern;
        }
    }
    context = context.push(this);
    if (this.condition != null) {
        this.condition = this.condition.resolve(markers, context);
        this.condition = TypeChecker.convertValue(this.condition, Types.BOOLEAN, null, markers, context, CONDITION_MARKER_SUPPLIER);
    }
    if (this.action != null) {
        this.action = this.action.resolve(markers, context);
    }
    context.pop();
}
Also used : Pattern(dyvilx.tools.compiler.ast.pattern.Pattern) Marker(dyvilx.tools.parsing.marker.Marker)

Example 7 with Marker

use of dyvilx.tools.parsing.marker.Marker in project Dyvil by Dyvil.

the class EnumConstant method check.

@Override
public void check(MarkerList markers, IContext context) {
    final IClass enclosingClass = this.getEnclosingClass();
    final IType classType = enclosingClass.getClassType();
    if (!enclosingClass.hasModifier(Modifiers.ENUM_CLASS)) {
        final Marker marker = Markers.semanticError(this.position, "field.enum.class", this.name);
        marker.addInfo(Markers.getSemantic("method.enclosing_class", classType));
        markers.add(marker);
    }
    super.check(markers, context);
}
Also used : IClass(dyvilx.tools.compiler.ast.classes.IClass) Marker(dyvilx.tools.parsing.marker.Marker) IType(dyvilx.tools.compiler.ast.type.IType)

Example 8 with Marker

use of dyvilx.tools.parsing.marker.Marker in project Dyvil by Dyvil.

the class AbstractCall method reportResolve.

protected void reportResolve(MarkerList markers, MatchList<IMethod> matches) {
    final Marker marker;
    if (// isAmbiguous returns false for empty lists
    matches == null || !matches.isAmbigous()) {
        marker = Markers.semanticError(this.position, "method.access.resolve", this.getName());
    } else {
        marker = Markers.semanticError(this.position, "method.access.ambiguous", this.getName());
    }
    this.addArgumentInfo(marker);
    this.addCandidates(matches, marker);
    markers.add(marker);
}
Also used : Marker(dyvilx.tools.parsing.marker.Marker)

Example 9 with Marker

use of dyvilx.tools.parsing.marker.Marker in project Dyvil by Dyvil.

the class ConstructorCall method resolveArrayConstructor.

private void resolveArrayConstructor(MarkerList markers, IContext context, ArrayType arrayType) {
    final IType elementType = arrayType.getElementType();
    if (elementType.hasTag(IType.TYPE_VAR)) {
        markers.add(Markers.semanticError(this.position, "constructor.access.array.typevar", elementType));
    }
    final int len = this.arguments.size();
    final int dims = 1 + getDimensions(arrayType.getElementType());
    if (len > dims) {
        final Marker marker = Markers.semanticError(this.position, "constructor.access.array.length");
        marker.addInfo(Markers.getSemantic("type.dimensions", dims));
        marker.addInfo(Markers.getSemantic("constructor.access.array.count", len));
        markers.add(marker);
        return;
    }
    for (int i = 0; i < len; i++) {
        final IValue value = this.arguments.get(i, null);
        final IValue typed = TypeChecker.convertValue(value, Types.INT, ITypeContext.DEFAULT, markers, context, TypeChecker.markerSupplier("constructor.access.array.type"));
        this.arguments.set(i, null, typed);
    }
}
Also used : IValue(dyvilx.tools.compiler.ast.expression.IValue) Marker(dyvilx.tools.parsing.marker.Marker) IType(dyvilx.tools.compiler.ast.type.IType)

Example 10 with Marker

use of dyvilx.tools.parsing.marker.Marker in project Dyvil by Dyvil.

the class FieldAssignment method reportResolve.

@Override
protected void reportResolve(MarkerList markers) {
    final Marker marker = Markers.semanticError(this.position, "resolve.field", this.name.unqualified);
    if (this.receiver != null) {
        marker.addInfo(Markers.getSemantic("receiver.type", this.receiver.getType()));
    }
    markers.add(marker);
}
Also used : Marker(dyvilx.tools.parsing.marker.Marker)

Aggregations

Marker (dyvilx.tools.parsing.marker.Marker)46 IType (dyvilx.tools.compiler.ast.type.IType)23 IClass (dyvilx.tools.compiler.ast.classes.IClass)11 IValue (dyvilx.tools.compiler.ast.expression.IValue)7 ITypeParameter (dyvilx.tools.compiler.ast.generic.ITypeParameter)4 TypeParameterList (dyvilx.tools.compiler.ast.generic.TypeParameterList)4 NonNull (dyvil.annotation.internal.NonNull)3 Name (dyvil.lang.Name)3 MarkerLevel (dyvil.util.MarkerLevel)3 ArgumentList (dyvilx.tools.compiler.ast.parameter.ArgumentList)3 Pattern (dyvilx.tools.compiler.ast.pattern.Pattern)3 TypeList (dyvilx.tools.compiler.ast.type.TypeList)3 SourcePosition (dyvil.source.position.SourcePosition)2 IContext (dyvilx.tools.compiler.ast.context.IContext)2 ITypeContext (dyvilx.tools.compiler.ast.generic.ITypeContext)2 AbstractPattern (dyvilx.tools.compiler.ast.pattern.AbstractPattern)2 Types (dyvilx.tools.compiler.ast.type.builtin.Types)2 ArrayType (dyvilx.tools.compiler.ast.type.compound.ArrayType)2 Markers (dyvilx.tools.compiler.util.Markers)2 MarkerList (dyvilx.tools.parsing.marker.MarkerList)2