[pypy-svn] r27750 - in pypy/dist/pypy/translator/cli: . test

antocuni at codespeak.net antocuni at codespeak.net
Sat May 27 12:03:38 CEST 2006


Author: antocuni
Date: Sat May 27 12:03:27 2006
New Revision: 27750

Modified:
   pypy/dist/pypy/translator/cli/gencli.py
   pypy/dist/pypy/translator/cli/opcodes.py
   pypy/dist/pypy/translator/cli/test/runtest.py
   pypy/dist/pypy/translator/cli/test/test_op.py
Log:
Fixed a bug that prevented code to compile when exception were not used.

Added some char support.



Modified: pypy/dist/pypy/translator/cli/gencli.py
==============================================================================
--- pypy/dist/pypy/translator/cli/gencli.py	(original)
+++ pypy/dist/pypy/translator/cli/gencli.py	Sat May 27 12:03:27 2006
@@ -9,7 +9,6 @@
 from pypy.translator.cli.database import LowLevelDatabase
 from pypy.translator.cli.cts import CTS
 from pypy.translator.cli.opcodes import opcodes
-from pypy.translator.squeak.node import LoopFinder
 
 class Tee(object):
     def __init__(self, *args):
@@ -25,14 +24,18 @@
                 outfile.close()
 
 class GenCli(object):
-    def __init__(self, tmpdir, translator, entrypoint = None, type_system_class = CTS, \
-        opcode_dict = opcodes, name_suffix = '.il', function_class = Function ):
+    def __init__(self, tmpdir, translator, entrypoint=None, type_system_class=CTS,
+                 opcode_dict=opcodes, name_suffix='.il', function_class=Function,
+                 pending_graphs=()):
         self.tmpdir = tmpdir
         self.translator = translator
         self.entrypoint = entrypoint
         self.db = LowLevelDatabase( type_system_class = type_system_class , opcode_dict = opcode_dict,
             function_class = function_class )
 
+        for graph in pending_graphs:
+            self.db.pending_function(graph)
+
         if entrypoint is None:
             self.assembly_name = self.translator.graphs[0].name
         else:

Modified: pypy/dist/pypy/translator/cli/opcodes.py
==============================================================================
--- pypy/dist/pypy/translator/cli/opcodes.py	(original)
+++ pypy/dist/pypy/translator/cli/opcodes.py	Sat May 27 12:03:27 2006
@@ -55,12 +55,12 @@
 
     'bool_not':                 [PushAllArgs]+Not,
 
-    'char_lt':                  None,
-    'char_le':                  None,
-    'char_eq':                  None,
-    'char_ne':                  None,
-    'char_gt':                  None,
-    'char_ge':                  None,
+    'char_lt':                  'clt',
+    'char_le':                  _not('cgt'),
+    'char_eq':                  'ceq',
+    'char_ne':                  _not('ceq'),
+    'char_gt':                  'cgt',
+    'char_ge':                  _not('clt'),
 
     'unichar_eq':               None,      # should we unify unichar and char, as Jython does?
     'unichar_ne':               None,

Modified: pypy/dist/pypy/translator/cli/test/runtest.py
==============================================================================
--- pypy/dist/pypy/translator/cli/test/runtest.py	(original)
+++ pypy/dist/pypy/translator/cli/test/runtest.py	Sat May 27 12:03:27 2006
@@ -126,10 +126,17 @@
             ann.build_graph_types(graph, inputcells)
             t.graphs.insert(0, graph)
         else:
-            t.buildannotator().build_types(func, annotation)
-            
+            ann = t.buildannotator()
+            ann.build_types(func, annotation)
+
+        # quick hack: force exceptions.Exception to be rendered
+        def raiseKeyError():
+            raise KeyError
+        ann.build_types(raiseKeyError, [])
+
         t.buildrtyper(type_system="ootype").specialize()
         self.graph = t.graphs[0]
+        raiseKeyError_graph = t.graphs[1]
 
         if getoption('view'):
            t.view()
@@ -139,7 +146,7 @@
         else:
             self.tmpdir = udir
 
-        return GenCli(self.tmpdir, t, TestEntryPoint(self.graph))
+        return GenCli(self.tmpdir, t, TestEntryPoint(self.graph), pending_graphs=[raiseKeyError_graph])
 
     def _build_exe(self):        
         tmpfile = self._gen.generate_source()

Modified: pypy/dist/pypy/translator/cli/test/test_op.py
==============================================================================
--- pypy/dist/pypy/translator/cli/test/test_op.py	(original)
+++ pypy/dist/pypy/translator/cli/test/test_op.py	Sat May 27 12:03:27 2006
@@ -1,35 +1,49 @@
 from pypy.translator.cli.test.runtest import check
 from pypy.rpython.rarithmetic import r_uint, r_ulonglong, r_longlong
-
+from pypy.annotation import model as annmodel
 import sys
 
+char = annmodel.SomeChar()
+
 def test_op():
-    yield check, op_any_ge, [int, int], (42, 42)
-    yield check, op_any_ge, [int, int], (13, 42)    
-    yield check, op_any_le, [int, int], (42, 42)
-    yield check, op_any_le, [int, int], (13, 42)    
-    
+##    yield check, op_any_ge, [int, int], (42, 42)
+##    yield check, op_any_ge, [int, int], (13, 42)
+##    yield check, op_any_le, [int, int], (42, 42)
+##    yield check, op_any_le, [int, int], (13, 42)
+
+    yield check, op_any_eq, [char, char], ('a', 'a')
+    yield check, op_any_ne, [char, char], ('a', 'b')
+    yield check, op_any_ge, [char, char], ('a', 'b')
+    yield check, op_any_ge, [char, char], ('b', 'a')
+    yield check, op_any_le, [char, char], ('a', 'b')
+    yield check, op_any_le, [char, char], ('b', 'a')
+
     for name, func in globals().iteritems():
         if not name.startswith('op_'):
             continue
 
         any = '_any_' in name
-        if any or '_int_' in name:
-            yield check, func, [int, int], (42, 13)
+##        if any or '_int_' in name:
+##            yield check, func, [int, int], (42, 13)
+
+##        if any or '_uint_' in name:
+##            yield check, func, [r_uint, r_uint], (r_uint(sys.maxint+1), r_uint(42))
 
-        if any or '_uint_' in name:
-            yield check, func, [r_uint, r_uint], (r_uint(sys.maxint+1), r_uint(42))
+##        if any or '_long_' in name:
+##            yield check, func, [r_longlong, r_longlong], (r_longlong(sys.maxint*3), r_longlong(42))
 
-        if any or '_long_' in name:
-            yield check, func, [r_longlong, r_longlong], (r_longlong(sys.maxint*3), r_longlong(42))
+##        if any or '_ulong_' in name:
+##            yield check, func, [r_ulonglong, r_ulonglong], (r_ulonglong(sys.maxint*3), r_ulonglong(42))
 
-        if any or '_ulong_' in name:
-            yield check, func, [r_ulonglong, r_ulonglong], (r_ulonglong(sys.maxint*3), r_ulonglong(42))
+##        if any or '_float_' in name:
+##            yield check, func, [float, float], (42.0, (10.0/3))
 
-        if any or '_float_' in name:
-            yield check, func, [float, float], (42.0, (10.0/3))
 
+def op_any_eq(x, y):
+    return x == y
 
+def op_any_ne(x, y):
+    return x != y
 
 def op_int_long_float_neg(x, y):
     return -x



More information about the Pypy-commit mailing list