Skip to content

Commit 336b0a4

Browse files
committed
Added a pseudo-documentation for the second generator
1 parent 307a4f5 commit 336b0a4

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

rebuild_printer.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
import sys
66
from math import ceil
77

8+
"""
9+
Generates src/dynarec/arm_printer.c
10+
===
11+
12+
See src/dynarec/arm_instructions.txt (the input file) for the syntax documentation.
13+
"""
14+
815
# Helper class to avoid displaying '\x1b[' on errors
916
class string(str):
1017
def __repr__(self):
@@ -172,13 +179,6 @@ def generate_bin_test(positions=[], specifics=[]):
172179
- specifics is an array of arrays the same length as positions that contains a tuple (mask, correctBit)
173180
that is at position positions[current_pos]
174181
"""
175-
if len(positions) != len(specifics):
176-
fail(
177-
AssertionError,
178-
"generate_bin_tests requires the same length for positions ({}) and specifics ({})!".format(
179-
len(positions), len(specifics)
180-
)
181-
)
182182

183183
if specifics == []:
184184
append("if ((opcode & " + arr2hex(mask) + ") == " + arr2hex(correctBits) + ") {\n")
@@ -194,8 +194,9 @@ def generate_bin_test(positions=[], specifics=[]):
194194
if any(map(lambda s: len(s) != l, specifics)):
195195
fail(
196196
AssertionError,
197-
"generate_bin_tests requires the same length for positions ({}) and specifics ({})!".format(
198-
len(positions), len(specifics)
197+
"generate_bin_tests requires the same length for positions ({}) and each element "
198+
"of the specifics array ({})!".format(
199+
len(positions), [len(s) for s in specifics]
199200
)
200201
)
201202

@@ -290,7 +291,7 @@ def add_custom_variables():
290291
# Custom ifs
291292
# Also, requires only a single '='
292293
if eq != "=":
293-
fail(ValueError, "Too many '=' switches (!@ modifier)")
294+
fail(ValueError, "Too many '=' switches (@@ modifier)")
294295

295296
# Extract the statements
296297
statements = []
@@ -1653,7 +1654,7 @@ def add_custom_variables():
16531654

16541655
# No C variable since we're invalidating!
16551656

1656-
# Now print the invalidation, numerote if debugging
1657+
# Now print the invalidation, number if debugging
16571658
if numberInvalids:
16581659
append("strcpy(ret, \"??? #" + str(invalidationCount) + "\");\n} else ")
16591660
invalidationCount = invalidationCount + 1
@@ -1963,12 +1964,12 @@ def add_custom_variables():
19631964
"""}
19641965

19651966
for f in files_header:
1966-
# Save the string for the next iteration, writing was successful
19671967
with open(os.path.join(root, "src", "dynarec", f), 'w') as file:
19681968
file.write(header.format(version = ver))
19691969
file.write(files_header[f])
19701970
file.write(output)
19711971
file.write(files_guard[f])
1972+
# Save the string for the next iteration, writing was successful
19721973
with open(os.path.join(root, "src", "dynarec", "last_run.txt"), 'w') as file:
19731974
file.write('\n'.join(insts))
19741975

0 commit comments

Comments
 (0)