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;
}
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());
}
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);
}
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));
}
}
}
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));
}
}
}
Aggregations