NewTempsExprNode cleanup -- easier to override temp handling
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Sat, 29 Nov 2008 21:32:23 +0000 (22:32 +0100)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Sat, 29 Nov 2008 21:32:23 +0000 (22:32 +0100)
Cython/Compiler/ExprNodes.py

index b7b328cf05e0d394d97c726d3a73e2d671d31e38..0cd6e8d5b3e72e41ed121ed5d035955920090784 100644 (file)
@@ -436,14 +436,10 @@ class ExprNode(Node):
         #  its sub-expressions, and dispose of any
         #  temporary results of its sub-expressions.
         self.generate_subexpr_evaluation_code(code)
-        self.pre_generate_result_code(code)
         self.generate_result_code(code)
         if self.is_temp:
             self.generate_subexpr_disposal_code(code)
 
-    def pre_generate_result_code(self, code):
-        pass
-    
     def generate_subexpr_evaluation_code(self, code):
         for node in self.subexpr_nodes():
             node.generate_evaluation_code(code)
@@ -602,7 +598,14 @@ class NewTempExprNode(ExprNode):
         else:
             self.release_subexpr_temps(env)
 
-    def pre_generate_result_code(self, code):
+    def generate_evaluation_code(self, code):
+        code.mark_pos(self.pos)
+        
+        #  Generate code to evaluate this node and
+        #  its sub-expressions, and dispose of any
+        #  temporary results of its sub-expressions.
+        self.generate_subexpr_evaluation_code(code)
+
         if self.is_temp:
             type = self.type
             if not type.is_void:
@@ -611,10 +614,15 @@ class NewTempExprNode(ExprNode):
                 if self.backwards_compatible_result:
                     self.temp_code = self.backwards_compatible_result
                 else:
-                    self.temp_code = code.funcstate.allocate_temp(type, manage_ref=True)
+                    self.temp_code = code.funcstate.allocate_temp(
+                        type, manage_ref=True)
             else:
                 self.temp_code = None
 
+        self.generate_result_code(code)
+        if self.is_temp:
+            self.generate_subexpr_disposal_code(code)
+
     def generate_disposal_code(self, code):
         if self.is_temp:
             if self.type.is_pyobject: