lukewagner / polyfill-prototype-1

Experimental WebAssembly polyfill library and tools
Apache License 2.0
241 stars 42 forks source link

parse stdlib globals #2

Closed kripken closed 9 years ago

kripken commented 9 years ago

This starts to parse stdlib globals like stdlib.NaN and stdlib.Infinity. This is mostly for feedback, as there are various ways to do this, let me know what you think.

kripken commented 9 years ago

With this commit in place, I can parse latest emscripten hello world output successfully, and emit a wasm. (But this doesn't store the stdlibness.)

lukewagner commented 9 years ago

So I didn't quite think this patch was the right strategy (I'm also not sure if it was finished, I couldn't find where the is_stdlib bool was used.

Instead, I wrote a patch (611ec5c8c41b08b112cf064ec49b13bf87e400cd) that adds a hash table of stdlib_doubles (in addition to the current stdlib_funcs) and added NaN and Infinity to that from analyze_imports. Then the analyze_name/write_name could be modified to note these names and convert them to plain old NaN/Infinity F64 literals. On the other end, when asked to print a NaN or Infinity, the name of the auto-imported stdlib is used instead.

Let me know if you have any other problems.

kripken commented 9 years ago

Cool, thanks.