Author: Ronan Lamy <[email protected]>
Branch: kill-ootype
Changeset: r65564:76485b3cc47f
Date: 2013-07-23 19:46 +0200
http://bitbucket.org/pypy/pypy/changeset/76485b3cc47f/

Log:    Kill ootype LLOps

diff --git a/rpython/rtyper/llinterp.py b/rpython/rtyper/llinterp.py
--- a/rpython/rtyper/llinterp.py
+++ b/rpython/rtyper/llinterp.py
@@ -14,7 +14,6 @@
 from rpython.rlib.rarithmetic import (ovfcheck, is_valid_int, intmask,
     r_uint, r_longlong, r_ulonglong, r_longlonglong)
 from rpython.rtyper.lltypesystem import lltype, llmemory, lloperation, llheap, 
rclass
-from rpython.rtyper.ootypesystem import ootype
 
 
 log = py.log.Producer('llinterp')
@@ -43,11 +42,7 @@
         return ': '.join([str(x) for x in self.args])
 
 def type_name(etype):
-    if isinstance(lltype.typeOf(etype), lltype.Ptr):
-        return ''.join(etype.name).rstrip('\x00')
-    else:
-        # ootype!
-        return etype._INSTANCE._name.split(".")[-1]
+    return ''.join(etype.name).rstrip('\x00')
 
 class LLInterpreter(object):
     """ low level interpreter working with concrete values. """
@@ -150,12 +145,8 @@
         assert isinstance(exc, LLException)
         klass, inst = exc.args[0], exc.args[1]
         for cls in enumerate_exceptions_top_down():
-            if hasattr(klass, 'name'):   # lltype
-                if "".join(klass.name).rstrip("\0") == cls.__name__:
-                    return cls
-            else:                        # ootype
-                if klass._INSTANCE._name.split('.')[-1] == cls.__name__:
-                    return cls
+            if "".join(klass.name).rstrip("\0") == cls.__name__:
+                return cls
         raise ValueError("couldn't match exception, maybe it"
                       " has RPython attributes like OSError?")
 
@@ -178,12 +169,6 @@
 def checkadr(addr):
     assert lltype.typeOf(addr) is llmemory.Address
 
-def is_inst(inst):
-    return isinstance(lltype.typeOf(inst), (ootype.Instance, 
ootype.BuiltinType, ootype.StaticMethod))
-
-def checkinst(inst):
-    assert is_inst(inst)
-
 
 class LLFrame(object):
     def __init__(self, graph, args, llinterpreter):
@@ -863,8 +848,6 @@
         PTR = lltype.typeOf(ptr)
         if isinstance(PTR, lltype.Ptr):
             return self.heap.gc_id(ptr)
-        elif isinstance(PTR, ootype.OOType):
-            return ootype.identityhash(ptr)     # XXX imprecise
         raise NotImplementedError("gc_id on %r" % (PTR,))
 
     def op_gc_set_max_heap_size(self, maxsize):
@@ -1117,84 +1100,6 @@
         exc_data.exc_value = lltype.typeOf(evalue)._defl()
         return bool(etype)
 
-    #Operation of ootype
-
-    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 is_valid_int(length)
-        return ootype.oonewarray(ARRAY, length)
-
-    def op_runtimenew(self, class_):
-        return ootype.runtimenew(class_)
-
-    def op_oonewcustomdict(self, DICT, eq_func, eq_obj, eq_method_name,
-                           hash_func, hash_obj, hash_method_name):
-        eq_name, interp_eq = \
-                 wrap_callable(self.llinterpreter, eq_func, eq_obj, 
eq_method_name)
-        EQ_FUNC = ootype.StaticMethod([DICT._KEYTYPE, DICT._KEYTYPE], 
ootype.Bool)
-        sm_eq = ootype.static_meth(EQ_FUNC, eq_name, _callable=interp_eq)
-
-        hash_name, interp_hash = \
-                   wrap_callable(self.llinterpreter, hash_func, hash_obj, 
hash_method_name)
-        HASH_FUNC = ootype.StaticMethod([DICT._KEYTYPE], ootype.Signed)
-        sm_hash = ootype.static_meth(HASH_FUNC, hash_name, 
_callable=interp_hash)
-
-        # XXX: is it fine to have StaticMethod type for bound methods, too?
-        return ootype.oonewcustomdict(DICT, sm_eq, sm_hash)
-
-    def op_oosetfield(self, inst, name, value):
-        checkinst(inst)
-        assert isinstance(name, str)
-        FIELDTYPE = lltype.typeOf(inst)._field_type(name)
-        if FIELDTYPE is not lltype.Void:
-            setattr(inst, name, value)
-
-    def op_oogetfield(self, inst, name):
-        checkinst(inst)
-        assert isinstance(name, str)
-        return getattr(inst, name)
-
-    def op_oosend(self, message, inst, *args):
-        checkinst(inst)
-        assert isinstance(message, str)
-        bm = getattr(inst, message)
-        inst = bm.inst
-        m = bm.meth
-        args = m._checkargs(args, check_callable=False)
-        if getattr(m, 'abstract', False):
-            raise RuntimeError("calling abstract method %r" % (m,))
-        return self.perform_call(m, 
(lltype.typeOf(inst),)+lltype.typeOf(m).ARGS, [inst]+args)
-
-    def op_oostring(self, obj, base):
-        return ootype.oostring(obj, base)
-
-    def op_oounicode(self, obj, base):
-        try:
-            return ootype.oounicode(obj, base)
-        except UnicodeDecodeError:
-            self.make_llexception()
-
-    def op_ooparse_int(self, s, base):
-        try:
-            return ootype.ooparse_int(s, base)
-        except ValueError:
-            self.make_llexception()
-
-    def op_ooparse_float(self, s):
-        try:
-            return ootype.ooparse_float(s)
-        except ValueError:
-            self.make_llexception()
-
-    def op_oobox_int(self, i):
-        return ootype.oobox_int(i)
-
-    def op_oounbox_int(self, x):
-        return ootype.oounbox_int(x)
 
 class Tracer(object):
     Counter = 0
diff --git a/rpython/rtyper/lltypesystem/lloperation.py 
b/rpython/rtyper/lltypesystem/lloperation.py
--- a/rpython/rtyper/lltypesystem/lloperation.py
+++ b/rpython/rtyper/lltypesystem/lloperation.py
@@ -8,8 +8,7 @@
 class LLOp(object):
 
     def __init__(self, sideeffects=True, canfold=False, canraise=(),
-                 canmallocgc=False, canrun=False, oo=False,
-                 tryfold=False):
+                 canmallocgc=False, canrun=False, tryfold=False):
         # self.opname = ... (set afterwards)
 
         if canfold:
@@ -42,9 +41,6 @@
         # The operation can be run directly with __call__
         self.canrun = canrun or canfold
 
-        # The operation belongs to the ootypesystem
-        self.oo = oo
-
     # __________ make the LLOp instances callable from LL helpers __________
 
     __name__ = property(lambda self: 'llop_'+self.opname)
@@ -68,10 +64,7 @@
         global lltype                 #  <- lazy import hack, worth an XXX
         from rpython.rtyper.lltypesystem import lltype
         if self.canrun:
-            if self.oo:
-                from rpython.rtyper.ootypesystem.ooopimpl import get_op_impl
-            else:
-                from rpython.rtyper.lltypesystem.opimpl import get_op_impl
+            from rpython.rtyper.lltypesystem.opimpl import get_op_impl
             op_impl = get_op_impl(self.opname)
         else:
             error = TypeError("cannot constant-fold operation %r" % (
@@ -87,14 +80,10 @@
             return True
         if self is llop.debug_assert:   # debug_assert is pure enough
             return True
-        # reading from immutable (lltype)
+        # reading from immutable
         if self is llop.getfield or self is llop.getarrayitem:
             field = getattr(args_v[1], 'value', None)
             return args_v[0].concretetype.TO._immutable_field(field)
-        # reading from immutable (ootype) (xxx what about arrays?)
-        if self is llop.oogetfield:
-            field = getattr(args_v[1], 'value', None)
-            return args_v[0].concretetype._immutable_field(field)
         # default
         return False
 
@@ -350,7 +339,7 @@
     'lllong_lshift':         LLOp(canfold=True),  # args (r_longlonglong, int)
     'lllong_rshift':         LLOp(canfold=True),  # args (r_longlonglong, int)
     'lllong_xor':            LLOp(canfold=True),
-    
+
     'cast_primitive':       LLOp(canfold=True),
     'cast_bool_to_int':     LLOp(canfold=True),
     'cast_bool_to_uint':    LLOp(canfold=True),
@@ -573,32 +562,6 @@
 
     # __________ instrumentation _________
     'instrument_count':     LLOp(),
-
-    # __________ ootype operations __________
-    'new':                  LLOp(oo=True, canraise=(MemoryError,)),
-    'runtimenew':           LLOp(oo=True, canraise=(MemoryError,)),
-    'oonewcustomdict':      LLOp(oo=True, canraise=(MemoryError,)),
-    'oonewarray':           LLOp(oo=True, canraise=(MemoryError,)),
-    'oosetfield':           LLOp(oo=True),
-    'oogetfield':           LLOp(oo=True, sideeffects=False, canrun=True),
-    'oosend':               LLOp(oo=True, canraise=(Exception,)),
-    'ooupcast':             LLOp(oo=True, canfold=True),
-    'oodowncast':           LLOp(oo=True, canfold=True),
-    'cast_to_object':       LLOp(oo=True, canfold=True),
-    'cast_from_object':     LLOp(oo=True, canfold=True),
-    'oononnull':            LLOp(oo=True, canfold=True),
-    'ooisnot':              LLOp(oo=True, canfold=True),
-    'ooisnull':             LLOp(oo=True, canfold=True),
-    'oois':                 LLOp(oo=True, canfold=True),
-    'instanceof':           LLOp(oo=True, canfold=True),
-    'classof':              LLOp(oo=True, canfold=True),
-    'subclassof':           LLOp(oo=True, canfold=True),
-    'oostring':             LLOp(oo=True, sideeffects=False),
-    'oobox_int':            LLOp(oo=True, sideeffects=False),
-    'oounbox_int':          LLOp(oo=True, sideeffects=False),
-    'ooparse_int':          LLOp(oo=True, canraise=(ValueError,)),
-    'ooparse_float':        LLOp(oo=True, canraise=(ValueError,)),
-    'oounicode':            LLOp(oo=True, canraise=(UnicodeDecodeError,)),
 }
 # ***** Run test_lloperation after changes. *****
 
diff --git a/rpython/rtyper/lltypesystem/test/test_lloperation.py 
b/rpython/rtyper/lltypesystem/test/test_lloperation.py
--- a/rpython/rtyper/lltypesystem/test/test_lloperation.py
+++ b/rpython/rtyper/lltypesystem/test/test_lloperation.py
@@ -1,7 +1,6 @@
 import py
 from rpython.rtyper.lltypesystem.lloperation import LL_OPERATIONS, llop, void
 from rpython.rtyper.lltypesystem import lltype, opimpl
-from rpython.rtyper.ootypesystem import ootype, ooopimpl
 from rpython.rtyper.llinterp import LLFrame
 from rpython.rtyper.test.test_llinterp import interpret
 from rpython.rtyper import rclass
@@ -16,10 +15,7 @@
     for opname, llop in LL_OPERATIONS.items():
         assert opname == llop.opname
         if llop.canfold:
-            if llop.oo:
-                func = ooopimpl.get_op_impl(opname)
-            else:
-                func = opimpl.get_op_impl(opname)
+            func = opimpl.get_op_impl(opname)
             assert callable(func)
 
 def test_llop_fold():
@@ -48,14 +44,13 @@
     def llf():
         s = lltype.malloc(S)
         llop.bare_setfield(lltype.Void, s, void('x'), 3)
-        llop.bare_setfield(lltype.Void, s, name_y, 2)        
+        llop.bare_setfield(lltype.Void, s, name_y, 2)
         return s.x + s.y
     res = interpret(llf, [], policy=LowLevelAnnotatorPolicy())
     assert res == 5
 
 def test_is_pure():
     from rpython.flowspace.model import Variable, Constant
-    from rpython.rtyper import rclass
     assert llop.bool_not.is_pure([Variable()])
     assert llop.debug_assert.is_pure([Variable()])
     assert not llop.int_add_ovf.is_pure([Variable(), Variable()])
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to