Skip to content

Commit 1c10ed5

Browse files
committed
latest. hopefully good and interactive?
1 parent 4f3c316 commit 1c10ed5

1 file changed

Lines changed: 30 additions & 11 deletions

File tree

patchVampireInteractive.sh

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,38 @@ if [[ -f "$TOD_PATH" ]]; then
153153
TOD_PATH="$TOD_PATH" python - <<'PY'
154154
from pathlib import Path
155155
import os
156+
import re
156157
157158
path = Path(os.environ["TOD_PATH"])
158-
text = path.read_text()
159-
needle = (
160-
" static_assert(sizeof(uint64_t) == sizeof(Branch));\n"
161-
" static_assert(sizeof(uint64_t) == sizeof(TermList));\n"
162-
" static_assert(sizeof(uint64_t) == sizeof(void*));\n"
163-
" static_assert(sizeof(uint64_t) == sizeof(intptr_t));\n"
164-
)
165-
if needle in text and "__EMSCRIPTEN__" not in text:
166-
repl = "#ifndef __EMSCRIPTEN__\n" + needle + "#endif\n"
167-
text = text.replace(needle, repl, 1)
168-
path.write_text(text)
159+
lines = path.read_text().splitlines(True)
160+
pattern = re.compile(r'^\s*static_assert\(sizeof\(uint64_t\)\s*==\s*sizeof\([^)]+\)\);\s*$')
161+
162+
groups = []
163+
start = None
164+
for i, line in enumerate(lines):
165+
if pattern.match(line):
166+
if start is None:
167+
start = i
168+
else:
169+
if start is not None:
170+
groups.append((start, i))
171+
start = None
172+
if start is not None:
173+
groups.append((start, len(lines)))
174+
175+
changed = False
176+
for start, end in reversed(groups):
177+
prev = start - 1
178+
while prev >= 0 and lines[prev].strip() == "":
179+
prev -= 1
180+
if prev >= 0 and lines[prev].strip() == "#ifndef __EMSCRIPTEN__":
181+
continue
182+
lines.insert(end, "#endif\n")
183+
lines.insert(start, "#ifndef __EMSCRIPTEN__\n")
184+
changed = True
185+
186+
if changed:
187+
path.write_text("".join(lines))
169188
print("Applied: Relax TermOrderingDiagram asserts for Emscripten (fallback)")
170189
PY
171190
fi

0 commit comments

Comments
 (0)