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
)
| 1046 | |
| 1047 | |
| 1048 | def 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 | |
| 1076 | def generate_dispatch_glue_native_function( |
no test coverage detected
searching dependent graphs…