Search in sources :

Example 31 with IntegerConstant

use of org.robovm.compiler.llvm.IntegerConstant in project robovm by robovm.

the class Linker method createCheckcast.

private Function createCheckcast(ModuleBuilder mb, Clazz clazz, TypeInfo typeInfo) {
    Function fn = FunctionBuilder.checkcast(clazz);
    Value info = getInfoStruct(mb, fn, clazz);
    if (typeInfo.error) {
        // This will trigger an exception
        call(fn, BC_LDC_CLASS, fn.getParameterRef(0), info);
        fn.add(new Ret(new NullConstant(Types.OBJECT_PTR)));
    } else if (!clazz.getClazzInfo().isInterface()) {
        Value result = call(fn, CHECKCAST_CLASS, fn.getParameterRef(0), info, fn.getParameterRef(1), new IntegerConstant((typeInfo.classTypes.length - 1) * 4 + 5 * 4), new IntegerConstant(typeInfo.id));
        fn.add(new Ret(result));
    } else {
        Value result = call(fn, CHECKCAST_INTERFACE, fn.getParameterRef(0), info, fn.getParameterRef(1), new IntegerConstant(typeInfo.id));
        fn.add(new Ret(result));
    }
    return fn;
}
Also used : Ret(org.robovm.compiler.llvm.Ret) ModifiedUtf8HashFunction(org.robovm.compiler.hash.ModifiedUtf8HashFunction) Function(org.robovm.compiler.llvm.Function) Value(org.robovm.compiler.llvm.Value) NullConstant(org.robovm.compiler.llvm.NullConstant) IntegerConstant(org.robovm.compiler.llvm.IntegerConstant)

Example 32 with IntegerConstant

use of org.robovm.compiler.llvm.IntegerConstant 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)

Example 33 with IntegerConstant

use of org.robovm.compiler.llvm.IntegerConstant in project robovm by robovm.

the class AttributesEncoder method encodeAnnotationTagValue.

private PackedStructureConstant encodeAnnotationTagValue(AnnotationTag tag) {
    Value[] values = new Value[tag.getNumElems() * 2 + 2];
    values[0] = getString(tag.getType());
    addDependencyIfNeeded(tag.getType());
    values[1] = new IntegerConstant(tag.getNumElems());
    for (int i = 0; i < tag.getNumElems(); i++) {
        values[i * 2 + 2] = getString(tag.getElemAt(i).getName());
        values[i * 2 + 2 + 1] = encodeAnnotationElementValue(tag.getElemAt(i));
    }
    return new PackedStructureConstant(getAnnotationTagType(tag), values);
}
Also used : Value(org.robovm.compiler.llvm.Value) IntegerConstant(org.robovm.compiler.llvm.IntegerConstant) PackedStructureConstant(org.robovm.compiler.llvm.PackedStructureConstant)

Example 34 with IntegerConstant

use of org.robovm.compiler.llvm.IntegerConstant in project robovm by robovm.

the class BridgeMethodCompiler method updateObject.

private void updateObject(SootMethod method, Function fn, Value env, long flags, List<MarshaledArg> marshaledArgs) {
    for (MarshaledArg value : marshaledArgs) {
        MarshalerMethod marshalerMethod = config.getMarshalerLookup().findMarshalerMethod(new MarshalSite(method, value.paramIndex));
        SootMethod afterMethod = ((PointerMarshalerMethod) marshalerMethod).getAfterBridgeCallMethod();
        if (afterMethod != null) {
            Invokestatic invokestatic = new Invokestatic(getInternalName(method.getDeclaringClass()), getInternalName(afterMethod.getDeclaringClass()), afterMethod.getName(), getDescriptor(afterMethod));
            trampolines.add(invokestatic);
            call(fn, invokestatic.getFunctionRef(), env, value.object, value.handle, new IntegerConstant(flags));
        }
    }
}
Also used : MarshalSite(org.robovm.compiler.MarshalerLookup.MarshalSite) Invokestatic(org.robovm.compiler.trampoline.Invokestatic) PointerMarshalerMethod(org.robovm.compiler.MarshalerLookup.PointerMarshalerMethod) SootMethod(soot.SootMethod) MarshalerMethod(org.robovm.compiler.MarshalerLookup.MarshalerMethod) PointerMarshalerMethod(org.robovm.compiler.MarshalerLookup.PointerMarshalerMethod) IntegerConstant(org.robovm.compiler.llvm.IntegerConstant)

Example 35 with IntegerConstant

use of org.robovm.compiler.llvm.IntegerConstant in project robovm by robovm.

the class CallbackMethodCompiler method updateNative.

private void updateNative(SootMethod method, Function fn, Value env, long flags, List<MarshaledArg> marshaledArgs) {
    for (MarshaledArg value : marshaledArgs) {
        MarshalerMethod marshalerMethod = config.getMarshalerLookup().findMarshalerMethod(new MarshalSite(method, value.paramIndex));
        SootMethod afterMethod = ((PointerMarshalerMethod) marshalerMethod).getAfterCallbackCallMethod();
        if (afterMethod != null) {
            Invokestatic invokestatic = new Invokestatic(getInternalName(method.getDeclaringClass()), getInternalName(afterMethod.getDeclaringClass()), afterMethod.getName(), getDescriptor(afterMethod));
            trampolines.add(invokestatic);
            call(fn, invokestatic.getFunctionRef(), env, value.handle, value.object, new IntegerConstant(flags));
        }
    }
}
Also used : MarshalSite(org.robovm.compiler.MarshalerLookup.MarshalSite) Invokestatic(org.robovm.compiler.trampoline.Invokestatic) PointerMarshalerMethod(org.robovm.compiler.MarshalerLookup.PointerMarshalerMethod) SootMethod(soot.SootMethod) MarshalerMethod(org.robovm.compiler.MarshalerLookup.MarshalerMethod) PointerMarshalerMethod(org.robovm.compiler.MarshalerLookup.PointerMarshalerMethod) IntegerConstant(org.robovm.compiler.llvm.IntegerConstant)

Aggregations

IntegerConstant (org.robovm.compiler.llvm.IntegerConstant)39 Value (org.robovm.compiler.llvm.Value)24 Variable (org.robovm.compiler.llvm.Variable)14 NullConstant (org.robovm.compiler.llvm.NullConstant)11 ConstantBitcast (org.robovm.compiler.llvm.ConstantBitcast)10 FunctionRef (org.robovm.compiler.llvm.FunctionRef)10 ArrayList (java.util.ArrayList)9 Function (org.robovm.compiler.llvm.Function)9 Ret (org.robovm.compiler.llvm.Ret)9 Constant (org.robovm.compiler.llvm.Constant)8 FunctionType (org.robovm.compiler.llvm.FunctionType)8 Global (org.robovm.compiler.llvm.Global)8 PointerType (org.robovm.compiler.llvm.PointerType)8 StructureConstant (org.robovm.compiler.llvm.StructureConstant)8 StructureConstantBuilder (org.robovm.compiler.llvm.StructureConstantBuilder)8 Invokestatic (org.robovm.compiler.trampoline.Invokestatic)8 Bitcast (org.robovm.compiler.llvm.Bitcast)6 Label (org.robovm.compiler.llvm.Label)6 Load (org.robovm.compiler.llvm.Load)6 Type (org.robovm.compiler.llvm.Type)6