@@ -10,6 +10,7 @@ import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation.NotDone
1010import at.petrak.hexcasting.api.casting.iota.*
1111import at.petrak.hexcasting.api.casting.mishaps.Mishap
1212import at.petrak.hexcasting.api.casting.mishaps.MishapInternalException
13+ import at.petrak.hexcasting.api.casting.mishaps.MishapStackSize
1314import at.petrak.hexcasting.common.casting.actions.eval.OpEval
1415import at.petrak.hexcasting.common.lib.hex.HexEvalSounds
1516import gay.`object`.hexdebug.adapter.LaunchArgs
@@ -486,7 +487,9 @@ class HexDebugger(
486487
487488 fun executeOnce () = executeNextDebugStep(getVM())
488489
489- // Copy of CastingVM.queueExecuteAndWrapIotas to allow stepping by one pattern at a time.
490+ /* *
491+ * Copy of [CastingVM.queueExecuteAndWrapIotas] to allow stepping by one pattern at a time.
492+ */
490493 private fun executeNextDebugStep (
491494 vm : CastingVM ,
492495 exactlyOnce : Boolean = false,
@@ -514,7 +517,20 @@ class HexDebugger(
514517 }
515518
516519 // ...and execute it.
517- val castResult = frame.evaluate(continuation.next, world, vm)
520+ val castResult = frame.evaluate(continuation.next, world, vm).let { result ->
521+ // if stack is unable to be serialized, have the result be an error
522+ val newData = result.newData
523+ if (newData != null && IotaType .isTooLargeToSerialize(newData.stack)) {
524+ result.copy(
525+ newData = null ,
526+ sideEffects = listOf (OperatorSideEffect .DoMishap (MishapStackSize (), Mishap .Context (null , null ))),
527+ resolutionType = ResolvedPatternType .ERRORED ,
528+ sound = HexEvalSounds .MISHAP ,
529+ )
530+ } else {
531+ result
532+ }
533+ }
518534
519535 val newImage = castResult.newData
520536
0 commit comments