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;
}
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
}
}
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;
}
Aggregations