Get the group prefix for a module (relative to the current group). The prefix should be prepended to the object name whenever accessing an object from this module. If the module lives is in the current compilation group, there is no prefix. But if it lives in a dif
(self, module_name: str)
| 296 | return "__LL%d" % self.context.temp_counter |
| 297 | |
| 298 | def get_module_group_prefix(self, module_name: str) -> str: |
| 299 | """Get the group prefix for a module (relative to the current group). |
| 300 | |
| 301 | The prefix should be prepended to the object name whenever |
| 302 | accessing an object from this module. |
| 303 | |
| 304 | If the module lives is in the current compilation group, there is |
| 305 | no prefix. But if it lives in a different group (and hence a separate |
| 306 | extension module), we need to access objects from it indirectly via an |
| 307 | export table. |
| 308 | |
| 309 | For example, for code in group `a` to call a function `bar` in group `b`, |
| 310 | it would need to do `exports_b.CPyDef_bar(...)`, while code that is |
| 311 | also in group `b` can simply do `CPyDef_bar(...)`. |
| 312 | |
| 313 | Thus the prefix for a module in group `b` is 'exports_b.' if the current |
| 314 | group is *not* b and just '' if it is. |
| 315 | """ |
| 316 | groups = self.context.group_map |
| 317 | target_group_name = groups.get(module_name) |
| 318 | if target_group_name and target_group_name != self.context.group_name: |
| 319 | self.context.group_deps.add(target_group_name) |
| 320 | return f"exports_{exported_name(target_group_name)}." |
| 321 | else: |
| 322 | return "" |
| 323 | |
| 324 | def get_group_prefix(self, obj: ClassIR | FuncDecl) -> str: |
| 325 | """Get the group prefix for an object.""" |
no test coverage detected