From 2cfb0a4c47c6db2e1c450d43c906c5b532cd5f27 Mon Sep 17 00:00:00 2001 From: object-Object Date: Mon, 22 Apr 2024 11:49:18 -0400 Subject: [PATCH 1/2] Avoid changing the paren count for regular patterns when using Evanition (fix #623) --- .../java/at/petrak/hexcasting/api/casting/eval/vm/CastingVM.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/CastingVM.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/CastingVM.kt index 04c34d774..8cbd8d51e 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/CastingVM.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/CastingVM.kt @@ -188,7 +188,7 @@ class CastingVM(var image: CastingImage, val env: CastingEnvironment) { val newParenCount = this.image.parenCount + if (last == null || last.escaped || last.iota !is PatternIota) 0 else when (last.iota.pattern) { SpecialPatterns.INTROSPECTION -> -1 SpecialPatterns.RETROSPECTION -> 1 - else -> -1 + else -> 0 } this.image.copy(parenthesized = newParens, parenCount = newParenCount) to if (last == null) ResolvedPatternType.ERRORED else ResolvedPatternType.UNDONE } From 838b6eebef050a4c78828e71cb4be3ab33a6e67f Mon Sep 17 00:00:00 2001 From: object-Object Date: Mon, 22 Apr 2024 12:03:10 -0400 Subject: [PATCH 2/2] Fix consideration/introspection carrying over to subsequent Thoth iterations and out of the Thoth --- .../at/petrak/hexcasting/api/casting/eval/vm/CastingImage.kt | 5 +++++ .../at/petrak/hexcasting/api/casting/eval/vm/FrameForEach.kt | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/CastingImage.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/CastingImage.kt index d04b1c29c..3ffd771bc 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/CastingImage.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/CastingImage.kt @@ -67,6 +67,11 @@ data class CastingImage private constructor( */ fun withOverriddenUsedOps(count: Long) = this.copy(opsConsumed = count) + /** + * Returns a copy of this with escape/paren-related fields cleared. + */ + fun withResetEscape() = this.copy(parenCount = 0, parenthesized = listOf(), escapeNext = false) + fun serializeToNbt() = NBTBuilder { TAG_STACK %= stack.serializeToNBT() diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/FrameForEach.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/FrameForEach.kt index ec587cb78..0221c1f36 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/FrameForEach.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/vm/FrameForEach.kt @@ -73,7 +73,8 @@ data class FrameForEach( return CastResult( ListIota(code), newCont, - newImage.copy(stack = tStack), + // reset escapes so they don't carry over to other iterations or out of thoth + newImage.withResetEscape().copy(stack = tStack), listOf(), ResolvedPatternType.EVALUATED, HexEvalSounds.THOTH,