[pypy-svn] r50571 - in pypy/branch/fixed-list-ootype/pypy: annotation rpython rpython/lltypesystem rpython/ootypesystem rpython/test translator/cli translator/js translator/jvm translator/oosupport

atobe at codespeak.net atobe at codespeak.net
Sun Jan 13 23:23:03 CET 2008


Author: atobe
Date: Sun Jan 13 23:23:01 2008
New Revision: 50571

Modified:
   pypy/branch/fixed-list-ootype/pypy/annotation/builtin.py
   pypy/branch/fixed-list-ootype/pypy/rpython/llinterp.py
   pypy/branch/fixed-list-ootype/pypy/rpython/lltypesystem/lloperation.py
   pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/ootype.py
   pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/rbuiltin.py
   pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/rdict.py
   pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/rlist.py
   pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/rstr.py
   pypy/branch/fixed-list-ootype/pypy/rpython/test/tool.py
   pypy/branch/fixed-list-ootype/pypy/translator/cli/constant.py
   pypy/branch/fixed-list-ootype/pypy/translator/cli/cts.py
   pypy/branch/fixed-list-ootype/pypy/translator/cli/entrypoint.py
   pypy/branch/fixed-list-ootype/pypy/translator/cli/oopspec.py
   pypy/branch/fixed-list-ootype/pypy/translator/js/jts.py
   pypy/branch/fixed-list-ootype/pypy/translator/jvm/node.py
   pypy/branch/fixed-list-ootype/pypy/translator/jvm/typesystem.py
   pypy/branch/fixed-list-ootype/pypy/translator/oosupport/constant.py
Log:
(cfbolz,atobe): Introduced a new ootype for arrays. Made sure fixed-sized lists are rtyped into those arrays. Missing backend support.

Modified: pypy/branch/fixed-list-ootype/pypy/annotation/builtin.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/annotation/builtin.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/annotation/builtin.py	Sun Jan 13 23:23:01 2008
@@ -517,6 +517,10 @@
     r = SomeOOInstance(ootype.typeOf(i))
     return r
 
+def oonewarray(s_type, length):
+    assert s_type.is_constant()
+    return SomeOOInstance(s_type.const)
+
 def null(I_OR_SM):
     assert I_OR_SM.is_constant()
     null = ootype.null(I_OR_SM.const)
@@ -564,6 +568,7 @@
 
 BUILTIN_ANALYZERS[ootype.instanceof] = instanceof
 BUILTIN_ANALYZERS[ootype.new] = new
+BUILTIN_ANALYZERS[ootype.oonewarray] = oonewarray
 BUILTIN_ANALYZERS[ootype.null] = null
 BUILTIN_ANALYZERS[ootype.runtimenew] = runtimenew
 BUILTIN_ANALYZERS[ootype.classof] = classof

Modified: pypy/branch/fixed-list-ootype/pypy/rpython/llinterp.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/rpython/llinterp.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/rpython/llinterp.py	Sun Jan 13 23:23:01 2008
@@ -1034,6 +1034,11 @@
     def op_new(self, INST):
         assert isinstance(INST, (ootype.Instance, ootype.BuiltinType))
         return ootype.new(INST)
+        
+    def op_oonewarray(self, ARRAY, length):
+        assert isinstance(ARRAY, ootype.Array)
+        assert isinstance(length, int)
+        return ootype.oonewarray(ARRAY, length)
 
     def op_runtimenew(self, class_):
         return ootype.runtimenew(class_)

Modified: pypy/branch/fixed-list-ootype/pypy/rpython/lltypesystem/lloperation.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/rpython/lltypesystem/lloperation.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/rpython/lltypesystem/lloperation.py	Sun Jan 13 23:23:01 2008
@@ -461,6 +461,7 @@
     'new':                  LLOp(oo=True, canraise=(Exception,)),
     'runtimenew':           LLOp(oo=True, canraise=(Exception,)),
     'oonewcustomdict':      LLOp(oo=True, canraise=(Exception,)),
+    'oonewarray':           LLOp(oo=True, canraise=(Exception,)),
     'oosetfield':           LLOp(oo=True),
     'oogetfield':           LLOp(oo=True, sideeffects=False),
     'oosend':               LLOp(oo=True, canraise=(Exception,)),

Modified: pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/ootype.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/ootype.py	Sun Jan 13 23:23:01 2008
@@ -453,7 +453,7 @@
     ITEMTYPE_T = object()
 
     def __init__(self, ITEMTYPE=None):
-        self._ITEMTYPE = ITEMTYPE
+        self.ITEM = ITEMTYPE
         self._null = _null_list(self)
         if ITEMTYPE is not None:
             self._init_methods()
@@ -464,13 +464,9 @@
         # 'ITEMTYPE_T' is used as a placeholder for indicating
         # arguments that should have ITEMTYPE type. 'SELFTYPE_T' indicates 'self'
 
-        # XXX clean-up later! Rename _ITEMTYPE to ITEM.  For now they are
-        # just synonyms, please use ITEM in new code.
-        self.ITEM = self._ITEMTYPE
-
         generic_types = {
             self.SELFTYPE_T: self,
-            self.ITEMTYPE_T: self._ITEMTYPE,
+            self.ITEMTYPE_T: self.ITEM,
             }
 
         # the methods are named after the ADT methods of lltypesystem's lists
@@ -503,7 +499,7 @@
             return True
         if not isinstance(other, List):
             return False
-        if self._ITEMTYPE is None or other._ITEMTYPE is None:
+        if self.ITEM is None or other.ITEM is None:
             raise TypeError("Can't compare uninitialized List type.")
         return BuiltinADTType.__eq__(self, other)
 
@@ -511,28 +507,106 @@
         return not (self == other)
 
     def __hash__(self):
-        if self._ITEMTYPE is None:
+        if self.ITEM is None:
             raise TypeError("Can't hash uninitialized List type.")
         return BuiltinADTType.__hash__(self)    
 
     def __str__(self):
         return '%s(%s)' % (self.__class__.__name__,
-                saferecursive(str, "...")(self._ITEMTYPE))
+                saferecursive(str, "...")(self.ITEM))
 
     def _get_interp_class(self):
         return _list
 
     def _specialize(self, generic_types):
-        ITEMTYPE = self._specialize_type(self._ITEMTYPE, generic_types)
+        ITEMTYPE = self._specialize_type(self.ITEM, generic_types)
         return self.__class__(ITEMTYPE)
     
     def _defl(self):
         return self._null
 
     def _set_itemtype(self, ITEMTYPE):
-        self._ITEMTYPE = ITEMTYPE
+        self.ITEM = ITEMTYPE
+        self._init_methods()
+
+
+class Array(BuiltinADTType):
+    # placeholders for types
+    # make sure that each derived class has his own SELFTYPE_T
+    # placeholder, because we want backends to distinguish that.
+    
+    SELFTYPE_T = object()
+    ITEMTYPE_T = object()
+
+    def __init__(self, ITEMTYPE=None):
+        self.ITEM = ITEMTYPE
+        self._null = _null_array(self)
+        if ITEMTYPE is not None:
+            self._init_methods()
+
+    def _init_methods(self):
+        # This defines the abstract list interface that backends will
+        # have to map to their native list implementations.
+        # 'ITEMTYPE_T' is used as a placeholder for indicating
+        # arguments that should have ITEMTYPE type. 'SELFTYPE_T' indicates 'self'
+
+        generic_types = {
+            self.SELFTYPE_T: self,
+            self.ITEMTYPE_T: self.ITEM,
+            }
+
+        # the methods are named after the ADT methods of lltypesystem's lists
+        self._GENERIC_METHODS = frozendict({
+            # "name": Meth([ARGUMENT1_TYPE, ARGUMENT2_TYPE, ...], RESULT_TYPE)
+            "ll_length": Meth([], Signed),
+            "ll_getitem_fast": Meth([Signed], self.ITEMTYPE_T),
+            "ll_setitem_fast": Meth([Signed, self.ITEMTYPE_T], Void),
+        })
+
+        self._setup_methods(generic_types)
+
+    def __eq__(self, other):
+        if self is other:
+            return True
+        if not isinstance(other, Array):
+            return False
+        if self.ITEM is None or other.ITEM is None:
+            raise TypeError("Can't compare uninitialized List type.")
+        return BuiltinADTType.__eq__(self, other)
+
+    def __ne__(self, other):
+        return not (self == other)
+
+    def __hash__(self):
+        if self.ITEM is None:
+            raise TypeError("Can't hash uninitialized List type.")
+        return BuiltinADTType.__hash__(self)    
+
+    def __str__(self):
+        return '%s(%s)' % (self.__class__.__name__,
+                saferecursive(str, "...")(self.ITEM))
+
+    def _get_interp_class(self):
+        return _array
+
+    def _specialize(self, generic_types):
+        ITEMTYPE = self._specialize_type(self.ITEM, generic_types)
+        return self.__class__(ITEMTYPE)
+
+    def _defl(self):
+        return self._null
+
+    def _example(self):
+        return oonewarray(self, 1)
+
+    def _set_itemtype(self, ITEMTYPE):
+        self.ITEM = ITEMTYPE
         self._init_methods()
 
+    def ll_newlist(self, length):
+        from pypy.rpython.ootypesystem import rlist
+        return rlist.ll_newarray(self, length)
+
 
 class Dict(BuiltinADTType):
     # placeholders for types
@@ -1247,6 +1321,8 @@
     def __init__(self, WEAK_REFERENCE):
         self.__dict__["_TYPE"] = WEAK_REFERENCE
 
+
+
 class _list(_builtin_type):
     def __init__(self, LIST):
         self._TYPE = LIST
@@ -1264,7 +1340,7 @@
         # NOT_RPYTHON        
         if len(self._list) < length:
             diff = length - len(self._list)
-            self._list += [self._TYPE._ITEMTYPE._defl()] * diff
+            self._list += [self._TYPE.ITEM._defl()] * diff
         assert len(self._list) >= length
 
     def _ll_resize_le(self, length):
@@ -1289,7 +1365,7 @@
 
     def ll_setitem_fast(self, index, item):
         # NOT_RPYTHON
-        assert self._TYPE._ITEMTYPE is Void or typeOf(item) == self._TYPE._ITEMTYPE
+        assert self._TYPE.ITEM is Void or typeOf(item) == self._TYPE.ITEM
         assert typeOf(index) == Signed
         assert index >= 0
         self._list[index] = item
@@ -1299,6 +1375,33 @@
     def __init__(self, LIST):
         self.__dict__["_TYPE"] = LIST 
 
+class _array(_builtin_type):
+    def __init__(self, ARRAY, length):
+        self._TYPE = ARRAY
+        self._array = [ARRAY.ITEM._defl()] * length
+
+    def ll_length(self):
+        # NOT_RPYTHON
+        return len(self._array)
+
+    def ll_getitem_fast(self, index):
+        # NOT_RPYTHON
+        assert typeOf(index) == Signed
+        assert index >= 0
+        return self._array[index]
+
+    def ll_setitem_fast(self, index, item):
+        # NOT_RPYTHON
+        assert self._TYPE.ITEM is Void or typeOf(item) == self._TYPE.ITEM
+        assert typeOf(index) == Signed
+        assert index >= 0
+        self._array[index] = item
+
+class _null_array(_null_mixin(_array), _array):
+
+    def __init__(self, ARRAY):
+        self.__dict__["_TYPE"] = ARRAY 
+
 class _dict(_builtin_type):
     def __init__(self, DICT):
         self._TYPE = DICT
@@ -1466,10 +1569,15 @@
         return TYPE._get_interp_class()(TYPE)
 
 def oonewcustomdict(DICT, ll_eq, ll_hash):
+    """NOT_RPYTHON"""
     d = new(DICT)
     d.ll_set_functions(ll_eq, ll_hash)
     return d
 
+def oonewarray(ARRAY, length):
+    """NOT_RPYTHON"""
+    return _array(ARRAY, length)
+
 def runtimenew(class_):
     assert isinstance(class_, _class)
     assert class_ is not nullruntimeclass
@@ -1595,7 +1703,7 @@
     return LIST._set_itemtype(ITEMTYPE)
 
 def hasItemType(LIST):
-    return LIST._ITEMTYPE is not None
+    return LIST.ITEM is not None
 
 def setDictTypes(DICT, KEYTYPE, VALUETYPE):
     return DICT._set_types(KEYTYPE, VALUETYPE)

Modified: pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/rbuiltin.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/rbuiltin.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/rbuiltin.py	Sun Jan 13 23:23:01 2008
@@ -12,6 +12,13 @@
     return hop.genop('new', vlist,
                      resulttype = hop.r_result.lowleveltype)
 
+def rtype_oonewarray(hop):
+    assert hop.args_s[0].is_constant()
+    vlist = hop.inputarg(ootype.Void, arg=0)
+    vlength = hop.inputarg(ootype.Signed, arg=1)
+    return hop.genop('oonewarray', [vlist, vlength],
+                     resulttype = hop.r_result.lowleveltype)
+
 def rtype_null(hop):
     assert hop.args_s[0].is_constant()
     TYPE = hop.args_s[0].const
@@ -105,6 +112,7 @@
 
 BUILTIN_TYPER = {}
 BUILTIN_TYPER[ootype.new] = rtype_new
+BUILTIN_TYPER[ootype.oonewarray] = rtype_oonewarray
 BUILTIN_TYPER[ootype.null] = rtype_null
 BUILTIN_TYPER[ootype.classof] = rtype_classof
 BUILTIN_TYPER[ootype.subclassof] = rtype_subclassof

Modified: pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/rdict.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/rdict.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/rdict.py	Sun Jan 13 23:23:01 2008
@@ -332,7 +332,7 @@
         elif func is dum_values:
             result.ll_setitem_fast(i, it.ll_current_value())
         if func is dum_items:
-            r = ootype.new(LIST._ITEMTYPE)
+            r = ootype.new(LIST.ITEM)
             r.item0 = it.ll_current_key()   # TODO: do we need casting?
             r.item1 = it.ll_current_value()
             result.ll_setitem_fast(i, r)

Modified: pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/rlist.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/rlist.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/rlist.py	Sun Jan 13 23:23:01 2008
@@ -1,6 +1,6 @@
 from pypy.tool.pairtype import pairtype
 from pypy.rpython.rlist import AbstractBaseListRepr, AbstractListRepr, \
-        AbstractListIteratorRepr, rtype_newlist, rtype_alloc_and_set
+        AbstractListIteratorRepr, AbstractFixedSizeListRepr, rtype_newlist, rtype_alloc_and_set
 from pypy.rpython.rmodel import Repr, IntegerRepr
 from pypy.rpython.rmodel import inputconst, externalvsinternal
 from pypy.rpython.lltypesystem.lltype import Signed, Void
@@ -21,15 +21,12 @@
         else:
             self.external_item_repr, self.item_repr = \
                     externalvsinternal(rtyper, item_repr)
-        self.LIST = ootype.List()
+        self.LIST = self._make_empty_type()
         self.lowleveltype = self.LIST
         self.listitem = listitem
         self.list_cache = {}
         # setup() needs to be called to finish this initialization
 
-    def _externalvsinternal(self, rtyper, item_repr):
-        return item_repr, item_repr
-    
     def _setup_repr(self):
         if 'item_repr' not in self.__dict__:
             self.external_item_repr, self.item_repr = \
@@ -37,13 +34,9 @@
         if not ootype.hasItemType(self.lowleveltype):
             ootype.setItemType(self.lowleveltype, self.item_repr.lowleveltype)
 
-    def null_const(self):
-        return self.LIST._null
-
-    def prepare_const(self, n):
-        result = self.LIST.ll_newlist(n)
-        return result
-
+    def _externalvsinternal(self, rtyper, item_repr):
+        return item_repr, item_repr
+    
     def send_message(self, hop, message, can_raise=False, v_args=None):
         if v_args is None:
             v_args = hop.inputargs(self, *hop.args_r[1:])
@@ -56,9 +49,6 @@
     def get_eqfunc(self):
         return inputconst(Void, self.item_repr.get_ll_eq_function())
 
-    def make_iterator_repr(self):
-        return ListIteratorRepr(self)
-
     def rtype_hint(self, hop):
         hints = hop.args_s[-1].const
         if 'maxlength' in hints:
@@ -71,10 +61,26 @@
 
 
 class ListRepr(AbstractListRepr, BaseListRepr):
+    def null_const(self):
+        return self.LIST._null
+
+    def prepare_const(self, n):
+        result = self.LIST.ll_newlist(n)
+        return result
+        
+    def make_iterator_repr(self):
+        return ListIteratorRepr(self)
 
-    pass
+    def _make_empty_type(self):
+        return ootype.List()
 
-FixedSizeListRepr = ListRepr
+    def _generate_newlist(self, llops, items_v, v_sizehint):
+        c_list = inputconst(ootype.Void, self.lowleveltype)
+        v_result = llops.genop("new", [c_list], resulttype=self.lowleveltype)
+        c_resize = inputconst(ootype.Void, "_ll_resize")
+        c_length = inputconst(ootype.Signed, len(items_v))
+        llops.genop("oosend", [c_resize, v_result, c_length], resulttype=ootype.Void)
+        return v_result
 
 class __extend__(pairtype(BaseListRepr, BaseListRepr)):
 
@@ -87,11 +93,7 @@
 
 def newlist(llops, r_list, items_v, v_sizehint=None):
     # XXX do something about v_sizehint
-    c_list = inputconst(ootype.Void, r_list.lowleveltype)
-    v_result = llops.genop("new", [c_list], resulttype=r_list.lowleveltype)
-    c_resize = inputconst(ootype.Void, "_ll_resize")
-    c_length = inputconst(ootype.Signed, len(items_v))
-    llops.genop("oosend", [c_resize, v_result, c_length], resulttype=ootype.Void)
+    v_result = r_list._generate_newlist(llops, items_v, v_sizehint)
 
     c_setitem = inputconst(ootype.Void, "ll_setitem_fast")
     for i, v_item in enumerate(items_v):
@@ -104,6 +106,31 @@
     lst._ll_resize(length)
     return lst
 
+# Fixed-size list 
+class FixedSizeListRepr(AbstractFixedSizeListRepr, BaseListRepr):
+    def compact_repr(self):
+        return 'FixedSizeListR %s' % (self.item_repr.compact_repr(),)
+
+    def _make_empty_type(self):
+        return ootype.Array()
+        
+    def null_const(self):
+        return self.LIST._null
+
+    def prepare_const(self, n):
+        return ll_newarray(self.LIST, n)
+
+    def make_iterator_repr(self):
+        return ListIteratorRepr(self)
+
+    def _generate_newlist(self, llops, items_v, v_sizehint):
+        c_array = inputconst(ootype.Void, self.lowleveltype)
+        c_length = inputconst(ootype.Signed, len(items_v))
+        v_result = llops.genop("oonewarray", [c_array, c_length], resulttype=self.lowleveltype)
+        return v_result
+
+def ll_newarray(ARRAY, length):
+    return ootype.oonewarray(ARRAY, length)
 
 # ____________________________________________________________
 #

Modified: pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/rstr.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/rstr.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/rpython/ootypesystem/rstr.py	Sun Jan 13 23:23:01 2008
@@ -170,7 +170,7 @@
         return buf.ll_build()
 
     def ll_join_chars(length_dummy, lst):
-        if typeOf(lst)._ITEMTYPE == Char:
+        if typeOf(lst).ITEM == Char:
             buf = ootype.new(ootype.StringBuilder)
         else:
             buf = ootype.new(ootype.UnicodeBuilder)
@@ -183,7 +183,7 @@
         return buf.ll_build()
 
     def ll_join_strs(length_dummy, lst):
-        if typeOf(lst)._ITEMTYPE == ootype.String:
+        if typeOf(lst).ITEM == ootype.String:
             buf = ootype.new(ootype.StringBuilder)
         else:
             buf = ootype.new(ootype.UnicodeBuilder)

Modified: pypy/branch/fixed-list-ootype/pypy/rpython/test/tool.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/rpython/test/tool.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/rpython/test/tool.py	Sun Jan 13 23:23:01 2008
@@ -107,7 +107,9 @@
         return OOSupport.to_runicode(u)
 
     def ll_to_list(self, l):
-        return l._list[:]
+        if hasattr(l, '_list'):
+            return l._list[:]
+        return l._array[:]
 
     def ll_unpack_tuple(self, t, length):
         return tuple([getattr(t, 'item%d' % i) for i in range(length)])

Modified: pypy/branch/fixed-list-ootype/pypy/translator/cli/constant.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/cli/constant.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/cli/constant.py	Sun Jan 13 23:23:01 2008
@@ -351,7 +351,7 @@
     
     def create_pointer(self, gen):
         self.db.const_count.inc('List')
-        self.db.const_count.inc('List', self.value._TYPE._ITEMTYPE)
+        self.db.const_count.inc('List', self.value._TYPE.ITEM)
         self.db.const_count.inc('List', len(self.value._list))
         super(CLIListConst, self).create_pointer(gen)        
 

Modified: pypy/branch/fixed-list-ootype/pypy/translator/cli/cts.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/cli/cts.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/cli/cts.py	Sun Jan 13 23:23:01 2008
@@ -242,7 +242,7 @@
             delegate = self.db.record_delegate(t)
             return CliClassType(None, delegate)
         elif isinstance(t, ootype.List):
-            item_type = self.lltype_to_cts(t._ITEMTYPE)
+            item_type = self.lltype_to_cts(t.ITEM)
             if item_type == types.void: # special case: List of Void
                 return types.list_of_void
             return types.list.specialize(item_type)

Modified: pypy/branch/fixed-list-ootype/pypy/translator/cli/entrypoint.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/cli/entrypoint.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/cli/entrypoint.py	Sun Jan 13 23:23:01 2008
@@ -9,7 +9,7 @@
         ARG0 = graph.getargs()[0].concretetype
     except IndexError:
         ARG0 = None
-    if isinstance(ARG0, ootype.List) and ARG0._ITEMTYPE is ootype.String:
+    if isinstance(ARG0, ootype.List) and ARG0.ITEM is ootype.String:
         return StandaloneEntryPoint(graph)
     else:
         return TestEntryPoint(graph)
@@ -45,7 +45,7 @@
             ARG0 = self.graph.getargs()[0].concretetype
         except IndexError:
             ARG0 = None
-        assert isinstance(ARG0, ootype.List) and ARG0._ITEMTYPE is ootype.String,\
+        assert isinstance(ARG0, ootype.List) and ARG0.ITEM is ootype.String,\
                'Wrong entry point signature: List(String) expected'
 
         ilasm.begin_function('main', [('string[]', 'argv')], 'void', True, 'static')

Modified: pypy/branch/fixed-list-ootype/pypy/translator/cli/oopspec.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/cli/oopspec.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/cli/oopspec.py	Sun Jan 13 23:23:01 2008
@@ -33,7 +33,7 @@
     try:
         # special case: when having List of Void, look at the concrete
         # methods, not the generic ones
-        if isinstance(TYPE, ootype.List) and TYPE._ITEMTYPE is ootype.Void:
+        if isinstance(TYPE, ootype.List) and TYPE.ITEM is ootype.Void:
             return TYPE._METHODS[name]
         else:
             return TYPE._GENERIC_METHODS[name]

Modified: pypy/branch/fixed-list-ootype/pypy/translator/js/jts.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/js/jts.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/js/jts.py	Sun Jan 13 23:23:01 2008
@@ -135,7 +135,7 @@
 ##        elif isinstance(t, ootype.StaticMethod):
 ##            return 'void' # TODO: is it correct to ignore StaticMethod?
 ##        elif isinstance(t, ootype.List):
-##            item_type = self.lltype_to_cts(t._ITEMTYPE)
+##            item_type = self.lltype_to_cts(t.ITEM)
 ##            return self.__class(PYPY_LIST % item_type, include_class)
 ##        elif isinstance(t, ootype.Dict):
 ##            key_type = self.lltype_to_cts(t._KEYTYPE)

Modified: pypy/branch/fixed-list-ootype/pypy/translator/jvm/node.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/jvm/node.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/jvm/node.py	Sun Jan 13 23:23:01 2008
@@ -141,7 +141,7 @@
             # python method expects
             arg0 = self.graph.getargs()[0]
             assert isinstance(arg0.concretetype, ootype.List), str(arg0.concretetype)
-            assert arg0.concretetype._ITEMTYPE is ootype.String
+            assert arg0.concretetype.ITEM is ootype.String
             gen.load_jvm_var(jStringArray, 0)
             gen.emit(jvmgen.PYPYARRAYTOLIST)
 

Modified: pypy/branch/fixed-list-ootype/pypy/translator/jvm/typesystem.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/jvm/typesystem.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/jvm/typesystem.py	Sun Jan 13 23:23:01 2008
@@ -260,7 +260,7 @@
         if hasattr(self.OOTYPE, 'SELFTYPE_T'):
             self.generics[self.OOTYPE.SELFTYPE_T] = (self.OOTYPE,self.OOTYPE)
             
-        for pname,pval in (('ITEMTYPE_T', '_ITEMTYPE'),
+        for pname,pval in (('ITEMTYPE_T', 'ITEM'),
                            ('KEYTYPE_T', '_KEYTYPE'),
                            ('VALUETYPE_T', '_VALUETYPE')):
             if hasattr(self.OOTYPE, pname):

Modified: pypy/branch/fixed-list-ootype/pypy/translator/oosupport/constant.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/oosupport/constant.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/oosupport/constant.py	Sun Jan 13 23:23:01 2008
@@ -578,7 +578,7 @@
         if not self.value:
             return
         for item in self.value._list:
-            self._record_const_if_complex(self.value._TYPE._ITEMTYPE, item)
+            self._record_const_if_complex(self.value._TYPE.ITEM, item)
 
     def create_pointer(self, gen):
         assert not self.is_null()
@@ -603,7 +603,7 @@
         can be overloaded by the backend if your conditions are wider.
         The default is not to initialize if the list is a list of
         Void. """
-        return self.value._TYPE._ITEMTYPE is ootype.Void
+        return self.value._TYPE.ITEM is ootype.Void
         try:
             return self.value._list == [0] * len(self.value._list)
         except:
@@ -612,7 +612,7 @@
     def initialize_data(self, constgen, gen):
         assert not self.is_null()
         SELFTYPE = self.value._TYPE
-        ITEMTYPE = self.value._TYPE._ITEMTYPE
+        ITEM = self.value._TYPE.ITEM
 
         # check for special cases and avoid initialization
         if self._do_not_initialize():
@@ -623,8 +623,8 @@
             constgen._consider_split_current_function(gen)
             gen.dup(SELFTYPE)
             push_constant(self.db, ootype.Signed, idx, gen)
-            push_constant(self.db, ITEMTYPE, item, gen)
-            gen.prepare_generic_argument(ITEMTYPE)
+            push_constant(self.db, ITEM, item, gen)
+            gen.prepare_generic_argument(ITEM)
             gen.call_method(SELFTYPE, 'll_setitem_fast')
 
 # ______________________________________________________________________



More information about the Pypy-commit mailing list