本文整理汇总了Python中pypy.interpreter.argument.Arguments.match_signature方法的典型用法代码示例。如果您正苦于以下问题:Python Arguments.match_signature方法的具体用法?Python Arguments.match_signature怎么用?Python Arguments.match_signature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypy.interpreter.argument.Arguments
的用法示例。
在下文中一共展示了Arguments.match_signature方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unmatch_signature
# 需要导入模块: from pypy.interpreter.argument import Arguments [as 别名]
# 或者: from pypy.interpreter.argument.Arguments import match_signature [as 别名]
def test_unmatch_signature(self):
space = DummySpace()
args = Arguments(space, [1, 2, 3])
sig = (["a", "b", "c"], None, None)
data = args.match_signature(sig, [])
new_args = args.unmatch_signature(sig, data)
assert args.unpack() == new_args.unpack()
args = Arguments(space, [1])
sig = (["a", "b", "c"], None, None)
data = args.match_signature(sig, [2, 3])
new_args = args.unmatch_signature(sig, data)
assert args.unpack() == new_args.unpack()
args = Arguments(space, [1, 2, 3, 4, 5])
sig = (["a", "b", "c"], "r", None)
data = args.match_signature(sig, [])
new_args = args.unmatch_signature(sig, data)
assert args.unpack() == new_args.unpack()
args = Arguments(space, [1], {"c": 3, "b": 2})
sig = (["a", "b", "c"], None, None)
data = args.match_signature(sig, [])
new_args = args.unmatch_signature(sig, data)
assert args.unpack() == new_args.unpack()
args = Arguments(space, [1], {"c": 5})
sig = (["a", "b", "c"], None, None)
data = args.match_signature(sig, [2, 3])
new_args = args.unmatch_signature(sig, data)
assert args.unpack() == new_args.unpack()
args = Arguments(space, [1], {"c": 5, "d": 7})
sig = (["a", "b", "c"], None, "kw")
data = args.match_signature(sig, [2, 3])
new_args = args.unmatch_signature(sig, data)
assert args.unpack() == new_args.unpack()
args = Arguments(space, [1, 2, 3, 4, 5], {"e": 5, "d": 7})
sig = (["a", "b", "c"], "r", "kw")
data = args.match_signature(sig, [2, 3])
new_args = args.unmatch_signature(sig, data)
assert args.unpack() == new_args.unpack()
args = Arguments(space, [], {}, w_stararg=[1], w_starstararg={"c": 5, "d": 7})
sig = (["a", "b", "c"], None, "kw")
data = args.match_signature(sig, [2, 3])
new_args = args.unmatch_signature(sig, data)
assert args.unpack() == new_args.unpack()
args = Arguments(space, [1, 2], {"g": 9}, w_stararg=[3, 4, 5], w_starstararg={"e": 5, "d": 7})
sig = (["a", "b", "c"], "r", "kw")
data = args.match_signature(sig, [2, 3])
new_args = args.unmatch_signature(sig, data)
assert args.unpack() == new_args.unpack()
示例2: callparse
# 需要导入模块: from pypy.interpreter.argument import Arguments [as 别名]
# 或者: from pypy.interpreter.argument.Arguments import match_signature [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)