/** * Represents a single slot in the symbolic EVM stack. * Tracks not just the raw value, but what it represents semantically. */ export type SymbolicStackSlot = { /** What this stack slot represents */ kind: 'variable' | 'parameter' | 'intermediate' | 'return_value' | 'unknown'; /** If this is a variable/parameter, reference to its AST node */ variableId?: number; /** Human-readable name of the variable/parameter */ variableName?: string; /** Type information for the variable */ variableType?: any; /** VM trace step where this value was produced */ originStep?: number; /** Opcode that produced this value */ originOp?: string; /** Array indices in the symbolic stack that this value was derived from (for operations like ADD, DUP) */ derivedFrom?: number[]; /** Whether this is a function parameter */ isParameter?: boolean; /** Whether this is a return parameter */ isReturnParameter?: boolean; /** Variable lifecycle state */ lifecycle?: 'registered' | 'declared' | 'assigned' | 'destroyed'; /** If this slot is a reference/copy of a variable (from DUP), contains original variable info */ referencesVariable?: { variableId?: number; variableName?: string; variableType?: any; sourceStackIndex: number; }; /** Variable Scope */ variableScope?: number; /** Function scope ID where this variable belongs */ functionScopeId?: string; }; /** * Manages the symbolic stack throughout execution. * Maps each VM trace step to its symbolic stack state. */ export declare class SymbolicStackManager { /** Map of VM trace step to symbolic stack state at that step */ private stackPerStep; /** Map of variable ID to its current stack position and lifecycle */ private variableLifecycle; /** * Initializes the symbolic stack manager */ constructor(); /** * Resets the symbolic stack manager to initial state */ reset(): void; /** * Gets the symbolic stack at a specific step * * @param step - VM trace step index * @returns Symbolic stack at that step, or empty array if not found */ getStackAtStep(step: number): SymbolicStackSlot[]; /** * Sets the symbolic stack for a specific step * * @param step - VM trace step index * @param stack - Symbolic stack state */ setStackAtStep(step: number, stack: SymbolicStackSlot[]): void; /** * Gets the previous step's symbolic stack * * @param step - Current VM trace step index * @returns Symbolic stack from previous step, or empty array if no previous step */ getPreviousStack(step: number): SymbolicStackSlot[]; /** * Binds a variable to a specific position in the symbolic stack with lifecycle tracking * * @param step - VM trace step where variable is declared/assigned * @param variable - Variable metadata (name, type, stackIndex, etc.) * @param stackIndex - Index in the symbolic stack where the variable should be bound * @param lifecycle - Variable lifecycle state * @param functionScopeId - Function scope ID where this variable belongs */ bindVariableWithLifecycle(step: number, variable: any, stackIndex: number, lifecycle?: 'registered' | 'declared' | 'assigned' | 'destroyed', functionScopeId?: string): void; /** * Legacy method for backward compatibility */ bindVariable(step: number, variable: any, stackIndex: number): void; /** * Finds which variable (if any) occupies a given stack position at a given step * * @param step - VM trace step index * @param stackPosition - Position in the stack (0 = bottom, length-1 = top) * @returns Variable information if found, null otherwise */ findVariableAtPosition(step: number, stackPosition: number): SymbolicStackSlot | null; /** * Gets all variables currently on the stack at a given step * * @param step - VM trace step index * @returns Array of variables and their stack positions */ getAllVariablesAtStep(step: number): Array<{ slot: SymbolicStackSlot; position: number; }>; /** * Gets all variables in a specific function scope * * @param step - VM trace step index * @param functionScopeId - Function scope ID * @returns Array of variables in the specified function scope */ getVariablesInFunctionScope(step: number, functionScopeId: string): Array<{ slot: SymbolicStackSlot; position: number; }>; /** * Gets variable lifecycle information * * @param variableId - Variable AST node ID * @returns Lifecycle information or null if not found */ getVariableLifecycle(variableId: number): { step: number; stackIndex: number; lifecycle: string; variable: any; functionScopeId: string; }; /** * Updates variable lifecycle state * * @param step - Current VM trace step * @param variableId - Variable AST node ID * @param newLifecycle - New lifecycle state */ updateVariableLifecycle(step: number, variableId: number, newLifecycle: 'declared' | 'assigned' | 'destroyed'): void; checkRegisteredVariables(step: number, currentStackLength: number): void; /** * Exports the complete stack state for debugging or serialization * * @returns Complete map of step to symbolic stack */ exportStackState(): { [step: number]: SymbolicStackSlot[]; }; }