Search in sources :

Example 51 with IValue

use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.

the class Deprecation method getReplacements.

private static String[] getReplacements(ArgumentList arguments) {
    IValue value = arguments.get(DEP_REPLACE_PARAM);
    if (value == null) {
        return null;
    }
    assert value.valueTag() == IValue.ARRAY;
    final ArrayExpr array = (ArrayExpr) value;
    final ArgumentList values = array.getValues();
    final int size = values.size();
    if (size == 0) {
        return null;
    }
    String[] replacements = new String[size];
    for (int i = 0; i < size; i++) {
        IValue element = values.get(i);
        assert element.valueTag() == IValue.STRING;
        replacements[i] = element.stringValue();
    }
    return replacements;
}
Also used : ArrayExpr(dyvilx.tools.compiler.ast.expression.ArrayExpr) IValue(dyvilx.tools.compiler.ast.expression.IValue) ArgumentList(dyvilx.tools.compiler.ast.parameter.ArgumentList)

Example 52 with IValue

use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.

the class TypeChecker method convertValue.

public static IValue convertValue(IValue value, IType type, ITypeContext typeContext, MarkerList markers, IContext context, MarkerSupplier markerSupplier) {
    final IType concreteType = type.getConcreteType(typeContext);
    final IValue newValue = convertValueDirect(value, concreteType, typeContext, markers, context);
    if (newValue != null) {
        if (typeContext != null && !typeContext.isReadonly() && type.hasTypeVariables()) {
            type.inferTypes(newValue.getType(), typeContext);
        }
        return newValue;
    }
    if (value.isResolved()) {
        markers.add(markerSupplier.createMarker(value.getPosition(), concreteType, value.getType()));
    }
    return value;
}
Also used : IValue(dyvilx.tools.compiler.ast.expression.IValue) IType(dyvilx.tools.compiler.ast.type.IType)

Example 53 with IValue

use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.

the class FieldAccess method toCompoundAssignment.

@Override
public IValue toCompoundAssignment(IValue rhs, SourcePosition position, MarkerList markers, IContext context, SideEffectHelper helper) {
    // x (op)= z
    // -> x = x (op) z
    // note that x is only evaluated once
    final IValue fieldReceiver = helper.processValue(this.receiver);
    this.receiver = fieldReceiver;
    return new FieldAssignment(position, fieldReceiver, this.field, rhs);
}
Also used : IValue(dyvilx.tools.compiler.ast.expression.IValue)

Example 54 with IValue

use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.

the class FieldAssignment method withType.

@Override
public IValue withType(IType type, ITypeContext typeContext, MarkerList markers, IContext context) {
    if (Types.isVoid(type)) {
        return this;
    }
    final IValue typedValue = this.value.withType(type, typeContext, markers, context);
    if (typedValue == null) {
        return null;
    }
    this.value = typedValue;
    return this;
}
Also used : IValue(dyvilx.tools.compiler.ast.expression.IValue)

Example 55 with IValue

use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.

the class ICall method wildcardCount.

default int wildcardCount() {
    int count = 0;
    IValue receiver = this.getReceiver();
    if (receiver != null && receiver.isPartialWildcard()) {
        count = 1;
    }
    for (IValue value : this.getArguments()) {
        if (value.isPartialWildcard()) {
            count++;
        }
    }
    return count;
}
Also used : IValue(dyvilx.tools.compiler.ast.expression.IValue)

Aggregations

IValue (dyvilx.tools.compiler.ast.expression.IValue)79 IType (dyvilx.tools.compiler.ast.type.IType)20 ArgumentList (dyvilx.tools.compiler.ast.parameter.ArgumentList)17 FieldAccess (dyvilx.tools.compiler.ast.expression.access.FieldAccess)11 SourcePosition (dyvil.source.position.SourcePosition)10 IParameter (dyvilx.tools.compiler.ast.parameter.IParameter)9 ArrayExpr (dyvilx.tools.compiler.ast.expression.ArrayExpr)7 Marker (dyvilx.tools.parsing.marker.Marker)7 IMethod (dyvilx.tools.compiler.ast.method.IMethod)6 AttributeList (dyvilx.tools.compiler.ast.attribute.AttributeList)5 IContext (dyvilx.tools.compiler.ast.context.IContext)5 MethodCall (dyvilx.tools.compiler.ast.expression.access.MethodCall)5 CodeParameter (dyvilx.tools.compiler.ast.parameter.CodeParameter)5 Annotation (dyvilx.tools.compiler.ast.attribute.annotation.Annotation)4 IClass (dyvilx.tools.compiler.ast.classes.IClass)4 Variable (dyvilx.tools.compiler.ast.field.Variable)4 ParameterList (dyvilx.tools.compiler.ast.parameter.ParameterList)4 CombiningContext (dyvilx.tools.compiler.ast.context.CombiningContext)3 IVariable (dyvilx.tools.compiler.ast.field.IVariable)3 CodeMethod (dyvilx.tools.compiler.ast.method.CodeMethod)3