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)
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)
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)
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)
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)
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)
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)
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)
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()))
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)
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)
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)
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)