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

Function gen_property_getter_ir

mypyc/irbuild/function.py:1184–1201  ·  view source on GitHub ↗

Generate an implicit trivial property getter for an attribute. These are used if an attribute can also be accessed as a property.

(
    builder: IRBuilder, func_decl: FuncDecl, cdef: ClassDef, is_trait: bool
)

Source from the content-addressed store, hash-verified

1182
1183
1184def gen_property_getter_ir(
1185 builder: IRBuilder, func_decl: FuncDecl, cdef: ClassDef, is_trait: bool
1186) -> FuncIR:
1187 """Generate an implicit trivial property getter for an attribute.
1188
1189 These are used if an attribute can also be accessed as a property.
1190 """
1191 name = func_decl.name
1192 builder.enter(name)
1193 self_reg = builder.add_argument("self", func_decl.sig.args[0].type)
1194 line = func_decl._line or -1
1195 if not is_trait:
1196 value = builder.builder.get_attr(self_reg, name, func_decl.sig.ret_type, line)
1197 builder.add(Return(value, line))
1198 else:
1199 builder.add(Unreachable())
1200 args, _, blocks, ret_type, fn_info = builder.leave()
1201 return FuncIR(func_decl, args, blocks)
1202
1203
1204def gen_property_setter_ir(

Callers 1

transform_class_defFunction · 0.90

Calls 8

ReturnClass · 0.90
UnreachableClass · 0.90
FuncIRClass · 0.90
add_argumentMethod · 0.80
get_attrMethod · 0.80
leaveMethod · 0.80
enterMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…