import Modification from '../../modification'; import * as Shift from 'shift-ast'; export default class ExpressionSimplifier extends Modification { private readonly types; private static readonly RESOLVABLE_UNARY_OPERATORS; private static readonly RESOLVABLE_BINARY_OPERATORS; /** * Creates a new modification. * @param ast The AST. */ constructor(ast: Shift.Script | Shift.Module); /** * Executes the modification. */ execute(): void; /** * Simplifies all binary and unary expressions. */ private simplifyExpressions; /** * Attempts to simplify an expression node. * @param expression The expression node. */ private simplifyExpression; /** * Attempts to simplify a unary expression node. * @param expression The unary expression node. */ private simplifyUnaryExpression; /** * Attempts to simplify a binary expression node. * @param expression The binary expression node. */ private simplifyBinaryExpression; /** * Applies a unary operation. * @param operator The operator. * @param argument The argument value. * @returns The resultant value. */ private applyUnaryOperation; /** * Applies a binary operation. * @param operator The resolvable binary operator. * @param left The value of the left expression. * @param right The value of the right expression. * @returns The resultant value. */ private applyBinaryOperation; /** * Gets the real value from a resolvable expression. * @param expression The resolvable expression. * @returns The value. */ private getResolvableExpressionValue; /** * Attempts to convert a value of unknown type to an expression node. * @param value The value. * @returns The expression or undefined. */ private convertValueToExpression; /** * Returns whether a node is a resolvable expression that can be * evaluated safely. * @param node The AST node. * @returns Whether. */ private isResolvableExpression; /** * Returns whether a node is a literal. * @param node The AST node. * @returns Whether. */ private isLiteral; }