Search in sources :

Example 1 with ArrayExpr

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());
}
Also used : ArrayExpr(dyvilx.tools.compiler.ast.expression.ArrayExpr)

Example 2 with ArrayExpr

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);
        }
    };
}
Also used : ArrayExpr(dyvilx.tools.compiler.ast.expression.ArrayExpr)

Example 3 with ArrayExpr

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);
}
Also used : MapExpr(dyvilx.tools.compiler.ast.expression.MapExpr) ArrayExpr(dyvilx.tools.compiler.ast.expression.ArrayExpr)

Example 4 with ArrayExpr

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
        }
    }
}
Also used : ElementType(java.lang.annotation.ElementType) ArrayExpr(dyvilx.tools.compiler.ast.expression.ArrayExpr) IValue(dyvilx.tools.compiler.ast.expression.IValue) INamed(dyvilx.tools.compiler.ast.member.INamed) ArgumentList(dyvilx.tools.compiler.ast.parameter.ArgumentList) Annotation(dyvilx.tools.compiler.ast.attribute.annotation.Annotation)

Example 5 with ArrayExpr

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;
}
Also used : ArrayExpr(dyvilx.tools.compiler.ast.expression.ArrayExpr) IValue(dyvilx.tools.compiler.ast.expression.IValue) IType(dyvilx.tools.compiler.ast.type.IType)

Aggregations

ArrayExpr (dyvilx.tools.compiler.ast.expression.ArrayExpr)12 IValue (dyvilx.tools.compiler.ast.expression.IValue)7 ArgumentList (dyvilx.tools.compiler.ast.parameter.ArgumentList)5 IType (dyvilx.tools.compiler.ast.type.IType)2 Reason (dyvil.annotation.Deprecated.Reason)1 Annotation (dyvilx.tools.compiler.ast.attribute.annotation.Annotation)1 ClassBody (dyvilx.tools.compiler.ast.classes.ClassBody)1 MapExpr (dyvilx.tools.compiler.ast.expression.MapExpr)1 EnumValue (dyvilx.tools.compiler.ast.expression.constant.EnumValue)1 IField (dyvilx.tools.compiler.ast.field.IField)1 INamed (dyvilx.tools.compiler.ast.member.INamed)1 Marker (dyvilx.tools.parsing.marker.Marker)1 ElementType (java.lang.annotation.ElementType)1