MCPcopy Index your code
hub / github.com/python/mypy / static_name

Method static_name

mypyc/codegen/emit.py:341–356  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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)

Callers 15

type_struct_nameMethod · 0.95
_emit_tracebackMethod · 0.95
generate_traceback_codeFunction · 0.80
emit_module_exec_funcMethod · 0.80
declare_moduleMethod · 0.80
declare_finalsMethod · 0.80
final_definitionMethod · 0.80
declare_type_varsMethod · 0.80

Calls 2

private_nameMethod · 0.80

Tested by

no test coverage detected