[pypy-svn] r22954 - in pypy/dist/pypy: jit jit/test translator/tool/pygame

pedronis at codespeak.net pedronis at codespeak.net
Thu Feb 2 14:04:55 CET 2006


Author: pedronis
Date: Thu Feb  2 14:04:54 2006
New Revision: 22954

Modified:
   pypy/dist/pypy/jit/hintmodel.py
   pypy/dist/pypy/jit/test/test_hint_annotation.py
   pypy/dist/pypy/translator/tool/pygame/drawgraph.py
Log:
some more ops.

a test with an even more toy interpreter, propably a good candidate for "rtyping" before the tl interp itself.



Modified: pypy/dist/pypy/jit/hintmodel.py
==============================================================================
--- pypy/dist/pypy/jit/hintmodel.py	(original)
+++ pypy/dist/pypy/jit/hintmodel.py	Thu Feb  2 14:04:54 2006
@@ -16,6 +16,7 @@
 
 BINARY_OPERATIONS = """int_add int_sub int_mul int_mod int_and int_rshift int_floordiv
                        uint_add uint_sub uint_mul uint_mod uint_and uint_rshift uint_floordiv
+                       char_gt char_lt char_le char_ge char_eq char_ne
                        int_gt int_lt int_le int_ge int_eq int_ne
                        uint_gt uint_lt uint_le uint_ge uint_eq uint_ne
                        getarrayitem""".split()
@@ -318,6 +319,8 @@
     int_lt = int_le = int_ge = int_ne = int_gt = int_eq = define_binary(lltype.Bool)
     uint_lt = uint_le = uint_ge = uint_ne = uint_gt = uint_eq = int_eq
 
+    char_gt = char_lt = char_le = char_ge = char_eq = char_ne = int_eq
+
     def union((hs_c1, hs_c2)):
         assert hs_c1.concretetype == hs_c2.concretetype
         d = newset(hs_c1.origins, hs_c2.origins)

Modified: pypy/dist/pypy/jit/test/test_hint_annotation.py
==============================================================================
--- pypy/dist/pypy/jit/test/test_hint_annotation.py	(original)
+++ pypy/dist/pypy/jit/test/test_hint_annotation.py	Thu Feb  2 14:04:54 2006
@@ -358,3 +358,20 @@
 def test_hannotate_tl():
     from pypy.jit import tl
     hannotate(tl.interp, [str, int], policy=P_OOPSPEC)
+
+def test_hannotate_plus_minus():
+    def ll_plus_minus(s, x, y):
+        acc = x
+        n = len(s)
+        pc = 0
+        while pc < n:
+            op = s[pc]
+            op = hint(op, concrete=True)
+            if op == '+':
+                acc += y
+            elif op == '-':
+                acc -= y
+            pc += 1
+        return acc
+    assert ll_plus_minus("+-+", 0, 2) == 2
+    hannotate(ll_plus_minus, [str, int, int])

Modified: pypy/dist/pypy/translator/tool/pygame/drawgraph.py
==============================================================================
--- pypy/dist/pypy/translator/tool/pygame/drawgraph.py	(original)
+++ pypy/dist/pypy/translator/tool/pygame/drawgraph.py	Thu Feb  2 14:04:54 2006
@@ -237,8 +237,16 @@
     else:
         return abs(vy*(x-x0) - vx*(y-y0))
 
+FIXUP = True
+
 def splitline(line, re_word = re.compile(r'[^\s"]\S*|["]["]|["].*?[^\\]["]')):
     result = []
+    if FIXUP:
+        q = line.find('"')
+        lt = line.find("<")
+        if lt != -1 and (q == -1 or q > lt):
+            lq = line.rfind(">")
+            line = line[:lt] + '"?' + line[lt+1:lq] + '"'+line[lq+1:]
     for word in re_word.findall(line):
         if word.startswith('"'):
             word = eval(word)



More information about the Pypy-commit mailing list