cleanup
authorRobert Bradshaw <robertwb@math.washington.edu>
Sun, 21 Feb 2010 09:05:36 +0000 (01:05 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Sun, 21 Feb 2010 09:05:36 +0000 (01:05 -0800)
Cython/Compiler/ExprNodes.py
Cython/Compiler/PyrexTypes.py
Cython/Compiler/Symtab.py

index c3902b4e92f5d3a5b7bf4d3b51390734a0c61448..e610fc62d3a677b7b5d7c2e387173e310aaff47e 100755 (executable)
@@ -1934,7 +1934,6 @@ class IndexNode(ExprNode):
                                 self.index.type)
                 elif self.base.type.is_cpp_class:
                     function = env.lookup_operator("[]", [self.base, self.index])
-                    function = self.base.type.scope.lookup("operator[]")
                     if function is None:
                         error(self.pos, "Indexing '%s' not supported for index type '%s'" % (self.base.type, self.index.type))
                         self.type = PyrexTypes.error_type
@@ -1946,7 +1945,7 @@ class IndexNode(ExprNode):
                     self.index = self.index.coerce_to(func_type.args[0].type, env)
                     self.type = func_type.return_type
                     if setting and not func_type.return_type.is_reference:
-                        error(self.pos, "Can't set non-reference '%s'" % self.type)
+                        error(self.pos, "Can't set non-reference result '%s'" % self.type)
                 else:
                     error(self.pos,
                         "Attempting to index non-array type '%s'" %
@@ -4201,7 +4200,7 @@ class UnopNode(ExprNode):
 
     def is_cpp_operation(self):
         type = self.operand.type
-        return type.is_cpp_class or type.is_reference and type.base_type.is_cpp_class
+        return type.is_cpp_class
     
     def coerce_operand_to_pyobject(self, env):
         self.operand = self.operand.coerce_to_pyobject(env)
@@ -4228,7 +4227,7 @@ class UnopNode(ExprNode):
 
     def analyse_cpp_operation(self, env):
         type = self.operand.type
-        if type.is_ptr or type.is_reference:
+        if type.is_ptr:
             type = type.base_type
         function = type.scope.lookup("operator%s" % self.operator)
         if not function:
@@ -4745,14 +4744,8 @@ class BinopNode(ExprNode):
         return type1.is_pyobject or type2.is_pyobject
 
     def is_cpp_operation(self):
-        type1 = self.operand1.type
-        type2 = self.operand2.type
-        if type1.is_reference:
-            type1 = type1.base_type
-        if type2.is_reference:
-            type2 = type2.base_type
-        return (type1.is_cpp_class
-            or type2.is_cpp_class)
+        return (self.operand1.type.is_cpp_class
+            or self.operand2.type.is_cpp_class)
     
     def analyse_cpp_operation(self, env):
         type1 = self.operand1.type
@@ -5401,13 +5394,7 @@ class CmpNode(object):
         return result
 
     def is_cpp_comparison(self):
-        type1 = self.operand1.type
-        type2 = self.operand2.type
-        if type1.is_reference:
-            type1 = type1.base_type
-        if type2.is_reference:
-            type2 = type2.base_type
-        return type1.is_cpp_class or type2.is_cpp_class
+        return self.operand1.type.is_cpp_class or self.operand2.type.is_cpp_class
 
     def find_common_int_type(self, env, op, operand1, operand2):
         # type1 != type2 and at least one of the types is not a C int
index c5e65642400ef98ca5b03d345fae8c61791250ea..8f8fb87d18ebc3c960a870c9ae00e6b25bf05d5b 100755 (executable)
@@ -1367,6 +1367,9 @@ class CReferenceType(BaseType):
 
     def __repr__(self):
         return "<CReferenceType %s>" % repr(self.ref_base_type)
+    
+    def __str__(self):
+        return "%s &" % self.ref_base_type
 
     def as_argument_type(self):
         return self
@@ -2303,9 +2306,7 @@ def best_match(args, functions, pos=None):
             src_type = args[i].type
             dst_type = func_type.args[i].type
             if dst_type.assignable_from(src_type):
-                if src_type == dst_type or (dst_type.is_reference and \
-                                            src_type == dst_type.base_type) \
-                                        or dst_type.same_as(src_type):
+                if src_type == dst_type or dst_type.same_as(src_type):
                     pass # score 0
                 elif is_promotion(src_type, dst_type):
                     score[2] += 1
index 13395144e41bf4ea6f52ba400feeb55e9faf930e..240e2c6fa78426158398abb05ddaec694cf10743 100644 (file)
@@ -604,8 +604,6 @@ class Scope(object):
     def lookup_operator(self, operator, operands):
         if operands[0].type.is_cpp_class:
             obj_type = operands[0].type
-            if obj_type.is_reference:
-                obj_type = obj_type.base_type
             method = obj_type.scope.lookup("operator%s" % operator)
             if method is not None:
                 res = PyrexTypes.best_match(operands[1:], method.all_alternatives())