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

antocuni at codespeak.net antocuni at codespeak.net
Sat May 27 14:40:38 CEST 2006


Author: antocuni
Date: Sat May 27 14:40:25 2006
New Revision: 27763

Modified:
   pypy/dist/pypy/translator/cli/cts.py
   pypy/dist/pypy/translator/cli/database.py
   pypy/dist/pypy/translator/cli/opcodes.py
   pypy/dist/pypy/translator/cli/src/pypylib.cs
   pypy/dist/pypy/translator/cli/test/runtest.py
   pypy/dist/pypy/translator/cli/test/test_op.py
Log:
Added support for unicode character. Some bugfixes.



Modified: pypy/dist/pypy/translator/cli/cts.py
==============================================================================
--- pypy/dist/pypy/translator/cli/cts.py	(original)
+++ pypy/dist/pypy/translator/cli/cts.py	Sat May 27 14:40:25 2006
@@ -4,9 +4,7 @@
 
 import exceptions
 
-#from pypy.rpython.lltypesystem.lltype import Signed, Unsigned, Void, Bool, Float
 from pypy.rpython.lltypesystem.lltype import SignedLongLong, UnsignedLongLong
-#from pypy.rpython.ootypesystem.ootype import Instance, Class, StaticMethod, List, Record, Dict
 from pypy.rpython.ootypesystem import ootype
 from pypy.translator.cli.option import getoption
 from pypy.translator.cli import oopspec
@@ -29,6 +27,7 @@
     ootype.Bool: 'bool',
     ootype.Float: 'float64',
     ootype.Char: 'char',
+    ootype.UniChar: 'char',
     ootype.Class: 'class [mscorlib]System.Type',
 
     # maps generic types to their ordinal

Modified: pypy/dist/pypy/translator/cli/database.py
==============================================================================
--- pypy/dist/pypy/translator/cli/database.py	(original)
+++ pypy/dist/pypy/translator/cli/database.py	Sat May 27 14:40:25 2006
@@ -141,7 +141,7 @@
             pass
         elif TYPE is ootype.Bool:
             ilasm.opcode('ldc.i4', str(int(value)))
-        elif TYPE is ootype.Char:
+        elif TYPE is ootype.Char or TYPE is ootype.UniChar:
             ilasm.opcode('ldc.i4', ord(value))
         elif TYPE is ootype.Float:
             ilasm.opcode('ldc.r8', repr(value))

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 14:40:25 2006
@@ -62,8 +62,8 @@
     'char_gt':                  'cgt',
     'char_ge':                  _not('clt'),
 
-    'unichar_eq':               None,      # should we unify unichar and char, as Jython does?
-    'unichar_ne':               None,
+    'unichar_eq':               'ceq',
+    'unichar_ne':               _not('ceq'),
 
     'int_is_true':              DoNothing,
     'int_neg':                  'neg',
@@ -187,7 +187,7 @@
     'ullong_lt':                'clt.un',
     'ullong_le':                _not('cgt.un'),
     'ullong_eq':                'ceq',
-    'ullong_ne':                _not('ceq.un'),
+    'ullong_ne':                _not('ceq'),
     'ullong_gt':                'cgt.un',
     'ullong_ge':                _not('clt.un'),
 

Modified: pypy/dist/pypy/translator/cli/src/pypylib.cs
==============================================================================
--- pypy/dist/pypy/translator/cli/src/pypylib.cs	(original)
+++ pypy/dist/pypy/translator/cli/src/pypylib.cs	Sat May 27 14:40:25 2006
@@ -11,6 +11,7 @@
         public static string ToPython(char x)   { return string.Format("'{0}'", x); }
         public static string ToPython(uint x)   { return x.ToString(); }
         public static string ToPython(long x)   { return x.ToString(); }
+        public static string ToPython(ulong x)  { return x.ToString(); }
 
         public static string ToPython(object obj) 
         { 

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 14:40:25 2006
@@ -173,14 +173,13 @@
 
         arglist = SDK.runtime() + [self._exe] + map(str, args)
         env = os.environ.copy()
-        env['LANG'] = 'C'        
+        env['LANG'] = 'C'
         mono = subprocess.Popen(arglist, stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE, env=env)
         stdout, stderr = mono.communicate()
         retval = mono.wait()
         assert retval == 0, stderr
 
-        print stdout
         res = eval(stdout)
         if isinstance(res, tuple):
             res = StructTuple(res) # so tests can access tuple elements with .item0, .item1, etc.

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 14:40:25 2006
@@ -6,10 +6,10 @@
 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')
@@ -18,25 +18,36 @@
     yield check, op_any_le, [char, char], ('a', 'b')
     yield check, op_any_le, [char, char], ('b', 'a')
 
+    yield check, op_unichar_eq, [int, int], (0, 0)
+    yield check, op_unichar_ne, [int, int], (0, 1)
+
     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 '_long_' in name:
+            yield check, func, [r_longlong, r_longlong], (r_longlong(sys.maxint*3), r_longlong(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 '_ulong_' in name:
+            yield check, func, [r_ulonglong, r_ulonglong], (r_ulonglong(sys.maxint*3), r_ulonglong(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 '_float_' in name:
+            yield check, func, [float, float], (42.0, (10.0/3))
 
-##        if any or '_ulong_' in name:
-##            yield check, func, [r_ulonglong, r_ulonglong], (r_ulonglong(sys.maxint*3), r_ulonglong(42))
+def op_unichar_eq(x, y):
+    const = [u'\u03b1', u'\u03b2']
+    return const[x] == const[y]
 
-##        if any or '_float_' in name:
-##            yield check, func, [float, float], (42.0, (10.0/3))
+def op_unichar_ne(x, y):
+    const = [u'\u03b1', u'\u03b2']
+    return const[x] != const[y]
 
 
 def op_any_eq(x, y):



More information about the Pypy-commit mailing list