• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python bookkeeper.getbookkeeper函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pypy.annotation.bookkeeper.getbookkeeper函数的典型用法代码示例。如果您正苦于以下问题:Python getbookkeeper函数的具体用法?Python getbookkeeper怎么用?Python getbookkeeper使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getbookkeeper函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: mod

 def mod((str, s_tuple)):
     for s_item in s_tuple.items:
         if isinstance(s_item, (SomeUnicodeCodePoint, SomeUnicodeString)):
             raise NotImplementedError(
                 "string formatting mixing strings and unicode not supported")
     getbookkeeper().count('strformat', str, s_tuple)
     return SomeString()
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:binaryop.py


示例2: getitem

 def getitem((tup1, int2)):
     if int2.is_immutable_constant():
         try:
             return tup1.items[int2.const]
         except IndexError:
             return s_ImpossibleValue
     else:
         getbookkeeper().count("tuple_random_getitem", tup1)
         return unionof(*tup1.items)
开发者ID:alkorzt,项目名称:pypy,代码行数:9,代码来源:binaryop.py


示例3: method_join

 def method_join(str, s_list):
     if s_None.contains(s_list):
         return SomeImpossibleValue()
     getbookkeeper().count("str_join", str)
     s_item = s_list.listdef.read_item()
     if isinstance(s_item, SomeImpossibleValue):
         if isinstance(str, SomeUnicodeString):
             return immutablevalue(u"")
         return immutablevalue("")
     no_nul = str.no_nul and s_item.no_nul
     return str.basestringclass(no_nul=no_nul)
开发者ID:Sherlockhlt,项目名称:pypy,代码行数:11,代码来源:unaryop.py


示例4: builtin_isinstance

def builtin_isinstance(s_obj, s_type, variables=None):
    r = SomeBool()
    if s_type.is_constant():
        typ = s_type.const
        if issubclass(typ, pypy.rlib.rarithmetic.base_int):
            r.const = issubclass(s_obj.knowntype, typ)
        else:
            if typ == long:
                getbookkeeper().warning("isinstance(., long) is not RPython")
                if s_obj.is_constant():
                    r.const = isinstance(s_obj.const, long)
                else:
                    if type(s_obj) is not SomeObject:  # only SomeObjects could be longs
                        # type(s_obj) < SomeObject -> SomeBool(False)
                        # type(s_obj) == SomeObject -> SomeBool()
                        r.const = False
                return r

            assert not issubclass(typ, (int, long)) or typ in (
                bool,
                int,
                long,
            ), "for integers only isinstance(.,int|r_uint) are supported"

            if s_obj.is_constant():
                r.const = isinstance(s_obj.const, typ)
            elif our_issubclass(s_obj.knowntype, typ):
                if not s_obj.can_be_none():
                    r.const = True
            elif not our_issubclass(typ, s_obj.knowntype):
                r.const = False
            elif s_obj.knowntype == int and typ == bool:  # xxx this will explode in case of generalisation
                # from bool to int, notice that isinstance( , bool|int)
                # is quite border case for RPython
                r.const = False
        # XXX HACK HACK HACK
        # XXX HACK HACK HACK
        # XXX HACK HACK HACK
        bk = getbookkeeper()
        if variables is None:
            fn, block, i = bk.position_key
            op = block.operations[i]
            assert op.opname == "simple_call"
            assert len(op.args) == 3
            assert op.args[0] == Constant(isinstance)
            variables = [op.args[1]]
        for variable in variables:
            assert bk.annotator.binding(variable) == s_obj
        r.knowntypedata = {}
        if not isinstance(s_type, SomeBuiltin) or typ.__module__ == "__builtin__":
            add_knowntypedata(r.knowntypedata, True, variables, bk.valueoftype(typ))
    return r
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:52,代码来源:builtin.py


示例5: builtin_hasattr

def builtin_hasattr(s_obj, s_attr):
    if not s_attr.is_constant() or not isinstance(s_attr.const, str):
        getbookkeeper().warning("hasattr(%r, %r) is not RPythonic enough" % (s_obj, s_attr))
    r = SomeBool()
    if s_obj.is_immutable_constant():
        r.const = hasattr(s_obj.const, s_attr.const)
    elif isinstance(s_obj, SomePBC) and s_obj.getKind() is description.FrozenDesc:
        answers = {}
        for d in s_obj.descriptions:
            answer = d.s_read_attribute(s_attr.const) != s_ImpossibleValue
            answers[answer] = True
        if len(answers) == 1:
            r.const, = answers
    return r
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:14,代码来源:builtin.py


示例6: mod

 def mod((str, s_tuple)):
     for s_item in s_tuple.items:
         if isinstance(s_item, (SomeUnicodeCodePoint, SomeUnicodeString)):
             raise NotImplementedError(
                 "string formatting mixing strings and unicode not supported")
     getbookkeeper().count('strformat', str, s_tuple)
     no_nul = str.no_nul
     for s_item in s_tuple.items:
         if isinstance(s_item, SomeFloat):
             pass   # or s_item is a subclass, like SomeInteger
         elif isinstance(s_item, SomeString) and s_item.no_nul:
             pass
         else:
             no_nul = False
             break
     return SomeString(no_nul=no_nul)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:16,代码来源:binaryop.py


示例7: getbookkeeper

    def getbookkeeper(self):
        if self.bookkeeper is None:
            from pypy.annotation.bookkeeper import getbookkeeper

            return getbookkeeper()
        else:
            return self.bookkeeper
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:listdef.py


示例8: builtin_range

def builtin_range(*args):
    s_step = immutablevalue(1)
    if len(args) == 1:
        s_start = immutablevalue(0)
        s_stop = args[0]
    elif len(args) == 2:
        s_start, s_stop = args
    elif len(args) == 3:
        s_start, s_stop = args[:2]
        s_step = args[2]
    else:
        raise Exception, "range() takes 1 to 3 arguments"
    empty = False  # so far
    if not s_step.is_constant():
        step = 0 # this case signals a variable step
    else:
        step = s_step.const
        if step == 0:
            raise Exception, "range() with step zero"
        if s_start.is_constant() and s_stop.is_constant():
            if len(xrange(s_start.const, s_stop.const, step)) == 0:
                empty = True
    if empty:
        s_item = s_ImpossibleValue
    else:
        nonneg = False # so far
        if step > 0:
            nonneg = s_start.nonneg
        elif step < 0:
            nonneg = s_stop.nonneg or (s_stop.is_constant() and
                                       s_stop.const >= -1)
        s_item = SomeInteger(nonneg=nonneg)
    return getbookkeeper().newlist(s_item, range_step=step)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:33,代码来源:builtin.py


示例9: getattr

 def getattr(ins, s_attr):
     if s_attr.is_constant() and isinstance(s_attr.const, str):
         attr = s_attr.const
         if attr == '__class__':
             return ins.classdef.read_attr__class__()
         attrdef = ins.classdef.find_attribute(attr)
         position = getbookkeeper().position_key
         attrdef.read_locations[position] = True
         s_result = attrdef.getvalue()
         # hack: if s_result is a set of methods, discard the ones
         #       that can't possibly apply to an instance of ins.classdef.
         # XXX do it more nicely
         if isinstance(s_result, SomePBC):
             s_result = ins.classdef.lookup_filter(s_result, attr,
                                                   ins.flags)
         elif isinstance(s_result, SomeImpossibleValue):
             ins.classdef.check_missing_attribute_update(attr)
             # blocking is harmless if the attribute is explicitly listed
             # in the class or a parent class.
             for basedef in ins.classdef.getmro():
                 if basedef.classdesc.all_enforced_attrs is not None:
                     if attr in basedef.classdesc.all_enforced_attrs:
                         raise HarmlesslyBlocked("get enforced attr")
         elif isinstance(s_result, SomeList):
             s_result = ins.classdef.classdesc.maybe_return_immutable_list(
                 attr, s_result)
         return s_result
     return SomeObject()
开发者ID:gorakhargosh,项目名称:pypy,代码行数:28,代码来源:unaryop.py


示例10: compute_result_annotation

 def compute_result_annotation(self, s_rpytype, s_obj):
     from pypy.annotation.bookkeeper import getbookkeeper
     from pypy.annotation.model import SomeInstance
     assert s_rpytype.is_constant()
     rpytype = s_rpytype.const
     bk = getbookkeeper()
     return SomeInstance(bk.getuniqueclassdef(rpytype))
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:7,代码来源:rcpy.py


示例11: our_issubclass

def our_issubclass(cls1, cls2):
    """ we're going to try to be less silly in the face of old-style classes"""
    from pypy.annotation.classdef import ClassDef
    if cls2 is object:
        return True
    def classify(cls):
        if isinstance(cls, ClassDef):
            return 'def'
        if cls.__module__ == '__builtin__':
            return 'builtin'
        else:
            return 'cls'
    kind1 = classify(cls1)
    kind2 = classify(cls2)
    if kind1 != 'def' and kind2 != 'def':
        return issubclass(cls1, cls2)
    if kind1 == 'builtin' and kind2 == 'def':
        return False
    elif kind1 == 'def' and kind2 == 'builtin':
        return issubclass(object, cls2)
    else:
        bk = getbookkeeper()
        def toclassdef(kind, cls):
            if kind != 'def':
                return bk.getuniqueclassdef(cls)
            else:
                return cls
        return toclassdef(kind1, cls1).issubclass(toclassdef(kind2, cls2))
开发者ID:alkorzt,项目名称:pypy,代码行数:28,代码来源:builtin.py


示例12: unioncheck

def unioncheck(*somevalues):
    s_value = unionof(*somevalues)
    if isdegenerated(s_value):
        if not getattr(TLS, 'no_side_effects_in_union', 0):
            bookkeeper = getbookkeeper()
            if bookkeeper is not None:
                bookkeeper.ondegenerated('union', s_value)
    return s_value
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:binaryop.py


示例13: robjmodel_r_dict

def robjmodel_r_dict(s_eqfn, s_hashfn, s_force_non_null=None):
    if s_force_non_null is None:
        force_non_null = False
    else:
        assert s_force_non_null.is_constant()
        force_non_null = s_force_non_null.const
    dictdef = getbookkeeper().getdictdef(is_r_dict=True, force_non_null=force_non_null)
    dictdef.dictkey.update_rdict_annotations(s_eqfn, s_hashfn)
    return SomeDict(dictdef)
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:9,代码来源:builtin.py


示例14: read_key

 def read_key(self, position_key=None):
     if position_key is None:
         if self.bookkeeper is None:   # for tests
             from pypy.annotation.bookkeeper import getbookkeeper
             position_key = getbookkeeper().position_key
         else:
             position_key = self.bookkeeper.position_key
     self.dictkey.read_locations[position_key] = True
     return self.dictkey.s_value
开发者ID:ieure,项目名称:pypy,代码行数:9,代码来源:dictdef.py


示例15: record_call

def record_call(func, args_s, symbol):
    from pypy.annotation import bookkeeper
    bk = bookkeeper.getbookkeeper()
    # this would be nice!
    #bk.pbc_call(bk.immutablevalue(func),
    #            bk.build_args("simple_call", args_s),
    #            emulated=True)
    bk.annotator.translator._implicitly_called_by_externals.append(
        (func, args_s, symbol))
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:9,代码来源:extfunctable.py


示例16: builtin_slice

def builtin_slice(*args):
    bk = getbookkeeper()
    if len(args) == 1:
        return SomeSlice(
            bk.immutablevalue(None), args[0], bk.immutablevalue(None))
    elif len(args) == 2:
        return SomeSlice(
            args[0], args[1], bk.immutablevalue(None))
    elif len(args) == 3:
        return SomeSlice(
            args[0], args[1], args[2])
    else:
        raise Exception, "bogus call to slice()"
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:13,代码来源:builtin.py


示例17: robjmodel_instantiate

def robjmodel_instantiate(s_clspbc):
    assert isinstance(s_clspbc, SomePBC)
    clsdef = None
    more_than_one = len(s_clspbc.descriptions)
    for desc in s_clspbc.descriptions:
        cdef = desc.getuniqueclassdef()
        if more_than_one:
            getbookkeeper().needs_generic_instantiate[cdef] = True
        if not clsdef:
            clsdef = cdef
        else:
            clsdef = clsdef.commonbase(cdef)
    return SomeInstance(clsdef)
开发者ID:alkorzt,项目名称:pypy,代码行数:13,代码来源:builtin.py


示例18: ann_startthr

def ann_startthr(s_bootstrap_function, s_argument_tuple):
    from pypy.annotation import model as annmodel
    from pypy.annotation.bookkeeper import getbookkeeper
    bookkeeper = getbookkeeper()
    assert (isinstance(s_argument_tuple, annmodel.SomeTuple) and
            len(s_argument_tuple.items) == 1), (
        """thread.start_new_thread(f, arg) is only supported with a tuple of
           length 1 for arg""")
    s_arg, = s_argument_tuple.items
    # XXX hack hack hack: emulate a call to s_bootstrap_function
    s_result = bookkeeper.emulate_pbc_call(bookkeeper.position_key, s_bootstrap_function, [s_arg])
    assert annmodel.s_None.contains(s_result), (
        """thread.start_new_thread(f, arg): f() should return None""")
    return annmodel.SomeInteger()
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:14,代码来源:exttable.py


示例19: ll_to_annotation

def ll_to_annotation(v):
    if v is None:
        # i think we can only get here in the case of void-returning
        # functions
        return s_None
    if isinstance(v, MethodType):
        ll_ptrtype = lltype.typeOf(v.im_self)
        assert isinstance(ll_ptrtype, lltype.Ptr)
        return SomeLLADTMeth(ll_ptrtype, v.im_func)
    if isinstance(v, FunctionType):
        # this case should only be for staticmethod instances used in
        # adtmeths: the getattr() result is then a plain FunctionType object.
        from pypy.annotation.bookkeeper import getbookkeeper
        return getbookkeeper().immutablevalue(v)
    return lltype_to_annotation(lltype.typeOf(v))
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:15,代码来源:model.py


示例20: compute_result_annotation

 def compute_result_annotation(self, s_arg):
     from pypy.annotation.bookkeeper import getbookkeeper
     from atype import SomeVarSizedCTypesType
     if isinstance(s_arg, SomeVarSizedCTypesType):
         # POINTER(varsized_array_type): given that rctypes performs
         # no index checking, this pointer-to-array type is equivalent
         # to a pointer to an array of whatever size.
         # ('0' is a bad idea, though, as FixedSizeArrays of length 0
         # tend to say they have impossible items.)
         RESTYPE = POINTER(s_arg.ctype_array._type_ * 1)
     else:
         # POINTER(constant_ctype) returns the constant annotation
         # corresponding to the POINTER(ctype).
         assert s_arg.is_constant(), (
             "POINTER(%r): argument must be constant" % (s_arg,))
         RESTYPE = POINTER(s_arg.const)
     return getbookkeeper().immutablevalue(RESTYPE)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:17,代码来源:apointer.py



注:本文中的pypy.annotation.bookkeeper.getbookkeeper函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python model.annotation_to_lltype函数代码示例发布时间:2022-05-27
下一篇:
Python annrpython.RPythonAnnotator类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap