(module, data_filename)
| 530 | |
| 531 | |
| 532 | def _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, |
no test coverage detected
searching dependent graphs…