[pypy-svn] r14054 - in pypy/dist/pypy/translator/llvm2: . test
ludal at codespeak.net
ludal at codespeak.net
Fri Jul 1 20:07:50 CEST 2005
Author: ludal
Date: Fri Jul 1 20:07:50 2005
New Revision: 14054
Modified:
pypy/dist/pypy/translator/llvm2/database.py
pypy/dist/pypy/translator/llvm2/funcnode.py
pypy/dist/pypy/translator/llvm2/pyxwrapper.py
pypy/dist/pypy/translator/llvm2/test/test_genllvm.py
Log:
(cfbolz, ludal):
implementation of floats + test
Modified: pypy/dist/pypy/translator/llvm2/database.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/database.py (original)
+++ pypy/dist/pypy/translator/llvm2/database.py Fri Jul 1 20:07:50 2005
@@ -8,7 +8,8 @@
PRIMITIVES_TO_LLVM = {lltype.Signed: "int",
lltype.Unsigned: "uint",
- lltype.Bool: "bool"}
+ lltype.Bool: "bool",
+ lltype.Float: "double" }
class Database(object):
def __init__(self, translator):
Modified: pypy/dist/pypy/translator/llvm2/funcnode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/funcnode.py (original)
+++ pypy/dist/pypy/translator/llvm2/funcnode.py Fri Jul 1 20:07:50 2005
@@ -125,7 +125,7 @@
'int_ne': 'setne',
'int_ge': 'setge',
'int_gt': 'setgt',
-
+
'uint_mul': 'mul',
'uint_add': 'add',
'uint_sub': 'sub',
@@ -136,7 +136,20 @@
'uint_eq': 'seteq',
'uint_ne': 'setne',
'uint_ge': 'setge',
- 'uint_gt': 'setgt'}
+ 'uint_gt': 'setgt',
+
+ 'float_mul': 'mul',
+ 'float_add': 'add',
+ 'float_sub': 'sub',
+ 'float_truediv': 'div',
+ 'float_mod': 'rem',
+ 'float_lt': 'setlt',
+ 'float_le': 'setle',
+ 'float_eq': 'seteq',
+ 'float_ne': 'setne',
+ 'float_ge': 'setge',
+ 'float_gt': 'setgt',
+ }
def __init__(self, db, codewriter):
self.db = db
@@ -148,7 +161,7 @@
else:
meth = getattr(self, op.opname, None)
assert meth is not None, "operation %r not found" %(op.opname,)
- meth(op)
+ meth(op)
def binaryop(self, op):
name = self.binary_operations[op.opname]
Modified: pypy/dist/pypy/translator/llvm2/pyxwrapper.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/pyxwrapper.py (original)
+++ pypy/dist/pypy/translator/llvm2/pyxwrapper.py Fri Jul 1 20:07:50 2005
@@ -4,7 +4,9 @@
PRIMITIVES_TO_C = {lltype.Signed: "int",
lltype.Unsigned: "unsigned int",
- lltype.Bool: "char"}
+ lltype.Bool: "char",
+ lltype.Float: "double",
+ }
def write_pyx_wrapper(funcgen, targetpath):
def c_declaration():
Modified: pypy/dist/pypy/translator/llvm2/test/test_genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/test/test_genllvm.py (original)
+++ pypy/dist/pypy/translator/llvm2/test/test_genllvm.py Fri Jul 1 20:07:50 2005
@@ -77,6 +77,22 @@
assert f(1) == 1
assert f(2) == 2
+def test_float_ops():
+ def ops(flt):
+ x = 0
+ x += flt < flt
+ x += flt <= flt
+ x += flt == flt
+ x += flt != flt
+ x += flt >= flt
+ x += flt > flt
+ #x += flt fs not None
+ #x += flt is None
+ return flt + 1 * flt / flt - 1
+ f = compile_function(ops, [float])
+ assert f(1) == 1
+ assert f(2) == 2
+
def test_function_call():
def callee():
@@ -112,7 +128,7 @@
f = compile_function(nested_tuple, [int])
assert f(4) == 4
-def test_string_getitem():
+def DONOTtest_string_getitem():
def string_test(i):
l = "Hello, World"
return l[i]
More information about the Pypy-commit
mailing list