Example #1
0
 def getitem((p, int1)):
     example = p.ll_ptrtype._example()
     try:
         v = example[0]
     except IndexError:
         return None       # impossible value, e.g. FixedSizeArray(0)
     return ll_to_annotation(v)
Example #2
0
 def getattr(r, s_attr):
     assert s_attr.is_constant(
     ), "getattr on ref %r with non-constant field-name" % r.ootype
     v = getattr(r.ootype._example(), s_attr.const)
     if isinstance(v, ootype._bound_meth):
         return SomeOOBoundMeth(r.ootype, s_attr.const)
     return ll_to_annotation(v)
Example #3
0
 def getitem((p, int1)):
     example = p.ll_ptrtype._example()
     try:
         v = example[0]
     except IndexError:
         return None  # impossible value, e.g. FixedSizeArray(0)
     return ll_to_annotation(v)
Example #4
0
 def call(m, args):
     args_s, kwds_s = args.unpack()
     if kwds_s:
         raise Exception("keyword arguments to call to a low-level static method")
     info = "argument to ll static method call"
     llargs = [annotation_to_lltype(s_arg, info)._defl() for s_arg in args_s]
     v = m.method._example()(*llargs)
     return ll_to_annotation(v)
Example #5
0
 def call(p, args):
     args_s, kwds_s = args.unpack()
     if kwds_s:
         raise Exception("keyword arguments to call to a low-level fn ptr")
     info = "argument to ll function pointer call"
     llargs = [annotation_to_lltype(s_arg, info)._defl() for s_arg in args_s]
     v = p.ll_ptrtype._example()(*llargs)
     return ll_to_annotation(v)
Example #6
0
 def call(p, args):
     args_s, kwds_s = args.unpack()
     if kwds_s:
         raise Exception("keyword arguments to call to a low-level fn ptr")
     info = 'argument to ll function pointer call'
     llargs = [
         annotation_to_lltype(s_arg, info)._defl() for s_arg in args_s
     ]
     v = p.ll_ptrtype._example()(*llargs)
     return ll_to_annotation(v)
Example #7
0
 def call(m, args):
     args_s, kwds_s = args.unpack()
     if kwds_s:
         raise Exception(
             "keyword arguments to call to a low-level static method")
     info = 'argument to ll static method call'
     llargs = [
         annotation_to_lltype(s_arg, info)._defl() for s_arg in args_s
     ]
     v = m.method._example()(*llargs)
     return ll_to_annotation(v)
Example #8
0
 def getattr(p, s_attr):
     assert s_attr.is_constant(), "getattr on ptr %r with non-constant field-name" % p.ll_ptrtype
     example = p.ll_ptrtype._example()
     try:
         v = example._lookup_adtmeth(s_attr.const)
     except AttributeError:
         v = getattr(example, s_attr.const)
         return ll_to_annotation(v)
     else:
         if isinstance(v, MethodType):
             from pypy.rpython.lltypesystem import lltype
             ll_ptrtype = lltype.typeOf(v.im_self)
             assert isinstance(ll_ptrtype, (lltype.Ptr, lltype.InteriorPtr))
             return SomeLLADTMeth(ll_ptrtype, v.im_func)
         return getbookkeeper().immutablevalue(v)
Example #9
0
 def getattr(p, s_attr):
     assert s_attr.is_constant(
     ), "getattr on ptr %r with non-constant field-name" % p.ll_ptrtype
     example = p.ll_ptrtype._example()
     try:
         v = example._lookup_adtmeth(s_attr.const)
     except AttributeError:
         v = getattr(example, s_attr.const)
         return ll_to_annotation(v)
     else:
         if isinstance(v, MethodType):
             from pypy.rpython.lltypesystem import lltype
             ll_ptrtype = lltype.typeOf(v.im_self)
             assert isinstance(ll_ptrtype, (lltype.Ptr, lltype.InteriorPtr))
             return SomeLLADTMeth(ll_ptrtype, v.im_func)
         return getbookkeeper().immutablevalue(v)
Example #10
0
def cast_primitive(T, s_v):
    assert T.is_constant()
    return ll_to_annotation(lltype.cast_primitive(T.const, annotation_to_lltype(s_v)._defl()))
Example #11
0
def cast_primitive(T, s_v):
    assert T.is_constant()
    return ll_to_annotation(lltype.cast_primitive(T.const, annotation_to_lltype(s_v)._defl()))
Example #12
0
 def getattr(r, s_attr):
     assert s_attr.is_constant(), "getattr on ref %r with non-constant field-name" % r.ootype
     v = getattr(r.ootype._example(), s_attr.const)
     if isinstance(v, ootype._bound_meth):
         return SomeOOBoundMeth(r.ootype, s_attr.const)
     return ll_to_annotation(v)
Example #13
0
 def getattr(p, s_attr):
     assert s_attr.is_constant(
     ), "getattr on ptr %r with non-constant field-name" % p.ll_ptrtype
     v = getattr(p.ll_ptrtype._example(), s_attr.const)
     return ll_to_annotation(v)
Example #14
0
 def simple_call(m, *args_s):
     llargs = [annotation_to_lltype(arg_s)._example() for arg_s in args_s]
     smeth = m.method._example()
     v = smeth(*llargs)
     return ll_to_annotation(v)
Example #15
0
 def getattr(p, s_attr):
     assert s_attr.is_constant(), "getattr on ptr %r with non-constant field-name" % p.ll_ptrtype
     v = getattr(p.ll_ptrtype._example(), s_attr.const)
     return ll_to_annotation(v)
Example #16
0
 def simple_call(m, *args_s):
     llargs = [annotation_to_lltype(arg_s)._example() for arg_s in args_s]
     smeth = m.method._example()
     v = smeth(*llargs)
     return ll_to_annotation(v)