Move nodes to exprnodes
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Sat, 3 Oct 2009 16:28:00 +0000 (18:28 +0200)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Sat, 3 Oct 2009 16:28:00 +0000 (18:28 +0200)
Cython/Compiler/AnalysedTreeTransforms.py
Cython/Compiler/ExprNodes.py

index d91fb4ac98449080e3232998d20ac97064f80abf..355c50c7d72fd9baf8ea7c2014baa141a0adbe13 100644 (file)
@@ -1,7 +1,7 @@
 from Cython.Compiler.Visitor import VisitorTransform, ScopeTrackingTransform, TreeVisitor
 from Nodes import StatListNode, SingleAssignmentNode
 from ExprNodes import (DictNode, DictItemNode, NameNode, UnicodeNode, NoneNode,
-                      ExprNode, AttributeNode)
+                      ExprNode, AttributeNode, ModuleRefNode, DocstringRefNode)
 from PyrexTypes import py_object_type
 from Builtin import dict_type
 from StringEncoding import EncodedString
@@ -77,37 +77,3 @@ class DoctestHackTransform(ScopeTrackingTransform):
             self.add_test(node.pos, name, getfunc)
         return node
 
-
-class ModuleRefNode(ExprNode):
-    type = py_object_type
-    is_temp = False
-    subexprs = []
-    
-    def analyse_types(self, env):
-        pass
-
-    def calculate_result_code(self):
-        return Naming.module_cname
-
-    def generate_result_code(self, code):
-        pass
-
-class DocstringRefNode(ExprNode):
-    # Extracts the docstring of the body element
-    
-    subexprs = ['body']
-    type = py_object_type
-    is_temp = True
-    
-    def __init__(self, pos, body):
-        ExprNode.__init__(self, pos)
-        assert body.type.is_pyobject
-        self.body = body
-
-    def analyse_types(self, env):
-        pass
-
-    def generate_result_code(self, code):
-        code.putln('%s = __Pyx_GetAttrString(%s, "__doc__");' %
-                   (self.result(), self.body.result()))
-        code.put_gotref(self.result())
index 18df89b53ac035205727c34006850d822ed66efb..b590ad7983804c39e0486050267f627b09f3b764 100644 (file)
@@ -5484,6 +5484,44 @@ class CloneNode(CoercionNode):
         pass
 
 
+class ModuleRefNode(ExprNode):
+    # Simple returns the module object
+    
+    type = py_object_type
+    is_temp = False
+    subexprs = []
+    
+    def analyse_types(self, env):
+        pass
+
+    def calculate_result_code(self):
+        return Naming.module_cname
+
+    def generate_result_code(self, code):
+        pass
+
+class DocstringRefNode(ExprNode):
+    # Extracts the docstring of the body element
+    
+    subexprs = ['body']
+    type = py_object_type
+    is_temp = True
+    
+    def __init__(self, pos, body):
+        ExprNode.__init__(self, pos)
+        assert body.type.is_pyobject
+        self.body = body
+
+    def analyse_types(self, env):
+        pass
+
+    def generate_result_code(self, code):
+        code.putln('%s = __Pyx_GetAttrString(%s, "__doc__");' %
+                   (self.result(), self.body.result()))
+        code.put_gotref(self.result())
+
+
+
 #------------------------------------------------------------------------------------
 #
 #  Runtime support code