Search in sources :

Example 1 with EnumValue

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

the class FieldAccess method resolveAsField.

@Override
protected IValue resolveAsField(IValue receiver, MarkerList markers, IContext context) {
    final IDataMember field = ICall.resolveField(context, receiver, this.name);
    if (field == null) {
        return null;
    }
    if (field.isEnumConstant()) {
        return new EnumValue(this.position, field);
    }
    this.receiver = receiver;
    this.field = field;
    this.capture(markers, context);
    return this;
}
Also used : EnumValue(dyvilx.tools.compiler.ast.expression.constant.EnumValue) IDataMember(dyvilx.tools.compiler.ast.field.IDataMember)

Example 2 with EnumValue

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

the class AnnotationMetadata method readRetention.

private void readRetention() {
    final Annotation retention = this.theClass.getAnnotation(Annotation.LazyFields.RETENTION_CLASS);
    if (retention == null) {
        return;
    }
    final IValue value = retention.getArguments().get(0, Names.value);
    if (!(value instanceof EnumValue)) {
        return;
    }
    try {
        final String name = ((EnumValue) value).getName().qualified;
        this.retention = RetentionPolicy.valueOf(name);
    } catch (IllegalArgumentException ignored) {
    // Problematic RetentionPolicy annotation - do not handle this
    }
}
Also used : IValue(dyvilx.tools.compiler.ast.expression.IValue) EnumValue(dyvilx.tools.compiler.ast.expression.constant.EnumValue) Annotation(dyvilx.tools.compiler.ast.attribute.annotation.Annotation)

Example 3 with EnumValue

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

the class Deprecation method getReasons.

private static Reason[] getReasons(ArgumentList arguments) {
    final IValue value = arguments.get(DEP_REASONS_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;
    }
    final Reason[] reasons = new Reason[size];
    for (int i = 0; i < size; i++) {
        final IValue element = values.get(i);
        assert element.valueTag() == IValue.ENUM_ACCESS;
        final EnumValue enumValue = (EnumValue) element;
        reasons[i] = Reason.valueOf(enumValue.getInternalName());
    }
    return reasons;
}
Also used : ArrayExpr(dyvilx.tools.compiler.ast.expression.ArrayExpr) IValue(dyvilx.tools.compiler.ast.expression.IValue) EnumValue(dyvilx.tools.compiler.ast.expression.constant.EnumValue) ArgumentList(dyvilx.tools.compiler.ast.parameter.ArgumentList) Reason(dyvil.annotation.Deprecated.Reason)

Aggregations

EnumValue (dyvilx.tools.compiler.ast.expression.constant.EnumValue)3 IValue (dyvilx.tools.compiler.ast.expression.IValue)2 Reason (dyvil.annotation.Deprecated.Reason)1 Annotation (dyvilx.tools.compiler.ast.attribute.annotation.Annotation)1 ArrayExpr (dyvilx.tools.compiler.ast.expression.ArrayExpr)1 IDataMember (dyvilx.tools.compiler.ast.field.IDataMember)1 ArgumentList (dyvilx.tools.compiler.ast.parameter.ArgumentList)1