MCPcopy Index your code
hub / github.com/python/mypy / gen_dispatch_func_ir

Function gen_dispatch_func_ir

mypyc/irbuild/function.py:1048–1073  ·  view source on GitHub ↗

Create a dispatch function (a function that checks the first argument type and dispatches to the correct implementation)

(
    builder: IRBuilder, fitem: FuncDef, main_func_name: str, dispatch_name: str, sig: FuncSignature
)

Source from the content-addressed store, hash-verified

1046
1047
1048def gen_dispatch_func_ir(
1049 builder: IRBuilder, fitem: FuncDef, main_func_name: str, dispatch_name: str, sig: FuncSignature
1050) -> tuple[FuncIR, Value]:
1051 """Create a dispatch function (a function that checks the first argument type and dispatches
1052 to the correct implementation)
1053 """
1054 builder.enter(FuncInfo(fitem, dispatch_name))
1055 setup_callable_class(builder)
1056 builder.fn_info.callable_class.ir.attributes["registry"] = dict_rprimitive
1057 builder.fn_info.callable_class.ir.attributes["dispatch_cache"] = dict_rprimitive
1058 builder.fn_info.callable_class.ir.has_dict = True
1059 builder.fn_info.callable_class.ir.needs_getseters = True
1060 generate_singledispatch_callable_class_ctor(builder)
1061
1062 generate_singledispatch_dispatch_function(builder, main_func_name, fitem)
1063 args, _, blocks, _, fn_info = builder.leave()
1064 dispatch_callable_class = add_call_to_callable_class(builder, args, blocks, sig, fn_info)
1065 builder.functions.append(dispatch_callable_class)
1066 add_get_to_callable_class(builder, fn_info)
1067 add_register_method_to_callable_class(builder, fn_info)
1068 func_reg = instantiate_callable_class(builder, fn_info)
1069 dispatch_func_ir = generate_dispatch_glue_native_function(
1070 builder, fitem, dispatch_callable_class.decl, dispatch_name
1071 )
1072
1073 return dispatch_func_ir, func_reg
1074
1075
1076def generate_dispatch_glue_native_function(

Callers 1

gen_func_itemFunction · 0.85

Calls 12

FuncInfoClass · 0.90
setup_callable_classFunction · 0.90
leaveMethod · 0.80
appendMethod · 0.80
enterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…