Search in sources :

Example 1 with SemanticError

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

the class TryStatement method resolve.

@Override
public IValue resolve(MarkerList markers, IContext context) {
    if (this.action != null) {
        context = context.push(this);
        this.action = this.action.resolve(markers, context);
        context = context.pop();
    }
    for (int i = 0; i < this.catchBlockCount; i++) {
        this.catchBlocks[i].resolve(markers, context);
    }
    if (this.finallyBlock != null) {
        this.finallyBlock = this.finallyBlock.resolve(markers, context);
        this.finallyBlock = IStatement.checkStatement(markers, context, this.finallyBlock, "try.finally.type");
    }
    if (DISALLOW_EXPRESSIONS && this.commonType != null && this.commonType != Types.VOID) {
        markers.add(new SemanticError(this.position, "Try Statements cannot currently be used as expressions"));
    }
    return this;
}
Also used : SemanticError(dyvilx.tools.parsing.marker.SemanticError)

Example 2 with SemanticError

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

the class AbstractMethod method checkMutating.

private void checkMutating(MarkerList markers, IValue receiver) {
    final IType receiverType = receiver.getType();
    if (receiverType.getMutability() != Mutability.IMMUTABLE) {
        return;
    }
    final Annotation mutatingAnnotation = this.getAnnotation(Types.MUTATING_CLASS);
    if (mutatingAnnotation == null) {
        return;
    }
    final IValue value = mutatingAnnotation.getArguments().get(0, Names.value);
    final String stringValue = value != null ? value.stringValue() : Mutating.DEFAULT_MESSAGE;
    StringBuilder builder = new StringBuilder(stringValue);
    int index = builder.indexOf("{method}");
    if (index >= 0) {
        builder.replace(index, index + 8, this.name.unqualified);
    }
    index = builder.indexOf("{type}");
    if (index >= 0) {
        builder.replace(index, index + 6, receiverType.toString());
    }
    markers.add(new SemanticError(receiver.getPosition(), builder.toString()));
}
Also used : IValue(dyvilx.tools.compiler.ast.expression.IValue) SemanticError(dyvilx.tools.parsing.marker.SemanticError) Annotation(dyvilx.tools.compiler.ast.attribute.annotation.Annotation) IType(dyvilx.tools.compiler.ast.type.IType)

Aggregations

SemanticError (dyvilx.tools.parsing.marker.SemanticError)2 Annotation (dyvilx.tools.compiler.ast.attribute.annotation.Annotation)1 IValue (dyvilx.tools.compiler.ast.expression.IValue)1 IType (dyvilx.tools.compiler.ast.type.IType)1