Skip to content

Commit

Permalink
Update MixinExtras, fixes compound instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Earthcomputer committed Apr 14, 2024
1 parent 87841dc commit d93dd13
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ dependencies {
implementation(files(Jvm.current().toolsJar))

// TODO: temporary waiting for MixinExtras expression library
testLibs(implementation("com.github.LlamaLad7.MixinExtras:mixinextras-common:290f3d8")!!)
testLibs(implementation("com.github.LlamaLad7.MixinExtras:mixinextras-common:86c9835")!!)
implementation("org.spongepowered:mixin:0.8.4")
implementation("org.ow2.asm:asm-util:9.3")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,16 +660,6 @@ object MEExpressionCompletionUtil {
}
}

private fun getFlowInputs(flow: FlowValue): List<FlowValue> {
var rootFlow = flow
val insn = flow.virtualInsnOrNull ?: return emptyList()
if (insn.insn.opcode == Opcodes.NEW) {
rootFlow = flow.getDecoration<InstantiationInfo>(Decorations.INSTANTIATION_INFO)?.initCall ?: rootFlow
}

return (0 until rootFlow.inputCount()).map(rootFlow::getInput)
}

private fun getInstructionsInFlowTree(
flow: FlowValue,
outInstructions: MutableSet<ExpandedInstruction>,
Expand All @@ -680,14 +670,13 @@ object MEExpressionCompletionUtil {
}

if (!strict) {
val originalInsn =
flow.getDecoration<InsnExpander.Expansion>(Decorations.EXPANSION_INFO)?.compound ?: flow.insn
val originalInsn = InsnExpander.getRepresentative(flow) ?: flow.insn
if (!outInstructions.add(ExpandedInstruction(flow.virtualInsn, originalInsn))) {
return
}
}
for (input in getFlowInputs(flow)) {
getInstructionsInFlowTree(input, outInstructions, false)
for (i in 0 until flow.inputCount()) {
getInstructionsInFlowTree(flow.getInput(i), outInstructions, false)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import com.llamalad7.mixinextras.expression.impl.flow.expansion.InsnExpander
import com.llamalad7.mixinextras.expression.impl.point.ExpressionContext
import com.llamalad7.mixinextras.expression.impl.pool.IdentifierPool
import com.llamalad7.mixinextras.expression.impl.pool.MemberDefinition
import com.llamalad7.mixinextras.utils.Decorations
import org.objectweb.asm.Handle
import org.objectweb.asm.Opcodes
import org.objectweb.asm.Type
Expand Down Expand Up @@ -146,7 +145,7 @@ object MEExpressionMatchUtil {
return@cached null
}

interpreter.finish().mapKeys { (insn, _) -> VirtualInsn(insn) }
interpreter.finish().asSequence().mapNotNull { flow -> flow.virtualInsnOrNull?.let { it to flow } }.toMap()
}
}

Expand Down Expand Up @@ -279,9 +278,7 @@ object MEExpressionMatchUtil {
if (expr.matches(flow, context)) {
for ((capturedFlow, startOffset) in captured) {
val capturedInsn = capturedFlow.virtualInsnOrNull ?: continue
val originalInsn =
capturedFlow.getDecoration<InsnExpander.Expansion>(Decorations.EXPANSION_INFO)?.compound
?: capturedInsn.insn
val originalInsn = InsnExpander.getRepresentative(capturedFlow) ?: capturedInsn.insn
callback(ExpressionMatch(flow, originalInsn, startOffset, decorations[capturedInsn].orEmpty()))
}
}
Expand Down

0 comments on commit d93dd13

Please sign in to comment.