[pypy-svn] r41116 - in pypy/dist/pypy/rpython: lltypesystem test
pedronis at codespeak.net
pedronis at codespeak.net
Thu Mar 22 19:46:28 CET 2007
Author: pedronis
Date: Thu Mar 22 19:46:26 2007
New Revision: 41116
Modified:
pypy/dist/pypy/rpython/lltypesystem/rclass.py
pypy/dist/pypy/rpython/test/test_rclass.py
Log:
(arigo, pedronis)
let attach immutable hints to classes (this can be used by the timeshifter produced code)
Modified: pypy/dist/pypy/rpython/lltypesystem/rclass.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rclass.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/rclass.py Thu Mar 22 19:46:26 2007
@@ -357,6 +357,9 @@
adtmeths = {}
if hints is None:
hints = {}
+ if '_immutable_' in self.classdef.classdesc.classdict:
+ hints = hints.copy()
+ hints['immutable'] = True
object_type = MkStruct(self.classdef.name,
('super', self.rbase.object_type),
hints=hints,
Modified: pypy/dist/pypy/rpython/test/test_rclass.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rclass.py (original)
+++ pypy/dist/pypy/rpython/test/test_rclass.py Thu Mar 22 19:46:26 2007
@@ -5,6 +5,7 @@
from pypy.rpython.ootypesystem import ootype
from pypy.rlib.rarithmetic import intmask
from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from pypy.objspace.flow.model import summary
class EmptyBase(object):
pass
@@ -652,6 +653,21 @@
assert destrptra is not None
assert destrptrb is not None
+ def test_immutable(self):
+ class I(object):
+ _immutable_ = True
+
+ def __init__(self, v):
+ self.v = v
+
+ i = I(3)
+ def f():
+ return i.v
+
+ t, typer, graph = self.gengraph(f, [], backendopt=True)
+ assert summary(graph) == {}
+
+
class TestOOtype(BaseTestRclass, OORtypeMixin):
def test__del__(self):
More information about the Pypy-commit
mailing list