Commits

Andrew Godwin committed eaf4070

Move return out.

  • Participants
  • Parent commits 554ec74

Comments (0)

Files changed (2)

kugelblitz/translator/__init__.py

 from kugelblitz.translator.expressions import ExprTranslator, BinOpTranslator, BoolOpTranslator, UnaryOpTranslator, CompareTranslator
 from kugelblitz.translator.values import NumTranslator, ListTranslator, NameTranslator
 from kugelblitz.translator.assignment import AssignTranslator, AugAssignTranslator
-from kugelblitz.translator.control import IfTranslator, IfExprTranslator, RaiseTranslator
+from kugelblitz.translator.control import IfTranslator, IfExprTranslator, RaiseTranslator, ReturnTranslator
 
 def wrap_old_translator(func):
     class WrappedTranslator(BaseTranslator):
             # stmt
             ast.FunctionDef: FunctionTranslator,
             ast.ClassDef: wrap_old_translator(translate_class),
-            ast.Return: wrap_old_translator(translate_return),
+            ast.Return: ReturnTranslator,
             
             ast.Delete: wrap_old_translator(translate_delete),
             ast.Assign: AssignTranslator,
         'method_defs': ",\n".join(body),
     }
 
-def translate_return(node):
-    return "return %s" % translate(node.value)
-
 def translate_delete(node):
     return ';\n'.join('delete %s' % translate(n) for n in node.targets)
 

kugelblitz/translator/control.py

         }
 
 class RaiseTranslator(BodyTranslator):
-    
     def translate(self):
-        return "throw"
+        return "throw"
+
+class ReturnTranslator(BodyTranslator):
+    def translate(self):
+        return "return %s" % self.sub_translate(self.node.value)