/**
 * ConstantPropagationPass
 *
 * Runs constant propagation + dead-code detection over the AST.
 *
 * Depends on: taint-matcher (to extract inter-procedural tainted parameters
 * before propagation, so method-parameter taint is seeded correctly).
 *
 * Receives the parsed Tree via constructor because it needs the raw AST for
 * node-level analysis — the CodeGraph contains only extracted IR.
 */
import { analyzeConstantPropagation } from '../constant-propagation.js';
export class ConstantPropagationPass {
    tree;
    name = 'constant-propagation';
    category = 'security';
    constructor(tree) {
        this.tree = tree;
    }
    run(ctx) {
        const { code } = ctx;
        const taintMatcher = ctx.getResult('taint-matcher');
        // Extract inter-procedural parameter sources from the preliminary taint results.
        // These seeds ensure that method parameters receiving tainted data are tracked.
        const taintedParameters = [];
        for (const source of taintMatcher.sources) {
            if (source.type === 'interprocedural_param') {
                // Location format: "ParamType paramName in methodName"
                const match = source.location.match(/(\S+)\s+(\S+)\s+in\s+(\S+)/);
                if (match) {
                    taintedParameters.push({
                        methodName: match[3],
                        paramName: match[2],
                    });
                }
            }
        }
        return analyzeConstantPropagation(this.tree, code, {
            sanitizerMethods: taintMatcher.sanitizerMethods,
            taintedParameters,
        });
    }
}
//# sourceMappingURL=constant-propagation-pass.js.map