Skip to content

Commit 06f96ce

Browse files
committed
Resolve compile errors in HexDebugger, and replace FrameBreakpoint with another scuffed mixin
1 parent ba958e4 commit 06f96ce

File tree

8 files changed

+266
-196
lines changed

8 files changed

+266
-196
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package gay.object.hexdebug.mixin;
2+
3+
import at.petrak.hexcasting.api.spell.casting.CastingHarness;
4+
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType;
5+
import at.petrak.hexcasting.api.spell.casting.eval.FrameEvaluate;
6+
import at.petrak.hexcasting.api.spell.casting.eval.SpellContinuation;
7+
import at.petrak.hexcasting.api.spell.iota.Iota;
8+
import at.petrak.hexcasting.common.lib.hex.HexEvalSounds;
9+
import gay.object.hexdebug.casting.eval.IMixinFrameEvaluate;
10+
import kotlin.Pair;
11+
import net.minecraft.server.level.ServerLevel;
12+
import org.spongepowered.asm.mixin.Mixin;
13+
import org.spongepowered.asm.mixin.Unique;
14+
import org.spongepowered.asm.mixin.injection.At;
15+
import org.spongepowered.asm.mixin.injection.Inject;
16+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
17+
18+
import java.util.ArrayList;
19+
import java.util.List;
20+
21+
@Mixin(FrameEvaluate.class)
22+
public class MixinFrameEvaluate implements IMixinFrameEvaluate {
23+
@Unique
24+
private boolean isFrameBreakpoint$hexdebug = false;
25+
@Unique
26+
private boolean stopBefore$hexdebug = false;
27+
@Unique
28+
private boolean isFatal$hexdebug = false;
29+
30+
@Inject(method = "breakDownwards", at = @At("HEAD"), cancellable = true)
31+
private void breakDownwardsFrameBreakpoint$hexdebug(
32+
List<Iota> stack,
33+
CallbackInfoReturnable<Pair<Boolean, List<Iota>>> cir
34+
) {
35+
if (!isFrameBreakpoint$hexdebug) return;
36+
37+
cir.setReturnValue(new Pair<>(false, stack));
38+
}
39+
40+
@Inject(method = "evaluate", at = @At("HEAD"), cancellable = true)
41+
private void evaluateFrameBreakpoint$hexdebug(
42+
SpellContinuation continuation,
43+
ServerLevel level,
44+
CastingHarness harness,
45+
CallbackInfoReturnable<CastingHarness.CastResult> cir
46+
) {
47+
if (!isFrameBreakpoint$hexdebug) return;
48+
49+
cir.setReturnValue(
50+
new CastingHarness.CastResult(
51+
continuation,
52+
null,
53+
ResolvedPatternType.EVALUATED,
54+
new ArrayList<>(),
55+
HexEvalSounds.NOTHING
56+
)
57+
);
58+
}
59+
60+
@Override
61+
public boolean isFrameBreakpoint$hexdebug() {
62+
return isFrameBreakpoint$hexdebug;
63+
}
64+
65+
@Override
66+
public void setFrameBreakpoint$hexdebug(boolean isFrameBreakpoint) {
67+
isFrameBreakpoint$hexdebug = isFrameBreakpoint;
68+
}
69+
70+
@Override
71+
public boolean getStopBefore$hexdebug() {
72+
return stopBefore$hexdebug;
73+
}
74+
75+
@Override
76+
public void setStopBefore$hexdebug(boolean stopBefore) {
77+
stopBefore$hexdebug = stopBefore;
78+
}
79+
80+
@Override
81+
public boolean isFatal$hexdebug() {
82+
return isFatal$hexdebug;
83+
}
84+
85+
@Override
86+
public void setFatal$hexdebug(boolean isFatal) {
87+
isFatal$hexdebug = isFatal;
88+
}
89+
}
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
package gay.`object`.hexdebug.casting.actions
22

3-
import at.petrak.hexcasting.api.casting.castables.Action
4-
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
5-
import at.petrak.hexcasting.api.casting.eval.OperationResult
6-
import at.petrak.hexcasting.api.casting.eval.vm.CastingImage
7-
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
8-
import at.petrak.hexcasting.common.lib.hex.HexEvalSounds
9-
import gay.`object`.hexdebug.casting.eval.FrameBreakpoint
3+
import at.petrak.hexcasting.api.spell.Action
4+
import at.petrak.hexcasting.api.spell.OperationResult
5+
import at.petrak.hexcasting.api.spell.casting.CastingContext
6+
import at.petrak.hexcasting.api.spell.casting.eval.SpellContinuation
7+
import at.petrak.hexcasting.api.spell.iota.Iota
8+
import gay.`object`.hexdebug.casting.eval.newFrameBreakpoint
109

1110
data class OpBreakpoint(val stopBefore: Boolean) : Action {
1211
override fun operate(
13-
env: CastingEnvironment,
14-
image: CastingImage,
15-
continuation: SpellContinuation
12+
continuation: SpellContinuation,
13+
stack: MutableList<Iota>,
14+
ravenmind: Iota?,
15+
ctx: CastingContext
1616
): OperationResult {
17-
val newCont = continuation.pushFrame(FrameBreakpoint(stopBefore))
18-
return OperationResult(image.withUsedOp(), listOf(), newCont, HexEvalSounds.NORMAL_EXECUTE)
17+
val newCont = continuation.pushFrame(newFrameBreakpoint(stopBefore))
18+
return OperationResult(newCont, stack, ravenmind, listOf())
1919
}
2020
}

Common/src/main/kotlin/gay/object/hexdebug/casting/eval/DebugItemCastEnv.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package gay.`object`.hexdebug.casting.eval
22

3-
import at.petrak.hexcasting.api.casting.castables.Action
4-
import at.petrak.hexcasting.api.casting.eval.env.PackagedItemCastEnv
5-
import at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect
63
import gay.`object`.hexdebug.debugger.DebugStepType
74
import net.minecraft.network.chat.Component
85
import net.minecraft.server.level.ServerPlayer
Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,29 @@
1-
package gay.`object`.hexdebug.casting.eval
2-
3-
import at.petrak.hexcasting.api.casting.eval.CastResult
4-
import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType
5-
import at.petrak.hexcasting.api.casting.eval.vm.CastingVM
6-
import at.petrak.hexcasting.api.casting.eval.vm.ContinuationFrame
7-
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
8-
import at.petrak.hexcasting.api.casting.iota.Iota
9-
import at.petrak.hexcasting.api.casting.iota.NullIota
10-
import at.petrak.hexcasting.api.utils.NBTBuilder
11-
import at.petrak.hexcasting.common.lib.hex.HexEvalSounds
12-
import net.minecraft.nbt.CompoundTag
13-
import net.minecraft.server.level.ServerLevel
14-
15-
data class FrameBreakpoint(val stopBefore: Boolean, val isFatal: Boolean = false) : ContinuationFrame {
16-
override fun breakDownwards(stack: List<Iota>) = false to stack
17-
18-
override fun evaluate(continuation: SpellContinuation, level: ServerLevel, harness: CastingVM) = CastResult(
19-
NullIota(),
20-
continuation,
21-
null,
22-
listOf(),
23-
ResolvedPatternType.EVALUATED,
24-
HexEvalSounds.NOTHING,
25-
)
1+
@file:Suppress("CAST_NEVER_SUCCEEDS")
262

27-
override fun size() = 0
3+
package gay.`object`.hexdebug.casting.eval
284

29-
override val type = TYPE
5+
import at.petrak.hexcasting.api.spell.SpellList
6+
import at.petrak.hexcasting.api.spell.casting.eval.FrameEvaluate
307

31-
override fun serializeToNBT() = NBTBuilder {
32-
"stopBefore" %= stopBefore
33-
"isFatal" %= isFatal
34-
}
8+
// ContinuationFrame is sealed in this version, so we need to smuggle data on a FrameEvaluate instead
9+
@Suppress("PropertyName")
10+
interface IMixinFrameEvaluate {
11+
var `isFrameBreakpoint$hexdebug`: Boolean
12+
var `stopBefore$hexdebug`: Boolean
13+
var `isFatal$hexdebug`: Boolean
14+
}
3515

36-
companion object {
37-
@JvmField
38-
val TYPE = object : ContinuationFrame.Type<FrameBreakpoint> {
39-
override fun deserializeFromNBT(tag: CompoundTag, world: ServerLevel) = FrameBreakpoint(
40-
tag.getBoolean("stopBefore"),
41-
tag.getBoolean("isFatal"),
42-
)
43-
}
16+
fun newFrameBreakpointFatal() = newFrameBreakpoint(stopBefore = true, isFatal = true)
4417

45-
fun fatal() = FrameBreakpoint(stopBefore = true, isFatal = true)
18+
fun newFrameBreakpoint(stopBefore: Boolean, isFatal: Boolean = false): FrameEvaluate {
19+
return FrameEvaluate(SpellList.LList(listOf()), false).also {
20+
it as IMixinFrameEvaluate
21+
it.`isFrameBreakpoint$hexdebug` = true
22+
it.`stopBefore$hexdebug` = stopBefore
23+
it.`isFatal$hexdebug` = isFatal
4624
}
4725
}
26+
27+
val FrameEvaluate.isFrameBreakpoint get() = (this as IMixinFrameEvaluate).`isFrameBreakpoint$hexdebug`
28+
val FrameEvaluate.stopBefore get() = (this as IMixinFrameEvaluate).`stopBefore$hexdebug`
29+
val FrameEvaluate.isFatal get() = (this as IMixinFrameEvaluate).`isFatal$hexdebug`

Common/src/main/kotlin/gay/object/hexdebug/casting/eval/IDebugCastEnv.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package gay.`object`.hexdebug.casting.eval
22

3-
import at.petrak.hexcasting.api.casting.castables.Action
3+
import at.petrak.hexcasting.api.spell.Action
44
import gay.`object`.hexdebug.adapter.DebugAdapterManager
55
import gay.`object`.hexdebug.debugger.DebugStepType
66
import net.minecraft.network.chat.Component

0 commit comments

Comments
 (0)