[pypy-svn] r53332 - in pypy/dist/pypy: annotation rpython/module rpython/test
arigo at codespeak.net
arigo at codespeak.net
Fri Apr 4 16:09:02 CEST 2008
Author: arigo
Date: Fri Apr 4 16:09:00 2008
New Revision: 53332
Modified:
pypy/dist/pypy/annotation/bookkeeper.py
pypy/dist/pypy/rpython/module/support.py
pypy/dist/pypy/rpython/test/test_rstr.py
Log:
(antocuni, niko, arigo, (cfbolz you've been spotted lurking))
Support for prebuilt ootype._string constants in the annotator.
Support for null string in string_to_ll().
Modified: pypy/dist/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/dist/pypy/annotation/bookkeeper.py (original)
+++ pypy/dist/pypy/annotation/bookkeeper.py Fri Apr 4 16:09:00 2008
@@ -415,7 +415,7 @@
result = SomeOOClass(x._INSTANCE) # NB. can be None
elif isinstance(x, ootype.instance_impl): # XXX
result = SomeOOInstance(ootype.typeOf(x))
- elif isinstance(x, ootype._record):
+ elif isinstance(x, (ootype._record, ootype._string)):
result = SomeOOInstance(ootype.typeOf(x))
elif callable(x):
if hasattr(x, '__self__') and x.__self__ is not None:
Modified: pypy/dist/pypy/rpython/module/support.py
==============================================================================
--- pypy/dist/pypy/rpython/module/support.py (original)
+++ pypy/dist/pypy/rpython/module/support.py Fri Apr 4 16:09:00 2008
@@ -54,6 +54,8 @@
_mixin_ = True
def to_rstr(s):
+ if s is None:
+ return ootype.null(ootype.String)
return ootype.oostring(s, -1)
to_rstr = staticmethod(to_rstr)
Modified: pypy/dist/pypy/rpython/test/test_rstr.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rstr.py (original)
+++ pypy/dist/pypy/rpython/test/test_rstr.py Fri Apr 4 16:09:00 2008
@@ -806,6 +806,20 @@
res = self.interpret(f, [self.string_to_ll(const("abba"))])
assert res
+ def test_prebuilt_ll_strings(self):
+ llstr0 = self.string_to_ll(None)
+ assert not llstr0
+ llstr1 = self.string_to_ll("hello")
+ def f(i):
+ if i == 0:
+ return llstr0
+ else:
+ return llstr1
+ res = self.interpret(f, [0])
+ assert res == self.string_to_ll(None)
+ res = self.interpret(f, [1])
+ assert self.ll_to_string(res) == "hello"
+
def FIXME_test_str_to_pystringobj():
def f(n):
if n >= 0:
More information about the Pypy-commit
mailing list