UNPKG

@akala/core

Version:
28 lines (27 loc) 1.3 kB
import type { Expressions, StrictExpressions, StrictTypedExpression, TypedExpression } from "../expression.js"; import { ExpressionVisitor } from "./expression-visitor.js"; import type { IVisitable } from "../visitable.js"; /** * Replaces occurrences of a specific expression with another during traversal. * This visitor updates an expression tree by substituting the original expression with the new one. */ export declare class ExpressionUpdater extends ExpressionVisitor { private original; private newExp; /** * Creates an instance of ExpressionUpdater. * @param original - The expression to be replaced in the tree. * @param newExp - The new expression that replaces the original. */ constructor(original: Expressions, newExp: Expressions); private rootCall; /** * Performs the expression replacement during traversal. * @param expression - The current expression being visited. * @returns The updated expression after potential substitution. */ visit<T>(expression: StrictTypedExpression<T>): StrictTypedExpression<T>; visit<T>(expression: TypedExpression<T>): TypedExpression<T>; visit(expression: StrictExpressions): StrictExpressions; visit(expression: IVisitable<ExpressionVisitor, any>): Expressions; }