Add function token count comments (rough draft)#14
Add function token count comments (rough draft)#14sparr wants to merge 1 commit intothisismypassport:mainfrom
Conversation
117fb00 to
970969f
Compare
|
Updated top comment with current status. Still very much WIP. Found a failure mode that I couldn't immediately resolve. This cart: local x = function() end
function y() x() endProduces this error: This is weird because it's happening when pico_annotate asks pico_rename to rename symbols in |
|
This is because pico_rename adds a few attributes (like used_globals) to the scopes it receives and assumes that all scopes then have it. Why do you need to run pico_rename on each function independently? It's unlikely to give sensible results anyway - you should run it on the entire thing. |
|
Running it on the whole thing will use two letter identifiers for files with more than 26 globals (or outer scope locals), while doing one function at a time will use single characters almost always. |
|
It'd probably make sense to move the used_globals/locals definitions to the Scope class itself (its init) instead of monkey patching it - should resolve this exception. |
|
I moved used_locals/globals (& now a very-rarely-needed used_members) to be lazy properties on Scope now, FYI. |
970969f to
e2bd693
Compare
|
Thanks! That resolved the problems I was having. The next thing I need to do is get it to recognize its own comments so it will overwrite them and be idempotent instead of adding more new comments each time. And then there's discussion about how to expose it with new options. I'm thinking of one option that adds the |
e2bd693 to
e752c3e
Compare
This needs a lot of work, but the core functionality is working so I'm submitting this for feedback on the implementation so far.
TODO list:
Stretch goals:
The
--annotateoption turns this:into this:
Closes #12