// Licensing scope: see ../../LICENSE and this directory's LICENSE and NOTICE.
// Potentially incorporated Binaryen expression retains Apache-2.0 terms.
// Original Starshine contributions use the scoped MIT grant in ../../LICENSE.
// Modified for Starshine through 2026: implementation and validation use
// Starshine's representations and APIs; this is not an unchanged upstream file.
// Conservative notice retention does not establish copying or independence.

///|
priv struct SimplifyLocalsEffectScanWorkspace {
  marks : Array[Int32]
  mut epoch : Int32
}

///|
fn SimplifyLocalsEffectScanWorkspace::new() -> SimplifyLocalsEffectScanWorkspace {
  { marks: [], epoch: 0, }
}

///|
// Each query gets a new epoch; only visitation storage is shared. No effect
// fact survives a query, so replacements, detached nodes and region edits are
// observed immediately without a revision cache.
fn SimplifyLocalsEffectScanWorkspace::begin(
  self : SimplifyLocalsEffectScanWorkspace,
  func : @ir.HotFunc,
) -> Array[Int32] {
  let nodes = @ir.hot_node_count(func)
  while self.marks.length() < nodes {
    self.marks.push(0)
  }
  if self.epoch >= 0x3fffffff {
    for index in 0..