[pypy-svn] r47943 - in pypy/dist/pypy: objspace/std translator/cli translator/jvm
xoraxax at codespeak.net
xoraxax at codespeak.net
Thu Oct 25 16:53:58 CEST 2007
Author: xoraxax
Date: Thu Oct 25 16:53:58 2007
New Revision: 47943
Modified:
pypy/dist/pypy/objspace/std/formatting.py
pypy/dist/pypy/translator/cli/ilgenerator.py
pypy/dist/pypy/translator/jvm/generator.py
Log:
Removed three other isnan or isinf occurences in the code.
Modified: pypy/dist/pypy/objspace/std/formatting.py
==============================================================================
--- pypy/dist/pypy/objspace/std/formatting.py (original)
+++ pypy/dist/pypy/objspace/std/formatting.py Thu Oct 25 16:53:58 2007
@@ -2,7 +2,7 @@
String formatting routines.
"""
from pypy.rlib.unroll import unrolling_iterable
-from pypy.rlib.rarithmetic import ovfcheck, formatd_overflow
+from pypy.rlib.rarithmetic import ovfcheck, formatd_overflow, isnan, isinf
from pypy.interpreter.error import OperationError
from pypy.tool.sourcetools import func_with_new_name
@@ -489,12 +489,3 @@
hex_num_helper = format_num_helper_generator('%x', '0123456789abcdef')
-# isinf isn't too hard...
-def isinf(v):
- return v != 0 and v*2.0 == v
-
-# To get isnan, working x-platform and both on 2.3 and 2.4, is a
-# horror. I think this works (for reasons I don't really want to talk
-# about), and probably when implemented on top of pypy, too.
-def isnan(v):
- return v != v*1.0 or (v == 1.0 and v == 2.0)
Modified: pypy/dist/pypy/translator/cli/ilgenerator.py
==============================================================================
--- pypy/dist/pypy/translator/cli/ilgenerator.py (original)
+++ pypy/dist/pypy/translator/cli/ilgenerator.py Thu Oct 25 16:53:58 2007
@@ -1,17 +1,13 @@
from pypy.rpython.lltypesystem.lltype import Signed, Unsigned, Void, Bool, Float
from pypy.rpython.lltypesystem.lltype import SignedLongLong, UnsignedLongLong
from pypy.rlib.objectmodel import CDefinedIntSymbolic
+from pypy.rlib.rarithmetic import isnan, isinf
from pypy.rpython.ootypesystem import ootype
from pypy.translator.oosupport.metavm import Generator
from pypy.translator.oosupport.constant import push_constant
from pypy.objspace.flow import model as flowmodel
from pypy.translator.cli.support import string_literal
-def isnan(v):
- return v != v*1.0 or (v == 1.0 and v == 2.0)
-
-def isinf(v):
- return v!=0 and (v == v*2)
class CodeGenerator(object):
def __init__(self, out, indentstep = 4, startblock = '{', endblock = '}'):
Modified: pypy/dist/pypy/translator/jvm/generator.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/generator.py (original)
+++ pypy/dist/pypy/translator/jvm/generator.py Thu Oct 25 16:53:58 2007
@@ -4,6 +4,7 @@
from pypy.translator.oosupport.function import render_sub_op
from pypy.rpython.ootypesystem import ootype
from pypy.rlib.objectmodel import CDefinedIntSymbolic
+from pypy.rlib.rarithmetic import isnan, isinf
from pypy.translator.oosupport.constant import push_constant
import pypy.translator.jvm.typesystem as jvmtype
from pypy.translator.jvm.typesystem import \
@@ -14,14 +15,6 @@
jObjectArray, jPyPyInterlink, jPyPyCustomDict, jPyPyEquals, \
jPyPyHashCode, jMap, jPyPyWeakRef, jSystem, jll_os
-# ___________________________________________________________________________
-# Miscellaneous helper functions
-
-def _isnan(v):
- return v != v*1.0 or (v == 1.0 and v == 2.0)
-
-def _isinf(v):
- return v!=0 and (v == v*2)
# ___________________________________________________________________________
# JVM Opcodes:
@@ -1109,9 +1102,9 @@
self.emit(LDC2, value)
def _push_double_constant(self, value):
- if _isnan(value):
+ if isnan(value):
DOUBLENAN.load(self)
- elif _isinf(value):
+ elif isinf(value):
if value > 0: DOUBLEPOSINF.load(self)
else: DOUBLENEGINF.load(self)
elif value == 0.0:
More information about the Pypy-commit
mailing list