def scrutinize(self, scrutine, context_frame):
constructor = type(scrutine)
if constructor.__name__ != self._constructor_name:
raise NoMatch()
kwargs = scrutine._kwargs
# the context to evaluate the thunk in
context = {
Call(Normal(name_lookup), (Normal(name),), {}): Normal(value)
for name, value in merge(
vars(builtins),
context_frame.f_globals,
context_frame.f_locals,
# the newly bound arguments have the highest precedence
dict(zip(self._argnames, scrutine._args)),
{v: kwargs[k] for k, v in self._kwargnames.items()},
).items()
}
bound_tree = LTree.parse(self._expr).subs(context)
return strict(bound_tree.lcompile())
评论列表
文章目录