[pypy-svn] r28392 - in pypy/dist/pypy: annotation rpython/ootypesystem rpython/test
antocuni at codespeak.net
antocuni at codespeak.net
Tue Jun 6 17:38:24 CEST 2006
Author: antocuni
Date: Tue Jun 6 17:38:23 2006
New Revision: 28392
Modified:
pypy/dist/pypy/annotation/unaryop.py
pypy/dist/pypy/rpython/ootypesystem/rclass.py
pypy/dist/pypy/rpython/ootypesystem/rootype.py
pypy/dist/pypy/rpython/test/test_remptydict.py
Log:
Make ootypesystem to work with SomeOOInstance with Void lowleveltype too.
Some more ootypesystem tests.
Modified: pypy/dist/pypy/annotation/unaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/unaryop.py (original)
+++ pypy/dist/pypy/annotation/unaryop.py Tue Jun 6 17:38:23 2006
@@ -634,8 +634,9 @@
def setattr(r, s_attr, s_value):
assert s_attr.is_constant(), "setattr on ref %r with non-constant field-name" % r.ootype
v = annotation_to_lltype(s_value)
- setattr(r.ootype._example(), s_attr.const,
- v._example())
+ example = r.ootype._example()
+ if example is not None:
+ setattr(r.ootype._example(), s_attr.const, v._example())
def is_true(p):
return SomeBool()
Modified: pypy/dist/pypy/rpython/ootypesystem/rclass.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/rclass.py (original)
+++ pypy/dist/pypy/rpython/ootypesystem/rclass.py Tue Jun 6 17:38:23 2006
@@ -2,7 +2,7 @@
from pypy.annotation import model as annmodel
from pypy.annotation import description
from pypy.objspace.flow import model as flowmodel
-from pypy.rpython.rmodel import inputconst, TyperError
+from pypy.rpython.rmodel import inputconst, TyperError, warning
from pypy.rpython.rmodel import mangle as pbcmangle
from pypy.rpython.rclass import AbstractClassRepr, AbstractInstanceRepr, \
getinstancerepr, getclassrepr, get_type_repr
Modified: pypy/dist/pypy/rpython/ootypesystem/rootype.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/rootype.py (original)
+++ pypy/dist/pypy/rpython/ootypesystem/rootype.py Tue Jun 6 17:38:23 2006
@@ -51,6 +51,8 @@
resulttype = hop.r_result.lowleveltype)
def rtype_setattr(self, hop):
+ if self.lowleveltype is Void:
+ return
attr = hop.args_s[1].const
self.lowleveltype._check_field(attr)
vlist = hop.inputargs(self, Void, hop.args_r[2])
Modified: pypy/dist/pypy/rpython/test/test_remptydict.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_remptydict.py (original)
+++ pypy/dist/pypy/rpython/test/test_remptydict.py Tue Jun 6 17:38:23 2006
@@ -1,27 +1,34 @@
import py
-from pypy.rpython.test.test_llinterp import interpret
+from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
-def test_empty_dict():
- class A:
- pass
- a = A()
- a.d1 = {}
- def func():
- a.d2 = {}
- return bool(a.d1) or bool(a.d2)
- res = interpret(func, [])
- assert res is False
+class BaseTestRemptydict(BaseRtypingTest):
+ def test_empty_dict(self):
+ class A:
+ pass
+ a = A()
+ a.d1 = {}
+ def func():
+ a.d2 = {}
+ return bool(a.d1) or bool(a.d2)
+ res = self.interpret(func, [])
+ assert res is False
-def test_iterate_over_empty_dict():
- def f():
- n = 0
- d = {}
- for x in []: n += x
- for y in d: n += y
- for z in d.iterkeys(): n += z
- for s in d.itervalues(): n += s
- for t, u in d.items(): n += t * u
- for t, u in d.iteritems(): n += t * u
- return n
- res = interpret(f, [])
- assert res == 0
+ def test_iterate_over_empty_dict(self):
+ def f():
+ n = 0
+ d = {}
+ for x in []: n += x
+ for y in d: n += y
+ for z in d.iterkeys(): n += z
+ for s in d.itervalues(): n += s
+ for t, u in d.items(): n += t * u
+ for t, u in d.iteritems(): n += t * u
+ return n
+ res = self.interpret(f, [])
+ assert res == 0
+
+class TestLLtype(BaseTestRemptydict, LLRtypeMixin):
+ pass
+
+class TestOOtype(BaseTestRemptydict, OORtypeMixin):
+ pass
More information about the Pypy-commit
mailing list