class FunctionArgumentInjector
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
FunctionArgumentInjector.ReferencedAfterSideEffect
Collect parameter names referenced after a non-local side-effect.
|
Modifier and Type | Field and Description |
---|---|
(package private) static java.lang.String |
THIS_MARKER |
Modifier | Constructor and Description |
---|---|
private |
FunctionArgumentInjector() |
Modifier and Type | Method and Description |
---|---|
(package private) static boolean |
bodyMayHaveConditionalCode(Node n)
We consider a return or expression trivial if it doesn't contain a conditional expression or
a function.
|
private static boolean |
canNameValueChange(Node n,
Node parent)
This is similar to NodeUtil.isLValue except that object properties and
array member modification aren't important ("o" in "o.a = 2" is still "o"
after assignment, where in as "o = x", "o" is now "x").
|
(package private) static java.util.Set<java.lang.String> |
findModifiedParameters(Node fnNode)
Retrieve a set of names that can not be safely substituted in place.
|
private static java.util.Set<java.lang.String> |
findModifiedParameters(Node n,
Node parent,
java.util.Set<java.lang.String> names,
java.util.Set<java.lang.String> unsafe,
boolean inInnerFunction)
Check for uses of the named value that imply a pass-by-value
parameter is expected.
|
private static java.util.Set<java.lang.String> |
findParametersReferencedAfterSideEffect(java.util.Set<java.lang.String> parameters,
Node root)
Boot strap a traversal to look for parameters referenced
after a non-local side-effect.
|
private static void |
gatherLocalNames(Node n,
java.util.Set<java.lang.String> names)
Gather any names declared in the local scope.
|
(package private) static java.util.LinkedHashMap<java.lang.String,Node> |
getFunctionCallParameterMap(Node fnNode,
Node callNode,
com.google.common.base.Supplier<java.lang.String> safeNameIdSupplier)
Get a mapping for function parameter names to call arguments.
|
private static java.util.Set<java.lang.String> |
getFunctionParameterSet(Node fnNode)
Get a set of function parameter names.
|
private static java.lang.String |
getUniqueAnonymousParameterName(com.google.common.base.Supplier<java.lang.String> safeNameIdSupplier)
Parameter names will be name unique when at a later time.
|
(package private) static Node |
inject(AbstractCompiler compiler,
Node node,
Node parent,
java.util.Map<java.lang.String,Node> replacements)
With the map provided, replace the names with expression trees.
|
(package private) static Node |
inject(AbstractCompiler compiler,
Node node,
Node parent,
java.util.Map<java.lang.String,Node> replacements,
boolean replaceThis) |
(package private) static void |
maybeAddTempsForCallArguments(Node fnNode,
java.util.Map<java.lang.String,Node> argMap,
java.util.Set<java.lang.String> namesNeedingTemps,
CodingConvention convention)
Updates the set of parameter names in set unsafe to include any
arguments from the call site that require aliases.
|
(package private) static boolean |
mayHaveConditionalCode(Node n)
We consider an expression trivial if it doesn't contain a conditional expression or
a function.
|
static final java.lang.String THIS_MARKER
static Node inject(AbstractCompiler compiler, Node node, Node parent, java.util.Map<java.lang.String,Node> replacements)
node
- The root of the node tree within which to perform the
substitutions.parent
- The parent root node.replacements
- The map of names to template node trees with which
to replace the name Nodes.static Node inject(AbstractCompiler compiler, Node node, Node parent, java.util.Map<java.lang.String,Node> replacements, boolean replaceThis)
static java.util.LinkedHashMap<java.lang.String,Node> getFunctionCallParameterMap(Node fnNode, Node callNode, com.google.common.base.Supplier<java.lang.String> safeNameIdSupplier)
private static java.lang.String getUniqueAnonymousParameterName(com.google.common.base.Supplier<java.lang.String> safeNameIdSupplier)
static java.util.Set<java.lang.String> findModifiedParameters(Node fnNode)
private static java.util.Set<java.lang.String> findModifiedParameters(Node n, Node parent, java.util.Set<java.lang.String> names, java.util.Set<java.lang.String> unsafe, boolean inInnerFunction)
n
- The node in question.parent
- The parent of the node.names
- The set of names to check.unsafe
- The set of names that require aliases.inInnerFunction
- Whether the inspection is occurring on a inner
function.private static boolean canNameValueChange(Node n, Node parent)
n
- The NAME node in question.parent
- The parent of the node.static void maybeAddTempsForCallArguments(Node fnNode, java.util.Map<java.lang.String,Node> argMap, java.util.Set<java.lang.String> namesNeedingTemps, CodingConvention convention)
fnNode
- The FUNCTION node to be inlined.argMap
- The argument list for the call to fnNode.namesNeedingTemps
- The set of names to update.static boolean bodyMayHaveConditionalCode(Node n)
static boolean mayHaveConditionalCode(Node n)
private static java.util.Set<java.lang.String> findParametersReferencedAfterSideEffect(java.util.Set<java.lang.String> parameters, Node root)
parameters
- The set of parameter names.root
- The function code block.private static void gatherLocalNames(Node n, java.util.Set<java.lang.String> names)
private static java.util.Set<java.lang.String> getFunctionParameterSet(Node fnNode)