| Remove globally unreferenced classes, interfaces, methods, parameters, and
fields from the AST. This algorithm is based on having known "entry points"
into the application which serve as the root(s) from which reachability is
determined and everything else is rescued. Pruner determines reachability at
a global level based on method calls and new operations; it does not perform
any local code flow analysis. But, a local code flow optimization pass that
can eliminate method calls would allow Pruner to prune additional nodes.
Note: references to pruned types may still exist in the tree after this pass
runs, however, it should only be in contexts that do not rely on any code
generation for the pruned type. For example, it's legal to have a variable of
a pruned type, or to try to cast to a pruned type. These will cause natural
failures at run time; or later optimizations might be able to hard-code
failures at compile time.
Note: this class is limited to pruning parameters of static methods only.
|