import { applyInstructionForArgInference } from "./entry-stack-effects.js";
import { createEntryStackState } from "./entry-stack-state.js";
export function inferRequiredEntryStackDepth(instructions) {
const state = createEntryStackState();
let sawSupportedOpcode = false;
for (const instruction of instructions) {
if (instruction.opcode.mnemonic === "RET") {
break;
}
if (!applyInstructionForArgInference(instruction, state)) {
return 0;
}
sawSupportedOpcode = true;
}
return sawSupportedOpcode ? state.required : 0;
}