소스 검색

Move bytecode_to_tree's create_return function to the module level

jonathanvdc 8 년 전
부모
커밋
0c7bf13c9c
1개의 변경된 파일8개의 추가작업 그리고 7개의 파일을 삭제
  1. 8 7
      kernel/modelverse_jit/bytecode_to_tree.py

+ 8 - 7
kernel/modelverse_jit/bytecode_to_tree.py

@@ -233,6 +233,14 @@ def create_indirect_call(target, argument_list):
         [('function_id', target), ('named_arguments', dict_literal)],
         tree_ir.LoadLocalInstruction(jit_runtime.KWARGS_PARAMETER_NAME))
 
+def create_return(return_value):
+    """Creates a return statement that returns the given return value."""
+    return tree_ir.ReturnInstruction(
+        tree_ir.CompoundInstruction(
+            return_value,
+            tree_ir.DeleteEdgeInstruction(
+                tree_ir.LoadLocalInstruction(jit_runtime.LOCALS_EDGE_NAME))))
+
 def with_debug_info_trace(instruction, debug_info, function_name):
     """Prepends the given instruction with a tracing instruction that prints
        the given debug information and function name."""
@@ -340,13 +348,6 @@ class AnalysisState(object):
 
     def analyze_return(self, instruction):
         """Tries to analyze the given 'return' instruction."""
-        def create_return(return_value):
-            return tree_ir.ReturnInstruction(
-                tree_ir.CompoundInstruction(
-                    return_value,
-                    tree_ir.DeleteEdgeInstruction(
-                        tree_ir.LoadLocalInstruction(jit_runtime.LOCALS_EDGE_NAME))))
-
         if instruction.value is None:
             raise primitive_functions.PrimitiveFinished(
                 create_return(