[pypy-svn] r13748 - in pypy/dist/pypy/rpython: . test
pedronis at codespeak.net
pedronis at codespeak.net
Thu Jun 23 21:41:40 CEST 2005
Author: pedronis
Date: Thu Jun 23 21:41:39 2005
New Revision: 13748
Modified:
pypy/dist/pypy/rpython/rbuiltin.py
pypy/dist/pypy/rpython/test/test_rint.py
Log:
rtyper support for min(int, int)
Modified: pypy/dist/pypy/rpython/rbuiltin.py
==============================================================================
--- pypy/dist/pypy/rpython/rbuiltin.py (original)
+++ pypy/dist/pypy/rpython/rbuiltin.py Thu Jun 23 21:41:39 2005
@@ -4,7 +4,7 @@
from pypy.rpython import rarithmetic
from pypy.rpython.rtyper import TyperError
from pypy.rpython.rrange import rtype_builtin_range
-from pypy.rpython.rmodel import Repr, TyperError
+from pypy.rpython.rmodel import Repr, TyperError, IntegerRepr
from pypy.rpython import rptr
from pypy.rpython.robject import pyobj_repr
from pypy.rpython.rfloat import float_repr
@@ -108,6 +108,19 @@
vlist = hop.inputargs(lltype.Unsigned)
return vlist[0]
+def rtype_builtin_min(hop):
+ rint1, rint2 = hop.args_r
+ assert isinstance(rint1, IntegerRepr)
+ assert isinstance(rint2, IntegerRepr)
+ assert rint1.lowleveltype == rint2.lowleveltype
+ v1, v2 = hop.inputargs(rint1, rint2)
+ return hop.gendirectcall(ll_min, v1, v2)
+
+def ll_min(i1, i2):
+ if i1 < i2:
+ return i1
+ return i2
+
# collect all functions
import __builtin__
Modified: pypy/dist/pypy/rpython/test/test_rint.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rint.py (original)
+++ pypy/dist/pypy/rpython/test/test_rint.py Thu Jun 23 21:41:39 2005
@@ -93,3 +93,12 @@
res = ev_fun(-1)
assert res is False # -1 ==> 0xffffffff
+
+def test_int_min():
+ def fn(i, j):
+ return min(i,j)
+ ev_fun = make_interpreter(fn, [0, 0])
+ assert ev_fun(1, 2) == 1
+ assert ev_fun(1, -1) == -1
+ assert ev_fun(2, 2) == 2
+ assert ev_fun(-1, -12) == -12
More information about the Pypy-commit
mailing list