diff options
Diffstat (limited to 'build-aux/stack.c.gen')
-rwxr-xr-x | build-aux/stack.c.gen | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/build-aux/stack.c.gen b/build-aux/stack.c.gen index 5a983cb..a8e2149 100755 --- a/build-aux/stack.c.gen +++ b/build-aux/stack.c.gen @@ -71,7 +71,7 @@ def parse_vcg(reader: typing.TextIO) -> typing.Iterator[VCGElem]: k = m.group(1) v = m.group(2) if k in elem.attrs: - _raise(f"duplicate key: {repr(k)}") + _raise(f"duplicate key: {k!r}") if v.startswith('"'): def unesc(esc: re.Match[str]) -> str: @@ -83,7 +83,7 @@ def parse_vcg(reader: typing.TextIO) -> typing.Iterator[VCGElem]: case "\\": return "\\" case _: - _raise(f"invalid escape code {repr(esc.group(0))}") + _raise(f"invalid escape code {esc.group(0)!r}") v = re_esc.sub(unesc, v[1:-1]) elem.attrs[k] = v @@ -107,7 +107,7 @@ class BaseName: def __init__(self, content: str) -> None: if ":" in content: - raise ValueError(f"invalid non-qualified name: {repr(content)}") + raise ValueError(f"invalid non-qualified name: {content!r}") self._content = content def __str__(self) -> str: @@ -240,9 +240,7 @@ def analyze( if elem.attrs.get("shape", "") != "ellipse": m = re_node_label.fullmatch(v) if not m: - raise ValueError( - f"unexpected label value {repr(v)}" - ) + raise ValueError(f"unexpected label value {v!r}") node.location = m.group("location") node.usage_kind = typing.cast( UsageKind, m.group("usage_kind") @@ -251,13 +249,13 @@ def analyze( node.ndynamic = int(m.group("ndynamic")) case "shape": if v != "ellipse": - raise ValueError(f"unexpected shape value {repr(v)}") + raise ValueError(f"unexpected shape value {v!r}") skip = True case _: - raise ValueError(f"unknown edge key {repr(k)}") + raise ValueError(f"unknown edge key {k!r}") if not skip: if node.funcname in graph: - raise ValueError(f"duplicate node {repr(str(node.funcname))}") + raise ValueError(f"duplicate node {str(node.funcname)!r}") graph[node.funcname] = node if ":" in str(node.funcname): basename = node.funcname.base() @@ -276,9 +274,9 @@ def analyze( case "label": pass case _: - raise ValueError(f"unknown edge key {repr(k)}") + raise ValueError(f"unknown edge key {k!r}") if caller is None or callee is None: - raise ValueError(f"incomplete edge: {repr(elem.attrs)}") + raise ValueError(f"incomplete edge: {elem.attrs!r}") if caller not in graph: raise ValueError(f"unknown caller: {caller}") if str(callee) == "__indirect_call": @@ -289,7 +287,7 @@ def analyze( else: graph[caller].calls[callee] = False case _: - raise ValueError(f"unknown elem type {repr(elem.typ)}") + raise ValueError(f"unknown elem type {elem.typ!r}") for ci_fname in ci_fnames: with open(ci_fname, "r", encoding="utf-8") as fh: @@ -298,7 +296,7 @@ def analyze( for node in app.extra_nodes(): if node.funcname in graph: - raise ValueError(f"duplicate node {repr(str(node.funcname))}") + raise ValueError(f"duplicate node {str(node.funcname)!r}") graph[node.funcname] = node missing: set[QName] = set() @@ -397,7 +395,7 @@ def read_source(location: str) -> str: re_location = re.compile(r"(?P<filename>.+):(?P<row>[0-9]+):(?P<col>[0-9]+)") m = re_location.fullmatch(location) if not m: - raise ValueError(f"unexpected label value {repr(location)}") + raise ValueError(f"unexpected label value {location!r}") filename = m.group("filename") row = int(m.group("row")) - 1 col = int(m.group("col")) - 1 @@ -1493,12 +1491,12 @@ def main( if val.nstatic == 0: continue print( - f"{name.ljust(namelen)} {str(val.nstatic).rjust(numlen)}" + f"{name:<{namelen}} {val.nstatic:>{numlen}}" + (f" * {val.cnt}" if val.cnt != 1 else "") ) print(sep2) - print(f"{'Total'.ljust(namelen)} {str(nsum).rjust(numlen)}") - print(f"{'Maximum'.ljust(namelen)} {str(nmax).rjust(numlen)}") + print(f"{'Total':<{namelen}} {nsum:>{numlen}}") + print(f"{'Maximum':<{namelen}} {nmax:>{numlen}}") print(sep1) def next_power_of_2(x: int) -> int: @@ -1542,8 +1540,8 @@ def main( if comment: print(f"/* {name}".ljust(len(prefix) + namelen), end="") else: - print(f"{prefix}{name.ljust(namelen)}", end="") - print(f" = {str(size).rjust(sizelen)};", end="") + print(f"{prefix}{name:<{namelen}}", end="") + print(f" = {size:>{sizelen}};", end="") if comment: print(" */", end="") elif eqn: @@ -1557,7 +1555,7 @@ def main( False, row.name, row.size, - f"LM_NEXT_POWER_OF_2({str(row.base).rjust(baselen)}+{intrstack}+{stack_guard_size})-{stack_guard_size}", + f"LM_NEXT_POWER_OF_2({row.base:>{baselen}}+{intrstack}+{stack_guard_size})-{stack_guard_size}", ) print_row(True, "TOTAL (inc. stack guard)", sizesum) if mainrow: @@ -1565,7 +1563,7 @@ def main( True, "MAIN/KERNEL", mainrow.size, - f" {str(mainrow.base).rjust(baselen)}+{intrstack}", + f" {mainrow.base:>{baselen}}+{intrstack}", ) print() print("/*") |