From 4acddaff97ce6afb28086f4ce93afffceebd4f53 Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Thu, 15 Aug 2013 13:00:51 -0400 Subject: imachine.json --- LICENSE | 4 ++- unrpyc/Makefile | 2 +- unrpyc/decompiler.py | 19 +++++++++++-- www/css/index.css | 10 ++++++- www/index.html | 2 +- www/js/api.js | 9 ++++-- www/js/imachine.js | 80 ++++++++++++++++++++++++++++++++-------------------- 7 files changed, 86 insertions(+), 40 deletions(-) diff --git a/LICENSE b/LICENSE index c3bb2aa..c4c289d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,8 @@ -Copyright © 2013 Alex Xu (Hello71) +© 2013 Alex Xu (Hello71) All Rights Reserved I haven't decided on an open-source license; contact me [0] to discuss. +The unrpyc/ subdirectory is released under the license in unrpyc/LICENSE. + [0] mailto:alex.hello71@gmail.com diff --git a/unrpyc/Makefile b/unrpyc/Makefile index d30347f..9566bea 100644 --- a/unrpyc/Makefile +++ b/unrpyc/Makefile @@ -27,7 +27,7 @@ test: all jshint --show-non-errors *.json install: all - install -t ../www/scripts script.json script.json.gz + install -t ../www/scripts script.json script.json.gz imachine.json imachine.json.gz .PHONY: all clean test install .PRECIOUS: imachine.json.o diff --git a/unrpyc/decompiler.py b/unrpyc/decompiler.py index d25fa21..75aced6 100644 --- a/unrpyc/decompiler.py +++ b/unrpyc/decompiler.py @@ -282,6 +282,13 @@ class PrintRenPython(python_ast.NodeVisitor): self.f.write(', '.join(map(self.visit, node.keywords))) self.f.write('],\n') + def visit_Compare(self, node): + self.f.write('[') + self.f.write(self.visit(node.left)) + self.f.write(', ') + self.f.write(self.visit(node.comparators[0])) + self.f.write('], ') + def quote(self, string): return '"%s"' % string @@ -395,7 +402,10 @@ def print_Call(f, stmt, indent_level): f.write('],\n') def print_If(f, stmt, indent_level): - f.write('["if", "%s", [\n' % (escape_string(stmt.entries[0][0]), )) + f.write('["if", ') + if_stmt = compile(stmt.entries[0][0], '', 'exec', python_ast.PyCF_ONLY_AST).body[0] + PrintRenPython(f).visit(if_stmt) + f.write('[\n') for inner_stmt in stmt.entries[0][1]: print_statement(f, inner_stmt, indent_level + 1) @@ -409,7 +419,10 @@ def print_If(f, stmt, indent_level): for case in elif_entries: indent(f, indent_level) - f.write('], "elif", "%s", [\n' % escape_string(case[0])) + f.write('], "elif", ') + elif_stmt = compile(case[0], '', 'exec', python_ast.PyCF_ONLY_AST).body[0] + PrintRenPython(f).visit(if_stmt) + f.write('[\n') for inner_stmt in case[1]: print_statement(f, inner_stmt, indent_level + 1) @@ -433,7 +446,7 @@ def print_args(f, arginfo): f.write(', ') # if name is not None: # f.write("%s = " % json.dumps(name)) - f.write(json.dumps(val)) + f.write(json.dumps(eval(val))) # TODO positional? def print_params(f, paraminfo): diff --git a/www/css/index.css b/www/css/index.css index 8b59a6b..775bfc6 100644 --- a/www/css/index.css +++ b/www/css/index.css @@ -159,11 +159,15 @@ html.no-js #gotit { } #centered { text-align: center; - width: 100%; + top: 0; + bottom: 0; + left: 0; + height: 0; } .centered { position: absolute; margin: auto; + width: 100%; left: 50%; top: 50%; } @@ -173,7 +177,11 @@ html.no-js #gotit { right: 10px; display: none; } +#choices { + left: 0; +} .choice { + text-align: center; background: url("../dump/ui/bg-choice.png") no-repeat top center; height: 35px; line-height: 30px; diff --git a/www/index.html b/www/index.html index 595bcbb..4c4f7fb 100644 --- a/www/index.html +++ b/www/index.html @@ -53,7 +53,7 @@
-
+