[pypy-svn] r12751 - pypy/dist/pypy/annotation

pedronis at codespeak.net pedronis at codespeak.net
Mon May 23 19:58:36 CEST 2005


Author: pedronis
Date: Mon May 23 19:58:36 2005
New Revision: 12751

Modified:
   pypy/dist/pypy/annotation/binaryop.py
   pypy/dist/pypy/annotation/bookkeeper.py
   pypy/dist/pypy/annotation/builtin.py
   pypy/dist/pypy/annotation/model.py
   pypy/dist/pypy/annotation/unaryop.py
Log:
support for

- 1-char unicode strings as SomeUnicodeCodePoint

- dict.get



Modified: pypy/dist/pypy/annotation/binaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/binaryop.py	(original)
+++ pypy/dist/pypy/annotation/binaryop.py	Mon May 23 19:58:36 2005
@@ -5,6 +5,7 @@
 from pypy.annotation.pairtype import pair, pairtype
 from pypy.annotation.model import SomeObject, SomeInteger, SomeBool
 from pypy.annotation.model import SomeString, SomeChar, SomeList, SomeDict
+from pypy.annotation.model import SomeUnicodeCodePoint
 from pypy.annotation.model import SomeTuple, SomeImpossibleValue
 from pypy.annotation.model import SomeInstance, SomeBuiltin, SomeIterator
 from pypy.annotation.model import SomePBC, SomeSlice, SomeFloat
@@ -247,6 +248,11 @@
     def union((chr1, chr2)):
         return SomeChar()
 
+class __extend__(pairtype(SomeUnicodeCodePoint, SomeUnicodeCodePoint)):
+
+    def union((uchr1, uchr2)):
+        return SomeUnicodeCodePoint()
+
 class __extend__(pairtype(SomeString, SomeObject)):
 
     def mod((str, args)):

Modified: pypy/dist/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/dist/pypy/annotation/bookkeeper.py	(original)
+++ pypy/dist/pypy/annotation/bookkeeper.py	Mon May 23 19:58:36 2005
@@ -140,6 +140,8 @@
                 result = SomeChar()
             else:
                 result = SomeString()
+        elif tp is unicode and len(x) == 1:
+            result = SomeUnicodeCodePoint()
         elif tp is tuple:
             result = SomeTuple(items = [self.immutablevalue(e) for e in x])
         elif tp is float:

Modified: pypy/dist/pypy/annotation/builtin.py
==============================================================================
--- pypy/dist/pypy/annotation/builtin.py	(original)
+++ pypy/dist/pypy/annotation/builtin.py	Mon May 23 19:58:36 2005
@@ -7,6 +7,7 @@
 from pypy.tool.ansi_print import ansi_print
 from pypy.annotation.model import SomeInteger, SomeObject, SomeChar, SomeBool
 from pypy.annotation.model import SomeList, SomeString, SomeTuple, SomeSlice
+from pypy.annotation.model import SomeUnicodeCodePoint
 from pypy.annotation.model import SomeFloat, unionof
 from pypy.annotation.bookkeeper import getbookkeeper
 from pypy.objspace.flow.model import Constant
@@ -42,8 +43,11 @@
 def builtin_chr(s_int):
     return SomeChar()
 
-def builtin_unicode(s_obj): # XXX
-    return SomeString() 
+def builtin_unichr(s_int):
+    return SomeUnicodeCodePoint()
+
+def builtin_unicode(s_obj):
+    raise TypeError, "unicode() calls should not happen at interp-level"
 
 def our_issubclass(cls1, cls2):
     """ we're going to try to be less silly in the face of old-style classes"""
@@ -187,7 +191,7 @@
     return SomeInteger()
 
 def unicodedata_decimal(s_uchr):
-    return SomeInteger()
+    raise TypeError, "unicodedate.decimal() calls should not happen at interp-level"    
 
 def test(*args):
     return SomeBool()

Modified: pypy/dist/pypy/annotation/model.py
==============================================================================
--- pypy/dist/pypy/annotation/model.py	(original)
+++ pypy/dist/pypy/annotation/model.py	Mon May 23 19:58:36 2005
@@ -180,6 +180,9 @@
 class SomeChar(SomeString):
     "Stands for an object known to be a string of length 1."
 
+class SomeUnicodeCodePoint(SomeObject):
+    knowntype = unicode
+    "Stands for an object known to be a unicode codepoint."
 
 class SomeList(SomeObject):
     "Stands for a homogenous list of any length."

Modified: pypy/dist/pypy/annotation/unaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/unaryop.py	(original)
+++ pypy/dist/pypy/annotation/unaryop.py	Mon May 23 19:58:36 2005
@@ -7,6 +7,7 @@
 from pypy.annotation.pairtype import pair
 from pypy.annotation.model import SomeObject, SomeInteger, SomeBool
 from pypy.annotation.model import SomeString, SomeChar, SomeList, SomeDict
+from pypy.annotation.model import SomeUnicodeCodePoint
 from pypy.annotation.model import SomeTuple, SomeImpossibleValue
 from pypy.annotation.model import SomeInstance, SomeBuiltin, SomeFloat
 from pypy.annotation.model import SomeIterator, SomePBC, new_or_old_class
@@ -241,6 +242,9 @@
     def iter(dct):
         return SomeIterator(dct.dictdef.read_key())
 
+    def method_get(dct, key, dfl):
+        return unionof(dct.dictdef.read_value(), dfl)
+
     def method_copy(dct):
         return dct
 
@@ -285,6 +289,11 @@
     def len(chr):
         return immutablevalue(1)
 
+class __extend__(SomeUnicodeCodePoint):
+
+    def ord(uchr):
+        return SomeInteger(nonneg=True)
+
 
 class __extend__(SomeIterator):
 



More information about the Pypy-commit mailing list