Create name of a C static variable. These are used for literals and imported modules, among other things. The caller should ensure that the (id, module) pair cannot overlap with other calls to this method within a compilation group.
(self, id: str, module: str | None, prefix: str = STATIC_PREFIX)
| 339 | self.context.group_deps.add(target_group) |
| 340 | |
| 341 | def static_name(self, id: str, module: str | None, prefix: str = STATIC_PREFIX) -> str: |
| 342 | """Create name of a C static variable. |
| 343 | |
| 344 | These are used for literals and imported modules, among other |
| 345 | things. |
| 346 | |
| 347 | The caller should ensure that the (id, module) pair cannot |
| 348 | overlap with other calls to this method within a compilation |
| 349 | group. |
| 350 | """ |
| 351 | lib_prefix = "" if not module else self.get_module_group_prefix(module) |
| 352 | # If we are accessing static via the export table, we need to dereference |
| 353 | # the pointer also. |
| 354 | star_maybe = "*" if lib_prefix else "" |
| 355 | suffix = self.names.private_name(module or "", id) |
| 356 | return f"{star_maybe}{lib_prefix}{prefix}{suffix}" |
| 357 | |
| 358 | def type_struct_name(self, cl: ClassIR) -> str: |
| 359 | return self.static_name(cl.name, cl.module_name, prefix=TYPE_PREFIX) |
no test coverage detected