refreshTerms ::
  SharedContext {- ^ shared context -} ->
  StateSpec     {- ^ current phase spec -} ->
  OverrideMatcher CJ.JVM w ()
refreshTerms sc ss =
  do extension <- Map.fromList <$> traverse freshenTerm (view MS.csFreshVars ss)
     OM (termSub %= Map.union extension)
  where
    freshenTerm (TypedExtCns _cty ec) =
      do ec' <- liftIO $ scFreshEC sc (toShortName (ecName ec)) (ecType ec)
         new <- liftIO $ scExtCns sc ec'
         return (ecVarIndex ec, new)

------------------------------------------------------------------------

-- | Generate assertions that all of the memory allocations matched by
-- an override's precondition are disjoint.
refreshTerms ::
  SharedContext {- ^ shared context -} ->
  StateSpec     {- ^ current phase spec -} ->
  OverrideMatcher CJ.JVM w ()
refreshTerms sc ss =
  do extension <- Map.fromList <$> traverse freshenTerm (view MS.csFreshVars ss)
     OM (termSub %= Map.union extension)
  where
    freshenTerm (TypedExtCns _cty ec) =
      do ec' <- liftIO $ scFreshEC sc (toShortName (ecName ec)) (ecType ec)
         new <- liftIO $ scExtCns sc ec'
         return (ecVarIndex ec, new)

------------------------------------------------------------------------

-- | Generate assertions that all of the memory allocations matched by
-- an override's precondition are disjoint.
refreshTerms sc ss =
  do extension <- Map.fromList <$> traverse freshenTerm (view MS.csFreshVars ss)
     OM (termSub %= Map.union extension)
  where
    freshenTerm (TypedExtCns _cty ec) =
      do ec' <- liftIO $ scFreshEC sc (toShortName (ecName ec)) (ecType ec)
         new <- liftIO $ scExtCns sc ec'
         return (ecVarIndex ec, new)

------------------------------------------------------------------------

-- | Generate assertions that all of the memory allocations matched by
-- an override's precondition are disjoint.