MCPcopy Create free account
hub / github.com/Nuitka/Nuitka / getFunctionMakerCode

Function getFunctionMakerCode

nuitka/code_generation/FunctionCodes.py:133–218  ·  view source on GitHub ↗
(
    function_body,
    function_identifier,
    closure_variables,
    defaults_name,
    kw_defaults_name,
    annotations_name,
    function_doc,
    type_params_name,
    context,
)

Source from the content-addressed store, hash-verified

131
132
133def getFunctionMakerCode(
134 function_body,
135 function_identifier,
136 closure_variables,
137 defaults_name,
138 kw_defaults_name,
139 annotations_name,
140 function_doc,
141 type_params_name,
142 context,
143):
144 # We really need this many parameters here and functions have many details,
145 # that we express as variables, pylint: disable=too-many-locals
146 function_creation_args = getFunctionCreationArgs(
147 defaults_name=defaults_name,
148 kw_defaults_name=kw_defaults_name,
149 annotations_name=annotations_name,
150 closure_variables=closure_variables,
151 type_params_name=type_params_name,
152 )
153
154 if function_doc is None:
155 function_doc = "NULL"
156 else:
157 function_doc = context.getConstantCode(constant=function_doc)
158
159 (
160 is_constant_returning,
161 constant_return_value,
162 ) = function_body.getConstantReturnValue()
163
164 if is_constant_returning:
165 function_impl_identifier = "NULL"
166
167 if constant_return_value is None:
168 # Default value, spare the code for common case.
169 constant_return_code = ""
170 elif constant_return_value is True:
171 constant_return_code = "Nuitka_Function_EnableConstReturnTrue(result);"
172 elif constant_return_value is False:
173 constant_return_code = "Nuitka_Function_EnableConstReturnFalse(result);"
174 else:
175 constant_return_code = (
176 "Nuitka_Function_EnableConstReturnGeneric(result, %s);"
177 % context.getConstantCode(constant_return_value)
178 )
179 else:
180 function_impl_identifier = _getFunctionEntryPointIdentifier(
181 function_identifier=function_identifier
182 )
183 constant_return_code = ""
184
185 function_maker_identifier = _getFunctionMakerIdentifier(
186 function_identifier=function_identifier
187 )
188
189 module_identifier = getModuleAccessCode(context=context)
190

Callers 1

Calls 13

getFunctionCreationArgsFunction · 0.85
getModuleAccessCodeFunction · 0.85
getFunctionQualnameObjFunction · 0.85
getCodeObjectAccessCodeFunction · 0.85
lenFunction · 0.85
indentedFunction · 0.85
getConstantCodeMethod · 0.45
getFunctionNameMethod · 0.45
getCodeObjectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…