decomp: Cleanup all unknown-types that we've actually defined

This commit is contained in:
Tyler Wilding
2021-05-08 22:19:36 -04:00
parent 971e0e3e24
commit 7cbf6e6174
3 changed files with 31 additions and 483 deletions
+4 -1
View File
@@ -16,4 +16,7 @@ tasks:
decomp-clean:
cmds:
- rm ./decompiler_out/**/*.asm
- rm ./decompiler_out/**/*disasm.gc
- rm ./decompiler_out/**/*disasm.gc
cleanup-all-types:
cmds:
- python ./scripts/cleanup-all-types.py
File diff suppressed because it is too large Load Diff
+27
View File
@@ -0,0 +1,27 @@
# all-types.gc can easily drift
# initially it's populated with many types that are unknown (these are commented out)
# but when we manually replace them, it's easy to forget to delete the duplicate commented out variant.
#
# additionally, ideally we'd be organizing them as well but this can come later (dont want to manually move all the type defs!)
# (deftype) or (define-extern)
# if we find a deftype or define-extern that has a define-extern with ;; unknown type on the same line, delete it!
import os
new_file = []
with open("./decompiler/config/all-types.gc") as f:
symbols_found = []
lines = f.readlines()
for line in lines:
if line.startswith("(deftype") or line.startswith("(define-extern") or line.startswith(";;(define-extern"):
symbol = line.split(" ")[1]
if symbol in symbols_found and "unknown type" in line:
continue
else:
symbols_found.append(symbol)
new_file.append(line)
os.remove("./decompiler/config/all-types.gc")
with open("./decompiler/config/all-types.gc", "w") as f:
f.writelines(new_file)