本文整理汇总了Python中pypy.rpython.ootypesystem.ootype.typeOf函数的典型用法代码示例。如果您正苦于以下问题:Python typeOf函数的具体用法?Python typeOf怎么用?Python typeOf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了typeOf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_oounicode
def test_oounicode():
u = ootype.oounicode(u'a', -1)
assert isinstance(u, ootype._string)
assert ootype.typeOf(u) is ootype.Unicode
s = ootype.make_string('a string')
u = ootype.oounicode(s, -1)
assert isinstance(u, ootype._string)
assert ootype.typeOf(u) is ootype.Unicode
s = ootype.make_string('non-ascii string: \xe0')
py.test.raises(UnicodeDecodeError, ootype.oounicode, s, -1)
示例2: constant
def constant(value):
if isinstance(lltype.typeOf(value), lltype.Ptr):
return ConstPtr(value)
elif isinstance(ootype.typeOf(value), ootype.OOType):
return ConstObj(ootype.cast_to_object(value))
else:
return ConstInt(value)
示例3: 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
示例4: get_primitive_constant
def get_primitive_constant(TYPE, value):
if is_primitive(TYPE):
return TYPE, value
if TYPE is ootype.Object:
obj = value.obj
T2 = ootype.typeOf(obj)
if obj is not None and is_primitive(T2):
return T2, obj
return None, None
示例5: static_meth_to_signature
def static_meth_to_signature(self, sm):
from pypy.translator.oosupport import metavm
graph = getattr(sm, 'graph', None)
if graph:
return self.graph_to_signature(graph)
module, name = metavm.get_primitive_name(sm)
func_name = '[pypylib]pypy.builtin.%s::%s' % (module, name)
T = ootype.typeOf(sm)
return self.format_signatue(func_name, T.ARGS, T.RESULT)
示例6: __init__
def __init__(self, rtyper, methdescs):
samplemdesc = methdescs.iterkeys().next()
concretetable, uniquerows = get_concrete_calltable(rtyper, samplemdesc.funcdesc.getcallfamily())
self.row_mapping = {}
for row in uniquerows:
sample_as_static_meth = row.itervalues().next()
SM = ootype.typeOf(sample_as_static_meth)
M = ootype.Meth(SM.ARGS[1:], SM.RESULT) # cut self
self.row_mapping[row.attrname] = row, M
示例7: genconst
def genconst(self, llvalue):
T = ootype.typeOf(llvalue)
if T is ootype.Signed:
return IntConst(llvalue)
elif T is ootype.Bool:
return IntConst(int(llvalue))
elif isinstance(T, ootype.OOType):
return ObjectConst(box(llvalue))
else:
assert False, "XXX not implemented"
示例8: attach_class_attr_accessor
def attach_class_attr_accessor(self, mangled, oovalue):
def ll_getclassattr(self):
return oovalue
M = ootype.Meth([], ootype.typeOf(oovalue))
ll_getclassattr = func_with_new_name(ll_getclassattr,
'll_get_' + mangled)
graph = self.rtyper.annotate_helper(ll_getclassattr, [self.lowleveltype])
m = ootype.meth(M, _name=mangled, _callable=ll_getclassattr,
graph=graph)
ootype.addMethods(self.lowleveltype, {mangled: m})
示例9: clrepr
def clrepr(item, symbol=False):
""" This is the main repr function and is the only one that should be
used to represent python values in lisp.
"""
if item is None:
return "nil"
fun = bltn_dispatch.get(type(item), None)
if fun is not None:
return fun(item, symbol)
if typeOf(item) is Class:
return "'" + item._INSTANCE._name
return repr_unknown(item)
示例10: _dont_store
def _dont_store(self, to_load, to_store):
# ugly workaround to make the exceptiontransformer work with
# valuetypes: when exceptiontransforming a function whose result is a
# .NET valuetype, it tries to store a null into the return variable.
# Since it is not possible to store a null into a valuetype, and that
# in that case the value is not used anyway, we simply ignore it.
from pypy.translator.cli.dotnet import NativeInstance
if isinstance(to_load, flowmodel.Constant):
value = to_load.value
is_null = (not isinstance(value, CDefinedIntSymbolic)) and (not value)
T = ootype.typeOf(to_load.value)
if isinstance(T, NativeInstance) and T._is_value_type and is_null:
return True
return OOFunction._dont_store(self, to_load, to_store)
示例11: __init__
def __init__(self, SELFTYPE, methname):
_, meth = SELFTYPE._lookup(methname)
METH = ootype.typeOf(meth)
self.SELFTYPE = SELFTYPE
self.METH = METH
self.methname = methname
RESULT = METH.RESULT
getargs = make_getargs(METH.ARGS)
def callmeth(selfbox, argboxes):
selfobj = selfbox.getref(SELFTYPE)
meth = getattr(selfobj, methname)
methargs = getargs(argboxes)
res = llimpl.call_maybe_on_top_of_llinterp(meth, methargs)
if RESULT is not ootype.Void:
return boxresult(RESULT, res)
self.callmeth = callmeth
示例12: __init__
def __init__(self, SELFTYPE, methname):
from pypy.jit.backend.llgraph.runner import boxresult, make_getargs
_, meth = SELFTYPE._lookup(methname)
METH = ootype.typeOf(meth)
getargs = make_getargs(METH.ARGS)
def callmeth(selfbox, argboxes):
selfobj = selfbox.getref(SELFTYPE)
meth = getattr(selfobj, methname)
methargs = getargs(argboxes)
res = meth(*methargs)
if METH.RESULT is not ootype.Void:
return boxresult(METH.RESULT, res)
self.callmeth = callmeth
self.selfclass = ootype.runtimeClass(SELFTYPE)
self.methname = methname
self.has_result = (METH.RESULT != ootype.Void)
self.key = key_manager.getkey((SELFTYPE, methname))
示例13: is_inst
def is_inst(inst):
T = ootype.typeOf(inst)
return T is ootype.Object or T is ootype.Class or\
isinstance(T, (ootype.Instance,
ootype.BuiltinType,
ootype.StaticMethod,))
示例14: test_simple_empty_base
def test_simple_empty_base():
def dummyfn():
x = EmptyBase()
return x
result = interpret(dummyfn, [])
assert isinstance(ootype.typeOf(result), ootype.Instance)
示例15: render
def render(self, generator, op):
generator.load(Constant(self.value, ootype.typeOf(self.value)))