Generate, instantiate, and set up the environment of an environment class.
(builder: IRBuilder, prefix: str = "")
| 67 | |
| 68 | |
| 69 | def finalize_env_class(builder: IRBuilder, prefix: str = "") -> None: |
| 70 | """Generate, instantiate, and set up the environment of an environment class.""" |
| 71 | if not builder.fn_info.can_merge_generator_and_env_classes(): |
| 72 | instantiate_env_class(builder) |
| 73 | |
| 74 | # Iterate through the function arguments and replace local definitions (using registers) |
| 75 | # that were previously added to the environment with references to the function's |
| 76 | # environment class. Comprehension scopes have no arguments to add. |
| 77 | if not builder.fn_info.is_comprehension_scope: |
| 78 | if builder.fn_info.is_nested: |
| 79 | add_args_to_env( |
| 80 | builder, local=False, base=builder.fn_info.callable_class, prefix=prefix |
| 81 | ) |
| 82 | else: |
| 83 | add_args_to_env(builder, local=False, base=builder.fn_info, prefix=prefix) |
| 84 | |
| 85 | |
| 86 | def instantiate_env_class(builder: IRBuilder) -> Value: |
no test coverage detected
searching dependent graphs…