Compile an SCC into ModuleIRs. Any modules that this SCC depends on must have either been compiled, type checked, or loaded from a cache into mapper. Arguments: scc: The list of MypyFiles to compile result: The BuildResult from the mypy front-end mapper: The Map
(
scc: list[MypyFile],
result: BuildResult,
mapper: Mapper,
compiler_options: CompilerOptions,
errors: Errors,
)
| 223 | |
| 224 | |
| 225 | def compile_scc_to_ir( |
| 226 | scc: list[MypyFile], |
| 227 | result: BuildResult, |
| 228 | mapper: Mapper, |
| 229 | compiler_options: CompilerOptions, |
| 230 | errors: Errors, |
| 231 | ) -> ModuleIRs: |
| 232 | """Compile an SCC into ModuleIRs. |
| 233 | |
| 234 | Any modules that this SCC depends on must have either been compiled, |
| 235 | type checked, or loaded from a cache into mapper. |
| 236 | |
| 237 | Arguments: |
| 238 | scc: The list of MypyFiles to compile |
| 239 | result: The BuildResult from the mypy front-end |
| 240 | mapper: The Mapper object mapping mypy ASTs to class and func IRs |
| 241 | compiler_options: The compilation options |
| 242 | errors: Where to report any errors encountered |
| 243 | |
| 244 | Returns the IR of the modules. |
| 245 | """ |
| 246 | |
| 247 | if compiler_options.verbose: |
| 248 | print("Compiling {}".format(", ".join(x.name for x in scc))) |
| 249 | |
| 250 | # Generate basic IR, with missing exception and refcount handling. |
| 251 | modules = build_ir(scc, result.graph, result.types, mapper, compiler_options, errors) |
| 252 | if errors.num_errors > 0: |
| 253 | return modules |
| 254 | |
| 255 | env_user_functions = {} |
| 256 | for module in modules.values(): |
| 257 | for cls in module.classes: |
| 258 | if cls.env_user_function: |
| 259 | env_user_functions[cls.env_user_function] = cls |
| 260 | |
| 261 | for module in modules.values(): |
| 262 | for fn in module.functions: |
| 263 | # Insert checks for uninitialized values. |
| 264 | insert_uninit_checks(fn, compiler_options.strict_traceback_checks) |
| 265 | # Insert exception handling. |
| 266 | insert_exception_handling(fn, compiler_options.strict_traceback_checks) |
| 267 | # Insert reference count handling. |
| 268 | insert_ref_count_opcodes(fn) |
| 269 | |
| 270 | if fn in env_user_functions: |
| 271 | insert_spills(fn, env_user_functions[fn]) |
| 272 | |
| 273 | if compiler_options.log_trace: |
| 274 | insert_event_trace_logging(fn, compiler_options) |
| 275 | |
| 276 | # Switch to lower abstraction level IR. |
| 277 | lower_ir(fn, compiler_options) |
| 278 | # Calculate implicit module dependencies (needed for librt) |
| 279 | deps = find_implicit_op_dependencies(fn) |
| 280 | if deps is not None: |
| 281 | module.dependencies.update(deps) |
| 282 | # Perform optimizations. |
no test coverage detected
searching dependent graphs…