move utility code inclusion from Name/AttributeNodes to the latest possible step...
authorStefan Behnel <stefan_ml@behnel.de>
Wed, 29 Aug 2012 16:50:19 +0000 (18:50 +0200)
committerStefan Behnel <stefan_ml@behnel.de>
Wed, 29 Aug 2012 16:50:19 +0000 (18:50 +0200)
Cython/Compiler/Pipeline.py

index 304dc7c..1045c27 100644 (file)
@@ -105,15 +105,19 @@ class UseUtilityCodeDefinitions(CythonTransform):
         self.scope = node.scope
         return super(UseUtilityCodeDefinitions, self).__call__(node)
 
+    def process_entry(self, entry):
+        if entry:
+            for utility_code in (entry.utility_code, entry.utility_code_definition):
+                if utility_code:
+                    self.scope.use_utility_code(utility_code)
+
     def visit_AttributeNode(self, node):
-        if node.entry and node.entry.utility_code_definition:
-            self.scope.use_utility_code(node.entry.utility_code_definition)
+        self.process_entry(node.entry)
         return node
 
     def visit_NameNode(self, node):
-        for e in (node.entry, node.type_entry):
-            if e and e.utility_code_definition:
-                self.scope.use_utility_code(e.utility_code_definition)
+        self.process_entry(node.entry)
+        self.process_entry(node.type_entry)
         return node
                      
 #