Rerumu / Wasynth

WebAssembly to Lua translation library and tool
https://discord.gg/JuekZtYmxx
GNU General Public License v3.0
140 stars 19 forks source link

Too much noise from `write_constant` #7

Closed Rerumu closed 2 years ago

Rerumu commented 2 years ago

The WebAssembly specification is not very clear on what a well-formed constant looks like, or how many constant instructions it may allow. As such, right now write_constant implementations for offsets and other values end up creating an entire function just to call it and receive its value.

This makes would would otherwise be 1 line (the expression of the constant) turn into at least 5 lines. It would be great if all this noise could be removed without breaking any unspoken rules.

https://github.com/Rerumu/Wasynth/blob/master/codegen-luajit/src/translator.rs#L51 https://github.com/Rerumu/Wasynth/blob/master/codegen-luau/src/translator.rs#L50