wasm-tools icon indicating copy to clipboard operation
wasm-tools copied to clipboard

Using wast in combination with wasm-encoder

Open LHolten opened this issue 3 years ago • 1 comments

I'm trying to parse a WAT Expression and emit the instructions into a wasm-encoder Function. This is for a language compiler i'm writing that has inlines WAT code.

The problem is that wast::Instruction is not compatible with wasm_encoder::Instruction. Also the wast::binary::Encode trait is private, so i can't use that in combination with wasm_encoder::Function::raw either.

My suggestion is to either make the wast Encode trait public, or implement From<wast::Instruction> for wasm_encoder::Instruction.

LHolten avatar Aug 31 '21 15:08 LHolten

Thanks for the report! The eventual goal is to have wast depend on wasm-encoder, and at that point we could have conversion from the wast AST to types in the wasm-encoder trait, such as wast::Expression returning a Vec<wasm_encoder::Instruction> or similar. At this time though that's not yet implemented, but if you're interested to help out I think it'd be great to implement!

alexcrichton avatar Aug 31 '21 17:08 alexcrichton