use of org.robovm.compiler.llvm.FunctionDeclaration in project robovm by robovm.
the class ITable method getStruct.
public StructureConstant getStruct(ModuleBuilder mb, SootClass clazz) {
if (clazz.isInterface()) {
throw new IllegalArgumentException("Expected a class got an interface: " + clazz.getName());
}
ArrayConstantBuilder table = new ArrayConstantBuilder(I8_PTR);
for (Entry entry : entries) {
ResolvedEntry resolvedEntry = entry.resolve(clazz);
if (resolvedEntry == null) {
FunctionRef defaultFunctionRef = entry.getFunctionRef();
if (defaultFunctionRef != null) {
if (!mb.hasSymbol(defaultFunctionRef.getName())) {
mb.addFunctionDeclaration(new FunctionDeclaration(defaultFunctionRef));
}
table.add(new ConstantBitcast(defaultFunctionRef, I8_PTR));
} else {
table.add(new ConstantBitcast(BC_ABSTRACT_METHOD_CALLED, I8_PTR));
}
} else if (Modifier.isAbstract(resolvedEntry.getModifiers())) {
table.add(new ConstantBitcast(BC_ABSTRACT_METHOD_CALLED, I8_PTR));
} else if (!Modifier.isPublic(resolvedEntry.getModifiers())) {
table.add(new ConstantBitcast(BC_NON_PUBLIC_METHOD_CALLED, I8_PTR));
} else {
/*
* Found a non-abstract method implementation. Either on the
* class, in one of its super classes or a default method in an
* implemented interface.
*/
FunctionRef functionRef = resolvedEntry.getFunctionRef();
if (!resolvedEntry.declaringClass.equals(clazz.getName())) {
if (!mb.hasSymbol(functionRef.getName())) {
mb.addFunctionDeclaration(new FunctionDeclaration(functionRef));
}
}
table.add(new ConstantBitcast(functionRef, I8_PTR));
}
}
return new StructureConstantBuilder().add(new IntegerConstant((short) entries.length)).add(table.build()).build();
}
use of org.robovm.compiler.llvm.FunctionDeclaration in project robovm by robovm.
the class TrampolineCompiler method alias.
private void alias(Trampoline t, String fnName) {
FunctionRef aliasee = new FunctionRef(fnName, t.getFunctionType());
if (!mb.hasSymbol(fnName)) {
mb.addFunctionDeclaration(new FunctionDeclaration(aliasee));
}
Function fn = new FunctionBuilder(t).linkage(aliasLinkage()).attribs(shouldInline(), optsize).build();
Value result = call(fn, aliasee, fn.getParameterRefs());
fn.add(new Ret(result));
mb.addFunction(fn);
}
Aggregations