diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-06-01 21:49:02 +0430 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-06-02 16:09:16 +0430 |
commit | 6b5d1eedcbc15077efa7c6188d34dcf2c13251be (patch) | |
tree | fd14867a9804e0ef3e4f32e45dc806d0b9024b02 /Meta/generate-libwasm-spec-test.py | |
parent | 6cd9906f60bff929d9c5fefcbed5f15328cb7e2b (diff) | |
download | serenity-6b5d1eedcbc15077efa7c6188d34dcf2c13251be.zip |
Meta: Make the wasm test generator cast numbers to i32 when needed
Otherwise the sign would be out of whack
Diffstat (limited to 'Meta/generate-libwasm-spec-test.py')
-rw-r--r-- | Meta/generate-libwasm-spec-test.py | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/Meta/generate-libwasm-spec-test.py b/Meta/generate-libwasm-spec-test.py index 8e0b63ea62..4c414f910c 100644 --- a/Meta/generate-libwasm-spec-test.py +++ b/Meta/generate-libwasm-spec-test.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 - +import struct from sys import argv, stderr from os import path from string import whitespace @@ -156,7 +156,7 @@ def genarg(spec): return '-NaN' if math.copysign(1.0, x) < 0 else 'NaN' if math.isinf(x): return 'Infinity' if x > 0 else '-Infinity' - return str(x) + return x except ValueError: try: x = float.fromhex(x) @@ -165,20 +165,25 @@ def genarg(spec): return '-NaN' if math.copysign(1.0, x) < 0 else 'NaN' if math.isinf(x): return 'Infinity' if x > 0 else '-Infinity' - return str(x) + return x except ValueError: try: x = int(x, 0) - return str(x) + return x except ValueError: return x x = gen() - if x.startswith('nan'): - return 'NaN' - if x.startswith('-nan'): - return '-NaN' - return x + if isinstance(x, str): + if x.startswith('nan'): + return 'NaN' + if x.startswith('-nan'): + return '-NaN' + return x + if spec['type'] == 'i32': + # cast back to i32 to get the correct sign + return str(struct.unpack('>i', struct.pack('>q', int(x))[4:])[0]) + return str(x) all_names_in_main = {} @@ -249,7 +254,7 @@ def main(): with NamedTemporaryFile("w+") as temp: temp.write(description["module"]) temp.flush() - rc = call(["wasm-as", "-n", temp.name, "-o", outpath]) + rc = call(["wasm-as", "-n", "-all", temp.name, "-o", outpath]) if rc != 0: print("Failed to compile", name, "module index", index, "skipping that test", file=stderr) continue |