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

Function gen_func_body

mypyc/irbuild/function.py:289–311  ·  view source on GitHub ↗
(
    builder: IRBuilder, sig: FuncSignature, cdef: ClassDef | None, is_singledispatch: bool
)

Source from the content-addressed store, hash-verified

287
288
289def gen_func_body(
290 builder: IRBuilder, sig: FuncSignature, cdef: ClassDef | None, is_singledispatch: bool
291) -> tuple[FuncIR, Value | None]:
292 load_env_registers(builder)
293 gen_arg_defaults(builder)
294 if builder.fn_info.contains_nested:
295 finalize_env_class(builder)
296 add_vars_to_env(builder)
297 builder.accept(builder.fn_info.fitem.body)
298 builder.maybe_add_implicit_return()
299
300 # Hang on to the local symbol table for a while, since we use it
301 # to calculate argument defaults below.
302 symtable = builder.symtables[-1]
303
304 args, _, blocks, ret_type, fn_info = builder.leave()
305
306 func_ir, func_reg = gen_func_ir(builder, args, blocks, sig, fn_info, cdef, is_singledispatch)
307
308 # Evaluate argument defaults in the surrounding scope, since we
309 # calculate them *once* when the function definition is evaluated.
310 calculate_arg_defaults(builder, fn_info, func_reg, symtable)
311 return func_ir, func_reg
312
313
314def has_nested_func_self_reference(builder: IRBuilder, fitem: FuncItem) -> bool:

Callers 1

gen_func_itemFunction · 0.85

Calls 9

load_env_registersFunction · 0.90
gen_arg_defaultsFunction · 0.90
finalize_env_classFunction · 0.90
add_vars_to_envFunction · 0.90
calculate_arg_defaultsFunction · 0.90
gen_func_irFunction · 0.85
leaveMethod · 0.80
acceptMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…