import Modification from '../../modification'; import * as Shift from 'shift-ast'; export default class ProxyRemover extends Modification { private readonly scopeTypes; private readonly proxyExpressionTypes; private shouldRemoveProxyFunctions; private globalScope; private proxyFunctions; private proxyFunctionNames; private cyclicProxyFunctionIds; private graph; /** * Creates a new modification. * @param ast The AST. * @param removeProxyFunctions Whether the functions should be removed. */ constructor(ast: Shift.Script | Shift.Module, removeProxyFunctions: boolean); /** * Executes the modification. */ execute(): void; /** * Finds all proxy functions and records them in the according scope. */ private findProxyFunctions; /** * Finds aliases for proxy functions. */ private findAliases; /** * Finds cycles in the proxy function graph and excludes those * proxy functions from replacing. */ private findCycles; /** * Searches for cycles within a branch. * @param node The current node. * @param seenNodes The set of all previously seen nodes. * @param branch The nodes in the current branch. */ private searchBranch; /** * Replaces all usages of proxy functions in a given node. * @param node The node to replace usages in. * @param startScope The scope of the node. */ private replaceProxyFunctionUsages; /** * Removes all proxy functions from a scope and its children. * @param scope The scope to remove proxy functions from. */ private removeProxyFunctions; /** * Returns whether a node is a proxy function declaration. * @param node The AST node. */ private isProxyFunctionDeclaration; /** * Returns whether a node is a proxy function expression variable * declaration. * @param node The AST node. */ private isProxyFunctionExpressionDeclaration; /** * Returns whether a node is a variable reassignment. * @param node The AST node. * @returns Whether. */ private isVariableReassignment; /** * Returns whether a node is a function call. * @param node The AST node. */ private isFunctionCall; }