本文整理汇总了Python中pypy.rpython.ootypesystem.ootype.null函数的典型用法代码示例。如果您正苦于以下问题:Python null函数的具体用法?Python null怎么用?Python null使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了null函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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)
示例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
示例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
示例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)
示例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
示例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"
示例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)
示例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)
示例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
示例11: convert_const
def convert_const(self, value):
if value is None:
return ootype.null(self.lowleveltype)
else:
return Repr.convert_const(self, value)
示例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
示例13: to_rstr
def to_rstr(s):
if s is None:
return ootype.null(ootype.String)
return ootype.oostring(s, -1)
示例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
示例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)