use of org.robovm.compiler.llvm.FunctionType in project robovm by robovm.
the class Functions method call.
public static Value call(Function currentFunction, Value fn, Value... args) {
Variable result = null;
Type returnType = ((FunctionType) fn.getType()).getReturnType();
if (returnType != VOID) {
result = currentFunction.newVariable(returnType);
}
currentFunction.add(new Call(result, fn, args));
return result == null ? null : result.ref();
}
use of org.robovm.compiler.llvm.FunctionType in project robovm by robovm.
the class Functions method tailcall.
public static Value tailcall(Function currentFunction, Value fn, Value... args) {
Variable result = null;
Type returnType = ((FunctionType) fn.getType()).getReturnType();
if (returnType != VOID) {
result = currentFunction.newVariable(returnType);
}
currentFunction.add(new TailCall(result, fn, args));
return result == null ? null : result.ref();
}
use of org.robovm.compiler.llvm.FunctionType in project robovm by robovm.
the class BridgeMethodCompilerTest method testCreateBridgeCWrapperComplexNestedStructByValParameter.
@Test
public void testCreateBridgeCWrapperComplexNestedStructByValParameter() {
FunctionType functionType = new FunctionType(VOID, new StructureType(new StructureType(I8, I16), new StructureType(I32, I64), new StructureType(FLOAT, DOUBLE), new StructureType(I8_PTR, new PointerType(new StructureType(I32)))));
assertEquals("void f(void* target, void* p0) {\n" + " struct f_0001_0003 {void* m0;void* m1;};\n" + " struct f_0001_0002 {float m0;double m1;};\n" + " struct f_0001_0001 {int m0;long long m1;};\n" + " struct f_0001_0000 {char m0;short m1;};\n" + " struct f_0001 {struct f_0001_0000 m0;struct f_0001_0001 m1;struct f_0001_0002 m2;struct f_0001_0003 m3;};\n" + " ((void (*)(struct f_0001)) target)(*((struct f_0001*)p0));\n" + "}\n", BridgeMethodCompiler.createBridgeCWrapper(functionType.getReturnType(), functionType.getParameterTypes(), functionType.getParameterTypes(), "f"));
}
use of org.robovm.compiler.llvm.FunctionType in project robovm by robovm.
the class BridgeMethodCompilerTest method testCreateBridgeCWrapperNestedStructByValParameter.
@Test
public void testCreateBridgeCWrapperNestedStructByValParameter() {
FunctionType functionType = new FunctionType(VOID, new StructureType(new StructureType(I32), new StructureType(I32)));
assertEquals("void f(void* target, void* p0) {\n" + " struct f_0001_0001 {int m0;};\n" + " struct f_0001_0000 {int m0;};\n" + " struct f_0001 {struct f_0001_0000 m0;struct f_0001_0001 m1;};\n" + " ((void (*)(struct f_0001)) target)(*((struct f_0001*)p0));\n" + "}\n", BridgeMethodCompiler.createBridgeCWrapper(functionType.getReturnType(), functionType.getParameterTypes(), functionType.getParameterTypes(), "f"));
}
use of org.robovm.compiler.llvm.FunctionType in project robovm by robovm.
the class BridgeMethodCompilerTest method testCreateBridgeCWrapperSmallStructByValParameter.
@Test
public void testCreateBridgeCWrapperSmallStructByValParameter() {
FunctionType functionType = new FunctionType(VOID, new StructureType(I32));
assertEquals("void f(void* target, void* p0) {\n" + " struct f_0001 {int m0;};\n" + " ((void (*)(struct f_0001)) target)(*((struct f_0001*)p0));\n" + "}\n", BridgeMethodCompiler.createBridgeCWrapper(functionType.getReturnType(), functionType.getParameterTypes(), functionType.getParameterTypes(), "f"));
}
Aggregations