use of dyvilx.tools.compiler.ast.expression.ArrayExpr in project Dyvil by Dyvil.
the class ArgumentList method checkVarargsValue.
protected static boolean checkVarargsValue(IValue[] values, int startIndex, int endIndex, IParameter param, GenericData genericData, MarkerList markers, IContext context) {
final IValue value = values[startIndex];
if (value.checkVarargs(true)) {
values[startIndex] = convertValue(value, param, genericData, markers, context);
return false;
}
final int count = endIndex - startIndex;
final ArrayExpr arrayExpr = newArrayExpr(values, startIndex, count);
final IValue converted = convertValue(arrayExpr, param, genericData, markers, context);
values[startIndex] = converted;
return true;
}
use of dyvilx.tools.compiler.ast.expression.ArrayExpr in project Dyvil by Dyvil.
the class Intrinsics method readAnnotation.
public static IntrinsicData readAnnotation(IMethod method, Annotation annotation) {
final ArgumentList arguments = annotation.getArguments();
final IValue compilerCode = arguments.get(LazyFields.COMPILER_CODE);
if (compilerCode != null && compilerCode.valueTag() == IValue.INT) {
return new CompilerIntrinsic(compilerCode.intValue());
}
final IValue value = arguments.get(LazyFields.VALUE);
if (value == null || value.valueTag() != IValue.ARRAY) {
return null;
}
final ArrayExpr valueArray = (ArrayExpr) value;
final ArgumentList values = valueArray.getValues();
final int size = values.size();
int insnCount = 0;
int[] ints = new int[size];
for (int i = 0; i < size; i++) {
int opcode = values.get(i).intValue();
ints[i] = opcode;
insnCount++;
if (Opcodes.isFieldOrMethodOpcode(opcode)) {
ints[i + 1] = values.get(i + 1).intValue();
ints[i + 2] = values.get(i + 2).intValue();
ints[i + 3] = values.get(i + 3).intValue();
i += 3;
} else if (Opcodes.isJumpOpcode(opcode) || Opcodes.isLoadOpcode(opcode) || Opcodes.isStoreOpcode(opcode) || opcode == Opcodes.LDC || opcode == Opcodes.BIPUSH || opcode == Opcodes.SIPUSH) {
ints[i + 1] = values.get(i + 1).intValue();
i += 1;
}
}
if (size > insnCount) {
IValue stringValue = arguments.get(LazyFields.STRINGS);
ArrayExpr strings = (ArrayExpr) stringValue;
return readComplex(method, insnCount, ints, strings);
}
return new SimpleIntrinsicData(method, ints);
}
use of dyvilx.tools.compiler.ast.expression.ArrayExpr in project Dyvil by Dyvil.
the class EnumClassMetadata method createValuesArray.
private IValue createValuesArray() {
final ArrayExpr arrayExpr = new ArrayExpr();
arrayExpr.setElementType(this.theClass.getClassType());
final ClassBody body = this.theClass.getBody();
if (body != null) {
final ArgumentList values = arrayExpr.getValues();
for (IField enumConstant : body.enumConstants()) {
values.add(new FieldAccess(enumConstant));
}
}
return arrayExpr;
}
use of dyvilx.tools.compiler.ast.expression.ArrayExpr in project Dyvil by Dyvil.
the class AnnotationReader method visitArray.
@Override
public AnnotationVisitor visitArray(String key) {
ArrayExpr valueList = new ArrayExpr();
this.arguments.add(Name.fromRaw(key), valueList);
return new AnnotationValueReader(valueList.getValues());
}
use of dyvilx.tools.compiler.ast.expression.ArrayExpr 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