From e50b6cc455047b0fb5b2c066c6f265f680c3613f Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Sun, 21 Feb 2010 01:05:36 -0800 Subject: [PATCH] cleanup --- Cython/Compiler/ExprNodes.py | 25 ++++++------------------- Cython/Compiler/PyrexTypes.py | 7 ++++--- Cython/Compiler/Symtab.py | 2 -- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index c3902b4e..e610fc62 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -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 diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index c5e65642..8f8fb87d 100755 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -1367,6 +1367,9 @@ class CReferenceType(BaseType): def __repr__(self): return "" % 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 diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index 13395144..240e2c6f 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -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()) -- 2.26.2