[pypy-svn] r55472 - in pypy/branch/judy-trees/pypy: rlib rpython rpython/test

fijal at codespeak.net fijal at codespeak.net
Sun Jun 1 17:35:32 CEST 2008


Author: fijal
Date: Sun Jun  1 17:35:31 2008
New Revision: 55472

Modified:
   pypy/branch/judy-trees/pypy/rlib/rjudy.py
   pypy/branch/judy-trees/pypy/rpython/rjudy.py
   pypy/branch/judy-trees/pypy/rpython/test/test_rjudy.py
Log:
* Add an explicit free and pass a test
* Add exception_is_here/cannot_occur


Modified: pypy/branch/judy-trees/pypy/rlib/rjudy.py
==============================================================================
--- pypy/branch/judy-trees/pypy/rlib/rjudy.py	(original)
+++ pypy/branch/judy-trees/pypy/rlib/rjudy.py	Sun Jun  1 17:35:31 2008
@@ -10,6 +10,9 @@
         from pypy.rpython.rjudy import JudyRepr
         return JudyRepr(rtyper)
 
+    def method_free(self):
+        return annmodel.s_None
+
 class JudyTreeEntry(ExtRegistryEntry):
     """ This registers JudyTree to be special-treated by a translation
     toolchain

Modified: pypy/branch/judy-trees/pypy/rpython/rjudy.py
==============================================================================
--- pypy/branch/judy-trees/pypy/rpython/rjudy.py	(original)
+++ pypy/branch/judy-trees/pypy/rpython/rjudy.py	Sun Jun  1 17:35:31 2008
@@ -30,11 +30,18 @@
 
     def rtype_len(self, hop):
         v_dict, = hop.inputargs(self)
+        hop.exception_cannot_occur()
         return hop.gendirectcall(ll_dict_len, v_dict)
 
     def rtype_new(self, hop):
+        hop.exception_is_here()
         return hop.gendirectcall(ll_newdict)
 
+    def rtype_method_free(self, hop):
+        v_j, = hop.inputargs(self)
+        hop.exception_is_here()
+        return hop.gendirectcall(ll_free, v_j)
+
 class __extend__(pairtype(JudyRepr, rmodel.Repr)): 
     def rtype_setitem((r_dict, r_key), hop):
         v_dict, v_key, v_value = hop.inputargs(r_dict, lltype.Signed, lltype.Signed)
@@ -52,3 +59,6 @@
     
 def ll_dict_len(dict):
     return JudyLCount(dict[0], 0, -1, 0)
+
+def ll_free(dict):
+    lltype.free(dict, flavor='raw')

Modified: pypy/branch/judy-trees/pypy/rpython/test/test_rjudy.py
==============================================================================
--- pypy/branch/judy-trees/pypy/rpython/test/test_rjudy.py	(original)
+++ pypy/branch/judy-trees/pypy/rpython/test/test_rjudy.py	Sun Jun  1 17:35:31 2008
@@ -7,7 +7,9 @@
     def test_creation(self):
         def f():
             x = JudyTree()
-            return len(x)
+            res = len(x)
+            x.free()
+            return res
         assert self.interpret(f, []) == 0
 
 class TestLLtype(BaseTest, LLRtypeMixin):



More information about the Pypy-commit mailing list