kripken/emscripten — pull request #1963 by coolwanglu (2014-01-01 16:21:56+00:00)
Title: Async transformation

This is a first implementation of #1881, still working in progress.
A number of `TODO`'s are left in the patch, those are questions about coding style, structures, naming convention etc.

This patches introduces a new suffix: `__async` in the library, which marks the functions as async. If any async function is used, the async transformation routine will be triggered. `shell.js` is modified to take care of `_main`

Async functions must take a callback function as its _1st_ argument, I chose the first instead of the last because of the possibility of optional arguments. It is possible to extend to support arbitrary index. It may not work with dynamic linking unless special declaration.

An example test case has been added.

Currently it doesn't work with ASM.js or relooper. I'm not sure about relooper, but with more efforts it should work with ASM.js — unless the type of the callback must be determined in ASM.js

The currently implementation is still kind of hacky, in `analyzer.js` and `jsifier.js`, I tried to hijack existing data structure, by defining the `async` property (and also a few others). I guess this is better than changing intertype, (e.g. change `call` to `async_call`).

Please review and leave comments if anything is inappropriate, and I'll make modifications accordingly.