本文整理汇总了Python中pypy.interpreter.argument.Arguments.fromshape方法的典型用法代码示例。如果您正苦于以下问题:Python Arguments.fromshape方法的具体用法?Python Arguments.fromshape怎么用?Python Arguments.fromshape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypy.interpreter.argument.Arguments
的用法示例。
在下文中一共展示了Arguments.fromshape方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_args
# 需要导入模块: from pypy.interpreter.argument import Arguments [as 别名]
# 或者: from pypy.interpreter.argument.Arguments import fromshape [as 别名]
def build_args(self, op, args_s):
space = RPythonCallsSpace()
if op == "simple_call":
return Arguments(space, list(args_s))
elif op == "call_args":
return Arguments.fromshape(space, args_s[0].const, # shape
list(args_s[1:]))
示例2: call_args_expand
# 需要导入模块: from pypy.interpreter.argument import Arguments [as 别名]
# 或者: from pypy.interpreter.argument.Arguments import fromshape [as 别名]
def call_args_expand(hop, takes_kwds = True):
hop = hop.copy()
from pypy.interpreter.argument import Arguments
arguments = Arguments.fromshape(None, hop.args_s[1].const, # shape
range(hop.nb_args-2))
if arguments.w_starstararg is not None:
raise TyperError("**kwds call not implemented")
if arguments.w_stararg is not None:
# expand the *arg in-place -- it must be a tuple
from pypy.rpython.rtuple import AbstractTupleRepr
if arguments.w_stararg != hop.nb_args - 3:
raise TyperError("call pattern too complex")
hop.nb_args -= 1
v_tuple = hop.args_v.pop()
s_tuple = hop.args_s.pop()
r_tuple = hop.args_r.pop()
if not isinstance(r_tuple, AbstractTupleRepr):
raise TyperError("*arg must be a tuple")
for i in range(len(r_tuple.items_r)):
v_item = r_tuple.getitem_internal(hop.llops, v_tuple, i)
hop.nb_args += 1
hop.args_v.append(v_item)
hop.args_s.append(s_tuple.items[i])
hop.args_r.append(r_tuple.items_r[i])
kwds = arguments.kwds_w or {}
if not takes_kwds and kwds:
raise TyperError("kwds args not supported")
# prefix keyword arguments with 'i_'
kwds_i = {}
for key, index in kwds.items():
kwds_i['i_'+key] = index
return hop, kwds_i
示例3: callparse
# 需要导入模块: from pypy.interpreter.argument import Arguments [as 别名]
# 或者: from pypy.interpreter.argument.Arguments import fromshape [as 别名]
def callparse(rtyper, graph, hop, opname, r_self=None):
"""Parse the arguments of 'hop' when calling the given 'graph'.
"""
rinputs = getrinputs(rtyper, graph)
space = RPythonCallsSpace()
def args_h(start):
return [VarHolder(i, hop.args_s[i]) for i in range(start, hop.nb_args)]
if r_self is None:
start = 1
else:
start = 0
rinputs[0] = r_self
if opname == "simple_call":
arguments = Arguments(space, args_h(start))
elif opname == "call_args":
arguments = Arguments.fromshape(space, hop.args_s[start].const, args_h(start + 1)) # shape
# parse the arguments according to the function we are calling
signature = graph.signature
defs_h = []
if graph.defaults:
for x in graph.defaults:
defs_h.append(ConstHolder(x))
try:
holders = arguments.match_signature(signature, defs_h)
except ArgErr, e:
raise TyperError, "signature mismatch: %s" % e.getmsg(graph.name)
示例4: op_call_args
# 需要导入模块: from pypy.interpreter.argument import Arguments [as 别名]
# 或者: from pypy.interpreter.argument.Arguments import fromshape [as 别名]
def op_call_args(self):
a = self.argnames
shape = self.op.args[1].value
args = Arguments.fromshape(None, shape, a[2:])
lst = args.arguments_w[:]
for key, value in args.kwds_w.items():
lst.append("%s=%s" % (key, value))
if args.w_stararg is not None:
lst.append("*%s" % args.w_stararg)
if args.w_starstararg is not None:
lst.append("**%s" % args.w_starstararg)
return "%s = %s(%s)" % (self.resultname, a[0], ", ".join(lst))