smfoote / tornado

HTML templates with asynchronous rendering, built with JavaScript.
http://smfoote.github.io/tornado/
Apache License 2.0
8 stars 3 forks source link

Move prod/dev short method name logic into an optimization pass #76

Open jimmyhchan opened 9 years ago

smfoote commented 9 years ago

I don't know if this is possible, because the method name logic is specific to the code generation phase, which happens after the transforms.

jimmyhchan commented 9 years ago

One very bad idea is to run a string replacement pass on the outputted code. Another bad idea is run the output through esprima and generate a tree and walk that :(. I believe there's a way for us to have an optimization pass but it may need to be done on the instructions pass, we might need some intermediate data type between instruction and code....

I hope there's a way for us to break the generateJS pass into a few passes. There's quite a bit of logic between generate and util/builder. I don't know if it's possible but it'll be nice.

smfoote commented 9 years ago

Those do sound like bad ideas ;) I like splitting things into different modules when it makes code easier to understand. I'm not certain that breaking generateJS into multiple passes will make the code easier to understand, so I'm unconvinced.