BYVoid / continuation

JavaScript asynchronous Continuation-Passing Style transformation (deprecated).
Other
388 stars 42 forks source link

Refactor normalize() and fix transforming nested block statements #6

Closed TomiBelan closed 11 years ago

TomiBelan commented 11 years ago

This does some refactoring, fixes issue #5 and a lot of other bugs as well.

The commit messages should be self-explanatory. If you want to read the diffs, I suggest reading them commit by commit instead of all at once in the "Files Changed" tab.

The first commit changes normalize() to use traverse() instead of calling normalize on child nodes manually. Some child nodes weren't being normalized, and many didn't pass on the "place" argument correctly. Plus, because only a few nodes actually need normalizing, this is also a lot less code. If I missed some disadvantages of this approach, please tell me.

The second commit removes the node.async properties and simply checks whether the transformed place is different instead. Some functions were setting async, some were checking the transform return value, some did both and some did neither. Now that there is a single thing to check, it should be easier to verify the code is correct.

I understand my patches are large and you might not have much time to spend on this project. So thanks for taking the time, and tell me if there's anything I can do to help. :-)

BYVoid commented 11 years ago

@TomiBelan Thank you for your great job! The code was a little messy and inconsistent especially in the parts of normalize() and redundant async property. I have merged your commits and added some tests for the two cases.

TomiBelan commented 11 years ago

Thanks! I'm impressed by your fast reply, and also that you've fixed issue #4 as well (originally I was planning to do that next). :-) Though #4 might not be completely fixed yet -- see my comment there.