[pypy-commit] pypy stm: Propagate this flag from the RPython class.
arigo
noreply at buildbot.pypy.org
Tue Jan 24 16:49:09 CET 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: stm
Changeset: r51713:1471ad7b2ff2
Date: 2012-01-24 15:28 +0100
http://bitbucket.org/pypy/pypy/changeset/1471ad7b2ff2/
Log: Propagate this flag from the RPython class.
diff --git a/pypy/rpython/rclass.py b/pypy/rpython/rclass.py
--- a/pypy/rpython/rclass.py
+++ b/pypy/rpython/rclass.py
@@ -206,6 +206,8 @@
self.immutable_field_set = set(immutable_fields.value)
accessor = FieldListAccessor()
hints['immutable_fields'] = accessor
+ if self.classdef.classdesc.lookup('_stm_access_directly_') is not None:
+ hints['stm_access_directly'] = True
return hints
def __repr__(self):
diff --git a/pypy/rpython/test/test_rclass.py b/pypy/rpython/test/test_rclass.py
--- a/pypy/rpython/test/test_rclass.py
+++ b/pypy/rpython/test/test_rclass.py
@@ -1142,6 +1142,35 @@
'cast_pointer': 1,
'setfield': 1}
+ def test_stm_access_directly(self):
+ for ret in ['a', 'b', 'c']:
+ class A(object):
+ pass
+ class B(A):
+ _stm_access_directly_ = True
+ class C(B):
+ pass
+ def f(n):
+ a = b = c = None
+ if n < 5:
+ a = A()
+ a.a = n
+ elif n < 10:
+ b = B()
+ b.b = n
+ else:
+ c = C()
+ c.c = n
+ if ret == 'a': return a
+ if ret == 'b': return b
+ if ret == 'c': return c
+ t, typer, graph = self.gengraph(f, [int])
+ TYPE = graph.getreturnvar().concretetype.TO
+ if ret == 'a':
+ assert "stm_access_directly" not in TYPE._hints
+ else:
+ assert TYPE._hints["stm_access_directly"] == True
+
class TestOOtype(BaseTestRclass, OORtypeMixin):
More information about the pypy-commit
mailing list