From fa9cca20c284f8611337f84e6a2d13cdbbf1baca Mon Sep 17 00:00:00 2001 From: Dag Sverre Seljebotn Date: Sat, 3 Oct 2009 18:28:00 +0200 Subject: [PATCH] Move nodes to exprnodes --- Cython/Compiler/AnalysedTreeTransforms.py | 36 +-------------------- Cython/Compiler/ExprNodes.py | 38 +++++++++++++++++++++++ 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/Cython/Compiler/AnalysedTreeTransforms.py b/Cython/Compiler/AnalysedTreeTransforms.py index d91fb4ac..355c50c7 100644 --- a/Cython/Compiler/AnalysedTreeTransforms.py +++ b/Cython/Compiler/AnalysedTreeTransforms.py @@ -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()) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 18df89b5..b590ad79 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -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 -- 2.26.2