rocky / elisp-decompile

Emacs Lisp Decompiler
GNU General Public License v3.0
29 stars 4 forks source link

unsupported listp in LAP file throws off scanner #5

Open danmcmahill opened 4 years ago

danmcmahill commented 4 years ago

my LAP file has this little bit in in:

20      constant  defalias
21      constant  il-return-car-string
22      constant  <compiled-function>
      args: (element)
    0       varref    element
    1       listp
    2       goto-if-nil 1
    5       varref    element
    6       car
    7       return
    8:1     varref    element
    9       return

23      call      2
24      return

in particular, note the listp on 1. This triggers

https://github.com/rocky/elisp-decompile/blob/2b3937015af7b203b155e820082bd75078be63ad/lapdecompile/scanner.py#L130-L139

and we end up with

  File "/home/dan/src/elisp-decompile/lapdecompile/scanner.py", line 139, in fn_scanner_internal
    count = int(opname[-1])
ValueError: invalid literal for int() with base 10: 'p'

this seems to get past the listp bit but I still have other problems preventing decompiling my files

diff --git a/lapdecompile/scanner.py b/lapdecompile/scanner.py
index e8f25b6..32a772b 100644
--- a/lapdecompile/scanner.py
+++ b/lapdecompile/scanner.py
@@ -127,7 +127,7 @@ class LapScanner:
                     self.fn_scanner_internal(fn_name, fn_type="defun")
                     attr = self.fns[fn_name]
                 tokens.append(Token("CONSTANT", attr, offset.strip(), label=label))
-            elif opname[:-1] in ("list", "concat", "cal"):
+            elif opname[:-1] in ("list", "concat", "cal") and opname != "listp":
                 if opname.startswith("call"):
                     count = int(fields[2])
                     opname = "%s_%d" % (opname, count)