h2o-py/h2o/astfun.py
def _call_func_bc(nargs, idx, ops, keys):
    """
    Implements transformation of CALL_FUNCTION bc inst to Rapids expression.
    The implementation follows definition of behavior defined in
    https://docs.python.org/3/library/dis.html
    
    :param nargs: number of arguments including keyword and positional arguments
    :param idx: index of current instruction on the stack
    :param ops: stack of instructions
    :param keys:  names of instructions
    :return: ExprNode representing method call
    """
    named_args = {}
    unnamed_args = []
    args = []
    # Extract arguments based on calling convention for CALL_FUNCTION_KW
    while nargs > 0:
        if nargs >= 256:  # named args ( foo(50,True,x=10) ) read first  ( right -> left )
            arg, idx = _opcode_read_arg(idx, ops, keys)
            named_args[ops[idx][1][0]] = arg
            idx -= 1  # skip the LOAD_CONST for the named args
            nargs -= 256  # drop 256
        else:
            arg, idx = _opcode_read_arg(idx, ops, keys)
            unnamed_args.insert(0, arg)
            nargs -= 1
    # LOAD_ATTR <method_name>: Map call arguments to a call of method on H2OFrame class
    op = ops[idx][1][0]
    args = _get_h2o_frame_method_args(op, named_args, unnamed_args) if is_attr(ops[idx][0]) else []
    # Map function name to proper rapids name
    op = _get_func_name(op, args)
    # Go to next instruction
    idx -= 1
    if is_bytecode_instruction(ops[idx][0]):
        arg, idx = _opcode_read_arg(idx, ops, keys)
        args.insert(0, arg)
    elif is_load_fast(ops[idx][0]):
        args.insert(0, _load_fast(ops[idx][1][0]))
        idx -= 1
    return [ExprNode(op, *args), idx]
def _call_func_bc(nargs, idx, ops, keys):
    """
    Implements transformation of CALL_FUNCTION bc inst to Rapids expression.
    The implementation follows definition of behavior defined in
    https://docs.python.org/3/library/dis.html
    
    :param nargs: number of arguments including keyword and positional arguments
    :param idx: index of current instruction on the stack
    :param ops: stack of instructions
    :param keys:  names of instructions
    :return: ExprNode representing method call
    """
    named_args = {}
    unnamed_args = []
    args = []
    # Extract arguments based on calling convention for CALL_FUNCTION_KW
    while nargs > 0:
        if nargs >= 256:  # named args ( foo(50,True,x=10) ) read first  ( right -> left )
            arg, idx = _opcode_read_arg(idx, ops, keys)
            named_args[ops[idx][1][0]] = arg
            idx -= 1  # skip the LOAD_CONST for the named args
            nargs -= 256  # drop 256
        else:
            arg, idx = _opcode_read_arg(idx, ops, keys)
            unnamed_args.insert(0, arg)
            nargs -= 1
    # LOAD_ATTR <method_name>: Map call arguments to a call of method on H2OFrame class
    op = ops[idx][1][0]
    args = _get_h2o_frame_method_args(op, named_args, unnamed_args) if is_attr(ops[idx][0]) else []
    # Map function name to proper rapids name
    op = _get_func_name(op, args)
    # Go to next instruction
    idx -= 1
    if is_bytecode_instruction(ops[idx][0]):
        arg, idx = _opcode_read_arg(idx, ops, keys)
        args.insert(0, arg)
    elif is_load_fast(ops[idx][0]):
        args.insert(0, _load_fast(ops[idx][1][0]))
        idx -= 1
    return [ExprNode(op, *args), idx]
Implements transformation of CALL_FUNCTION bc inst to Rapids expression.
    The implementation follows definition of behavior defined in
    https://docs.python.org/3/library/dis.html
    
    :param nargs: number of arguments including keyword and positional arguments
    :param idx: index of current instruction on the stack
    :param ops: stack of instructions
    :param keys:  names of instructions
    :return: ExprNode representing method call