MCPcopy
hub / github.com/Nuitka/Nuitka / _generateModuleCode

Function _generateModuleCode

nuitka/code_generation/CodeGeneration.py:532–594  ·  view source on GitHub ↗
(module, data_filename)

Source from the content-addressed store, hash-verified

530
531
532def _generateModuleCode(module, data_filename):
533 # As this not only creates all modules, but also functions, it deals
534 # also with its functions.
535 assert module.isCompiledPythonModule(), module
536
537 context = PythonModuleContext(
538 module=module,
539 data_filename=data_filename,
540 )
541
542 context.setExceptionEscape("module_exception_exit")
543
544 function_decl_codes = []
545 function_body_codes = []
546
547 for function_body in module.getUsedFunctions():
548 if function_body.needsCreation():
549 # Constant function returners get no code.
550 (
551 is_constant_returning,
552 _constant_return_value,
553 ) = function_body.getConstantReturnValue()
554 if is_constant_returning:
555 continue
556
557 function_code, function_decl = generateFunctionBodyCode(
558 function_body=function_body, context=context
559 )
560
561 if function_code is not None:
562 function_body_codes.append(function_code)
563
564 if function_decl is not None:
565 function_decl_codes.append(function_decl)
566
567 # These are for functions used from other modules. Due to cyclic
568 # dependencies, we cannot rely on those to be already created.
569 for function_body in module.getCrossUsedFunctions():
570 assert function_body.isCrossModuleUsed()
571
572 function_decl = getFunctionDirectDecl(
573 function_identifier=function_body.getCodeName(),
574 closure_variables=function_body.getClosureVariables(),
575 file_scope=getExportScopeCode(
576 cross_module=function_body.isCrossModuleUsed()
577 ),
578 context=PythonFunctionDirectContext(
579 parent=context,
580 function=function_body,
581 ),
582 )
583
584 function_decl_codes.append(function_decl)
585
586 return getModuleCode(
587 module=module,
588 function_decl_codes=function_decl_codes,
589 function_body_codes=function_body_codes,

Callers 1

generateModuleCodeFunction · 0.85

Calls 15

encodePythonStringToCFunction · 0.90
PythonModuleContextClass · 0.85
generateFunctionBodyCodeFunction · 0.85
getFunctionDirectDeclFunction · 0.85
getExportScopeCodeFunction · 0.85
getModuleCodeFunction · 0.85
getCrossUsedFunctionsMethod · 0.80
isCrossModuleUsedMethod · 0.80
getClosureVariablesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…