Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #672 - Invalid-inputs mishap from Thoth reads the stack backwards #723

Merged
merged 8 commits into from
Aug 21, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package at.petrak.hexcasting.common.casting.actions.eval

import at.petrak.hexcasting.api.casting.SpellList
import at.petrak.hexcasting.api.casting.castables.Action
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.eval.OperationResult
import at.petrak.hexcasting.api.casting.eval.vm.CastingImage
import at.petrak.hexcasting.api.casting.eval.vm.FrameForEach
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.getList
import at.petrak.hexcasting.api.casting.iota.Iota
navarchus marked this conversation as resolved.
Show resolved Hide resolved
import at.petrak.hexcasting.api.casting.mishaps.MishapInvalidIota
navarchus marked this conversation as resolved.
Show resolved Hide resolved
import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs
import at.petrak.hexcasting.common.lib.hex.HexEvalSounds

Expand All @@ -17,14 +20,15 @@ object OpForEach : Action {
if (stack.size < 2)
throw MishapNotEnoughArgs(2, stack.size)

val instrs = stack.getList(stack.lastIndex - 1)
val datums = stack.getList(stack.lastIndex)

val instrs = stack.getList(stack.lastIndex - 1, stack.size)
val datums = stack.getList(stack.lastIndex, stack.size)

stack.removeLastOrNull()
stack.removeLastOrNull()

val frame = FrameForEach(datums, instrs, null, mutableListOf())
val image2 = image.withUsedOp().copy(stack = stack)

navarchus marked this conversation as resolved.
Show resolved Hide resolved
return OperationResult(image2, listOf(), continuation.pushFrame(frame), HexEvalSounds.THOTH)
}
}
Loading