From b3afeeac8758be7ba17243d636b3467e545b73ab Mon Sep 17 00:00:00 2001 From: CensoredUsername Date: Tue, 30 Dec 2014 01:46:37 +0100 Subject: [PATCH 1/2] escape_string is called string_escape --- decompiler/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/decompiler/__init__.py b/decompiler/__init__.py index 79f4dc0c..9ed6de13 100644 --- a/decompiler/__init__.py +++ b/decompiler/__init__.py @@ -490,9 +490,9 @@ def print_translatestring(self, ast): self.indent_level += 1 self.indent() - self.write('old "%s"' % escape_string(ast.old)) + self.write('old "%s"' % string_escape(ast.old)) self.indent() - self.write('new "%s"' % escape_string(ast.new)) + self.write('new "%s"' % string_escape(ast.new)) self.indent_level -= 1 dispatch[renpy.ast.TranslateString] = print_translatestring From b71f86a0b6cd388a95ce3ddc3acf1acf3f0867a7 Mon Sep 17 00:00:00 2001 From: CensoredUsername Date: Tue, 30 Dec 2014 02:15:10 +0100 Subject: [PATCH 2/2] Fix #19, slast.SLBlock can contain keyword arguments for the statement containing the if statement it's in --- decompiler/sl2decompiler.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/decompiler/sl2decompiler.py b/decompiler/sl2decompiler.py index e630435d..c2fa4be9 100644 --- a/decompiler/sl2decompiler.py +++ b/decompiler/sl2decompiler.py @@ -121,11 +121,22 @@ def _print_if(self, ast, keyword): self.write("%s %s:" % (keyword(), condition)) # Every condition has a block of type slast.SLBlock - self.print_block(block, 1) + self.print_block(block) - def print_block(self, ast, extra_indent=0): - # A block just contains a list of children - self.print_nodes(ast.children, extra_indent) + def print_block(self, ast): + # A block contains possible keyword arguments and a list of child nodes + # this is the reason if doesn't keep a list of children but special Blocks + self.indent_level += 1 + + for key, value in ast.keyword: + if ' ' in value: + value = '(%s)' % value + + self.indent() + self.write("%s %s" % (key, value)) + + self.print_nodes(ast.children) + self.indent_level -= 1 dispatch[sl2.slast.SLBlock] = print_block def print_for(self, ast):