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

Python rmodel.inputconst函数代码示例

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

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



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

示例1: _generate_newlist

 def _generate_newlist(self, llops, items_v):
     c_list = inputconst(ootype.Void, self.lowleveltype)
     v_result = llops.genop("new", [c_list], resulttype=self.lowleveltype)
     c_resize = inputconst(ootype.Void, "_ll_resize")
     c_length = inputconst(ootype.Signed, len(items_v))
     llops.genop("oosend", [c_resize, v_result, c_length], resulttype=ootype.Void)
     return v_result
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:rlist.py


示例2: gettype_from_unboxed

 def gettype_from_unboxed(self, llops, vinst, can_be_none=False):
     unboxedclass_repr = getclassrepr(self.rtyper, self.unboxedclassdef)
     cunboxedcls = inputconst(CLASSTYPE, unboxedclass_repr.getvtable())
     if self.is_parent:
         # If the lltype of vinst shows that it cannot be a tagged value,
         # we can directly read the typeptr.  Otherwise, call a helper that
         # checks if the tag bit is set in the pointer.
         unboxedinstance_repr = getinstancerepr(self.rtyper,
                                                self.unboxedclassdef)
         try:
             lltype.castable(unboxedinstance_repr.lowleveltype,
                             vinst.concretetype)
         except lltype.InvalidCast:
             can_be_tagged = False
         else:
             can_be_tagged = True
         vinst = llops.genop('cast_pointer', [vinst],
                             resulttype=self.common_repr())
         if can_be_tagged:
             if can_be_none:
                 func = ll_unboxed_getclass_canbenone
             else:
                 func = ll_unboxed_getclass
             return llops.gendirectcall(func, vinst,
                                        cunboxedcls)
         elif can_be_none:
             return llops.gendirectcall(ll_inst_type, vinst)
         else:
             ctypeptr = inputconst(lltype.Void, 'typeptr')
             return llops.genop('getfield', [vinst, ctypeptr],
                                resulttype = CLASSTYPE)
     else:
         return cunboxedcls
开发者ID:alkorzt,项目名称:pypy,代码行数:33,代码来源:rtagged.py


示例3: _gct_resize_buffer_no_realloc

 def _gct_resize_buffer_no_realloc(self, hop, v_lgt):
     op = hop.spaceop
     meth = self.gct_fv_gc_malloc_varsize
     flags = {'flavor':'gc', 'varsize': True, 'keep_current_args': True}
     self.varsize_malloc_helper(hop, flags, meth, [])
     # fish resvar
     v_newbuf = hop.llops[-1].result
     v_src = op.args[0]
     TYPE = v_src.concretetype.TO
     c_fldname = rmodel.inputconst(lltype.Void, TYPE._arrayfld)
     v_adrsrc = hop.genop('cast_ptr_to_adr', [v_src],
                          resulttype=llmemory.Address)
     v_adrnewbuf = hop.genop('cast_ptr_to_adr', [v_newbuf],
                             resulttype=llmemory.Address)
     ofs = (llmemory.offsetof(TYPE, TYPE._arrayfld) +
            llmemory.itemoffsetof(getattr(TYPE, TYPE._arrayfld), 0))
     v_ofs = rmodel.inputconst(lltype.Signed, ofs)
     v_adrsrc = hop.genop('adr_add', [v_adrsrc, v_ofs],
                          resulttype=llmemory.Address)
     v_adrnewbuf = hop.genop('adr_add', [v_adrnewbuf, v_ofs],
                             resulttype=llmemory.Address)
     size = llmemory.sizeof(getattr(TYPE, TYPE._arrayfld).OF)
     c_size = rmodel.inputconst(lltype.Signed, size)
     v_lgtsym = hop.genop('int_mul', [c_size, v_lgt],
                          resulttype=lltype.Signed) 
     vlist = [v_adrsrc, v_adrnewbuf, v_lgtsym]
     hop.genop('raw_memcopy', vlist)
开发者ID:enyst,项目名称:plexnet,代码行数:27,代码来源:transform.py


示例4: gendirectcall

    def gendirectcall(self, ll_function, *args_v):
        rtyper = self.rtyper
        args_s = []
        newargs_v = []
        for v in args_v:
            if v.concretetype is Void:
                s_value = rtyper.binding(v, default=annmodel.s_None)
                if not s_value.is_constant():
                    raise TyperError("non-constant variable of type Void")
                if not isinstance(s_value, annmodel.SomePBC):
                    raise TyperError("non-PBC Void argument: %r", (s_value,))
                args_s.append(s_value)
            else:
                args_s.append(annmodel.lltype_to_annotation(v.concretetype))
            newargs_v.append(v)
        
        self.rtyper.call_all_setups()  # compute ForwardReferences now

        # hack for bound methods
        if hasattr(ll_function, 'im_func'):
            bk = rtyper.annotator.bookkeeper
            args_s.insert(0, bk.immutablevalue(ll_function.im_self))
            newargs_v.insert(0, inputconst(Void, ll_function.im_self))
            ll_function = ll_function.im_func

        graph = annotate_lowlevel_helper(rtyper.annotator, ll_function, args_s,
                                         rtyper.lowlevel_ann_policy)
        self.record_extra_call(graph)

        # build the 'direct_call' operation
        f = self.rtyper.getcallable(graph)
        c = inputconst(typeOf(f), f)
        fobj = self.rtyper.type_system_deref(f)
        return self.genop('direct_call', [c]+newargs_v,
                          resulttype = typeOf(fobj).RESULT)
开发者ID:ieure,项目名称:pypy,代码行数:35,代码来源:rtyper.py


示例5: rtype_bltn_list

    def rtype_bltn_list(self, hop):
        from pypy.rpython.ootypesystem import rlist
        v_tup = hop.inputarg(self, 0)
        RESULT = hop.r_result.lowleveltype
        c_resulttype = inputconst(ootype.Void, RESULT)
        c_length = inputconst(ootype.Signed, len(self.items_r))
        hop.exception_is_here()
        if isinstance(RESULT, ootype.Array):
            v_list = hop.genop('oonewarray', [c_resulttype, c_length], resulttype=RESULT)
        else:
            assert isinstance(RESULT, ootype.List)
            v_list = hop.genop('new', [c_resulttype], resulttype=RESULT)
            c_resize = inputconst(ootype.Void, '_ll_resize')
            hop.genop('oosend', [c_resize, v_list, c_length], resulttype=ootype.Void)

        c_setitem = inputconst(ootype.Void, 'll_setitem_fast')
        
        for index in range(len(self.items_r)):
            name = self.fieldnames[index]
            r_item = self.items_r[index]
            c_name = hop.inputconst(ootype.Void, name)
            v_item = hop.genop("oogetfield", [v_tup, c_name], resulttype=r_item)
            v_item = hop.llops.convertvar(v_item, r_item, hop.r_result.item_repr)
            c_index = inputconst(ootype.Signed, index)
            hop.genop('oosend', [c_setitem, v_list, c_index, v_item], resulttype=ootype.Void)
            
        return v_list
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:27,代码来源:rtuple.py


示例6: new_instance

 def new_instance(self, llops, classcallhop=None):
     """Build a new instance, without calling __init__."""
     flavor = self.gcflavor
     flags = {'flavor': flavor }
     ctype = inputconst(Void, self.object_type)
     cflags = inputconst(Void, flags)
     vlist = [ctype, cflags]
     vptr = llops.genop('malloc', vlist,
                        resulttype = Ptr(self.object_type))
     ctypeptr = inputconst(CLASSTYPE, self.rclass.getvtable())
     self.setfield(vptr, '__class__', ctypeptr, llops)
     # initialize instance attributes from their defaults from the class
     if self.classdef is not None:
         flds = self.allinstancefields.keys()
         flds.sort()
         for fldname in flds:
             if fldname == '__class__':
                 continue
             mangled_name, r = self.allinstancefields[fldname]
             if r.lowleveltype is Void:
                 continue
             if fldname == '_hash_cache_':
                 value = Constant(0, Signed)
             else:
                 value = self.classdef.classdesc.read_attribute(fldname, None)
             if value is not None:
                 cvalue = inputconst(r.lowleveltype,
                                     r.convert_desc_or_const(value))
                 self.setfield(vptr, fldname, cvalue, llops,
                               {'access_directly': True})
     return vptr
开发者ID:antoine1fr,项目名称:pygirl,代码行数:31,代码来源:rclass.py


示例7: rtype_is_true

 def rtype_is_true(self, hop):
     if not self.s_pbc.can_be_None:
         return inputconst(Bool, True)
     else:
         v1, = hop.inputargs(self)
         return hop.genop('char_ne', [v1, inputconst(Char, '\000')],
                      resulttype=Bool)
开发者ID:ieure,项目名称:pypy,代码行数:7,代码来源:rpbc.py


示例8: dispatcher

 def dispatcher(self, shape, index, argtypes, resulttype):
     key = shape, index, tuple(argtypes), resulttype
     if key in self._dispatch_cache:
         return self._dispatch_cache[key]
     from pypy.translator.unsimplify import varoftype
     from pypy.objspace.flow.model import FunctionGraph, Link, Block, SpaceOperation
     inputargs = [varoftype(t) for t in [Char] + argtypes]
     startblock = Block(inputargs)
     startblock.exitswitch = inputargs[0]
     graph = FunctionGraph("dispatcher", startblock, varoftype(resulttype))
     row_of_graphs = self.callfamily.calltables[shape][index]
     links = []
     descs = list(self.s_pbc.descriptions)
     if self.s_pbc.can_be_None:
         descs.insert(0, None)
     for desc in descs:
         if desc is None:
             continue
         args_v = [varoftype(t) for t in argtypes]
         b = Block(args_v)
         llfn = self.rtyper.getcallable(row_of_graphs[desc])
         v_fn = inputconst(typeOf(llfn), llfn)
         v_result = varoftype(resulttype)
         b.operations.append(
             SpaceOperation("direct_call", [v_fn] + args_v, v_result))
         b.closeblock(Link([v_result], graph.returnblock))
         i = self.descriptions.index(desc)
         links.append(Link(inputargs[1:], b, chr(i)))
         links[-1].llexitcase = chr(i)
     startblock.closeblock(*links)
     self.rtyper.annotator.translator.graphs.append(graph)
     ll_ret = self.rtyper.type_system.getcallable(graph)
     #FTYPE = FuncType
     c_ret = self._dispatch_cache[key] = inputconst(typeOf(ll_ret), ll_ret)
     return c_ret
开发者ID:ieure,项目名称:pypy,代码行数:35,代码来源:rpbc.py


示例9: gct_fv_gc_coalloc

    def gct_fv_gc_coalloc(self, hop, coallocator, flags, TYPE, *args):
        if self.coalloc_clear_ptr is None:
            return self.gct_fv_gc_malloc(
                    hop, flags, TYPE, *args)
        op = hop.spaceop
        flavor = flags['flavor']
        assert not flags.get("nocollect", False)

        PTRTYPE = op.result.concretetype
        assert PTRTYPE.TO == TYPE
        type_id = self.get_type_id(TYPE)

        c_type_id = rmodel.inputconst(lltype.Signed, type_id)
        info = self.layoutbuilder.type_info_list[type_id]
        c_size = rmodel.inputconst(lltype.Signed, info.fixedsize)
        has_finalizer = bool(self.finalizer_funcptr_for_type(TYPE))
        assert not has_finalizer

        v_coallocator = gen_cast(hop.llops, llmemory.Address, coallocator)

        if not op.opname.endswith('_varsize'):
            malloc_ptr = self.coalloc_clear_ptr
            args = [self.c_const_gc, v_coallocator, c_type_id, c_size]
        else:
            v_length = op.args[-1]
            c_ofstolength = rmodel.inputconst(lltype.Signed, info.ofstolength)
            c_varitemsize = rmodel.inputconst(lltype.Signed, info.varitemsize)
            malloc_ptr = self.coalloc_varsize_clear_ptr
            args = [self.c_const_gc, v_coallocator, c_type_id, v_length, c_size,
                    c_varitemsize, c_ofstolength]
        livevars = self.push_roots(hop)
        v_result = hop.genop("direct_call", [malloc_ptr] + args,
                             resulttype=llmemory.GCREF)
        self.pop_roots(hop, livevars)
        return v_result
开发者ID:antoine1fr,项目名称:pygirl,代码行数:35,代码来源:framework.py


示例10: gct_weakref_create

    def gct_weakref_create(self, hop):
        op = hop.spaceop

        type_id = self.get_type_id(WEAKREF)

        c_type_id = rmodel.inputconst(lltype.Signed, type_id)
        info = self.layoutbuilder.type_info_list[type_id]
        c_size = rmodel.inputconst(lltype.Signed, info.fixedsize)
        malloc_ptr = self.malloc_fixedsize_ptr
        c_has_finalizer = rmodel.inputconst(lltype.Bool, False)
        c_has_weakptr = c_can_collect = rmodel.inputconst(lltype.Bool, True)
        args = [self.c_const_gc, c_type_id, c_size, c_can_collect,
                c_has_finalizer, c_has_weakptr]

        # push and pop the current live variables *including* the argument
        # to the weakref_create operation, which must be kept alive and
        # moved if the GC needs to collect
        livevars = self.push_roots(hop, keep_current_args=True)
        v_result = hop.genop("direct_call", [malloc_ptr] + args,
                             resulttype=llmemory.GCREF)
        v_result = hop.genop("cast_opaque_ptr", [v_result],
                            resulttype=WEAKREFPTR)
        self.pop_roots(hop, livevars)
        # cast_ptr_to_adr must be done after malloc, as the GC pointer
        # might have moved just now.
        v_instance, = op.args
        v_addr = hop.genop("cast_ptr_to_adr", [v_instance],
                           resulttype=llmemory.Address)
        hop.genop("bare_setfield",
                  [v_result, rmodel.inputconst(lltype.Void, "weakptr"), v_addr])
        v_weakref = hop.genop("cast_ptr_to_weakrefptr", [v_result],
                              resulttype=llmemory.WeakRefPtr)
        hop.cast_result(v_weakref)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:33,代码来源:framework.py


示例11: get_resume_point_link

    def get_resume_point_link(self, block):
        try:
            return self.resumepoints[block]
        except KeyError:
            resumeblock = Block([])
            redcount   = 0
            greencount = 0
            newvars = []
            for v in block.inputargs:
                if v.concretetype is lltype.Void:
                    v1 = self.c_dummy
                elif self.hannotator.binding(v).is_green():
                    c = inputconst(lltype.Signed, greencount)
                    v1 = self.genop(resumeblock, 'restore_green', [c],
                                    result_like = v)
                    greencount += 1
                else:
                    c = inputconst(lltype.Signed, redcount)
                    v1 = self.genop(resumeblock, 'restore_local', [c],
                                    result_like = v)
                    redcount += 1
                newvars.append(v1)

            resumeblock.closeblock(Link(newvars, block))
            reenter_link = Link([], resumeblock)
            N = len(self.resumepoints)
            reenter_link.exitcase = N
            self.resumepoints[block] = reenter_link
            return reenter_link
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:29,代码来源:transform.py


示例12: newlist

def newlist(llops, r_list, items_v):
    v_result = r_list._generate_newlist(llops, items_v)

    c_setitem = inputconst(ootype.Void, "ll_setitem_fast")
    for i, v_item in enumerate(items_v):
        ci = inputconst(Signed, i)
        llops.genop("oosend", [c_setitem, v_result, ci, v_item], resulttype=ootype.Void)
    return v_result
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:rlist.py


示例13: set_vable

 def set_vable(self, llops, vinst, force_cast=False):
     if self.top_of_virtualizable_hierarchy:
         if force_cast:
             vinst = llops.genop('cast_pointer', [vinst], resulttype=self)
         cname = inputconst(lltype.Void, 'vable_token')
         cvalue = inputconst(lltype.Signed, 0)
         llops.genop('setfield', [vinst, cname, cvalue])
     else:
         self.rbase.set_vable(llops, vinst, force_cast=True)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:9,代码来源:rvirtualizable2.py


示例14: set_vable

 def set_vable(self, llops, vinst, force_cast=False):
     if self.top_of_virtualizable_hierarchy:
         if force_cast:
             vinst = llops.genop('cast_pointer', [vinst], resulttype=self)
         cname = inputconst(lltype.Void, 'vable_rti')
         vvalue = inputconst(VABLERTIPTR, lltype.nullptr(VABLERTIPTR.TO))
         llops.genop('setfield', [vinst, cname, vvalue])
     else:
         self.rbase.set_vable(llops, vinst, force_cast=True)
开发者ID:enyst,项目名称:plexnet,代码行数:9,代码来源:rvirtualizable2.py


示例15: get_c_data

 def get_c_data(self, llops, v_box):
     if self.ownsmemory:
         inputargs = [v_box, inputconst(lltype.Void, "c_data")]
         return llops.genop('getsubstruct', inputargs,
                     lltype.Ptr(self.c_data_type) )
     else:
         inputargs = [v_box, inputconst(lltype.Void, "c_data")]
         return llops.genop('getfield', inputargs,
                     lltype.Ptr(self.c_data_type) )
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:9,代码来源:rmodel.py


示例16: newtuple

 def newtuple(cls, llops, r_tuple, items_v):
     # items_v should have the lowleveltype of the internal reprs
     if len(r_tuple.items_r) == 0:
         return inputconst(r_tuple, ()) # always the same empty tuple
     c1 = inputconst(ootype.Void, r_tuple.lowleveltype)
     v_result = llops.genop("new", [c1], resulttype=r_tuple.lowleveltype)
     for i in range(len(r_tuple.items_r)):
         cname = inputconst(ootype.Void, r_tuple.fieldnames[i])
         llops.genop("oosetfield", [v_result, cname, items_v[i]])
     return v_result
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:10,代码来源:rtuple.py


示例17: convert_scalar_to_array

def convert_scalar_to_array(r_item, v_item, llops):
    # x -> array([x])
    s_item = lltype_to_annotation(r_item.lowleveltype)
    s_array = aarray.build_annotation_from_scalar(s_item)
    r_array = llops.rtyper.getrepr(s_array)
    from pypy.rpython.rmodel import inputconst
    cARRAY = inputconst(Void, r_array.ARRAY.TO)
    cITEM = inputconst(Void, r_array.ITEM)
    v_casted = llops.genop("cast_primitive", [v_item], r_array.ITEM)
    v_array = llops.gendirectcall(ll_build_from_scalar, cARRAY, v_casted)
    return r_array, v_array
开发者ID:alkorzt,项目名称:pypy,代码行数:11,代码来源:rarray.py


示例18: push_roots

 def push_roots(self, hop):
     if self.push_root_ptr is None:
         return
     livevars = [var for var in self.livevars if not var_ispyobj(var)]
     c_len = rmodel.inputconst(lltype.Signed, len(livevars) )
     base_addr = hop.genop("direct_call", [self.incr_stack_ptr, c_len ],
                           resulttype=llmemory.Address)
     for k,var in enumerate(livevars):
         c_k = rmodel.inputconst(lltype.Signed, k)
         v_adr = gen_cast(hop.llops, llmemory.Address, var)
         hop.genop("direct_call", [self.save_addr_ptr, base_addr, c_k, v_adr])
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:11,代码来源:framework.py


示例19: set_vable

 def set_vable(self, llops, vinst, force_cast=False):
     if self.top_of_virtualizable_hierarchy:
         if force_cast:
             vinst = llops.genop('cast_pointer', [vinst], resulttype=self)
         for name, llvalue in (('access', lltype.nullptr(self.ACCESS)),
                               ('base',   llmemory.NULL),
                               ('rti',    lltype.nullptr(VABLERTIPTR.TO))):
             cname = inputconst(lltype.Void, 'vable_'+name)
             vvalue = inputconst(lltype.typeOf(llvalue), llvalue)
             llops.genop('setfield', [vinst, cname, vvalue])
     else:
         self.rbase.set_vable(llops, vinst, force_cast=True)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:12,代码来源:rvirtualizable.py


示例20: newtuple

 def newtuple(cls, llops, r_tuple, items_v):
     # items_v should have the lowleveltype of the internal reprs
     if len(r_tuple.items_r) == 0:
         return inputconst(Void, ())    # a Void empty tuple
     c1 = inputconst(Void, r_tuple.lowleveltype.TO)
     cflags = inputconst(Void, {'flavor': 'gc'})
     v_result = llops.genop('malloc', [c1, cflags],
                                      resulttype = r_tuple.lowleveltype)
     for i in range(len(r_tuple.items_r)):
         cname = inputconst(Void, r_tuple.fieldnames[i])
         llops.genop('setfield', [v_result, cname, items_v[i]])
     return v_result
开发者ID:alkorzt,项目名称:pypy,代码行数:12,代码来源:rtuple.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python rtyper.RPythonTyper类代码示例发布时间:2022-05-27
下一篇:
Python rclass.getinstancerepr函数代码示例发布时间: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