Code review

Added a test, simplified another and added
a lot of TODO's.
This commit is contained in:
Johan B.W. de Vries 2025-04-06 12:58:20 +02:00
parent 521171540b
commit 5d9ef0e276
3 changed files with 34 additions and 5 deletions

17
TODO.md
View File

@ -10,3 +10,20 @@
- Storing u8 in memory still claims 32 bits (since that's what you need in local variables). However, using load8_u / loadu_s we can optimize this. - Storing u8 in memory still claims 32 bits (since that's what you need in local variables). However, using load8_u / loadu_s we can optimize this.
- Implement a FizzBuzz example - Implement a FizzBuzz example
- Also, check the codes for FIXME and TODO - Also, check the codes for FIXME and TODO
- Allocation is done using pointers for members, is this desired?
- Merge in type classes
- test_bitwise_or_inv_type
- test_bytes_index_out_of_bounds vs static trap(?)
- test_num.py is probably best as part of the generator?
- Find pytest.mark.skip
- There's a weird resolve_as reference in calculate_alloc_size
- Either there should be more of them or less
- At first glance, looks like failure in the typing system
- Related to the FIXME in phasm_type3?
- WEBASSEMBLY_BUILTIN_FLOAT_OPS and WEBASSEMBLY_BUILTIN_BYTES_OPS are special cased
- Should be part of a prelude
- Casting is not implemented except u32 which is special cased
- Parser is putting stuff in ModuleDataBlock
- Compiler should probably do that

View File

@ -20,7 +20,7 @@ def testEntry() -> {type_}:
@pytest.mark.integration_test @pytest.mark.integration_test
@pytest.mark.parametrize('type_', TYPE_LIST) @pytest.mark.parametrize('type_', TYPE_LIST)
def test_division_zero_let_it_crash_float(type_): def test_division_float_follow_ieee_so_inf_pos(type_):
code_py = f""" code_py = f"""
@exported @exported
def testEntry() -> {type_}: def testEntry() -> {type_}:
@ -31,3 +31,17 @@ def testEntry() -> {type_}:
# https://www.w3.org/TR/wasm-core-1/#-hrefop-fdivmathrmfdiv_n-z_1-z_2 # https://www.w3.org/TR/wasm-core-1/#-hrefop-fdivmathrmfdiv_n-z_1-z_2
result = Suite(code_py).run_code() result = Suite(code_py).run_code()
assert float('+inf') == result.returned_value assert float('+inf') == result.returned_value
@pytest.mark.integration_test
@pytest.mark.parametrize('type_', TYPE_LIST)
def test_division_float_follow_ieee_so_inf_neg(type_):
code_py = f"""
@exported
def testEntry() -> {type_}:
return -10.0 / 0.0
"""
# WebAssembly dictates that float division follows the IEEE rules
# https://www.w3.org/TR/wasm-core-1/#-hrefop-fdivmathrmfdiv_n-z_1-z_2
result = Suite(code_py).run_code()
assert float('-inf') == result.returned_value

View File

@ -74,11 +74,9 @@ CONSTANT: (u32, u8, u8, ) = (24, 4000, 1, )
@pytest.mark.integration_test @pytest.mark.integration_test
def test_tuple_must_use_literal_for_indexing(): def test_tuple_must_use_literal_for_indexing():
code_py = """ code_py = """
CONSTANT: u32 = 0
@exported @exported
def testEntry(x: (u8, u32, u64)) -> u64: def testEntry(x: (u8, u32, u64), y: u8) -> u64:
return x[CONSTANT] return x[y]
""" """
with pytest.raises(Type3Exception, match='Must index with literal'): with pytest.raises(Type3Exception, match='Must index with literal'):