Before, a type class was a property of a type.
But that doesn't make any sense for multi parameter
type classes.
Had to make a hacky way for type classes with
type constructors.
They look a lot like placeholders, but they exist before
the typing system takes place. And there's a (much smaller)
context to deal with.
For now, removes Placeholders in user function definitions
as they were not implemented.
Adds signature to function to try to get them closer to
type class methods. Already seeing some benefit in the
constraint generator.
Stricter zipping for safety.
Also adds the remaining unexposed WebAssembly opcodes as
comments (eqz, clz, ctz, popcnt, copysign).
This also means that BinaryOp.operator is now always
a type class method.
"An arithmetic shift is usually equivalent to
multiplying the number by a positive or a negative
integral power of the radix." -- Federal Standard 1037C
"This is the same as multiplying x by 2**y."
"A right shift by n bits is defined as floor division
by pow(2,n). A left shift by n bits is defined as
multiplication with pow(2,n)."
This is because Haskell defines negate, abs and signum
for Num, but they don't work with our unsigned number
types. (abs would be a noop.) Haskell has Word32 / Word64,
but there negate doesn't make much sense to me.
Implemented neg and abs.
Implemented a type class inheritance check.
Removed Integral from u8 and i8 since it wasn't implemented.
Also extended the hack around u8 to u32 cast used
in crc32 - its type was lost, so it would just cast
to whatever the environment was expecting.
Had to do_format_check=False since the file has
some comments and such.
Various updates to bring the project uptodate.
- Updated required packages
- Removed runtimes that are not being updated
- wasmtime is for now the only supported runtime
- Implements imports for wasmtime runtime
- Fixes a memory access bug for wasmtime runtime
- compile_wasm is now optional - runtimes have to
implement and call this themselves
- Typing fixes
- Linting fixes
Prior to this PR, each type would have its own handwritten
test suite. The end result was that not all types were tested
for all situations.
This PR adds a framework based on a Markdown file, which
generates the basic tests for the types defined in json
files. These are auto generated and updated by the Makefile
before the test suite is run.
Also, a number of unsupported type combinations are now
supported.
Also, we now support negative literals.
Also, allocation calculation fixes for nested types.
Also, the test helpers can now properly import and export
typed variables such as bytes, static arrays and tuples. This
may come in handy when it comes to phasm platform wanting to
route data.
Also, adds better support for i8 type.
Also, started on a runtime.py, since there's quite some code
now that deals with compile time handling of WebAssembly stuff.
Also, minor improvement to the type constrains, namely we
better match 'tuple' literals with static array types.
Also, reduced spam when printing the type analysis results;
constraints that go back on the backlog are now no longer
printed one by one. It now also prints the end results of
the typing analysis.
Also, reorganized the big test_primitives test into type
classes.
Also, replaced pylint with ruff.
Prior to this PR, the compiler would call stdlib.types's
__subscript_bytes__.
However, that function performs some checks we do not need.
After this MR, folding iterates directly over the bytes
memory, saving the memory access checks and the function
calls. This gets us a speedup of about 43% less CPU time
used on Firefox.
Also, by default, the CRC32 page runs a shorter timing test.