Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).
No functional changes.
Same as Vector, ByteBuffer now also signals allocation failure by
returning an ENOMEM Error instead of a bool, allowing us to use the
TRY() and MUST() patterns.
It's possible for the module to request too many locals, we now reject
such modules instead of trying to allocate space for them.
The value itself is chosen arbitrarily, so future tweaks _might_ be
necessary.
Found by OSS-Fuzz: https://oss-fuzz.com/testcase?key=4755809098661888
This commit is a fairly large refactor, mainly because it unified the
two different ways that existed to represent references.
Now Reference values are also a kind of value.
It also implements a printer for values/references instead of copying
the implementation everywhere.
Previously, the ip would not be propagated correctly, and we would
produce invalid jumps when more than one level of nesting was involved.
This makes loops work :P
These aren't actually an extra set, without them the fold operation
would be syntactically invalid.
Also remove possible cast of float->double/double->float in Value::to()
Previously, this was parsing only one kind because I mistakenly assumed
that they all had the same shape, now it can parse two kinds, and will
return NotImplemented for the rest.
With this, the parser should technically be able to parse all wasm
modules. Any parse failure on correct modules should henceforth be
labelled a bug :^)
With this, we can parse a module at least as simple as the following C
code would generate:
```c
int add(int x, int y) {
if (x > y)
return x + y;
return y - x; // Haha goteeem
}
```
It's much better to tell the user "hey, the magic numbers don't check
out" than "oh there was a problem with your input" :P
Also refactors some stuff to make it possible to efficiently use the
parser error enum without it getting in the way.
This can currently parse a really simple module.
Note that it cannot parse the DataCount section, and it's still missing
almost all of the instructions.
This commit also adds a 'wasm' test utility that tries to parse a given
webassembly binary file.
It currently does nothing but exit when the parse fails, but it's a
start :^)