[pypy-svn] r17830 - in pypy/dist/pypy: rpython translator/c

arigo at codespeak.net arigo at codespeak.net
Sat Sep 24 17:25:46 CEST 2005


Author: arigo
Date: Sat Sep 24 17:25:35 2005
New Revision: 17830

Modified:
   pypy/dist/pypy/rpython/rclass.py
   pypy/dist/pypy/rpython/rmodel.py
   pypy/dist/pypy/rpython/rpbc.py
   pypy/dist/pypy/rpython/rtyper.py
   pypy/dist/pypy/translator/c/database.py
   pypy/dist/pypy/translator/c/external.py
   pypy/dist/pypy/translator/c/funcgen.py
   pypy/dist/pypy/translator/c/node.py
   pypy/dist/pypy/translator/c/symboltable.py
Log:
Mindless replacement of '== Void' with 'is Void' and '!= Void' with 'is not
Void'.  As it's a primitive low-level type it should be a singleton.



Modified: pypy/dist/pypy/rpython/rclass.py
==============================================================================
--- pypy/dist/pypy/rpython/rclass.py	(original)
+++ pypy/dist/pypy/rpython/rclass.py	Sat Sep 24 17:25:35 2005
@@ -270,7 +270,7 @@
             mro = list(rsubcls.classdef.getmro())
             for fldname in self.clsfields:
                 mangled_name, r = self.clsfields[fldname]
-                if r.lowleveltype == Void:
+                if r.lowleveltype is Void:
                     continue
                 for clsdef in mro:
                     if fldname in clsdef.cls.__dict__:
@@ -279,7 +279,7 @@
                         break
             # extra PBC attributes
             for (access_set, attr), (mangled_name, r) in self.pbcfields.items():
-                if r.lowleveltype == Void:
+                if r.lowleveltype is Void:
                     continue
                 for clsdef in mro:
                     try:
@@ -513,7 +513,7 @@
                                                     result.super)
             # then add instance attributes from this level
             for name, (mangled_name, r) in self.fields.items():
-                if r.lowleveltype == Void:
+                if r.lowleveltype is Void:
                     llattrvalue = None
                 elif name == '_hash_cache_': # hash() support
                     llattrvalue = hash(value)
@@ -596,7 +596,7 @@
                 if fldname == '__class__':
                     continue
                 mangled_name, r = self.allinstancefields[fldname]
-                if r.lowleveltype == Void:
+                if r.lowleveltype is Void:
                     continue
                 for clsdef in mro:
                     if fldname in clsdef.cls.__dict__:

Modified: pypy/dist/pypy/rpython/rmodel.py
==============================================================================
--- pypy/dist/pypy/rpython/rmodel.py	(original)
+++ pypy/dist/pypy/rpython/rmodel.py	Sat Sep 24 17:25:35 2005
@@ -91,7 +91,7 @@
 
     def convert_const(self, value):
         "Convert the given constant value to the low-level repr of 'self'."
-        if self.lowleveltype != Void:
+        if self.lowleveltype is not Void:
             try:
                 realtype = typeOf(value)
             except (AssertionError, AttributeError):
@@ -199,9 +199,9 @@
     def rtype_is_((robj1, robj2), hop):
         if hop.s_result.is_constant():
             return inputconst(Bool, hop.s_result.const)
-        if robj1.lowleveltype == Void:
+        if robj1.lowleveltype is Void:
             robj1 = robj2
-        elif robj2.lowleveltype == Void:
+        elif robj2.lowleveltype is Void:
             robj2 = robj1
         if (not isinstance(robj1.lowleveltype, Ptr) or
             not isinstance(robj2.lowleveltype, Ptr)):
@@ -287,7 +287,7 @@
         raise TypeError(repr(reqtype))
     # Void Constants can hold any value;
     # non-Void Constants must hold a correctly ll-typed value
-    if lltype != Void:
+    if lltype is not Void:
         try:
             realtype = typeOf(value)
         except (AssertionError, AttributeError):

Modified: pypy/dist/pypy/rpython/rpbc.py
==============================================================================
--- pypy/dist/pypy/rpython/rpbc.py	(original)
+++ pypy/dist/pypy/rpython/rpbc.py	Sat Sep 24 17:25:35 2005
@@ -232,7 +232,7 @@
             result = malloc(self.pbc_type, immortal=True)
             self.pbc_cache[pbc] = result
             for attr, (mangled_name, r_value) in self.llfieldmap.items():
-                if r_value.lowleveltype == Void:
+                if r_value.lowleveltype is Void:
                     continue
                 try: 
                     thisattrvalue = self.access_set.values[(pbc, attr)] 
@@ -436,7 +436,7 @@
         return self.call(hop, f, vlist, rresult)
 
     def call(self, hop, f, vlist, rresult):
-        if self.lowleveltype == Void:
+        if self.lowleveltype is Void:
             assert len(self.function_signatures()) == 1
             vlist[0] = hop.inputconst(typeOf(f), f)
         hop.exception_is_here()
@@ -466,7 +466,7 @@
             # this check makes sense because both source and dest repr are FunctionsPBCRepr
             if r_fpbc1.lowleveltype == r_fpbc2.lowleveltype:
                 return v
-            if r_fpbc1.lowleveltype == Void:
+            if r_fpbc1.lowleveltype is Void:
                 return inputconst(r_fpbc2, r_fpbc1.s_pbc.const)
             return NotImplemented
 
@@ -622,7 +622,7 @@
     def convert_const(self, cls):
         if cls not in self.s_pbc.prebuiltinstances:
             raise TyperError("%r not in %r" % (cls, self))
-        if self.lowleveltype == Void:
+        if self.lowleveltype is Void:
             return cls
         return rclass.get_type_repr(self.rtyper).convert_const(cls)
 
@@ -633,7 +633,7 @@
         return self.redispatch_call(hop, call_args=True)
 
     def redispatch_call(self, hop, call_args):
-        if self.lowleveltype != Void:
+        if self.lowleveltype is not Void:
             # instantiating a class from multiple possible classes
             vcls = hop.inputarg(self, arg=0)
             access_set = self.get_access_set()
@@ -696,7 +696,7 @@
             # this check makes sense because both source and dest repr are ClassesPBCRepr
             if r_clspbc1.lowleveltype == r_clspbc2.lowleveltype:
                 return v
-            if r_clspbc1.lowleveltype == Void:
+            if r_clspbc1.lowleveltype is Void:
                 return inputconst(r_clspbc2, r_clspbc1.s_pbc.const)
             return NotImplemented
             

Modified: pypy/dist/pypy/rpython/rtyper.py
==============================================================================
--- pypy/dist/pypy/rpython/rtyper.py	(original)
+++ pypy/dist/pypy/rpython/rtyper.py	Sat Sep 24 17:25:35 2005
@@ -212,7 +212,7 @@
         if not hasattr(c, 'concretetype'):
             c = inputconst(using_repr, c.value)
         else:
-            if c.concretetype != Void:
+            if c.concretetype is not Void:
                 assert typeOf(c.value) == using_repr.lowleveltype
         return c
 
@@ -393,7 +393,7 @@
             if hop.s_result.is_constant():
                 if isinstance(resultvar, Constant) and \
                        isinstance(hop.r_result.lowleveltype, Primitive) and \
-                       hop.r_result.lowleveltype != Void:
+                       hop.r_result.lowleveltype is not Void:
                     assert resultvar.value == hop.s_result.const
             resulttype = resultvar.concretetype
             op.result.concretetype = hop.r_result.lowleveltype
@@ -707,7 +707,7 @@
         args_s = []
         newargs_v = []
         for v in args_v:
-            if v.concretetype == Void:
+            if v.concretetype is Void:
                 s_value = rtyper.binding(v)
                 if not s_value.is_constant():
                     raise TyperError("non-constant variable of type Void")

Modified: pypy/dist/pypy/translator/c/database.py
==============================================================================
--- pypy/dist/pypy/translator/c/database.py	(original)
+++ pypy/dist/pypy/translator/c/database.py	Sat Sep 24 17:25:35 2005
@@ -69,7 +69,7 @@
             resulttype = self.gettype(T.RESULT)
             argtypes = []
             for i in range(len(T.ARGS)):
-                if T.ARGS[i] != Void:
+                if T.ARGS[i] is not Void:
                     argtype = self.gettype(T.ARGS[i])
                     try:
                         argname = argnames[i]

Modified: pypy/dist/pypy/translator/c/external.py
==============================================================================
--- pypy/dist/pypy/translator/c/external.py	(original)
+++ pypy/dist/pypy/translator/c/external.py	Sat Sep 24 17:25:35 2005
@@ -27,12 +27,12 @@
         pass
 
     def cfunction_declarations(self):
-        if self.FUNCTYPE.RESULT != Void:
+        if self.FUNCTYPE.RESULT is not Void:
             yield '%s;' % cdecl(self.resulttypename, 'result')
 
     def cfunction_body(self):
         call = '%s(%s)' % (self.fnptr._name, ', '.join(self.argnames()))
-        if self.FUNCTYPE.RESULT != Void:
+        if self.FUNCTYPE.RESULT is not Void:
             yield 'result = %s;' % call
             yield 'if (PyErr_Occurred()) RPyConvertExceptionFromCPython();'
             yield 'return result;'

Modified: pypy/dist/pypy/translator/c/funcgen.py
==============================================================================
--- pypy/dist/pypy/translator/c/funcgen.py	(original)
+++ pypy/dist/pypy/translator/c/funcgen.py	Sat Sep 24 17:25:35 2005
@@ -100,7 +100,7 @@
 
     def expr(self, v, special_case_void=True):
         if isinstance(v, Variable):
-            if self.lltypemap(v) == Void and special_case_void:
+            if self.lltypemap(v) is Void and special_case_void:
                 return '/* nothing */'
             else:
                 return LOCALVAR % v.name
@@ -143,7 +143,7 @@
             if name not in seen:
                 seen[name] = True
                 result = cdecl(self.lltypename(v), LOCALVAR % name) + ';'
-                if self.lltypemap(v) == Void:
+                if self.lltypemap(v) is Void:
                     result = '/*%s*/' % result
                 result_by_name.append((v._name, result))
         result_by_name.sort()
@@ -174,7 +174,7 @@
             multiple_times_alive = []
             for a1, a2 in zip(link.args, link.target.inputargs):
                 a2type, a2typename = self.lltypes[id(a2)]
-                if a2type == Void:
+                if a2type is Void:
                     continue
                 if a1 in linklocalvars:
                     src = linklocalvars[a1]
@@ -237,7 +237,7 @@
                 to_release.append(op.result)
 
                 T = self.lltypemap(op.result)
-                if T != Void:
+                if T is not Void:
                     res = LOCALVAR % op.result.name
                     line = push_alive_op_result(op.opname, res, T)
                     if line:
@@ -395,8 +395,8 @@
 
     def OP_DIRECT_CALL(self, op, err):
         # skip 'void' arguments
-        args = [self.expr(v) for v in op.args if self.lltypemap(v) != Void]
-        if self.lltypemap(op.result) == Void:
+        args = [self.expr(v) for v in op.args if self.lltypemap(v) is not Void]
+        if self.lltypemap(op.result) is Void:
             # skip assignment of 'void' return value
             return '%s(%s); if (RPyExceptionOccurred()) FAIL(%s);' % (
                 args[0], ', '.join(args[1:]), err)
@@ -414,7 +414,7 @@
         if T == PyObjPtr:
             result.append(self.pyobj_incref_expr(newvalue, T))
         result = '\t'.join(result)
-        if T == Void:
+        if T is Void:
             result = '/* %s */' % result
         return result
 
@@ -425,7 +425,7 @@
         T = self.lltypemap(op.args[2])
         self.gcpolicy.write_barrier(result, newvalue, T, targetexpr)
         result = '\t'.join(result)
-        if T == Void:
+        if T is Void:
             result = '/* %s */' % result
         return result
 
@@ -506,7 +506,7 @@
         itemtypename = self.db.gettype(VARPART.OF)
         elength = self.expr(op.args[1])
         eresult = self.expr(op.result)
-        if VARPART.OF == Void:    # strange
+        if VARPART.OF is Void:    # strange
             esize = 'sizeof(%s)' % (cdecl(typename, ''),)
         else:
             esize = 'sizeof(%s)+((%s-1)*sizeof(%s))' % (cdecl(typename, ''),
@@ -532,7 +532,7 @@
         result = []
         TYPE = self.lltypemap(op.result)
         assert self.lltypemap(op.args[0]) == TYPE
-        if TYPE != Void:
+        if TYPE is not Void:
             result.append('%s = %s;' % (self.expr(op.result),
                                         self.expr(op.args[0])))
             if TYPE == PyObjPtr:

Modified: pypy/dist/pypy/translator/c/node.py
==============================================================================
--- pypy/dist/pypy/translator/c/node.py	(original)
+++ pypy/dist/pypy/translator/c/node.py	Sat Sep 24 17:25:35 2005
@@ -142,7 +142,7 @@
         STRUCT = self.STRUCT
         for name in STRUCT._names:
             FIELD_T = self.c_struct_field_type(name)
-            if FIELD_T == Void:
+            if FIELD_T is Void:
                 yield '-1'
             else:
                 cname = self.c_struct_field_name(name)
@@ -201,7 +201,7 @@
                     yield '\t' + line
             yield '\tlong length;'
             line = '%s;' % cdecl(self.itemtypename, 'items[%d]'% self.varlength)
-            if self.ARRAY.OF == Void:    # strange
+            if self.ARRAY.OF is Void:    # strange
                 line = '/* %s */' % line
             yield '\t' + line
             yield '};'
@@ -241,7 +241,7 @@
     def debug_offsets(self):
         # generate three offsets for debugging inspection
         yield 'offsetof(struct %s, length)' % (self.name,)
-        if self.ARRAY.OF != Void:
+        if self.ARRAY.OF is not Void:
             yield 'offsetof(struct %s, items[0])' % (self.name,)
             yield 'offsetof(struct %s, items[1])' % (self.name,)
         else:
@@ -381,7 +381,7 @@
             line = self.db.gcpolicy.array_gcheader_initializationexpr(self)
             if line:
                 yield '\t' + line
-        if self.T.OF == Void or len(self.obj.items) == 0:
+        if self.T.OF is Void or len(self.obj.items) == 0:
             yield '\t%d' % len(self.obj.items)
             yield '}'
         elif self.T.OF == Char:
@@ -416,7 +416,7 @@
             node.where_to_copy_me.append('&%s' % access_expr)
         else:
             expr = db.get(value)
-            if typeOf(value) == Void:
+            if typeOf(value) is Void:
                 comma = ''
         expr += comma
         i = expr.find('\n')

Modified: pypy/dist/pypy/translator/c/symboltable.py
==============================================================================
--- pypy/dist/pypy/translator/c/symboltable.py	(original)
+++ pypy/dist/pypy/translator/c/symboltable.py	Sat Sep 24 17:25:35 2005
@@ -107,7 +107,7 @@
         if isinstance(FIELD_TYPE, ContainerType):
             return debugptr(Ptr(FIELD_TYPE), address, self._symtable)
         elif isinstance(FIELD_TYPE, Primitive):
-            if FIELD_TYPE == Void:
+            if FIELD_TYPE is Void:
                 return None
             tag = PrimitiveTag[FIELD_TYPE]
             size = struct.calcsize(tag)



More information about the Pypy-commit mailing list