use of dyvilx.tools.compiler.ast.expression.ArrayExpr in project Dyvil by Dyvil.
the class ValueAnnotationVisitor method visitArray.
@Override
public AnnotationVisitor visitArray(String key) {
final ArrayExpr valueList = new ArrayExpr();
this.consumer.setValue(valueList);
return new AnnotationValueReader(valueList.getValues());
}
use of dyvilx.tools.compiler.ast.expression.ArrayExpr in project Dyvil by Dyvil.
the class AnnotationValueReader method visitArray.
@Override
public AnnotationVisitor visitArray(String key) {
final ArrayExpr valueList = new ArrayExpr();
return new AnnotationValueReader(valueList.getValues()) {
@Override
public void visitEnd() {
valueList.getType();
this.consumer.setValue(valueList);
}
};
}
use of dyvilx.tools.compiler.ast.expression.ArrayExpr in project Dyvil by Dyvil.
the class ArrayLiteralParser method end.
private void end(IToken token) {
if (this.values != null) {
final MapExpr map = new MapExpr(this.startPosition.to(token), this.keys, this.values);
this.consumer.setValue(map);
return;
}
final ArrayExpr array = new ArrayExpr(this.startPosition.to(token), this.keys);
this.consumer.setValue(array);
}
use of dyvilx.tools.compiler.ast.expression.ArrayExpr in project Dyvil by Dyvil.
the class AnnotationMetadata method readTargets.
private void readTargets() {
final Annotation target = this.theClass.getAnnotation(Annotation.LazyFields.TARGET_CLASS);
if (target == null) {
return;
}
this.targets = EnumSet.noneOf(ElementType.class);
final IValue argument = target.getArguments().get(0, Names.value);
if (!(argument instanceof ArrayExpr)) {
return;
}
final ArgumentList values = ((ArrayExpr) argument).getValues();
final int size = values.size();
for (int i = 0; i < size; i++) {
final INamed value = (INamed) values.get(i);
try {
this.targets.add(ElementType.valueOf(value.getName().qualified));
} catch (IllegalArgumentException ignored) {
// Problematic Target annotation - do not handle this
}
}
}
use of dyvilx.tools.compiler.ast.expression.ArrayExpr in project Dyvil by Dyvil.
the class ArgumentList method checkVarargsMatch.
protected static //
int checkVarargsMatch(//
int[] matchValues, //
IType[] matchTypes, //
int matchStartIndex, //
IValue[] values, //
int startIndex, //
int endIndex, IParameter param, IImplicitContext implicitContext) {
final IValue argument = values[startIndex];
final IType paramType = param.getCovariantType();
final int matchIndex = matchStartIndex + startIndex;
if (argument.checkVarargs(false)) {
return checkMatch_(matchValues, matchTypes, matchIndex, argument, paramType, implicitContext) ? 0 : MISMATCH;
}
if (startIndex == endIndex) {
return 0;
}
final int count = endIndex - startIndex;
final ArrayExpr arrayExpr = newArrayExpr(values, startIndex, count);
if (!checkMatch_(matchValues, matchTypes, matchIndex, arrayExpr, paramType, implicitContext)) {
return MISMATCH;
}
// We fill the remaining entries that are reserved for the (now wrapped) varargs values with the match value
// of the array expression and the element type
final int value = matchValues[matchIndex];
final IType type = arrayExpr.getElementType();
for (int i = 0; i < count; i++) {
matchValues[matchIndex + i] = value;
matchTypes[matchIndex + i] = type;
}
return count;
}
Aggregations