[pypy-svn] r12210 - in pypy/dist/pypy: annotation rpython/test
pedronis at codespeak.net
pedronis at codespeak.net
Thu May 12 13:06:58 CEST 2005
Author: pedronis
Date: Thu May 12 13:06:58 2005
New Revision: 12210
Modified:
pypy/dist/pypy/annotation/unaryop.py
pypy/dist/pypy/rpython/test/test_llann.py
Log:
same semantics as concrete impl len for ptrs, test
Modified: pypy/dist/pypy/annotation/unaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/unaryop.py (original)
+++ pypy/dist/pypy/annotation/unaryop.py Thu May 12 13:06:58 2005
@@ -434,6 +434,9 @@
v = getattr(p.ll_ptrtype._example(), s_attr.const)
return ll_to_annotation(v)
+ def len(p):
+ return ll_to_annotation(len(p.ll_ptrtype._example()))
+
def setattr(p, s_attr, s_value): # just doing checking
assert s_attr.is_constant(), "getattr on ptr %r with non-constant field-name" % p.ll_ptrtype
v_lltype = annotation_to_lltype(s_value)
Modified: pypy/dist/pypy/rpython/test/test_llann.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_llann.py (original)
+++ pypy/dist/pypy/rpython/test/test_llann.py Thu May 12 13:06:58 2005
@@ -60,3 +60,12 @@
s = a.build_types(llf, [])
assert isinstance(s, annmodel.SomePtr)
assert s.ll_ptrtype == GCPS1
+
+ def test_array_length(self):
+ A = Array(('v', Signed))
+ def llf():
+ a = malloc(A, 1)
+ return len(a)
+ a = self.RPythonAnnotator()
+ s = a.build_types(llf, [])
+ assert s.knowntype == int
More information about the Pypy-commit
mailing list