MCPcopy Index your code
hub / github.com/python/cpython / to_c

Method to_c

Tools/cases_generator/stack.py:115–129  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

113 return tuple(p_orig + p_uniq), tuple(n_orig + n_uniq)
114
115 def to_c(self) -> str:
116 symbol_offset = ""
117 for item in self.negative:
118 symbol_offset += f" - {maybe_parenthesize(item)}"
119 for item in self.positive:
120 symbol_offset += f" + {maybe_parenthesize(item)}"
121 if symbol_offset and self.numeric == 0:
122 res = symbol_offset
123 else:
124 res = f"{self.numeric}{symbol_offset}"
125 if res.startswith(" + "):
126 res = res[3:]
127 if res.startswith(" - "):
128 res = "-" + res[3:]
129 return res
130
131 def as_int(self) -> int | None:
132 if self.positive or self.negative:

Callers 14

__str__Method · 0.95
__repr__Method · 0.95
test_effect_sizesMethod · 0.80
emit_defaultFunction · 0.80
popMethod · 0.80
_do_emitMethod · 0.80
_save_physical_spMethod · 0.80
sp_offsetMethod · 0.80
as_commentMethod · 0.80
alignMethod · 0.80
for_uopMethod · 0.80
generate_names_and_flagsFunction · 0.80

Calls 2

maybe_parenthesizeFunction · 0.85
startswithMethod · 0.45

Tested by 1

test_effect_sizesMethod · 0.64