Shared emitter state for a compilation group.
| 129 | |
| 130 | |
| 131 | class EmitterContext: |
| 132 | """Shared emitter state for a compilation group.""" |
| 133 | |
| 134 | def __init__( |
| 135 | self, |
| 136 | names: NameGenerator, |
| 137 | strict_traceback_checks: bool, |
| 138 | group_name: str | None = None, |
| 139 | group_map: dict[str, str | None] | None = None, |
| 140 | ) -> None: |
| 141 | """Setup shared emitter state. |
| 142 | |
| 143 | Args: |
| 144 | names: The name generator to use |
| 145 | group_map: Map from module names to group name |
| 146 | group_name: Current group name |
| 147 | """ |
| 148 | self.temp_counter = 0 |
| 149 | self.names = names |
| 150 | self.group_name = group_name |
| 151 | self.group_map = group_map or {} |
| 152 | # Groups that this group depends on |
| 153 | self.group_deps: set[str] = set() |
| 154 | |
| 155 | # The map below is used for generating declarations and |
| 156 | # definitions at the top of the C file. The main idea is that they can |
| 157 | # be generated at any time during the emit phase. |
| 158 | |
| 159 | # A map of a C identifier to whatever the C identifier declares. Currently this is |
| 160 | # used for declaring structs and the key corresponds to the name of the struct. |
| 161 | # The declaration contains the body of the struct. |
| 162 | self.declarations: dict[str, HeaderDeclaration] = {} |
| 163 | |
| 164 | self.literals = Literals() |
| 165 | # See mypyc/options.py for context. |
| 166 | self.strict_traceback_checks = strict_traceback_checks |
| 167 | |
| 168 | |
| 169 | class ErrorHandler: |
no outgoing calls
searching dependent graphs…