[pypy-commit] pypy default: move SomePtr, SomeInteriorPtr, SomeLLADTMeth to rpython.rtyper

rlamy noreply at buildbot.pypy.org
Mon Jan 27 04:29:31 CET 2014


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: 
Changeset: r68959:3534680bda85
Date: 2014-01-27 03:28 +0000
http://bitbucket.org/pypy/pypy/changeset/3534680bda85/

Log:	move SomePtr, SomeInteriorPtr, SomeLLADTMeth to rpython.rtyper

diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py
--- a/rpython/annotator/binaryop.py
+++ b/rpython/annotator/binaryop.py
@@ -829,7 +829,7 @@
 
 # ____________________________________________________________
 # annotation of low-level types
-from rpython.annotator.model import SomePtr
+from rpython.rtyper.llannotation import SomePtr
 from rpython.annotator.model import ll_to_annotation, annotation_to_lltype
 
 class __extend__(pairtype(SomePtr, SomePtr)):
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -8,12 +8,12 @@
 
 from rpython.flowspace.model import Constant
 from rpython.annotator.model import (SomeOrderedDict,
-    SomeString, SomeChar, SomeFloat, SomePtr, unionof, SomeInstance, SomeDict,
+    SomeString, SomeChar, SomeFloat, unionof, SomeInstance, SomeDict,
     SomeBuiltin, SomePBC, SomeInteger, TLS, SomeUnicodeCodePoint,
-    s_None, s_ImpossibleValue, SomeLLADTMeth, SomeBool, SomeTuple,
+    s_None, s_ImpossibleValue, SomeBool, SomeTuple,
     SomeImpossibleValue, SomeUnicodeString, SomeList, HarmlesslyBlocked,
-    SomeWeakRef, lltype_to_annotation, SomeType, SomeByteArray, SomeConstantType)
-from rpython.rtyper.llannotation import SomeAddress
+    SomeWeakRef, lltype_to_annotation, SomeByteArray, SomeConstantType)
+from rpython.rtyper.llannotation import SomeAddress, SomePtr, SomeLLADTMeth
 from rpython.annotator.classdef import InstanceSource, ClassDef
 from rpython.annotator.listdef import ListDef, ListItem
 from rpython.annotator.dictdef import DictDef
diff --git a/rpython/annotator/builtin.py b/rpython/annotator/builtin.py
--- a/rpython/annotator/builtin.py
+++ b/rpython/annotator/builtin.py
@@ -357,7 +357,7 @@
 
 @analyzer_for(rpython.rtyper.lltypesystem.llmemory.cast_ptr_to_adr)
 def llmemory_cast_ptr_to_adr(s):
-    from rpython.annotator.model import SomeInteriorPtr
+    from rpython.rtyper.llannotation import SomeInteriorPtr
     assert not isinstance(s, SomeInteriorPtr)
     return SomeAddress()
 
@@ -390,7 +390,7 @@
 
 
 # annotation of low-level types
-from rpython.annotator.model import SomePtr
+from rpython.rtyper.llannotation import SomePtr
 from rpython.rtyper.lltypesystem import lltype
 
 @analyzer_for(lltype.malloc)
diff --git a/rpython/annotator/description.py b/rpython/annotator/description.py
--- a/rpython/annotator/description.py
+++ b/rpython/annotator/description.py
@@ -624,7 +624,7 @@
                 except ValueError:
                     pass
                 else:
-                    from rpython.annotator.model import SomePtr
+                    from rpython.rtyper.llannotation import SomePtr
                     assert not isinstance(s_arg, SomePtr)
         else:
             # call the constructor
diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -574,36 +574,8 @@
 from rpython.rtyper.lltypesystem import lltype
 
 
-class SomePtr(SomeObject):
-    knowntype = lltype._ptr
-    immutable = True
 
-    def __init__(self, ll_ptrtype):
-        assert isinstance(ll_ptrtype, lltype.Ptr)
-        self.ll_ptrtype = ll_ptrtype
-
-    def can_be_none(self):
-        return False
-
-
-class SomeInteriorPtr(SomePtr):
-    def __init__(self, ll_ptrtype):
-        assert isinstance(ll_ptrtype, lltype.InteriorPtr)
-        self.ll_ptrtype = ll_ptrtype
-
-
-class SomeLLADTMeth(SomeObject):
-    immutable = True
-
-    def __init__(self, ll_ptrtype, func):
-        self.ll_ptrtype = ll_ptrtype
-        self.func = func
-
-    def can_be_none(self):
-        return False
-
-
-from rpython.rtyper.llannotation import SomeAddress
+from rpython.rtyper.llannotation import SomeAddress, SomePtr, SomeInteriorPtr
 from rpython.rtyper.lltypesystem import llmemory
 
 annotation_to_ll_map = [
diff --git a/rpython/annotator/test/test_model.py b/rpython/annotator/test/test_model.py
--- a/rpython/annotator/test/test_model.py
+++ b/rpython/annotator/test/test_model.py
@@ -1,6 +1,7 @@
 import py
 
 from rpython.annotator.model import *
+from rpython.rtyper.llannotation import SomePtr
 from rpython.annotator.listdef import ListDef
 from rpython.translator.translator import TranslationContext
 
diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -759,7 +759,7 @@
             raise AnnotatorError("Cannot call len on a pbc")
 
 # annotation of low-level types
-from rpython.annotator.model import SomePtr, SomeLLADTMeth
+from rpython.rtyper.llannotation import SomePtr, SomeLLADTMeth
 from rpython.annotator.model import ll_to_annotation, lltype_to_annotation, annotation_to_lltype
 
 class __extend__(SomePtr):
diff --git a/rpython/memory/gctransform/framework.py b/rpython/memory/gctransform/framework.py
--- a/rpython/memory/gctransform/framework.py
+++ b/rpython/memory/gctransform/framework.py
@@ -1,5 +1,5 @@
 from rpython.annotator import model as annmodel
-from rpython.rtyper.llannotation import SomeAddress
+from rpython.rtyper.llannotation import SomeAddress, SomePtr
 from rpython.rlib import rgc
 from rpython.rtyper import rmodel, annlowlevel
 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi, llgroup
@@ -268,7 +268,7 @@
         from rpython.memory.gc.base import ARRAY_TYPEID_MAP
         from rpython.memory.gc import inspector
 
-        s_gcref = annmodel.SomePtr(llmemory.GCREF)
+        s_gcref = SomePtr(llmemory.GCREF)
         gcdata = self.gcdata
         translator = self.translator
 
@@ -314,7 +314,7 @@
 
         if hasattr(GCClass, 'heap_stats'):
             self.heap_stats_ptr = getfn(GCClass.heap_stats.im_func,
-                    [s_gc], annmodel.SomePtr(lltype.Ptr(ARRAY_TYPEID_MAP)),
+                    [s_gc], SomePtr(lltype.Ptr(ARRAY_TYPEID_MAP)),
                     minimal_transform=False)
             self.get_member_index_ptr = getfn(
                 GCClass.get_member_index.im_func,
@@ -448,8 +448,7 @@
                                        minimal_transform=False)
         self.get_typeids_z_ptr = getfn(inspector.get_typeids_z,
                                        [s_gc],
-                                       annmodel.SomePtr(
-                                           lltype.Ptr(rgc.ARRAY_OF_CHAR)),
+                                       SomePtr(lltype.Ptr(rgc.ARRAY_OF_CHAR)),
                                        minimal_transform=False)
 
         self.set_max_heap_size_ptr = getfn(GCClass.set_max_heap_size.im_func,
diff --git a/rpython/memory/gctransform/shadowstack.py b/rpython/memory/gctransform/shadowstack.py
--- a/rpython/memory/gctransform/shadowstack.py
+++ b/rpython/memory/gctransform/shadowstack.py
@@ -1,4 +1,5 @@
 from rpython.annotator import model as annmodel
+from rpython.rtyper.llannotation import SomePtr
 from rpython.rlib.debug import ll_assert
 from rpython.rlib.nonconst import NonConstant
 from rpython.rlib import rgc
@@ -242,7 +243,7 @@
         def gc_start_fresh_new_state():
             shadow_stack_pool.start_fresh_new_state()
 
-        s_gcref = annmodel.SomePtr(llmemory.GCREF)
+        s_gcref = SomePtr(llmemory.GCREF)
         s_addr = SomeAddress()
         self.gc_shadowstackref_new_ptr = getfn(gc_shadowstackref_new,
                                                [], s_gcref,
diff --git a/rpython/memory/test/test_transformed_gc.py b/rpython/memory/test/test_transformed_gc.py
--- a/rpython/memory/test/test_transformed_gc.py
+++ b/rpython/memory/test/test_transformed_gc.py
@@ -3,6 +3,7 @@
 
 from rpython.translator.c import gc
 from rpython.annotator import model as annmodel
+from rpython.rtyper.llannotation import SomePtr
 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi, llgroup
 from rpython.memory.gctransform import framework, shadowstack
 from rpython.rtyper.lltypesystem.lloperation import llop, void
@@ -98,7 +99,7 @@
 
         from rpython.translator.c.genc import CStandaloneBuilder
 
-        s_args = annmodel.SomePtr(lltype.Ptr(ARGS))
+        s_args = SomePtr(lltype.Ptr(ARGS))
         t = rtype(entrypoint, [s_args], gcname=cls.gcname,
                   taggedpointers=cls.taggedpointers)
 
@@ -827,7 +828,7 @@
             from rpython.translator.translator import graphof
             from rpython.flowspace.model import Constant
             from rpython.rtyper.lltypesystem import rffi
-            layoutbuilder = cls.ensure_layoutbuilder(translator)            
+            layoutbuilder = cls.ensure_layoutbuilder(translator)
             type_id = layoutbuilder.get_type_id(P)
             #
             # now fix the do_malloc_fixedsize_clear in the graph of g
@@ -1116,7 +1117,7 @@
 
     def test_adr_of_nursery(self):
         run = self.runner("adr_of_nursery")
-        res = run([])        
+        res = run([])
 
 class TestGenerationalNoFullCollectGC(GCTest):
     # test that nursery is doing its job and that no full collection
diff --git a/rpython/rlib/jit_hooks.py b/rpython/rlib/jit_hooks.py
--- a/rpython/rlib/jit_hooks.py
+++ b/rpython/rlib/jit_hooks.py
@@ -1,4 +1,5 @@
 from rpython.annotator import model as annmodel
+from rpython.rtyper.llannotation import SomePtr
 from rpython.rlib.objectmodel import specialize
 from rpython.rtyper.annlowlevel import (cast_instance_to_base_ptr,
     cast_base_ptr_to_instance, llstr)
@@ -50,7 +51,7 @@
 def emptyval():
     return lltype.nullptr(llmemory.GCREF.TO)
 
- at register_helper(annmodel.SomePtr(llmemory.GCREF))
+ at register_helper(SomePtr(llmemory.GCREF))
 def resop_new(no, llargs, llres):
     from rpython.jit.metainterp.history import ResOperation
 
@@ -61,7 +62,7 @@
         res = None
     return _cast_to_gcref(ResOperation(no, args, res))
 
- at register_helper(annmodel.SomePtr(llmemory.GCREF))
+ at register_helper(SomePtr(llmemory.GCREF))
 def boxint_new(no):
     from rpython.jit.metainterp.history import BoxInt
     return _cast_to_gcref(BoxInt(no))
@@ -74,7 +75,7 @@
 def resop_getopname(llop):
     return llstr(_cast_to_resop(llop).getopname())
 
- at register_helper(annmodel.SomePtr(llmemory.GCREF))
+ at register_helper(SomePtr(llmemory.GCREF))
 def resop_getarg(llop, no):
     return _cast_to_gcref(_cast_to_resop(llop).getarg(no))
 
@@ -82,7 +83,7 @@
 def resop_setarg(llop, no, llbox):
     _cast_to_resop(llop).setarg(no, _cast_to_box(llbox))
 
- at register_helper(annmodel.SomePtr(llmemory.GCREF))
+ at register_helper(SomePtr(llmemory.GCREF))
 def resop_getresult(llop):
     return _cast_to_gcref(_cast_to_resop(llop).result)
 
@@ -94,15 +95,15 @@
 def box_getint(llbox):
     return _cast_to_box(llbox).getint()
 
- at register_helper(annmodel.SomePtr(llmemory.GCREF))
+ at register_helper(SomePtr(llmemory.GCREF))
 def box_clone(llbox):
     return _cast_to_gcref(_cast_to_box(llbox).clonebox())
 
- at register_helper(annmodel.SomePtr(llmemory.GCREF))
+ at register_helper(SomePtr(llmemory.GCREF))
 def box_constbox(llbox):
     return _cast_to_gcref(_cast_to_box(llbox).constbox())
 
- at register_helper(annmodel.SomePtr(llmemory.GCREF))
+ at register_helper(SomePtr(llmemory.GCREF))
 def box_nonconstbox(llbox):
     return _cast_to_gcref(_cast_to_box(llbox).nonconstbox())
 
diff --git a/rpython/rlib/rgc.py b/rpython/rlib/rgc.py
--- a/rpython/rlib/rgc.py
+++ b/rpython/rlib/rgc.py
@@ -94,9 +94,9 @@
     _about_ = _heap_stats
 
     def compute_result_annotation(self):
-        from rpython.annotator import model as annmodel
+        from rpython.rtyper.llannotation import SomePtr
         from rpython.memory.gc.base import ARRAY_TYPEID_MAP
-        return annmodel.SomePtr(lltype.Ptr(ARRAY_TYPEID_MAP))
+        return SomePtr(lltype.Ptr(ARRAY_TYPEID_MAP))
 
     def specialize_call(self, hop):
         hop.exception_is_here()
@@ -452,8 +452,9 @@
     global _cache_s_list_of_gcrefs
     if _cache_s_list_of_gcrefs is None:
         from rpython.annotator import model as annmodel
+        from rpython.rtyper.llannotation import SomePtr
         from rpython.annotator.listdef import ListDef
-        s_gcref = annmodel.SomePtr(llmemory.GCREF)
+        s_gcref = SomePtr(llmemory.GCREF)
         _cache_s_list_of_gcrefs = annmodel.SomeList(
             ListDef(None, s_gcref, mutated=True, resized=False))
     return _cache_s_list_of_gcrefs
@@ -468,15 +469,17 @@
 
 class Entry(ExtRegistryEntry):
     _about_ = get_rpy_referents
+
     def compute_result_annotation(self, s_gcref):
-        from rpython.annotator import model as annmodel
-        assert annmodel.SomePtr(llmemory.GCREF).contains(s_gcref)
+        from rpython.rtyper.llannotation import SomePtr
+        assert SomePtr(llmemory.GCREF).contains(s_gcref)
         return s_list_of_gcrefs()
+
     def specialize_call(self, hop):
         vlist = hop.inputargs(hop.args_r[0])
         hop.exception_cannot_occur()
         return hop.genop('gc_get_rpy_referents', vlist,
-                         resulttype = hop.r_result)
+                         resulttype=hop.r_result)
 
 class Entry(ExtRegistryEntry):
     _about_ = get_rpy_memory_usage
@@ -522,10 +525,11 @@
 class Entry(ExtRegistryEntry):
     _about_ = _get_llcls_from_cls
     def compute_result_annotation(self, s_Class):
-        from rpython.annotator import model as annmodel
+        from rpython.rtyper.llannotation import SomePtr
         from rpython.rtyper.lltypesystem import rclass
         assert s_Class.is_constant()
-        return annmodel.SomePtr(rclass.CLASSTYPE)
+        return SomePtr(rclass.CLASSTYPE)
+
     def specialize_call(self, hop):
         from rpython.rtyper.rclass import getclassrepr
         from rpython.flowspace.model import Constant
@@ -550,9 +554,11 @@
 
 class Entry(ExtRegistryEntry):
     _about_ = get_typeids_z
+
     def compute_result_annotation(self):
-        from rpython.annotator.model import SomePtr
+        from rpython.rtyper.llannotation import SomePtr
         return SomePtr(lltype.Ptr(ARRAY_OF_CHAR))
+
     def specialize_call(self, hop):
         hop.exception_is_here()
         return hop.genop('gc_typeids_z', [], resulttype = hop.r_result)
diff --git a/rpython/rlib/rstring.py b/rpython/rlib/rstring.py
--- a/rpython/rlib/rstring.py
+++ b/rpython/rlib/rstring.py
@@ -3,7 +3,8 @@
 import sys
 
 from rpython.annotator.model import (SomeObject, SomeString, s_None, SomeChar,
-    SomeInteger, SomeUnicodeCodePoint, SomeUnicodeString, SomePtr, SomePBC)
+    SomeInteger, SomeUnicodeCodePoint, SomeUnicodeString, SomePBC)
+from rpython.rtyper.llannotation import SomePtr
 from rpython.rlib import jit
 from rpython.rlib.objectmodel import newlist_hint, specialize
 from rpython.rlib.rarithmetic import ovfcheck
diff --git a/rpython/rlib/test/test_signature.py b/rpython/rlib/test/test_signature.py
--- a/rpython/rlib/test/test_signature.py
+++ b/rpython/rlib/test/test_signature.py
@@ -2,6 +2,7 @@
 from rpython.rlib.signature import signature, finishsigs, FieldSpec, ClassSpec
 from rpython.rlib import types
 from rpython.annotator import model
+from rpython.rtyper.llannotation import SomePtr
 from rpython.annotator.signature import SignatureError
 from rpython.translator.translator import TranslationContext, graphof
 from rpython.rtyper.lltypesystem import rstr
@@ -127,7 +128,7 @@
     def f(buf):
         pass
     argtype = getsig(f, policy=policy)[0]
-    assert isinstance(argtype, model.SomePtr)
+    assert isinstance(argtype, SomePtr)
     assert argtype.ll_ptrtype.TO == rstr.STR
 
     def g():
diff --git a/rpython/rtyper/annlowlevel.py b/rpython/rtyper/annlowlevel.py
--- a/rpython/rtyper/annlowlevel.py
+++ b/rpython/rtyper/annlowlevel.py
@@ -7,6 +7,7 @@
 from rpython.annotator.policy import AnnotatorPolicy
 from rpython.annotator.signature import Sig
 from rpython.annotator.specialize import flatten_star_args
+from rpython.rtyper.llannotation import SomePtr
 from rpython.rtyper.normalizecalls import perform_normalizations
 from rpython.rtyper.lltypesystem import lltype, llmemory
 from rpython.flowspace.model import Constant
@@ -359,7 +360,7 @@
         key = (llhelper, s_callable.const)
         s_res = self.bookkeeper.emulate_pbc_call(key, s_callable, args_s)
         assert annmodel.lltype_to_annotation(FUNC.RESULT).contains(s_res)
-        return annmodel.SomePtr(F)
+        return SomePtr(F)
 
     def specialize_call(self, hop):
         hop.exception_cannot_occur()
@@ -476,7 +477,7 @@
     def compute_result_annotation(self, s_PTR, s_object):
         assert s_PTR.is_constant()
         if isinstance(s_PTR.const, lltype.Ptr):
-            return annmodel.SomePtr(s_PTR.const)
+            return SomePtr(s_PTR.const)
         else:
             assert False
 
@@ -535,14 +536,14 @@
 def placeholder_sigarg(s):
     if s == "self":
         def expand(s_self, *args_s):
-            assert isinstance(s_self, annmodel.SomePtr)
+            assert isinstance(s_self, SomePtr)
             return s_self
     elif s == "SELF":
         raise NotImplementedError
     else:
         assert s.islower()
         def expand(s_self, *args_s):
-            assert isinstance(s_self, annmodel.SomePtr)
+            assert isinstance(s_self, SomePtr)
             return getattr(s_self.ll_ptrtype.TO, s.upper())
     return expand
 
diff --git a/rpython/rtyper/exceptiondata.py b/rpython/rtyper/exceptiondata.py
--- a/rpython/rtyper/exceptiondata.py
+++ b/rpython/rtyper/exceptiondata.py
@@ -1,4 +1,5 @@
 from rpython.annotator import model as annmodel
+from rpython.rtyper.llannotation import SomePtr
 from rpython.rlib import rstackovf
 from rpython.rtyper import rclass
 from rpython.rtyper.lltypesystem.rclass import (ll_issubclass, ll_type,
@@ -72,12 +73,12 @@
 
     def make_exception_matcher(self, rtyper):
         # ll_exception_matcher(real_exception_vtable, match_exception_vtable)
-        s_typeptr = annmodel.SomePtr(self.lltype_of_exception_type)
+        s_typeptr = SomePtr(self.lltype_of_exception_type)
         helper_fn = rtyper.annotate_helper_fn(ll_issubclass, [s_typeptr, s_typeptr])
         return helper_fn
 
     def make_type_of_exc_inst(self, rtyper):
         # ll_type_of_exc_inst(exception_instance) -> exception_vtable
-        s_excinst = annmodel.SomePtr(self.lltype_of_exception_value)
+        s_excinst = SomePtr(self.lltype_of_exception_value)
         helper_fn = rtyper.annotate_helper_fn(ll_type, [s_excinst])
         return helper_fn
diff --git a/rpython/rtyper/llannotation.py b/rpython/rtyper/llannotation.py
--- a/rpython/rtyper/llannotation.py
+++ b/rpython/rtyper/llannotation.py
@@ -2,6 +2,7 @@
 Code for annotating low-level thingies.
 """
 from rpython.annotator.model import SomeObject
+from rpython.rtyper.lltypesystem import lltype
 
 class SomeAddress(SomeObject):
     immutable = True
@@ -24,3 +25,30 @@
     def can_be_none(self):
         return False
 
+class SomePtr(SomeObject):
+    knowntype = lltype._ptr
+    immutable = True
+
+    def __init__(self, ll_ptrtype):
+        assert isinstance(ll_ptrtype, lltype.Ptr)
+        self.ll_ptrtype = ll_ptrtype
+
+    def can_be_none(self):
+        return False
+
+
+class SomeInteriorPtr(SomePtr):
+    def __init__(self, ll_ptrtype):
+        assert isinstance(ll_ptrtype, lltype.InteriorPtr)
+        self.ll_ptrtype = ll_ptrtype
+
+
+class SomeLLADTMeth(SomeObject):
+    immutable = True
+
+    def __init__(self, ll_ptrtype, func):
+        self.ll_ptrtype = ll_ptrtype
+        self.func = func
+
+    def can_be_none(self):
+        return False
diff --git a/rpython/rtyper/lltypesystem/ll2ctypes.py b/rpython/rtyper/lltypesystem/ll2ctypes.py
--- a/rpython/rtyper/lltypesystem/ll2ctypes.py
+++ b/rpython/rtyper/lltypesystem/ll2ctypes.py
@@ -22,6 +22,7 @@
 from rpython.rlib.rarithmetic import r_singlefloat, r_longfloat, base_int, intmask
 from rpython.rlib.rarithmetic import is_emulated_long, maxint
 from rpython.annotator import model as annmodel
+from rpython.rtyper.llannotation import SomePtr
 from rpython.rtyper.llinterp import LLInterpreter, LLException
 from rpython.rtyper.lltypesystem.rclass import OBJECT, OBJECT_VTABLE
 from rpython.rtyper import raddress
@@ -161,7 +162,7 @@
         llmemory.GCREF:    ctypes.c_void_p,
         llmemory.WeakRef:  ctypes.c_void_p, # XXX
         })
-        
+
     if '__int128_t' in rffi.TYPES:
         _ctypes_cache[rffi.__INT128_T] = ctypes.c_longlong # XXX: Not right at all. But for some reason, It started by while doing JIT compile after a merge with default. Can't extend ctypes, because thats a python standard, right?
 
@@ -1339,7 +1340,7 @@
 
     def compute_result_annotation(self, s_ptr, s_n):
         assert isinstance(s_n, annmodel.SomeInteger)
-        assert isinstance(s_ptr, annmodel.SomePtr)
+        assert isinstance(s_ptr, SomePtr)
         typecheck_ptradd(s_ptr.ll_ptrtype)
         return annmodel.lltype_to_annotation(s_ptr.ll_ptrtype)
 
diff --git a/rpython/rtyper/lltypesystem/rffi.py b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -1,5 +1,6 @@
 import py
 from rpython.annotator import model as annmodel
+from rpython.rtyper.llannotation import SomePtr
 from rpython.rtyper.lltypesystem import lltype, rstr
 from rpython.rtyper.lltypesystem import ll2ctypes
 from rpython.rtyper.lltypesystem.llmemory import cast_ptr_to_adr
@@ -52,7 +53,7 @@
 class _IsLLPtrEntry(ExtRegistryEntry):
     _about_ = _isllptr
     def compute_result_annotation(self, s_p):
-        result = isinstance(s_p, annmodel.SomePtr)
+        result = isinstance(s_p, SomePtr)
         return self.bookkeeper.immutablevalue(result)
     def specialize_call(self, hop):
         hop.exception_cannot_occur()
@@ -996,7 +997,7 @@
         TP = s_type.const
         if not isinstance(TP, lltype.Struct):
             raise TypeError("make called with %s instead of Struct as first argument" % TP)
-        return annmodel.SomePtr(lltype.Ptr(TP))
+        return SomePtr(lltype.Ptr(TP))
 
     def specialize_call(self, hop, **fields):
         assert hop.args_s[0].is_constant()
diff --git a/rpython/rtyper/rptr.py b/rpython/rtyper/rptr.py
--- a/rpython/rtyper/rptr.py
+++ b/rpython/rtyper/rptr.py
@@ -1,4 +1,6 @@
 from rpython.annotator import model as annmodel
+from rpython.rtyper.llannotation import (
+    SomePtr, SomeInteriorPtr, SomeLLADTMeth)
 from rpython.flowspace import model as flowmodel
 from rpython.rlib.rarithmetic import r_uint
 from rpython.rtyper.error import TyperError
@@ -7,7 +9,7 @@
 from rpython.tool.pairtype import pairtype
 
 
-class __extend__(annmodel.SomePtr):
+class __extend__(SomePtr):
     def rtyper_makerepr(self, rtyper):
         return PtrRepr(self.ll_ptrtype)
 
@@ -15,7 +17,7 @@
         return self.__class__, self.ll_ptrtype
 
 
-class __extend__(annmodel.SomeInteriorPtr):
+class __extend__(SomeInteriorPtr):
     def rtyper_makerepr(self, rtyper):
         return InteriorPtrRepr(self.ll_ptrtype)
 
@@ -38,7 +40,7 @@
 
     def rtype_getattr(self, hop):
         attr = hop.args_s[1].const
-        if isinstance(hop.s_result, annmodel.SomeLLADTMeth):
+        if isinstance(hop.s_result, SomeLLADTMeth):
             return hop.inputarg(hop.r_result, arg=0)
         try:
             self.lowleveltype._example()._lookup_adtmeth(attr)
@@ -179,7 +181,7 @@
 # ________________________________________________________________
 # ADT  methods
 
-class __extend__(annmodel.SomeLLADTMeth):
+class __extend__(SomeLLADTMeth):
     def rtyper_makerepr(self, rtyper):
         return LLADTMethRepr(self, rtyper)
     def rtyper_makekey(self):
@@ -270,7 +272,7 @@
 
     def rtype_getattr(self, hop):
         attr = hop.args_s[1].const
-        if isinstance(hop.s_result, annmodel.SomeLLADTMeth):
+        if isinstance(hop.s_result, SomeLLADTMeth):
             return hop.inputarg(hop.r_result, arg=0)
         FIELD_TYPE = getattr(self.resulttype.TO, attr)
         if isinstance(FIELD_TYPE, lltype.ContainerType):
diff --git a/rpython/rtyper/rtyper.py b/rpython/rtyper/rtyper.py
--- a/rpython/rtyper/rtyper.py
+++ b/rpython/rtyper/rtyper.py
@@ -16,6 +16,7 @@
 import py
 
 from rpython.annotator import model as annmodel, unaryop, binaryop
+from rpython.rtyper.llannotation import SomePtr
 from rpython.annotator.annrpython import FAIL
 from rpython.flowspace.model import Variable, Constant, SpaceOperation, c_last_exception
 from rpython.rtyper.annlowlevel import annotate_lowlevel_helper, LowLevelAnnotatorPolicy
@@ -639,10 +640,10 @@
         self.call_all_setups()  # compute ForwardReferences now
         if ARG_GCSTRUCT is None:
             ARG_GCSTRUCT = GCSTRUCT
-        args_s = [annmodel.SomePtr(Ptr(ARG_GCSTRUCT))]
+        args_s = [SomePtr(Ptr(ARG_GCSTRUCT))]
         graph = self.annotate_helper(func, args_s)
         s = self.annotator.binding(graph.getreturnvar())
-        if (not isinstance(s, annmodel.SomePtr) or
+        if (not isinstance(s, SomePtr) or
             s.ll_ptrtype != Ptr(RuntimeTypeInfo)):
             raise TyperError("runtime type info function %r returns %r, "
                              "excepted Ptr(RuntimeTypeInfo)" % (func, s))
diff --git a/rpython/rtyper/test/test_llann.py b/rpython/rtyper/test/test_llann.py
--- a/rpython/rtyper/test/test_llann.py
+++ b/rpython/rtyper/test/test_llann.py
@@ -1,6 +1,7 @@
 import py
 
 from rpython.annotator import model as annmodel
+from rpython.rtyper.llannotation import SomePtr
 from rpython.conftest import option
 from rpython.rtyper.annlowlevel import (annotate_lowlevel_helper,
     MixLevelHelperAnnotator, PseudoHighLevelCallable, llhelper,
@@ -100,8 +101,8 @@
             p2 = p1.sub1
             p3 = cast_pointer(PS1, p2)
             return p3
-        s = self.annotate(llf, [annmodel.SomePtr(PS1)])
-        assert isinstance(s, annmodel.SomePtr)
+        s = self.annotate(llf, [SomePtr(PS1)])
+        assert isinstance(s, SomePtr)
         assert s.ll_ptrtype == PS1
 
     def test_cast_simple_widening_from_gc(self):
@@ -114,7 +115,7 @@
             p3 = cast_pointer(PS1, p2)
             return p3
         s = self.annotate(llf, [])
-        assert isinstance(s, annmodel.SomePtr)
+        assert isinstance(s, SomePtr)
         assert s.ll_ptrtype == PS1
 
     def test_cast_pointer(self):
@@ -152,7 +153,7 @@
         PF = Ptr(F)
         def llf(p):
             return p(0)
-        s = self.annotate(llf, [annmodel.SomePtr(PF)])
+        s = self.annotate(llf, [SomePtr(PF)])
         assert s.knowntype == int
 
 
@@ -344,7 +345,7 @@
         def llf():
             return getRuntimeTypeInfo(S)
         s = self.annotate(llf, [])
-        assert isinstance(s, annmodel.SomePtr)
+        assert isinstance(s, SomePtr)
         assert s.ll_ptrtype == Ptr(RuntimeTypeInfo)
         assert s.const == getRuntimeTypeInfo(S)
 
@@ -352,8 +353,8 @@
         S = GcStruct('s', ('x', Signed), rtti=True)
         def llf(p):
             return runtime_type_info(p)
-        s = self.annotate(llf, [annmodel.SomePtr(Ptr(S))])
-        assert isinstance(s, annmodel.SomePtr)
+        s = self.annotate(llf, [SomePtr(Ptr(S))])
+        assert isinstance(s, SomePtr)
         assert s.ll_ptrtype == Ptr(RuntimeTypeInfo)
 
     def test_cast_primitive(self):
diff --git a/rpython/rtyper/test/test_rpbc.py b/rpython/rtyper/test/test_rpbc.py
--- a/rpython/rtyper/test/test_rpbc.py
+++ b/rpython/rtyper/test/test_rpbc.py
@@ -3,6 +3,7 @@
 from rpython.annotator import policy, specialize
 from rpython.rtyper.lltypesystem.lltype import typeOf
 from rpython.rtyper.test.tool import BaseRtypingTest
+from rpython.rtyper.llannotation import SomePtr
 
 
 class MyBase:
@@ -1817,7 +1818,8 @@
     s_ll_f = annmodel.lltype_to_annotation(r_f.lowleveltype)
     A_repr = rclass.getinstancerepr(rt, a.bookkeeper.getdesc(A).
                                     getuniqueclassdef())
-    ll_h_graph = annlowlevel.annotate_lowlevel_helper(a, ll_h, [s_R, s_ll_f, annmodel.SomePtr(A_repr.lowleveltype)])
+    ll_h_graph = annlowlevel.annotate_lowlevel_helper(
+        a, ll_h, [s_R, s_ll_f, SomePtr(A_repr.lowleveltype)])
     s = a.binding(ll_h_graph.getreturnvar())
     assert s.ll_ptrtype == A_repr.lowleveltype
     rt.specialize_more_blocks()
@@ -1873,7 +1875,8 @@
     s_ll_f = annmodel.lltype_to_annotation(r_f.lowleveltype)
     A_repr = rclass.getinstancerepr(rt, a.bookkeeper.getdesc(A).
                                     getuniqueclassdef())
-    ll_h_graph = annlowlevel.annotate_lowlevel_helper(a, ll_h, [s_R, s_ll_f, annmodel.SomePtr(A_repr.lowleveltype)])
+    ll_h_graph = annlowlevel.annotate_lowlevel_helper(
+        a, ll_h, [s_R, s_ll_f, SomePtr(A_repr.lowleveltype)])
     s = a.binding(ll_h_graph.getreturnvar())
     assert s.ll_ptrtype == A_repr.lowleveltype
     rt.specialize_more_blocks()
@@ -1929,7 +1932,8 @@
 
     A_repr = rclass.getinstancerepr(rt, a.bookkeeper.getdesc(A).
                                     getuniqueclassdef())
-    ll_h_graph = annlowlevel.annotate_lowlevel_helper(a, ll_h, [s_R, s_ll_f, annmodel.SomePtr(A_repr.lowleveltype)])
+    ll_h_graph = annlowlevel.annotate_lowlevel_helper(
+        a, ll_h, [s_R, s_ll_f, SomePtr(A_repr.lowleveltype)])
     s = a.binding(ll_h_graph.getreturnvar())
     assert s.ll_ptrtype == A_repr.lowleveltype
     rt.specialize_more_blocks()
diff --git a/rpython/rtyper/test/test_rptr.py b/rpython/rtyper/test/test_rptr.py
--- a/rpython/rtyper/test/test_rptr.py
+++ b/rpython/rtyper/test/test_rptr.py
@@ -3,6 +3,7 @@
 import py
 
 from rpython.annotator import model as annmodel
+from rpython.rtyper.llannotation import SomePtr
 from rpython.annotator.annrpython import RPythonAnnotator
 from rpython.rlib.rarithmetic import is_valid_int
 from rpython.rtyper.annlowlevel import annotate_lowlevel_helper, LowLevelAnnotatorPolicy
@@ -31,11 +32,11 @@
     PS2 = lltype.Ptr(S2)
     def lldown(p):
         return lltype.cast_pointer(PS, p)
-    s, t = ll_rtype(lldown, [annmodel.SomePtr(PS2)])
+    s, t = ll_rtype(lldown, [SomePtr(PS2)])
     assert s.ll_ptrtype == PS
     def llup(p):
         return lltype.cast_pointer(PS2, p)
-    s, t = ll_rtype(llup, [annmodel.SomePtr(PS)])
+    s, t = ll_rtype(llup, [SomePtr(PS)])
     assert s.ll_ptrtype == PS2
 
 def test_runtime_type_info():
@@ -45,8 +46,8 @@
                 lltype.runtime_type_info(p) == lltype.getRuntimeTypeInfo(S))
 
     assert ll_example(lltype.malloc(S)) == (lltype.getRuntimeTypeInfo(S), True)
-    s, t = ll_rtype(ll_example, [annmodel.SomePtr(lltype.Ptr(S))])
-    assert s == annmodel.SomeTuple([annmodel.SomePtr(lltype.Ptr(lltype.RuntimeTypeInfo)),
+    s, t = ll_rtype(ll_example, [SomePtr(lltype.Ptr(S))])
+    assert s == annmodel.SomeTuple([SomePtr(lltype.Ptr(lltype.RuntimeTypeInfo)),
                                     annmodel.SomeBool()])
 
 from rpython.rtyper.test.test_llinterp import interpret, gengraph
diff --git a/rpython/rtyper/test/test_rvirtualizable.py b/rpython/rtyper/test/test_rvirtualizable.py
--- a/rpython/rtyper/test/test_rvirtualizable.py
+++ b/rpython/rtyper/test/test_rvirtualizable.py
@@ -1,4 +1,5 @@
 import py
+from rpython.rtyper.llannotation import SomePtr
 from rpython.rtyper.lltypesystem import lltype, llmemory
 from rpython.rtyper.test.tool import BaseRtypingTest
 from rpython.rtyper.rvirtualizable import replace_force_virtualizable_with_call
@@ -153,7 +154,7 @@
                 raise ValueError
         annhelper = MixLevelHelperAnnotator(rtyper)
         if self.type_system == 'lltype':
-            s_vinst = annmodel.SomePtr(v_inst_ll_type)
+            s_vinst = SomePtr(v_inst_ll_type)
         else:
             s_vinst = annmodel.SomeOOInstance(v_inst_ll_type)
         funcptr = annhelper.delayedfunction(mycall, [s_vinst], annmodel.s_None)


More information about the pypy-commit mailing list