[pypy-svn] r14372 - in pypy/dist/pypy/translator/llvm2: . test

rxe at codespeak.net rxe at codespeak.net
Thu Jul 7 11:23:24 CEST 2005


Author: rxe
Date: Thu Jul  7 11:23:23 2005
New Revision: 14372

Modified:
   pypy/dist/pypy/translator/llvm2/funcnode.py
   pypy/dist/pypy/translator/llvm2/test/test_genllvm.py
Log:
Add some more operations and add a test to do some simple string rpython
operations.



Modified: pypy/dist/pypy/translator/llvm2/funcnode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/funcnode.py	(original)
+++ pypy/dist/pypy/translator/llvm2/funcnode.py	Thu Jul  7 11:23:23 2005
@@ -161,13 +161,12 @@
 
     fnmapping = {
         "%ll_os_dup": "%dup",
-        "%ll_os_open": "%open",
         "%ll_os_close": "%close",
-        #"%": ("int" "%open", "sbyte*", "int"),
-        #"%ll_os_write": ("int" "%write", "int", "sbyte*", "int"),
+        "%ll_os_open": "%open",
         }
 
-    ignoreset = "%ll_time_time %ll_time_clock %ll_time_sleep".split() 
+    ignoreset = "%ll_time_time %ll_time_clock %ll_time_sleep " \
+                "%ll_os_read %ll_os_write".split() 
 
     def __init__(self, db, value):
         self.db = db
@@ -226,10 +225,9 @@
         # get function name
         fnname = self.fnmapping[self.ref]
         
-        # call 
-
-        # map resulttype ??? XXX
+        # call
         if resulttype != "void":
+            # map resulttype ??? XXX
             codewriter.call("%res", resulttype, fnname, argrefs, argtypes)
             codewriter.ret(resulttype, "%res")
         else:
@@ -263,6 +261,13 @@
                          'uint_ge': 'setge',
                          'uint_gt': 'setgt',
 
+                         'char_lt': 'setlt',
+                         'char_le': 'setle',
+                         'char_eq': 'seteq',
+                         'char_ne': 'setne',
+                         'char_ge': 'setge',
+                         'char_gt': 'setgt',
+
                          'float_mul': 'mul',
                          'float_add': 'add',
                          'float_sub': 'sub',
@@ -295,6 +300,14 @@
                                  "0", 
                                  self.db.repr_arg(op.args[0]),
                                  )
+
+    def bool_not(self, op):
+        self.codewriter.binaryop("xor",
+                                 self.db.repr_arg(op.result),
+                                 self.db.repr_arg_type(op.args[0]),
+                                 self.db.repr_arg(op.args[0]), 
+                                 "true")
+
                     
 
     def binaryop(self, op):

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	Thu Jul  7 11:23:23 2005
@@ -379,6 +379,20 @@
         return ord(str(i))
     f = compile_function(string_simple, [int], view=False)
     assert f(0) 
+    
+def test_string_simple_ops(): 
+    def string_simple_ops(i): 
+        res = 0
+        s = str(i)
+        s2 = s + s + s + s
+        s3 = s + s + s + s
+        res += s != s2
+        res += s2 == s3
+        res += ord(s)
+        return res
+    f = compile_function(string_simple_ops, [int])
+    assert f(5) == ord('5') + 2
+        
 
 def Xtest_string_getitem1():
     l = "Hello, World"



More information about the Pypy-commit mailing list