mirror of
https://github.com/DMaroo/GhidRust.git
synced 2025-06-19 04:53:42 +02:00
Update the comment
This commit is contained in:
@ -1,18 +1,32 @@
|
|||||||
package ghidrust.decompiler.codegen.rust;
|
package ghidrust.decompiler.codegen.rust;
|
||||||
|
|
||||||
import ghidra.app.decompiler.ClangNode;
|
import ghidra.app.decompiler.ClangNode;
|
||||||
|
import ghidra.app.decompiler.ClangToken;
|
||||||
import ghidra.app.decompiler.ClangBreak;
|
import ghidra.app.decompiler.ClangBreak;
|
||||||
|
import ghidra.app.decompiler.ClangCommentToken;
|
||||||
|
import ghidra.app.decompiler.ClangFieldToken;
|
||||||
|
import ghidra.app.decompiler.ClangFuncNameToken;
|
||||||
|
import ghidra.app.decompiler.ClangLabelToken;
|
||||||
|
|
||||||
public class RustVisitor {
|
public class RustVisitor {
|
||||||
public String visit(ClangNode cn) {
|
public String visit(ClangNode cn) {
|
||||||
/* This part is very ugly, but we don't have open classes
|
/* This part is very ugly, but we don't have open classes so we can't
|
||||||
* do we can't define new virtual methods, hence the only
|
* define new virtual methods in the tokens, hence the only reasonable
|
||||||
* way to dispatch is to check the node's type dynamically
|
* way to dispatch is to check the node's type dynamically */
|
||||||
*/
|
|
||||||
|
|
||||||
if (cn instanceof ClangBreak) {
|
if (cn instanceof ClangToken) {
|
||||||
return "break;";
|
ClangToken ct = (ClangToken) cn;
|
||||||
} else {
|
if (cn instanceof ClangBreak) {
|
||||||
|
return ClangBreakVisitor((ClangBreak) ct);
|
||||||
|
} else if (cn instanceof ClangCommentToken) {
|
||||||
|
return ClangCommentTokenVisitor((ClangCommentToken) ct);
|
||||||
|
} else if (ct instanceof ClangLabelToken) {
|
||||||
|
return ClangLabelTokenVisitor((ClangLabelToken) ct);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return DummyVisitor(ct);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
/* Unimplemented */
|
/* Unimplemented */
|
||||||
StringBuilder sb = new StringBuilder("unimplemented {");
|
StringBuilder sb = new StringBuilder("unimplemented {");
|
||||||
for (int i = 0; i < cn.numChildren(); i++) {
|
for (int i = 0; i < cn.numChildren(); i++) {
|
||||||
@ -20,6 +34,22 @@ public class RustVisitor {
|
|||||||
}
|
}
|
||||||
sb.append(" }");
|
sb.append(" }");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String ClangLabelTokenVisitor(ClangLabelToken clt) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private String DummyVisitor(ClangToken cn) {
|
||||||
|
return cn.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String ClangBreakVisitor(ClangBreak cb) {
|
||||||
|
return "break;";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String ClangCommentTokenVisitor(ClangCommentToken cct) {
|
||||||
|
return "/* " + cct.getText() + " */";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user