- All Implemented Interfaces:
- com.google.common.base.Predicate<Node>, NodeUtil.Visitor
- Enclosing class:
- FunctionArgumentInjector
private static class FunctionArgumentInjector.ReferencedAfterSideEffect
extends java.lang.Object
implements NodeUtil.Visitor, com.google.common.base.Predicate<Node>
Collect parameter names referenced after a non-local side-effect.
Assumptions:
- We assume parameters are not modified in the function body
(that is checked separately).
- There are no inner functions (also checked separately).
As we are trying to replace parameters with there passed in values
we are interested in anything that may affect those value. So, ignoring
changes to local variables, we look for things that may affect anything
outside the local-state. Once such a side-effect is seen any following
reference to the function parameters are collected. These will need
to be assigned to temporaries to prevent changes to their value as would
have happened during the function call.
To properly handle loop structures all references to the function
parameters are recorded and the decision to keep or throw away those
references is deferred until exiting the loop structure.