[pypy-svn] r46739 - in pypy/dist/pypy: annotation annotation/test jit/codegen/test rpython rpython/lltypesystem rpython/test
cfbolz at codespeak.net
cfbolz at codespeak.net
Wed Sep 19 17:56:34 CEST 2007
Author: cfbolz
Date: Wed Sep 19 17:56:33 2007
New Revision: 46739
Modified:
pypy/dist/pypy/annotation/binaryop.py
pypy/dist/pypy/annotation/test/test_annrpython.py
pypy/dist/pypy/jit/codegen/test/operation_tests.py
pypy/dist/pypy/rpython/lltypesystem/lloperation.py
pypy/dist/pypy/rpython/lltypesystem/opimpl.py
pypy/dist/pypy/rpython/rfloat.py
pypy/dist/pypy/rpython/test/snippet.py
pypy/dist/pypy/rpython/test/test_rfloat.py
Log:
issue311 in-progress
remove most support for float ** float. Annotator, rtyper is done, some
backends missing
Modified: pypy/dist/pypy/annotation/binaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/binaryop.py (original)
+++ pypy/dist/pypy/annotation/binaryop.py Wed Sep 19 17:56:33 2007
@@ -434,16 +434,12 @@
truediv = div
def pow((flt1, flt2), obj3):
- return SomeFloat()
- pow.can_only_throw = [ZeroDivisionError, ValueError, OverflowError]
+ raise NotImplementedError("float power not supported, use math.pow")
# repeat these in order to copy the 'can_only_throw' attribute
inplace_div = div
inplace_truediv = truediv
- def inplace_pow((flt1, flt2)):
- return SomeFloat()
- inplace_pow.can_only_throw = [ZeroDivisionError, ValueError, OverflowError]
class __extend__(pairtype(SomeList, SomeList)):
Modified: pypy/dist/pypy/annotation/test/test_annrpython.py
==============================================================================
--- pypy/dist/pypy/annotation/test/test_annrpython.py (original)
+++ pypy/dist/pypy/annotation/test/test_annrpython.py Wed Sep 19 17:56:33 2007
@@ -2829,6 +2829,18 @@
assert isinstance(s, annmodel.SomeInteger)
assert not s.is_constant()
+ def test_float_pow_unsupported(self):
+ def f(x, y):
+ x **= y
+ return x ** y
+ a = self.RPythonAnnotator()
+ s = a.build_types(f, [int, int])
+ assert isinstance(s, annmodel.SomeInteger)
+ a = self.RPythonAnnotator()
+ py.test.raises(NotImplementedError, a.build_types, f, [float, float])
+
+
+
def g(n):
return [0,1,2,n]
Modified: pypy/dist/pypy/jit/codegen/test/operation_tests.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/test/operation_tests.py (original)
+++ pypy/dist/pypy/jit/codegen/test/operation_tests.py Wed Sep 19 17:56:33 2007
@@ -320,13 +320,6 @@
assert fp(40.0, 2.0) == fn(40.0, 2.0), op
assert fp(25.125, 1.5) == fn(25.125, 1.5), op
- def test_float_pow(self): #harder test for llvm
- for op, fn in [('x ** y', lambda x, y: x ** y), #not supported in llvm backend
- ]:
- fp = self.rgen(fn, [float, float], float)
- assert fp(40.0, 2.0) == fn(40.0, 2.0), op
- assert fp(25.125, 1.5) == fn(25.125, 1.5), op
-
def test_float_cast(self): #because of different rettype
for op, fn in [('bool(x)', lambda x: bool(x)),
('bool(2.0 - x)', lambda x: bool(x - 2.0)),
Modified: pypy/dist/pypy/rpython/lltypesystem/lloperation.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/lloperation.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/lloperation.py Wed Sep 19 17:56:33 2007
@@ -236,8 +236,8 @@
'float_ne': LLOp(canfold=True),
'float_gt': LLOp(canfold=True),
'float_ge': LLOp(canfold=True),
- 'float_pow': LLOp(canfold=True),
# don't implement float_mod, use math.fmod instead
+ # don't implement float_pow, use math.pow instead
'llong_is_true': LLOp(canfold=True),
'llong_neg': LLOp(canfold=True),
Modified: pypy/dist/pypy/rpython/lltypesystem/opimpl.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/opimpl.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/opimpl.py Wed Sep 19 17:56:33 2007
@@ -265,12 +265,6 @@
assert -sys.maxint-1 <= b <= sys.maxint
return int(b)
-def op_float_pow(b,c):
- assert type(b) is float
- assert type(c) is float
- return math.pow(b,c)
-
-
def op_cast_pointer(RESTYPE, obj):
checkptr(obj)
return lltype.cast_pointer(RESTYPE, obj)
Modified: pypy/dist/pypy/rpython/rfloat.py
==============================================================================
--- pypy/dist/pypy/rpython/rfloat.py (original)
+++ pypy/dist/pypy/rpython/rfloat.py Wed Sep 19 17:56:33 2007
@@ -53,16 +53,7 @@
# 'floordiv' on floats not supported in RPython
- def rtype_pow(_, hop):
- s_float3 = hop.args_s[2]
- if s_float3.is_constant() and s_float3.const is None:
- vlist = hop.inputargs(Float, Float, Void)[:2]
- return hop.genop('float_pow', vlist, resulttype=Float)
- else:
- raise TyperError("cannot handle pow with three float arguments")
-
- def rtype_inplace_pow(_, hop):
- return _rtype_template(hop, 'pow')
+ # pow on floats not supported in RPython
#comparisons: eq is_ ne lt le gt ge
Modified: pypy/dist/pypy/rpython/test/snippet.py
==============================================================================
--- pypy/dist/pypy/rpython/test/snippet.py (original)
+++ pypy/dist/pypy/rpython/test/snippet.py Wed Sep 19 17:56:33 2007
@@ -114,9 +114,6 @@
i += abs(i)
i &= 255
- i **= n
- i += n**3
-
i += -n
i += +n
i += not n
Modified: pypy/dist/pypy/rpython/test/test_rfloat.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rfloat.py (original)
+++ pypy/dist/pypy/rpython/test/test_rfloat.py Wed Sep 19 17:56:33 2007
@@ -102,12 +102,6 @@
res = self.interpret(fn, [])
assert self.float_eq(res, 42.0)
- def test_pow(self):
- def fn(x, y):
- return x**y
- res = self.interpret(fn, [2.0, 3.0])
- assert res == 8.0
-
def test_exceptions(self):
def fn(x, y, z):
try:
More information about the Pypy-commit
mailing list