(
module, function_decl_codes, function_body_codes, module_const_blob_name, context
)
| 44 | |
| 45 | |
| 46 | def getModuleCode( |
| 47 | module, function_decl_codes, function_body_codes, module_const_blob_name, context |
| 48 | ): |
| 49 | # For the module code, lots of arguments and attributes come together. |
| 50 | # pylint: disable=too-many-branches,too-many-locals,too-many-statements |
| 51 | |
| 52 | # Temporary variable initializations |
| 53 | # TODO: Move that to a place outside of functions. |
| 54 | from .FunctionCodes import ( |
| 55 | finalizeFunctionLocalVariables, |
| 56 | setupFunctionLocalVariables, |
| 57 | ) |
| 58 | |
| 59 | setupFunctionLocalVariables( |
| 60 | context=context, |
| 61 | parameters=None, |
| 62 | closure_variables=(), |
| 63 | user_variables=module.getOutlineLocalVariables(), |
| 64 | temp_variables=module.getAllTempVariables(), |
| 65 | ) |
| 66 | |
| 67 | module_codes = Emission.SourceCodeCollector() |
| 68 | |
| 69 | module = context.getOwner() |
| 70 | module_body = module.subnode_body |
| 71 | |
| 72 | generateStatementSequenceCode( |
| 73 | statement_sequence=module_body, |
| 74 | emit=module_codes, |
| 75 | allow_none=True, |
| 76 | context=context, |
| 77 | ) |
| 78 | |
| 79 | for _identifier, code in sorted(iterItems(context.getHelperCodes())): |
| 80 | function_body_codes.append(code) |
| 81 | |
| 82 | for _identifier, code in sorted(iterItems(context.getDeclarations())): |
| 83 | function_decl_codes.append(code) |
| 84 | |
| 85 | function_body_codes = "\n\n".join(function_body_codes) |
| 86 | function_decl_codes = "\n\n".join(function_decl_codes) |
| 87 | |
| 88 | _cleanup = finalizeFunctionLocalVariables(context) |
| 89 | |
| 90 | # TODO: Seems like a bug, classes could produce those. |
| 91 | # assert not _cleanup, _cleanup |
| 92 | |
| 93 | module_identifier = module.getCodeName() |
| 94 | |
| 95 | if module_body is not None and module_body.mayRaiseException(BaseException): |
| 96 | module_exit = template_module_exception_exit % { |
| 97 | "module_identifier": module_identifier, |
| 98 | "is_top": 1 if module.isTopModule() else 0, |
| 99 | } |
| 100 | else: |
| 101 | module_exit = template_module_no_exception_exit |
| 102 | |
| 103 | local_var_inits = context.variable_storage.makeCFunctionLevelDeclarations() |
no test coverage detected
searching dependent graphs…