[pypy-svn] r30706 - in pypy/dist/pypy/rpython: . lltypesystem

fijal at codespeak.net fijal at codespeak.net
Fri Jul 28 19:38:10 CEST 2006


Author: fijal
Date: Fri Jul 28 19:38:08 2006
New Revision: 30706

Modified:
   pypy/dist/pypy/rpython/lltypesystem/opimpl.py
   pypy/dist/pypy/rpython/objectmodel.py
   pypy/dist/pypy/rpython/rlist.py
Log:
Added llinterp patch which handles CDefinedIntSymbolic. rlist test now passes.


Modified: pypy/dist/pypy/rpython/lltypesystem/opimpl.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/opimpl.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/opimpl.py	Fri Jul 28 19:38:08 2006
@@ -2,6 +2,7 @@
 from pypy.tool.sourcetools import func_with_new_name
 from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rpython.lltypesystem.lloperation import opimpls
+from pypy.rpython.objectmodel import CDefinedIntSymbolic
 
 # ____________________________________________________________
 # Implementation of the 'canfold' operations
@@ -26,6 +27,10 @@
     'ullong': r_ulonglong,
     }
 
+# this is just a flag, when we should check for
+# CDefinedSymbolicInt
+ops_to_check = {'is_true':True}
+
 def no_op(x):
     return x
 
@@ -58,7 +63,16 @@
             fullopname,)
         argtype = type_by_name[typname]
 
-        if opname in ops_unary:
+        if opname in ops_to_check:
+            def op_function(x):
+                # is instead of isinstance for performance
+                if type(x) is CDefinedIntSymbolic:
+                    x = x.default
+                if not isinstance(x, argtype):
+                    raise TypeError("%r arg must be %s, got %r instead" % (
+                        fullopname, typname, type(x).__name__))
+                return adjust_result(func(x))
+        elif opname in ops_unary:
             def op_function(x):
                 if not isinstance(x, argtype):
                     raise TypeError("%r arg must be %s, got %r instead" % (

Modified: pypy/dist/pypy/rpython/objectmodel.py
==============================================================================
--- pypy/dist/pypy/rpython/objectmodel.py	(original)
+++ pypy/dist/pypy/rpython/objectmodel.py	Fri Jul 28 19:38:08 2006
@@ -21,18 +21,9 @@
 
     def __hash__(self):
         raise TypeError("Symbolics are not hashable!")
-
-class BackendFlagSymbolic(object):
-    def __init__(self, val):
-        self.val = val
-    
-    def annotation(self):
-        from pypy.annotation import model
-        return model.SomeBoolean()
     
-    def lltype(self):
-        from pypy.rpython.lltypesystem import lltype
-        return lltype.Bool
+    def __nonzero__(self):
+        raise TypeError("Symbolics are not comparable")
 
 class ComputedIntSymbolic(Symbolic):
 
@@ -49,8 +40,9 @@
 
 class CDefinedIntSymbolic(Symbolic):
 
-    def __init__(self, expr):
+    def __init__(self, expr, default=0):
         self.expr = expr
+        self.default = default
 
     def annotation(self):
         from pypy.annotation import model
@@ -59,8 +51,8 @@
     def lltype(self):
         from pypy.rpython.lltypesystem import lltype
         return lltype.Signed
-
-malloc_zero_filled = CDefinedIntSymbolic('MALLOC_ZERO_FILLED')
+    
+malloc_zero_filled = CDefinedIntSymbolic('MALLOC_ZERO_FILLED', default=1)
 
 def instantiate(cls):
     "Create an empty instance of 'cls'."

Modified: pypy/dist/pypy/rpython/rlist.py
==============================================================================
--- pypy/dist/pypy/rpython/rlist.py	(original)
+++ pypy/dist/pypy/rpython/rlist.py	Fri Jul 28 19:38:08 2006
@@ -372,7 +372,7 @@
         check = ord(item)
     else:
         check = item
-    if (not malloc_zero_check) or check: # as long as malloc it is known to zero the allocated memory avoid zeroing twice
+    if (not malloc_zero_filled) or check: # as long as malloc it is known to zero the allocated memory avoid zeroing twice
     
         i = 0
         while i < count:



More information about the Pypy-commit mailing list