import Modification from '../../modification'; import * as Shift from 'shift-ast'; export default class ArrayUnpacker extends Modification { private readonly scopeTypes; private readonly shouldRemoveArrays; private readonly globalScope; private readonly arrayNodes; /** * Creates a new modification. * @param ast The AST. * @param shouldRemoveArrays Whether the arrays should be removed. */ constructor(ast: Shift.Script | Shift.Module, removeArrays: boolean); /** * Executes the modification. */ execute(): void; /** * Finds all literal arrays and stores them in the according scope. * @returns Whether any new literal arrays were found. */ private findArrays; /** * Replaces all usages of literal arrays. */ private unpackArrays; /** * Removes all the (suitable) arrays in a scope and its children. * @param scope The scope to remove arrays from. */ private removeArrays; /** * Returns whether a node is a literal array declaration. * @param node The AST node. */ private isLiteralArrayDeclaration; /** * Returns whether a node is accessing an index of an array. * @param node The AST node. */ private isSimpleArrayAccess; }