3 ms·
Puzzled why you'd want this. So you trace the execution of a dynamic program in an attempt to determine all possible variable types, only to annotate its source
by forgotusername 15y ago
Puzzled why you'd want this. So you trace the execution of a dynamic program in an attempt to determine all possible variable types, only to annotate its source with those types, so that on next compilation.. the compiler can statically enforce that the same code that created that trace doesn't violate the types deduced from it? (It seems to me the only possible use for doing this would be to test the tracing implementation is sound!)
Or perhaps it's for documentation or something. In that case, it'd be a hell of a lot of hand-editing to remove noise from the output.
Another side, the set of types used by any variable may be affected by program inputs, so the result can never be complete, unless you run V8 for every possible program input (likely an impossible task).
- chrisdew 15y agoYes, mostly for documentation, and also to spot any unexpected types. I would like to run this during automated testing. For modules where code coverage is 100%, it could be possible that most input-dependent type paths are covered.
- tlrobinson 15y agoOnce the annotations are added (and presumably verified by the developer), Closure can do more aggressive optimizations like stripping unused code, etc.