Open jcelerier opened 2 years ago
I'm interested
hi and welcome @dtee1 ! My recommendation for this would be to try to make a self-contained header-only library which is able to execute bytebeat expressions correctly.
Here are some test cases: (one per line)
(((t & t>>8)-(t>>13&t))&((t & t>>8)-(t>>13)))^(t>>8&t)
t<<((t>>8&t)|(t>>14&t))
t/(t%(t>>8|t>>16))
(t<<(t/(t>>8&t)))
t<<((t>>1|t>>8)^(t>>13))
t<<((t>>1|t>>8)*(t>>13&t>>12))
t<<(t>>8&(t/(t>>10&t)))
(t>>8&t>>16)*t>>4
(t & (t>>15+(t>>8&t)))*t
the idea would be that t
instead of being int, would be some struct type with all the operators reimplemented so that dividing by 0 or calling % 0 does not fail like it does currently.
A "fun" alternative would be to try and reimplement a bytebeat interpreter with boost.metaparse ? this would allow to copy-paste JS functions directly, e.g. Math.sin instead of std::sin.
Idea: having a struc instead of t which reimplements the operators and replaces division by zero by zero