[pypy-svn] pypy ootype-virtualrefs: implement int_between for the cli backend
antocuni
commits-noreply at bitbucket.org
Thu Apr 7 12:31:39 CEST 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: ootype-virtualrefs
Changeset: r43194:a92cd3b9d3f1
Date: 2011-04-07 12:31 +0200
http://bitbucket.org/pypy/pypy/changeset/a92cd3b9d3f1/
Log: implement int_between for the cli backend
diff --git a/pypy/rpython/test/test_rint.py b/pypy/rpython/test/test_rint.py
--- a/pypy/rpython/test/test_rint.py
+++ b/pypy/rpython/test/test_rint.py
@@ -4,7 +4,7 @@
from pypy.annotation import model as annmodel
from pypy.rpython.test import snippet
from pypy.rlib.rarithmetic import r_int, r_uint, r_longlong, r_ulonglong
-from pypy.rlib.rarithmetic import ovfcheck, r_int64, intmask
+from pypy.rlib.rarithmetic import ovfcheck, r_int64, intmask, int_between
from pypy.rlib import objectmodel
from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
@@ -396,6 +396,18 @@
else:
assert res == 123456789012345678
+ def test_int_between(self):
+ def fn(a, b, c):
+ return int_between(a, b, c)
+ assert self.interpret(fn, [1, 1, 3])
+ assert self.interpret(fn, [1, 2, 3])
+ assert not self.interpret(fn, [1, 0, 2])
+ assert not self.interpret(fn, [1, 5, 2])
+ assert not self.interpret(fn, [1, 2, 2])
+ assert not self.interpret(fn, [1, 1, 1])
+
+
+
class TestLLtype(BaseTestRint, LLRtypeMixin):
pass
diff --git a/pypy/rpython/llinterp.py b/pypy/rpython/llinterp.py
--- a/pypy/rpython/llinterp.py
+++ b/pypy/rpython/llinterp.py
@@ -673,7 +673,6 @@
return frame.eval()
def op_direct_call(self, f, *args):
- import pdb;pdb.set_trace()
FTYPE = self.llinterpreter.typer.type_system.derefType(lltype.typeOf(f))
return self.perform_call(f, FTYPE.ARGS, args)
diff --git a/pypy/translator/cli/opcodes.py b/pypy/translator/cli/opcodes.py
--- a/pypy/translator/cli/opcodes.py
+++ b/pypy/translator/cli/opcodes.py
@@ -71,6 +71,8 @@
'hint': [PushArg(0), StoreResult],
'direct_call': [Call],
'indirect_call': [IndirectCall],
+ 'int_between': [PushAllArgs, 'call bool [pypylib]pypy.runtime.Utils::IntBetween(int32, int32, int32)'],
+
'cast_ptr_to_weakadr': [PushAllArgs, 'newobj instance void class %s::.ctor(object)' % WEAKREF],
'gc__collect': 'call void class [mscorlib]System.GC::Collect()',
diff --git a/pypy/translator/cli/src/pypylib.cs b/pypy/translator/cli/src/pypylib.cs
--- a/pypy/translator/cli/src/pypylib.cs
+++ b/pypy/translator/cli/src/pypylib.cs
@@ -501,6 +501,11 @@
}
}
+ public static bool IntBetween(int a, int b, int c)
+ {
+ return a <= b && b < c;
+ }
+
public static bool Equal<T>(T t1, T t2)
{
if (t1 == null)
More information about the Pypy-commit
mailing list