Start using clang tokens for the Rust code generation

This commit is contained in:
Dhruv Maroo
2023-05-20 13:00:50 +08:00
parent a9592b2b93
commit 54611042f1
75 changed files with 58 additions and 13019 deletions

View File

@@ -0,0 +1,25 @@
package ghidrust.decompiler.codegen.rust;
import ghidra.app.decompiler.ClangNode;
import ghidra.app.decompiler.ClangBreak;
public class RustVisitor {
public String visit(ClangNode cn) {
/* This part is very ugly, but we don't have open classes
* do we can't define new virtual methods, hence the only
* way to dispatch is to check the node's type dynamically
*/
if (cn instanceof ClangBreak) {
return "break;";
} else {
/* Unimplemented */
StringBuilder sb = new StringBuilder("unimplemented {");
for (int i = 0; i < cn.numChildren(); i++) {
sb.append(visit(cn.Child(i)));
}
sb.append(" }");
return sb.toString();
}
}
}