Search in sources :

Example 46 with Value

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

the class MethodCompiler method throw_.

private void throw_(ThrowStmt stmt) {
    Value obj = immediate(stmt, (Immediate) stmt.getOp());
    checkNull(stmt, obj);
    call(stmt, BC_THROW, env, obj);
    function.add(new Unreachable()).attach(stmt);
}
Also used : Unreachable(org.robovm.compiler.llvm.Unreachable) Value(org.robovm.compiler.llvm.Value)

Example 47 with Value

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

the class MethodCompiler method initializeClassFields.

private void initializeClassFields() {
    for (SootField field : sootMethod.getDeclaringClass().getFields()) {
        if (!field.isStatic()) {
            continue;
        }
        for (Tag tag : field.getTags()) {
            Value value = null;
            if (tag instanceof DoubleConstantValueTag) {
                DoubleConstantValueTag dtag = (DoubleConstantValueTag) tag;
                value = new FloatingPointConstant(dtag.getDoubleValue());
            } else if (tag instanceof FloatConstantValueTag) {
                FloatConstantValueTag ftag = (FloatConstantValueTag) tag;
                value = new FloatingPointConstant(ftag.getFloatValue());
            } else if (tag instanceof IntegerConstantValueTag) {
                IntegerConstantValueTag itag = (IntegerConstantValueTag) tag;
                value = new IntegerConstant(itag.getIntValue());
                IntegerType type = (IntegerType) getType(field.getType());
                if (type.getBits() < 32) {
                    value = new ConstantTrunc((Constant) value, type);
                }
            } else if (tag instanceof LongConstantValueTag) {
                LongConstantValueTag ltag = (LongConstantValueTag) tag;
                value = new IntegerConstant(ltag.getLongValue());
            } else if (tag instanceof StringConstantValueTag) {
                String s = ((StringConstantValueTag) tag).getStringValue();
                value = call(ldcString(s), env);
            }
            if (value != null) {
                FunctionRef fn = FunctionBuilder.setter(field).ref();
                call(fn, env, value);
            }
        }
    }
}
Also used : FloatingPointConstant(org.robovm.compiler.llvm.FloatingPointConstant) FloatingPointConstant(org.robovm.compiler.llvm.FloatingPointConstant) Constant(org.robovm.compiler.llvm.Constant) NullConstant(org.robovm.compiler.llvm.NullConstant) IntegerConstant(org.robovm.compiler.llvm.IntegerConstant) IntegerConstantValueTag(soot.tagkit.IntegerConstantValueTag) DoubleConstantValueTag(soot.tagkit.DoubleConstantValueTag) IntegerConstant(org.robovm.compiler.llvm.IntegerConstant) IntegerType(org.robovm.compiler.llvm.IntegerType) ConstantTrunc(org.robovm.compiler.llvm.ConstantTrunc) Value(org.robovm.compiler.llvm.Value) LongConstantValueTag(soot.tagkit.LongConstantValueTag) SootField(soot.SootField) ArrayCheckTag(soot.jimple.toolkits.annotation.tags.ArrayCheckTag) NullCheckTag(soot.jimple.toolkits.annotation.tags.NullCheckTag) FloatConstantValueTag(soot.tagkit.FloatConstantValueTag) IntegerConstantValueTag(soot.tagkit.IntegerConstantValueTag) Tag(soot.tagkit.Tag) DoubleConstantValueTag(soot.tagkit.DoubleConstantValueTag) LongConstantValueTag(soot.tagkit.LongConstantValueTag) StringConstantValueTag(soot.tagkit.StringConstantValueTag) StringConstantValueTag(soot.tagkit.StringConstantValueTag) FloatConstantValueTag(soot.tagkit.FloatConstantValueTag) FunctionRef(org.robovm.compiler.llvm.FunctionRef)

Example 48 with Value

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

Aggregations

Value (org.robovm.compiler.llvm.Value)48 Ret (org.robovm.compiler.llvm.Ret)26 IntegerConstant (org.robovm.compiler.llvm.IntegerConstant)24 Function (org.robovm.compiler.llvm.Function)22 Variable (org.robovm.compiler.llvm.Variable)18 FunctionRef (org.robovm.compiler.llvm.FunctionRef)16 Label (org.robovm.compiler.llvm.Label)10 Load (org.robovm.compiler.llvm.Load)10 ArrayList (java.util.ArrayList)9 PointerType (org.robovm.compiler.llvm.PointerType)9 Bitcast (org.robovm.compiler.llvm.Bitcast)8 FunctionType (org.robovm.compiler.llvm.FunctionType)8 NullConstant (org.robovm.compiler.llvm.NullConstant)8 ConstantBitcast (org.robovm.compiler.llvm.ConstantBitcast)7 StructureType (org.robovm.compiler.llvm.StructureType)7 Type (org.robovm.compiler.llvm.Type)7 VariableRef (org.robovm.compiler.llvm.VariableRef)7 Invokestatic (org.robovm.compiler.trampoline.Invokestatic)7 BasicBlockRef (org.robovm.compiler.llvm.BasicBlockRef)6 Br (org.robovm.compiler.llvm.Br)6