Skip to content

Commit

Permalink
fix: TeaVM analyzer bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zlataovce committed Aug 20, 2024
1 parent 1502dfa commit 5aa4538
Showing 1 changed file with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,45 @@ public Instruction create(Clazz clazz, CodeAttribute codeAttribute, int index) {
instructionSequenceMatcher.matchedInstructionOffset(matchedInstructionIndex);

// Create the instruction.
replacementInstructions[index].accept(
clazz, null, codeAttribute, matchedInstructionOffset, this);
Instruction insn = replacementInstructions[index]/*.accept(clazz, null, codeAttribute, matchedInstructionOffset, this)*/;

// fix TeaVM analyzer bug, we can't have nice things
if (insn instanceof SimpleInstruction) {
this.visitSimpleInstruction(clazz, null, codeAttribute, matchedInstructionOffset, (SimpleInstruction) insn);
} else if (insn instanceof VariableInstruction) {
this.visitVariableInstruction(clazz, null, codeAttribute, matchedInstructionOffset, (VariableInstruction) insn);
} else if (insn instanceof ConstantInstruction) {
this.visitConstantInstruction(clazz, null, codeAttribute, matchedInstructionOffset, (ConstantInstruction) insn);
} else if (insn instanceof BranchInstruction) {
this.visitBranchInstruction(clazz, null, codeAttribute, matchedInstructionOffset, (BranchInstruction) insn);
} else if (insn instanceof TableSwitchInstruction) {
this.visitTableSwitchInstruction(clazz, null, codeAttribute, matchedInstructionOffset, (TableSwitchInstruction) insn);
} else if (insn instanceof LookUpSwitchInstruction) {
this.visitLookUpSwitchInstruction(clazz, null, codeAttribute, matchedInstructionOffset, (LookUpSwitchInstruction) insn);
} else if (insn instanceof Catch) {
this.visitCatchInstruction(clazz, null, codeAttribute, matchedInstructionOffset, (Catch) insn);
} else if (insn instanceof Label) {
this.visitLabelInstruction(clazz, null, codeAttribute, matchedInstructionOffset, (Label) insn);
} else {
this.visitAnyInstruction(clazz, null, codeAttribute, matchedInstructionOffset, insn);
}

// Return it.
return replacementInstruction;
}

@SuppressWarnings("DataFlowIssue")
private void teaVMFix0() {
this.visitSimpleInstruction(null, null, null, 0, null);
this.visitVariableInstruction(null, null, null, 0, null);
this.visitConstantInstruction(null, null, null, 0, null);
this.visitBranchInstruction(null, null, null, 0, null);
this.visitTableSwitchInstruction(null, null, null, 0, null);
this.visitLookUpSwitchInstruction(null, null, null, 0, null);
this.visitLabelInstruction(null, null, null, 0, null);
this.visitCatchInstruction(null, null, null, 0, null);
}

// Implementations for InstructionVisitor.

@Override
Expand Down

0 comments on commit 5aa4538

Please sign in to comment.