def __run_natively(self, context: _VSContext, instruction: dis.Instruction):
"""
Invokes a function natively.
"""
# Get the number of arguments to pop off of the stack.
number_of_args = instruction.arg
args = []
for x in range(0, number_of_args):
# Pop each argument off of the stack.
args.append(context.stack.pop())
args = reversed(args)
# Now pop the function, which is underneath all the others.
fn = context.stack.pop()
if not callable(fn):
safe_raise(context, TypeError("'{}' object is not callable".format(fn)))
return
# Run the function.
try:
result = fn(*args)
except BaseException as e:
safe_raise(context, e)
return
return result
评论列表
文章目录