Search in sources :

Example 1 with AnnotationDoubleElem

use of soot.tagkit.AnnotationDoubleElem in project robovm by robovm.

the class AttributesEncoder method encodeAnnotationElementValue.

private PackedStructureConstant encodeAnnotationElementValue(AnnotationElem ae) {
    PackedStructureType type = getAnnotationElementType(ae);
    Value kind = new IntegerConstant((byte) ae.getKind());
    if (ae instanceof AnnotationIntElem) {
        AnnotationIntElem aie = (AnnotationIntElem) ae;
        return new PackedStructureConstant(type, kind, new IntegerConstant(aie.getValue()));
    } else if (ae instanceof AnnotationLongElem) {
        AnnotationLongElem ale = (AnnotationLongElem) ae;
        return new PackedStructureConstant(type, kind, new IntegerConstant(ale.getValue()));
    } else if (ae instanceof AnnotationFloatElem) {
        AnnotationFloatElem afe = (AnnotationFloatElem) ae;
        return new PackedStructureConstant(type, kind, new FloatingPointConstant(afe.getValue()));
    } else if (ae instanceof AnnotationDoubleElem) {
        AnnotationDoubleElem ade = (AnnotationDoubleElem) ae;
        return new PackedStructureConstant(type, kind, new FloatingPointConstant(ade.getValue()));
    } else if (ae instanceof AnnotationStringElem) {
        AnnotationStringElem ase = (AnnotationStringElem) ae;
        return new PackedStructureConstant(type, kind, getStringOrNull(ase.getValue()));
    } else if (ae instanceof AnnotationClassElem) {
        AnnotationClassElem ace = (AnnotationClassElem) ae;
        addDependencyIfNeeded(ace.getDesc());
        return new PackedStructureConstant(type, kind, getStringOrNull(ace.getDesc()));
    } else if (ae instanceof AnnotationEnumElem) {
        AnnotationEnumElem aee = (AnnotationEnumElem) ae;
        addDependencyIfNeeded(aee.getTypeName());
        return new PackedStructureConstant(type, kind, getStringOrNull(aee.getTypeName()), getStringOrNull(aee.getConstantName()));
    } else if (ae instanceof AnnotationArrayElem) {
        AnnotationArrayElem aae = (AnnotationArrayElem) ae;
        Value[] values = new Value[aae.getNumValues() + 2];
        values[0] = kind;
        values[1] = new IntegerConstant((char) aae.getNumValues());
        for (int i = 0; i < aae.getNumValues(); i++) {
            values[i + 2] = encodeAnnotationElementValue(aae.getValueAt(i));
        }
        return new PackedStructureConstant(type, values);
    } else if (ae instanceof AnnotationAnnotationElem) {
        AnnotationAnnotationElem aae = (AnnotationAnnotationElem) ae;
        return new PackedStructureConstant(type, kind, encodeAnnotationTagValue(aae.getValue()));
    }
    throw new IllegalArgumentException("Unknown AnnotationElem type: " + ae.getClass());
}
Also used : AnnotationStringElem(soot.tagkit.AnnotationStringElem) AnnotationAnnotationElem(soot.tagkit.AnnotationAnnotationElem) FloatingPointConstant(org.robovm.compiler.llvm.FloatingPointConstant) AnnotationLongElem(soot.tagkit.AnnotationLongElem) AnnotationArrayElem(soot.tagkit.AnnotationArrayElem) PackedStructureType(org.robovm.compiler.llvm.PackedStructureType) IntegerConstant(org.robovm.compiler.llvm.IntegerConstant) PackedStructureConstant(org.robovm.compiler.llvm.PackedStructureConstant) AnnotationEnumElem(soot.tagkit.AnnotationEnumElem) AnnotationDoubleElem(soot.tagkit.AnnotationDoubleElem) AnnotationIntElem(soot.tagkit.AnnotationIntElem) AnnotationFloatElem(soot.tagkit.AnnotationFloatElem) AnnotationClassElem(soot.tagkit.AnnotationClassElem) Value(org.robovm.compiler.llvm.Value)

Aggregations

FloatingPointConstant (org.robovm.compiler.llvm.FloatingPointConstant)1 IntegerConstant (org.robovm.compiler.llvm.IntegerConstant)1 PackedStructureConstant (org.robovm.compiler.llvm.PackedStructureConstant)1 PackedStructureType (org.robovm.compiler.llvm.PackedStructureType)1 Value (org.robovm.compiler.llvm.Value)1 AnnotationAnnotationElem (soot.tagkit.AnnotationAnnotationElem)1 AnnotationArrayElem (soot.tagkit.AnnotationArrayElem)1 AnnotationClassElem (soot.tagkit.AnnotationClassElem)1 AnnotationDoubleElem (soot.tagkit.AnnotationDoubleElem)1 AnnotationEnumElem (soot.tagkit.AnnotationEnumElem)1 AnnotationFloatElem (soot.tagkit.AnnotationFloatElem)1 AnnotationIntElem (soot.tagkit.AnnotationIntElem)1 AnnotationLongElem (soot.tagkit.AnnotationLongElem)1 AnnotationStringElem (soot.tagkit.AnnotationStringElem)1