mirror of
https://github.com/DMaroo/GhidRust.git
synced 2025-09-10 04:53:36 +02:00
Add decompilation support for function arguments
This commit is contained in:
@@ -4,6 +4,6 @@ import ghidrust.decompiler.parser.c.gen.CParser;
|
||||
|
||||
public class Run {
|
||||
public static void main(String[] args) {
|
||||
System.out.println(CParser.transpile("/* hello::return_0 */\n\n undefined8 hello::return_0(void)\n\n {\n return 0;\n }"));
|
||||
System.out.println(CParser.transpile("int main(int a, int b) { return 0; }"));
|
||||
}
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ public class CVisitor implements CParserVisitor {
|
||||
String ret = (String) child.jjtAccept(this, data);
|
||||
if (ret != null) {
|
||||
sb.append(ret);
|
||||
if (!ret.equals("")) {
|
||||
if (!ret.equals("") && i != child_count - 1) {
|
||||
sb.append(" ");
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ public class CVisitor implements CParserVisitor {
|
||||
String[] ret = new String[2];
|
||||
ret[0] = (String) node.jjtGetChild(0).jjtAccept(this, data);
|
||||
if (node.jjtGetNumChildren() == 1) {
|
||||
ret[1] = "0";
|
||||
ret[1] = null;
|
||||
} else {
|
||||
ret[1] = (String) node.jjtGetChild(1).jjtAccept(this, data);
|
||||
}
|
||||
@@ -195,12 +195,23 @@ public class CVisitor implements CParserVisitor {
|
||||
}
|
||||
|
||||
public Object visit(ASTParameterList node, Object data) {
|
||||
return defaultVisit(node, data);
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
|
||||
if (i != 0) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(node.jjtGetChild(i).jjtAccept(this, data));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public Object visit(ASTParameterDeclaration node, Object data) {
|
||||
StringBuilder param = new StringBuilder((String) defaultSpacedVisit(node, data));
|
||||
return param.toString();
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
sb.append(node.jjtGetChild(1).jjtAccept(this, data));
|
||||
sb.append(": ");
|
||||
sb.append(node.jjtGetChild(0).jjtAccept(this, data));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public Object visit(ASTIdentifierList node, Object data) {
|
||||
|
Reference in New Issue
Block a user