1. David Malcolm
  2. pypy-cgeneration

Commits

David Schneider  committed d1981fa

(lukas) Rerased pointer patch

  • Participants
  • Parent commits 6d4ae65
  • Branches default

Comments (0)

Files changed (2)

File pypy/rlib/rerased.py

View file
  • Ignore whitespace
         bk = self.rtyper.annotator.bookkeeper
         s_obj = value._identity.get_input_annotation(bk)
         r_obj = self.rtyper.getrepr(s_obj)
+        if r_obj.lowleveltype is lltype.Void:
+            return lltype.nullptr(self.lowleveltype.TO)
         v = r_obj.convert_const(value._x)
         return lltype.cast_opaque_ptr(self.lowleveltype, v)

File pypy/rlib/test/test_rerased.py

View file
  • Ignore whitespace
     x = interpret(f, [])
     assert x == 16 + 42 + 1
 
+def test_prebuilt_erased_in_instance():
+    erase_empty, unerase_empty = new_erasing_pair("empty")
+    class FakeList(object):
+        pass
+
+    x1 = X()
+    x1.foobar = 42
+    l1 = FakeList()
+    l1.storage = eraseX(x1)
+    l2 = FakeList()
+    l2.storage = erase_empty(None)
+
+    def f():
+        #assert is_integer(e1)
+        #assert not is_integer(e2)
+        x1.foobar += 1
+        x2 = uneraseX(l1.storage).foobar + (unerase_empty(l2.storage) is None)
+        return x2
+    x = interpret(f, [])
+    assert x == 43 + True
+
+
 def test_overflow():
     def f(i):
         try: