executeAllocation ::
  Options                        ->
  JVMCrucibleContext                ->
  (AllocIndex, (W4.ProgramLoc, Allocation)) ->
  OverrideMatcher CJ.JVM w ()
executeAllocation opts cc (var, (loc, alloc)) =
  jccWithBackend cc $ \bak ->
  do liftIO $ printOutLn opts Debug $ unwords ["executeAllocation:", show var, show alloc]
     let jc = cc^.jccJVMContext
     let halloc = cc^.jccHandleAllocator
     globals <- OM (use overrideGlobals)
     let mut = True -- allocate objects/arrays from post-state as mutable
     (ptr, globals') <-
       case alloc of
         AllocObject cname ->
           liftIO $ CJ.doAllocateObject bak halloc jc cname (const mut) globals
         AllocArray len elemTy ->
           liftIO $ CJ.doAllocateArray bak halloc jc len elemTy (const mut) globals
     OM (overrideGlobals .= globals')
     assignVar cc loc var ptr

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

-- | Update the simulator state based on the postconditions from the
-- procedure specification.
executeAllocation ::
  Options                        ->
  JVMCrucibleContext                ->
  (AllocIndex, (W4.ProgramLoc, Allocation)) ->
  OverrideMatcher CJ.JVM w ()
executeAllocation opts cc (var, (loc, alloc)) =
  jccWithBackend cc $ \bak ->
  do liftIO $ printOutLn opts Debug $ unwords ["executeAllocation:", show var, show alloc]
     let jc = cc^.jccJVMContext
     let halloc = cc^.jccHandleAllocator
     globals <- OM (use overrideGlobals)
     let mut = True -- allocate objects/arrays from post-state as mutable
     (ptr, globals') <-
       case alloc of
         AllocObject cname ->
           liftIO $ CJ.doAllocateObject bak halloc jc cname (const mut) globals
         AllocArray len elemTy ->
           liftIO $ CJ.doAllocateArray bak halloc jc len elemTy (const mut) globals
     OM (overrideGlobals .= globals')
     assignVar cc loc var ptr

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

-- | Update the simulator state based on the postconditions from the
-- procedure specification.
executeAllocation opts cc (var, (loc, alloc)) =
  jccWithBackend cc $ \bak ->
  do liftIO $ printOutLn opts Debug $ unwords ["executeAllocation:", show var, show alloc]
     let jc = cc^.jccJVMContext
     let halloc = cc^.jccHandleAllocator
     globals <- OM (use overrideGlobals)
     let mut = True -- allocate objects/arrays from post-state as mutable
     (ptr, globals') <-
       case alloc of
         AllocObject cname ->
           liftIO $ CJ.doAllocateObject bak halloc jc cname (const mut) globals
         AllocArray len elemTy ->
           liftIO $ CJ.doAllocateArray bak halloc jc len elemTy (const mut) globals
     OM (overrideGlobals .= globals')
     assignVar cc loc var ptr

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

-- | Update the simulator state based on the postconditions from the
-- procedure specification.