use of soot.SootMethod in project robovm by robovm.
the class MarshalerLookupTest method testFindMarshalerStructMemberPrimitiveArray3D.
@Test
public void testFindMarshalerStructMemberPrimitiveArray3D() {
MarshalerLookup lookup = new MarshalerLookup(config).searchBuiltins(false);
SootMethod getter = toSootClass(TestStruct.class).getMethodByName("getV4");
SootMethod setter = toSootClass(TestStruct.class).getMethodByName("setV4");
assertEquals(toSootClass(M2.class).getMethodByName("byteArray3DToObject"), lookup.findMarshalerMethod(new MarshalSite(getter)).getMethod());
assertEquals(toSootClass(M2.class).getMethodByName("byteArray3DToNative"), lookup.findMarshalerMethod(new MarshalSite(setter, 0)).getMethod());
}
use of soot.SootMethod in project robovm by robovm.
the class MarshalerLookupTest method testFindMarshalerMethodInterfaceMatchPointer.
@Test
public void testFindMarshalerMethodInterfaceMatchPointer() {
MarshalerLookup lookup = new MarshalerLookup(config).searchBuiltins(false);
SootMethod method = toSootClass(Foo4.class).getMethodByName("foo3");
assertEquals(toSootClass(M2.class).getMethodByName("charSequenceToObject"), lookup.findMarshalerMethod(new MarshalSite(method)).getMethod());
assertEquals(toSootClass(M2.class).getMethodByName("charSequenceToNative"), lookup.findMarshalerMethod(new MarshalSite(method, 0)).getMethod());
}
use of soot.SootMethod in project robovm by robovm.
the class MarshalerLookupTest method testFindMarshalerStructMemberPrimitiveArray2D.
@Test
public void testFindMarshalerStructMemberPrimitiveArray2D() {
MarshalerLookup lookup = new MarshalerLookup(config).searchBuiltins(false);
SootMethod getter = toSootClass(TestStruct.class).getMethodByName("getV3");
SootMethod setter = toSootClass(TestStruct.class).getMethodByName("setV3");
assertEquals(toSootClass(M2.class).getMethodByName("byteArray2DToObject"), lookup.findMarshalerMethod(new MarshalSite(getter)).getMethod());
assertEquals(toSootClass(M2.class).getMethodByName("byteArray2DToNative"), lookup.findMarshalerMethod(new MarshalSite(setter, 0)).getMethod());
}
use of soot.SootMethod in project robovm by robovm.
the class ClassCompiler method getOverriddenMethods.
private Map<SootMethod, Set<SootMethod>> getOverriddenMethods(SootClass sc) {
Map<SootMethod, Set<SootMethod>> result = new HashMap<>();
for (SootMethod m : sc.getMethods()) {
if (!m.isStatic() && !m.isPrivate() && !m.getName().equals("<init>")) {
result.put(m, new HashSet<SootMethod>());
}
}
findOverriddenSuperMethods(sc, sc, result);
return result;
}
use of soot.SootMethod in project robovm by robovm.
the class ClassCompiler method patchAsmWithFunctionSizes.
private static void patchAsmWithFunctionSizes(Config config, Clazz clazz, InputStream inStream, OutputStream outStream) throws IOException {
String labelPrefix = config.getOs().getFamily() == OS.Family.darwin ? "_" : "";
String localLabelPrefix = config.getOs().getFamily() == OS.Family.darwin ? "L" : ".L";
Set<String> functionNames = new HashSet<String>();
for (SootMethod method : clazz.getSootClass().getMethods()) {
if (!method.isAbstract()) {
String name = labelPrefix + Symbols.methodSymbol(method);
functionNames.add(name);
}
}
String infoStructLabel = labelPrefix + Symbols.infoStructSymbol(clazz.getInternalName());
Pattern methodImplPattern = Pattern.compile("\\s*\\.(?:quad|long)\\s+\"?(" + Pattern.quote(labelPrefix + Symbols.methodSymbolPrefix(clazz.getInternalName())) + "[^\\s\"]+)\"?.*");
BufferedReader in = null;
BufferedWriter out = null;
try {
in = new BufferedReader(new InputStreamReader(inStream, "UTF-8"));
out = new BufferedWriter(new OutputStreamWriter(outStream, "UTF-8"));
String line = null;
String currentFunction = null;
while ((line = in.readLine()) != null) {
if (currentFunction == null) {
out.write(line);
out.write('\n');
int colon = line.indexOf(':');
if (colon != -1) {
String label = line.substring(0, colon);
if (label.startsWith("\"") && label.endsWith("\"")) {
label = label.substring(1, label.length() - 1);
}
if (functionNames.contains(label)) {
currentFunction = label;
} else if (label.equals(infoStructLabel)) {
break;
}
}
} else if (line.trim().equals(".cfi_endproc") || line.trim().startsWith(".section") || line.trim().startsWith(".globl")) {
out.write("\"");
out.write(localLabelPrefix);
out.write(currentFunction);
out.write("_end\":\n\n");
currentFunction = null;
out.write(line);
out.write('\n');
} else {
out.write(line);
out.write('\n');
}
}
while ((line = in.readLine()) != null) {
out.write(line);
out.write('\n');
Matcher matcher = methodImplPattern.matcher(line);
if (matcher.matches()) {
String functionName = matcher.group(1);
if (functionNames.contains(functionName)) {
line = in.readLine();
if (line.contains(String.valueOf(DUMMY_METHOD_SIZE))) {
out.write("\t.long\t");
out.write("\"" + localLabelPrefix + functionName + "_end\" - \"" + functionName + "\"");
out.write('\n');
} else {
out.write(line);
out.write('\n');
}
}
}
}
} finally {
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(out);
}
}
Aggregations