本文整理汇总了Python中pypy.translator.cli.dotnet.typeof函数的典型用法代码示例。如果您正苦于以下问题:Python typeof函数的具体用法?Python typeof怎么用?Python typeof使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了typeof函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: fn
def fn(flag):
if flag:
clitype = typeof(System.Int32)
else:
clitype = typeof(System.String)
cls = type2class(clitype)
return cls is cInt32
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:7,代码来源:test_dotnet.py
示例2: cli2py
def cli2py(space, b_obj):
# TODO: support other types and find the most efficient way to
# select the correct case
if b_obj is None:
return space.w_None
w_obj = unbox(b_obj, W_Root)
if w_obj is not None:
return w_obj # it's already a wrapped object!
b_type = b_obj.GetType()
if b_type == typeof(System.Int32):
intval = unbox(b_obj, ootype.Signed)
return space.wrap(intval)
elif b_type == typeof(System.Double):
floatval = unbox(b_obj, ootype.Float)
return space.wrap(floatval)
elif b_type == typeof(System.Boolean):
boolval = unbox(b_obj, ootype.Bool)
return space.wrap(boolval)
elif b_type == typeof(System.String):
strval = unbox(b_obj, ootype.String)
return space.wrap(strval)
else:
namespace, classname = split_fullname(b_type.ToString())
assemblyname = b_type.get_Assembly().get_FullName()
w_cls = load_cli_class(space, assemblyname, namespace, classname)
cliobj = W_CliObject(space, b_obj)
return wrapper_from_cliobj(space, w_cls, cliobj)
开发者ID:alkorzt,项目名称:pypy,代码行数:29,代码来源:interp_clr.py
示例3: cli2py
def cli2py(space, b_obj):
# TODO: support other types and find the most efficient way to
# select the correct case
if b_obj is None:
return space.w_None
w_obj = unbox(b_obj, W_Root)
if w_obj is not None:
return w_obj # it's already a wrapped object!
b_type = b_obj.GetType()
if b_type == typeof(System.Int32):
intval = unbox(b_obj, ootype.Signed)
return space.wrap(intval)
elif b_type == typeof(System.Double):
floatval = unbox(b_obj, ootype.Float)
return space.wrap(floatval)
elif b_type == typeof(System.Boolean):
boolval = unbox(b_obj, ootype.Bool)
return space.wrap(boolval)
elif b_type == typeof(System.String):
strval = unbox(b_obj, ootype.String)
return space.wrap(strval)
else:
msg = "Can't convert object %s to Python" % str(b_obj.ToString())
raise OperationError(space.w_TypeError, space.wrap(msg))
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:26,代码来源:interp_clr.py
示例4: build_fn
def build_fn():
tInt = typeof(System.Int32)
args = init_array(System.Type, tInt, tInt)
meth = Utils.CreateDynamicMethod("add", tInt, args)
il = meth.GetILGenerator()
il.Emit(OpCodes.Ldarg_0)
il.Emit(OpCodes.Ldarg_1)
il.Emit(OpCodes.Add)
il.Emit(OpCodes.Ret)
myfunc = meth.CreateDelegate(typeof(FUNCTYPE))
return myfunc
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:11,代码来源:test_dotnet.py
示例5: getCliType
def getCliType(self, meth):
if self in meth.box2type:
return meth.box2type[self]
if self.type == history.INT:
return dotnet.typeof(System.Int32)
elif self.type == history.FLOAT:
return dotnet.typeof(System.Double)
elif self.type == history.REF:
return dotnet.typeof(System.Object)
else:
assert False, 'Unknown type: %s' % self.type
开发者ID:alkorzt,项目名称:pypy,代码行数:12,代码来源:method.py
示例6: emit_op_subclassof
def emit_op_subclassof(self, op):
clitype_utils = dotnet.typeof(Utils)
methinfo = clitype_utils.GetMethod('SubclassOf')
op.args[0].load(self)
op.args[1].load(self)
self.il.Emit(OpCodes.Call, methinfo)
self.store_result(op)
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:method.py
示例7: load
def load(self, meth):
holdertype = self.holder.GetType()
funcfield = holdertype.GetField('func')
Const.load(self, meth)
meth.il.Emit(OpCodes.Castclass, holdertype)
meth.il.Emit(OpCodes.Ldfld, funcfield)
meth.il.Emit(OpCodes.Castclass, dotnet.typeof(LoopDelegate))
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:method.py
示例8: emit_op_guard_class
def emit_op_guard_class(self, op):
assert len(op.args) == 2
il_label = self.newbranch(op)
self.push_arg(op, 0)
meth = dotnet.typeof(System.Object).GetMethod("GetType")
self.il.Emit(OpCodes.Callvirt, meth)
self.push_arg(op, 1)
self.il.Emit(OpCodes.Bne_Un, il_label)
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:method.py
示例9: emit_new_arrayofvoids
def emit_new_arrayofvoids(self, op):
clitype = dotnet.typeof(ListOfVoid)
ctor = clitype.GetConstructor(dotnet.new_array(System.Type, 0))
_ll_resize = clitype.GetMethod('_ll_resize')
self.il.Emit(OpCodes.Newobj, ctor)
self.il.Emit(OpCodes.Dup)
op.args[0].load(self)
self.il.Emit(OpCodes.Callvirt, _ll_resize)
self.store_result(op)
开发者ID:alkorzt,项目名称:pypy,代码行数:9,代码来源:method.py
示例10: emit_return_failed_op
def emit_return_failed_op(self, op, args):
# store the index of the failed op
index_op = self.get_index_for_failing_op(op)
self.av_inputargs.load(self)
self.il.Emit(OpCodes.Ldc_I4, index_op)
field = dotnet.typeof(InputArgs).GetField('failed_op')
self.il.Emit(OpCodes.Stfld, field)
self.emit_store_opargs(args)
self.il.Emit(OpCodes.Ret)
开发者ID:alkorzt,项目名称:pypy,代码行数:9,代码来源:method.py
示例11: finish_code
def finish_code(self):
delegatetype = dotnet.typeof(LoopDelegate)
# initialize the array of genconsts
consts = dotnet.new_array(System.Object, len(self.consts))
for av_const, i in self.consts.iteritems():
consts[i] = av_const.get_cliobj()
# build the delegate
func = self.meth_wrapper.create_delegate(delegatetype, consts)
return dotnet.clidowncast(func, LoopDelegate)
开发者ID:alkorzt,项目名称:pypy,代码行数:9,代码来源:method.py
示例12: get_inputarg_field
def get_inputarg_field(self, type):
t = dotnet.typeof(InputArgs)
if type == history.INT:
fieldname = 'ints'
elif type == history.FLOAT:
fieldname = 'floats'
elif type == history.REF:
fieldname = 'objs'
else:
assert False, 'Unknown type %s' % type
return t.GetField(fieldname)
开发者ID:alkorzt,项目名称:pypy,代码行数:11,代码来源:method.py
示例13: emit_ovf_op_and_guard
def emit_ovf_op_and_guard(self, op, opguard, emit_op):
# emit the checked operation
lbl = self.il.BeginExceptionBlock()
emit_op(self, op)
self.il.Emit(OpCodes.Leave, lbl)
self.il.BeginCatchBlock(dotnet.typeof(System.OverflowException))
# emit the guard
assert len(opguard.args) == 0
il_label = self.newbranch(opguard)
self.il.Emit(OpCodes.Leave, il_label)
self.il.EndExceptionBlock()
开发者ID:alkorzt,项目名称:pypy,代码行数:11,代码来源:method.py
示例14: rewrap_args
def rewrap_args(space, w_args, startfrom):
args = space.unpackiterable(w_args)
paramlen = len(args)-startfrom
b_args = new_array(System.Object, paramlen)
b_paramtypes = new_array(System.Type, paramlen)
for i in range(startfrom, len(args)):
j = i-startfrom
b_obj = py2cli(space, args[i])
b_args[j] = b_obj
if b_obj is None:
b_paramtypes[j] = typeof(System.Object) # we really can't be more precise
else:
b_paramtypes[j] = b_obj.GetType() # XXX: potentially inefficient
return b_args, b_paramtypes
开发者ID:alkorzt,项目名称:pypy,代码行数:14,代码来源:interp_clr.py
示例15: emit_ovf_op
def emit_ovf_op(self, op, emit_op):
next_op = self.oplist[self.i+1]
if next_op.opnum == rop.GUARD_NO_OVERFLOW:
self.i += 1
self.emit_ovf_op_and_guard(op, next_op, emit_op)
return
# clear the overflow flag
self.il.Emit(OpCodes.Ldc_I4_0)
self.av_ovf_flag.store(self)
lbl = self.il.BeginExceptionBlock()
emit_op(self, op)
self.il.Emit(OpCodes.Leave, lbl)
self.il.BeginCatchBlock(dotnet.typeof(System.OverflowException))
self.il.Emit(OpCodes.Ldc_I4_1)
self.av_ovf_flag.store(self)
self.il.EndExceptionBlock()
开发者ID:alkorzt,项目名称:pypy,代码行数:16,代码来源:method.py
示例16: emit_raising_op
def emit_raising_op(self, op, emit_op, exctypes):
self.emit_clear_exception()
lbl = self.il.BeginExceptionBlock()
emit_op(self, op)
self.il.Emit(OpCodes.Leave, lbl)
for exctype in exctypes:
v = self.il.DeclareLocal(exctype)
self.il.BeginCatchBlock(exctype)
if exctype == dotnet.typeof(System.OverflowException) and self.av_OverflowError:
self.il.Emit(OpCodes.Ldc_I4_1)
self.av_ovf_flag.store(self)
else:
self.il.Emit(OpCodes.Stloc, v)
self.av_inputargs.load(self)
self.il.Emit(OpCodes.Ldloc, v)
self.il.Emit(OpCodes.Stfld, self.exc_value_field)
self.il.EndExceptionBlock()
开发者ID:alkorzt,项目名称:pypy,代码行数:17,代码来源:method.py
示例17: __init__
def __init__(self, cpu, cliloop):
self.setoptions()
self.cpu = cpu
self.name = cliloop.get_fresh_cli_name()
self.cliloop = cliloop
self.boxes = {} # box --> local var
self.branches = []
self.branchlabels = []
self.consts = {} # object --> index
self.meth_wrapper = self._get_meth_wrapper()
self.il = self.meth_wrapper.get_il_generator()
self.av_consts = MethodArgument(0, System.Type.GetType("System.Object[]"))
t_InputArgs = dotnet.typeof(InputArgs)
self.av_inputargs = MethodArgument(1,t_InputArgs )
self.av_ovf_flag = BoxInt()
self.exc_value_field = t_InputArgs.GetField('exc_value')
if cpu.rtyper:
self.av_OverflowError = ConstObj(ootype.cast_to_object(cpu.ll_ovf_exc))
self.av_ZeroDivisionError = ConstObj(ootype.cast_to_object(cpu.ll_zero_exc))
else:
self.av_OverflowError = None
self.av_ZeroDivisionError = None
self.box2type = {}
开发者ID:alkorzt,项目名称:pypy,代码行数:23,代码来源:method.py
示例18: emit_op_jump
def emit_op_jump(self, op):
target_token = op.descr
assert isinstance(target_token, LoopToken)
if target_token.cliloop is self.cliloop:
# jump to the beginning of the loop
i = 0
for i in range(len(op.args)):
op.args[i].load(self)
self.cliloop.inputargs[i].store(self)
self.il.Emit(OpCodes.Br, self.il_loop_start)
else:
# it's a real bridge
cliloop = target_token.cliloop
assert len(op.args) == len(cliloop.inputargs)
self.emit_debug('jumping to ' + cliloop.name)
self.emit_store_opargs(op.args)
cliloop.funcbox.load(self)
self.av_inputargs.load(self)
methinfo = dotnet.typeof(LoopDelegate).GetMethod('Invoke')
if self.tailcall:
self.il.Emit(OpCodes.Tailcall)
self.il.Emit(OpCodes.Callvirt, methinfo)
self.il.Emit(OpCodes.Ret)
开发者ID:alkorzt,项目名称:pypy,代码行数:23,代码来源:method.py
示例19: restype_unichar
def restype_unichar(self): return typeof(System.Char)
def restype_longlong(self): return typeof(System.Int64)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:2,代码来源:operation.py
示例20: restype_longlong
def restype_longlong(self): return typeof(System.Int64)
def fillops(ops, baseclass):
开发者ID:antoine1fr,项目名称:pygirl,代码行数:3,代码来源:operation.py
注:本文中的pypy.translator.cli.dotnet.typeof函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论