binji / wasm-clang

Running Clang/LLD in WebAssembly Demo
https://binji.github.io/wasm-clang
Apache License 2.0
259 stars 27 forks source link

Stdin input #14

Open nullxx opened 1 year ago

nullxx commented 1 year ago

So far, the input had to be provided before running the program. This was a bit complicated, as the function that handled this, 'host_read', expected a synchronous response, and to get a real-time response from the user, it was necessary to wait for a while (asynchronous). That's why I have implemented a possible solution.

Could you take a look at it?

https://github.com/nullxx/compy/blob/81b5463dad671335825f74ea27c78681b2a71cea/src/lib/worker/lib/memfs.ts#L139-L157

binji commented 1 year ago

Sorry I didn't take a look at this earlier!

I think it makes sense to turn this into an async function, but I don't recall where else it's being used. It may be that it's required to be synchronous elsewhere. In any case, it looks like you were able to get it working for the most part.