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

Python ootype.null函数代码示例

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

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



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

示例1: fn_null

 def fn_null():
     a = ootype.null(A)
     b = ootype.null(B)
     obj1 = ootype.cast_to_object(a)
     obj2 = ootype.cast_to_object(b)
     assert obj1 == obj2
     assert ootype.cast_from_object(A, obj1) == a
     assert ootype.cast_from_object(B, obj2) == b
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:test_rclass.py


示例2: fn_is_true

 def fn_is_true(flag):
     if flag:
         a = ootype.new(A)
     else:
         a = ootype.null(A)
     obj = ootype.cast_to_object(a)
     return bool(obj)
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:test_rclass.py


示例3: push_primitive_constant

    def push_primitive_constant(self, TYPE, value):

        if TYPE is ootype.Void:
            return
        elif isinstance(value, CDefinedIntSymbolic):
            self.emit(jvm.ICONST, self.DEFINED_INT_SYMBOLICS[value.expr])
        elif TYPE in (ootype.Bool, ootype.Signed):
            self.emit(jvm.ICONST, int(value))
        elif TYPE is ootype.Unsigned:
            # Converts the unsigned int into its corresponding signed value:
            if value > 0x7FFFFFFF:
                value = -((int(value) ^ 0xFFFFFFFF)+1)
            self.emit(jvm.ICONST, value)
        elif TYPE is ootype.Char or TYPE is ootype.UniChar:
            self.emit(jvm.ICONST, ord(value))
        elif TYPE is ootype.SignedLongLong:
            self._push_long_constant(long(value))
        elif TYPE is ootype.UnsignedLongLong:
            # Converts the unsigned long into its corresponding signed value:
            if value > 0x7FFFFFFFFFFFFFFF:
                value = -((long(value) ^ 0xFFFFFFFFFFFFFFFF)+1)
            self._push_long_constant(value)
        elif TYPE is ootype.Float:
            self._push_double_constant(float(value))
        elif TYPE in (ootype.String, ootype.Unicode):
            if value == ootype.null(TYPE):
                self.emit(jvm.ACONST_NULL)
            else:
                self.load_string(value._str)
        else:
            assert False, 'Unknown constant type: %s' % TYPE
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:31,代码来源:generator.py


示例4: setup_excdata

    def setup_excdata(self):
        EXCDATA = ootype.Record({'exc_type': self.lltype_of_exception_type,
                                 'exc_value': self.lltype_of_exception_value})
        self.EXCDATA = EXCDATA

        exc_data = ootype.new(EXCDATA)
        null_type = ootype.null(self.lltype_of_exception_type)
        null_value = ootype.null(self.lltype_of_exception_value)

        self.exc_data_ptr = exc_data
        self.cexcdata = Constant(exc_data, self.EXCDATA)

        self.c_null_etype = Constant(null_type, self.lltype_of_exception_type)
        self.c_null_evalue = Constant(null_value, self.lltype_of_exception_value)

        return exc_data, null_type, null_value
开发者ID:antoine1fr,项目名称:pygirl,代码行数:16,代码来源:exceptiontransform.py


示例5: record_dependencies

 def record_dependencies(self):
     if self.value is ootype.null(self.value._TYPE):
         self.delegate_impl = None
         return
     StaticMethodConst.record_dependencies(self)
     self.delegate_impl = self.db.record_delegate_standalone_func_impl(
         self.value.graph)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:7,代码来源:constant.py


示例6: ll_tuplenext

def ll_tuplenext(iter):
    # for iterating over length 1 tuples only!
    t = iter.iterable
    if t:
        iter.iterable = ootype.null(ootype.typeOf(t))
        return t.item0
    else:
        raise StopIteration
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:8,代码来源:rtuple.py


示例7: error_value

def error_value(T):
    if isinstance(T, lltype.Primitive):
        return PrimitiveErrorValue[T]
    elif isinstance(T, lltype.Ptr):
        return lltype.nullptr(T.TO)
    elif isinstance(T, ootype.OOType):
        return ootype.null(T)
    assert 0, "not implemented yet"
开发者ID:antoine1fr,项目名称:pygirl,代码行数:8,代码来源:exceptiontransform.py


示例8: check_declaration

 def check_declaration(self, arg):
     if isinstance(arg, Constant):
         if isinstance(arg.concretetype, (Record, Instance)):
             if arg.value is null(arg.concretetype):
                 return "nil"
         if isinstance(arg.concretetype, Instance):
             return self.declare_constant_instance(arg)
     return clrepr(arg)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:8,代码来源:gencl.py


示例9: specialize_call

    def specialize_call(self, hop):
        from pypy.rpython import rpbc
        PTR = hop.r_result.lowleveltype
        if isinstance(PTR, lltype.Ptr):
            T = lltype.Ptr
            opname = 'cast_pointer'
            null = lltype.nullptr(PTR.TO)
        elif isinstance(PTR, ootype.Instance):
            T = ootype.Instance
            opname = 'ooupcast'
            null = ootype.null(PTR)
        else:
            assert False

        if isinstance(hop.args_r[1], rpbc.NoneFrozenPBCRepr):
            return hop.inputconst(PTR, null)
        v_arg = hop.inputarg(hop.args_r[1], arg=1)
        assert isinstance(v_arg.concretetype, T)
        hop.exception_cannot_occur()
        return hop.genop(opname, [v_arg], resulttype = PTR)
开发者ID:gorakhargosh,项目名称:pypy,代码行数:20,代码来源:annlowlevel.py


示例10: _create_complex_const

    def _create_complex_const(self, value):

        """ A helper method which creates a Constant wrapper object for
        the given value.  Uses the types defined in the sub-class. """

        # Determine if the static type differs from the dynamic type.
        if isinstance(value, ootype._view):
            static_type = value._TYPE
            value = value._inst
        else:
            static_type = None

        # Find the appropriate kind of Const object.
        genoo = self.genoo
        uniq = self.db.unique()
        if isinstance(value, ootype._instance):
            return genoo.InstanceConst(self.db, value, static_type, uniq)
        elif isinstance(value, ootype._record):
            return genoo.RecordConst(self.db, value, uniq)
        elif isinstance(value, ootype._class):
            return genoo.ClassConst(self.db, value, uniq)
        elif isinstance(value, ootype._list):
            return genoo.ListConst(self.db, value, uniq)
        elif isinstance(value, ootype._array):
            return genoo.ArrayConst(self.db, value, uniq)
        elif isinstance(value, ootype._static_meth):
            return genoo.StaticMethodConst(self.db, value, uniq)
        elif isinstance(value, ootype._custom_dict):
            return genoo.CustomDictConst(self.db, value, uniq)
        elif isinstance(value, ootype._dict):
            return genoo.DictConst(self.db, value, uniq)
        elif isinstance(value, ootype._weak_reference):
            return genoo.WeakRefConst(self.db, value, uniq)
        elif value is ootype.null(value._TYPE):
            # for NULL values, we can just use "NULL" const.  This is
            # a fallback since we sometimes have constants of
            # unhandled types which are equal to NULL.
            return genoo.NullConst(self.db, value, uniq)
        else:
            assert False, 'Unknown constant: %s' % value        
开发者ID:enyst,项目名称:plexnet,代码行数:40,代码来源:constant.py


示例11: convert_const

 def convert_const(self, value):
     if value is None:
         return ootype.null(self.lowleveltype)
     else:
         return Repr.convert_const(self, value)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:5,代码来源:rootype.py


示例12: null

def null(I_OR_SM):
    assert I_OR_SM.is_constant()
    null = ootype.null(I_OR_SM.const)
    r = lltype_to_annotation(ootype.typeOf(null))
    return r
开发者ID:alkorzt,项目名称:pypy,代码行数:5,代码来源:builtin.py


示例13: to_rstr

 def to_rstr(s):
     if s is None:
         return ootype.null(ootype.String)
     return ootype.oostring(s, -1)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:4,代码来源:support.py


示例14: test_cast_record_mix_object

 def test_cast_record_mix_object(self):
     T = ootype.Record({'x': ootype.Signed})
     NULL = ootype.null(System.Object._INSTANCE)
     record = cast_record_to_object(ootype.new(T))
     assert record != NULL
     assert NULL != record
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:6,代码来源:test_dotnet.py


示例15: rtype_null

def rtype_null(hop):
    hop.exception_cannot_occur()
    assert hop.args_s[0].is_constant()
    TYPE = hop.args_s[0].const
    nullvalue = ootype.null(TYPE)
    return hop.inputconst(TYPE, nullvalue)
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:6,代码来源:rbuiltin.py


示例16: record_dependencies

 def record_dependencies(self):
     if self.value is ootype.null(self.value._TYPE):
         return
     if hasattr(self.value, 'graph'):
         self.db.pending_function(self.value.graph)
     self.delegate_type = self.db.record_delegate(self.value._TYPE)
开发者ID:enyst,项目名称:plexnet,代码行数:6,代码来源:constant.py


示例17: is_null

 def is_null(self):
     return self.value is ootype.null(self.value._TYPE)
开发者ID:enyst,项目名称:plexnet,代码行数:2,代码来源:constant.py


示例18: null_callable

 def null_callable(self, T):
     return ootype.null(T)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:2,代码来源:typesystem.py


示例19: genop2

    @specialize.arg(1)
    def genop2(self, opname, gv_arg1, gv_arg2):
        # XXX: this only serves to mask a bug in gencli which I don't
        # feel like fixing now. Try to uncomment this and run
        # test_goto_compile to see why it fails
        return Builder.genop2(self, opname, gv_arg1, gv_arg2)

    def emit(self, op):
        self.operations.append(op)

    def appendbranch(self, branch):
        self.parent.appendbranch(branch)

    def appendreturn(self, retlabel, gv_returnvar):
        self.parent.appendreturn(retlabel, gv_returnvar)

    def end(self):
        self.parent.end()

    def replayops(self):
        assert not self.isOpen
        assert not self.parent.isOpen
        il = self.parent.il
        il.MarkLabel(self.label)        
        for op in self.operations:
            op.emit()

global_rgenop = RCliGenOp()
RCliGenOp.constPrebuiltGlobal = global_rgenop.genconst
zero_const = ObjectConst(ootype.null(ootype.ROOT))
开发者ID:antoine1fr,项目名称:pygirl,代码行数:30,代码来源:rgenop.py


示例20: ll_inst_type

def ll_inst_type(obj):
    if obj:
        return obj.meta
    else:
        # type(None) -> NULL  (for now)
        return ootype.null(CLASSTYPE)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:6,代码来源:rclass.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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