Skip to content

Instantly share code, notes, and snippets.

@TerrorJack
Created November 12, 2020 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TerrorJack/6f420c532f50b70f7287dd6107ec0a7e to your computer and use it in GitHub Desktop.
Save TerrorJack/6f420c532f50b70f7287dd6107ec0a7e to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import ast
import subprocess
import sys
if __name__ == "__main__":
r = subprocess.run(["wasm2wat", "--enable-all", sys.argv[2]],
capture_output=True,
check=True,
text=True).stdout
for l in r.splitlines():
toks = [tok.strip("($)") for tok in l.split()]
if toks[0] == "data":
print("{0} D - {1:x}".format(toks[1],
len(ast.literal_eval(toks[4]))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment