本文整理汇总了Python中Target.unpack_unpack_args方法的典型用法代码示例。如果您正苦于以下问题:Python Target.unpack_unpack_args方法的具体用法?Python Target.unpack_unpack_args怎么用?Python Target.unpack_unpack_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Target
的用法示例。
在下文中一共展示了Target.unpack_unpack_args方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _instr_unpack_args
# 需要导入模块: import Target [as 别名]
# 或者: from Target import unpack_unpack_args [as 别名]
def _instr_unpack_args(self, instr, cf):
num_fargs, has_vargs = Target.unpack_unpack_args(instr)
num_fargs = jit.promote(num_fargs)
has_vargs = jit.promote(has_vargs)
if not has_vargs:
nargs = jit.promote(cf.nargs)
else:
nargs = cf.nargs
if nargs > num_fargs and not has_vargs:
msg = "Too many parameters (%d passed, but a maximum of %d allowed)." % \
(nargs, num_fargs)
self.raise_helper("Parameters_Exception", [Builtins.Con_String(self, msg)])
if num_fargs > 0:
arg_offset = cf.bc_off + Target.INTSIZE + num_fargs * Target.INTSIZE
for i in range(num_fargs - 1, -1, -1):
arg_offset -= Target.INTSIZE
arg_info = Target.read_word(cf.pc.mod.bc, arg_offset)
if i >= nargs:
if not Target.unpack_unpack_args_is_mandatory(arg_info):
msg = "No value passed for parameter %d." % (i + 1)
self.raise_helper("Parameters_Exception", [Builtins.Con_String(self, msg)])
else:
if nargs > num_fargs:
o = cf.stack_pop_n(nargs - num_fargs)
else:
o = cf.stack_pop()
assert isinstance(o, Builtins.Con_Object)
cf.closure.vars[Target.unpack_unpack_args_arg_num(arg_info)] = o
if has_vargs:
arg_offset = cf.bc_off + Target.INTSIZE + num_fargs * Target.INTSIZE
arg_info = Target.read_word(cf.pc.mod.bc, arg_offset)
if nargs <= num_fargs:
l = []
else:
j = cf.stackpe
i = j - (nargs - num_fargs)
assert i >= 0 and j >= 0
l = cf.stack_get_slice(i, j)
cf.stackpe = i + 1
cf.closure.vars[Target.unpack_unpack_args_arg_num(arg_info)] = Builtins.Con_List(self, l)
cf.bc_off += Target.INTSIZE + (num_fargs + 1) * Target.INTSIZE
else:
cf.bc_off += Target.INTSIZE + num_fargs * Target.INTSIZE