public class FunctionCallGraph extends Object
| Constructor and Description | 
|---|
FunctionCallGraph(DMLProgram prog)
Constructs the function call graph for all functions
 reachable from the main program. 
 | 
FunctionCallGraph(StatementBlock sb)
Constructs the function call graph for all functions
 reachable from the given statement block. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
boolean | 
containsSecondOrderCall()
Indicates if the function call graph, i.e., functions that are transitively
 reachable from the main program, contains a second-order builtin function call 
 (e.g., eval, paramserv), which prohibits the removal of unused functions. 
 | 
Set<String> | 
getCalledFunctions(String fkey)
Returns all functions called from the given function. 
 | 
Set<String> | 
getCalledFunctions(String fnamespace,
                  String fname)
Returns all functions called from the given function. 
 | 
List<FunctionOp> | 
getFunctionCalls(String fkey)
Returns all function operators calling the given function. 
 | 
List<StatementBlock> | 
getFunctionCallsSB(String fkey)
Returns all statement blocks that contain a function operator
 calling the given function. 
 | 
Set<String> | 
getReachableFunctions()
Returns all functions that are reachable either directly or indirectly
 form the main program, except the main program itself. 
 | 
Set<String> | 
getReachableFunctions(Set<String> excludeList)
Returns all functions that are reachable either directly or indirectly
 form the main program, except the main program itself and the given 
 exclude-list of function names. 
 | 
boolean | 
isReachableFunction(String fkey)
Indicates if the given function is reachable either directly or indirectly
 from the main program. 
 | 
boolean | 
isReachableFunction(String fnamespace,
                   String fname)
Indicates if the given function is reachable either directly or indirectly
 from the main program. 
 | 
boolean | 
isRecursiveFunction(String fkey)
Indicates if the given function is either directly or indirectly recursive. 
 | 
boolean | 
isRecursiveFunction(String fnamespace,
                   String fname)
Indicates if the given function is either directly or indirectly recursive. 
 | 
boolean | 
isSideEffectFreeFunction(String fkey)
Indicates if the given function is side effect free, i.e., has no
 prints, no persistent write, and includes no or only calls to
 side-effect-free functions. 
 | 
boolean | 
isSideEffectFreeFunction(String fnamespace,
                        String fname)
Indicates if the given function is side effect free, i.e., has no
 prints, no persistent write, and includes no or only calls to
 side-effect-free functions. 
 | 
void | 
removeFunctionCall(String fkey,
                  FunctionOp fop,
                  StatementBlock sb)
Removes a single function call identified by target function name,
 and source function op and statement block. 
 | 
void | 
removeFunctionCalls(String fkey)
Removes all calls of the given function. 
 | 
void | 
replaceFunctionCalls(String fkeyOld,
                    String fkey)
Replaces a function call to fkeyOld with a call to fkey,
 but using the function op and statement block from the old. 
 | 
public FunctionCallGraph(DMLProgram prog)
prog - dml program of given scriptpublic FunctionCallGraph(StatementBlock sb)
sb - statement block (potentially hierarchical)public Set<String> getCalledFunctions(String fnamespace, String fname)
fnamespace - function namespacefname - function namepublic Set<String> getCalledFunctions(String fkey)
fkey - function key of calling function, null indicates the main programpublic List<FunctionOp> getFunctionCalls(String fkey)
fkey - function key of called function,
      null indicates the main program and returns an empty listpublic List<StatementBlock> getFunctionCallsSB(String fkey)
fkey - function key of called function,
      null indicates the main program and returns an empty listpublic void removeFunctionCalls(String fkey)
fkey - function key of called function,
      null indicates the main program, which has no affectpublic void removeFunctionCall(String fkey, FunctionOp fop, StatementBlock sb)
fkey - function key of called functionfop - source function call operatorsb - source statement blockpublic void replaceFunctionCalls(String fkeyOld, String fkey)
fkeyOld - old function key of called functionfkey - new function key of called functionpublic boolean isRecursiveFunction(String fnamespace, String fname)
fnamespace - function namespacefname - function namepublic boolean isRecursiveFunction(String fkey)
fkey - function key of calling function, null indicates the main programpublic boolean isSideEffectFreeFunction(String fnamespace, String fname)
fnamespace - function namespacefname - function namepublic boolean isSideEffectFreeFunction(String fkey)
fkey - function key of calling function, null indicates the main programpublic Set<String> getReachableFunctions()
public Set<String> getReachableFunctions(Set<String> excludeList)
excludeList - list of function keys to excludepublic boolean isReachableFunction(String fnamespace, String fname)
fnamespace - function namespacefname - function namepublic boolean isReachableFunction(String fkey)
fkey - function key of calling function, null indicates the main programpublic boolean containsSecondOrderCall()
Copyright © 2021 The Apache Software Foundation. All rights reserved.