diff options
-rw-r--r-- | unrpyc/Makefile | 9 | ||||
-rw-r--r-- | unrpyc/decompiler.py | 15 |
2 files changed, 15 insertions, 9 deletions
diff --git a/unrpyc/Makefile b/unrpyc/Makefile index 77a0838..d30347f 100644 --- a/unrpyc/Makefile +++ b/unrpyc/Makefile @@ -2,9 +2,9 @@ all: script.json.gz imachine.json.gz imachine.json.gz: imachine.json -script.json.gz: script.json - gzip -9c script.json > script.json.gz - touch script.json script.json.gz +%.json.gz: %.json + gzip -9c $< > $@ + touch $< $@ script.json: $(patsubst %.rpyc,%.json,$(wildcard *.rpyc)) cat script-*.json > script.json @@ -13,6 +13,9 @@ script.json: $(patsubst %.rpyc,%.json,$(wildcard *.rpyc)) %.json.o: %.rpyc *.py python unrpyc.py --clobber $< $@ +imachine.json: imachine.json.o + node fix.js $< $@ + %.json: %.json.o node fix.js $< $@ sed -i -e 's/^{//;s/}$$/,/' $@ diff --git a/unrpyc/decompiler.py b/unrpyc/decompiler.py index c66e280..06e758c 100644 --- a/unrpyc/decompiler.py +++ b/unrpyc/decompiler.py @@ -22,6 +22,7 @@ import ast as python_ast import renpy.ast as ast import renpy.atl as atl import code +import json DECOMPILE_SCREENS = False global firstLabel @@ -394,7 +395,7 @@ def print_Call(f, stmt, indent_level): f.write('],\n') def print_If(f, stmt, indent_level): - f.write("if %s:\n" % (stmt.entries[0][0], )) + f.write('["if", "%s", [\n' % (escape_string(stmt.entries[0][0]), )) for inner_stmt in stmt.entries[0][1]: print_statement(f, inner_stmt, indent_level + 1) @@ -408,16 +409,18 @@ def print_If(f, stmt, indent_level): for case in elif_entries: indent(f, indent_level) - f.write("elif %s:\n" % (case[0], )) + f.write('], "elif", "%s", [\n' % escape_string(case[0])) for inner_stmt in case[1]: print_statement(f, inner_stmt, indent_level + 1) if else_entry is not None: indent(f, indent_level) - f.write("else:\n") + f.write('], "else", [\n') for inner_stmt in else_entry[1]: print_statement(f, inner_stmt, indent_level + 1) + f.write(']],\n') + def print_EarlyPython(f, stmt, indent_level): print_Python(f, stmt, indent_level, early=True) @@ -428,9 +431,9 @@ def print_args(f, arginfo): for (name, val) in arginfo.arguments: f.write(', ') - if name is not None: - f.write("%s = " % (name, )) - f.write(val) +# if name is not None: +# f.write("%s = " % json.dumps(name)) + f.write(json.dumps(val)) # TODO positional? def print_params(f, paraminfo): |