merge
authorStefan Behnel <scoder@users.berlios.de>
Sun, 4 Oct 2009 07:38:57 +0000 (09:38 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Sun, 4 Oct 2009 07:38:57 +0000 (09:38 +0200)
1  2 
Cython/Compiler/ExprNodes.py
Cython/Compiler/Visitor.py

index b1b26e02a373643259ba8c28adbb9dfe3a6b45cc,b590ad7983804c39e0486050267f627b09f3b764..0eb76619b785705fa95f8eaf31122ca1ce0d0413
@@@ -3503,10 -3501,9 +3503,12 @@@ class DictNode(ExprNode)
      # obj_conversion_errors    [PyrexError]   used internally
      
      subexprs = ['key_value_pairs']
+     is_temp = 1
+     type = dict_type
  
 +    type = dict_type
 +    obj_conversion_errors = []
 +
      def calculate_constant_result(self):
          self.constant_result = dict([
                  item.constant_result for item in self.key_value_pairs])
index cfc79f96d94223173ae2118aad0f1bedae69de61,636d9d0595f0c272225d6afad2a104703b547760..86354dd6fa757eefd4660f18570b05be8de5269b
@@@ -272,22 -275,37 +275,53 @@@ class CythonTransform(VisitorTransform)
          self.visitchildren(node)
          return node
  
+ class ScopeTrackingTransform(CythonTransform):
+     # Keeps track of type of scopes
+     scope_type = None # can be either of 'module', 'function', 'cclass', 'pyclass'
+     scope_node = None
+     
+     def visit_ModuleNode(self, node):
+         self.scope_type = 'module'
+         self.scope_node = node
+         self.visitchildren(node)
+         return node
+     def visit_scope(self, node, scope_type):
+         prev = self.scope_type, self.scope_node
+         self.scope_type = scope_type
+         self.scope_node = node
+         self.visitchildren(node)
+         self.scope_type, self.scope_node = prev
+         return node
+     
+     def visit_CClassDefNode(self, node):
+         return self.visit_scope(node, 'cclass')
+     def visit_PyClassDefNode(self, node):
+         return self.visit_scope(node, 'pyclass')
+     def visit_FuncDefNode(self, node):
+         return self.visit_scope(node, 'function')
+     def visit_CStructOrUnionDefNode(self, node):
+         return self.visit_scope(node, 'struct')
 +class RecursiveNodeReplacer(VisitorTransform):
 +    """
 +    Recursively replace all occurrences of a node in a subtree by
 +    another node.
 +    """
 +    def __init__(self, orig_node, new_node):
 +        super(RecursiveNodeReplacer, self).__init__()
 +        self.orig_node, self.new_node = orig_node, new_node
 +
 +    def visit_Node(self, node):
 +        self.visitchildren(node)
 +        if node is self.orig_node:
 +            return self.new_node
 +        else:
 +            return node
 +