Skip to content

Commit

Permalink
Rename MakeInvalid to Invalidate
Browse files Browse the repository at this point in the history
  • Loading branch information
ds5678 authored and SamboyCoding committed Jun 19, 2024
1 parent 82e36b7 commit b6094e0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion Cpp2IL.Core/ISIL/InstructionSetIndependentInstruction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ public InstructionSetIndependentInstruction(InstructionSetIndependentOpCode opCo

public override string ToString() => $"{InstructionIndex:000} {OpCode} {string.Join(", ", (IEnumerable<InstructionSetIndependentOperand>) Operands)}";

public void MakeInvalid(string reason)
/// <summary>
/// Marks the instruction as <see cref="IsilMnemonic.Invalid"/>.
/// </summary>
/// <param name="reason">The reason that this instruction is being invalidated.</param>
public void Invalidate(string reason)
{
OpCode = InstructionSetIndependentOpCode.Invalid;
Operands = [InstructionSetIndependentOperand.MakeImmediate(reason)];
Expand Down
4 changes: 2 additions & 2 deletions Cpp2IL.Core/ISIL/InstructionSetIndependentOpCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void Validate(InstructionSetIndependentInstruction instruction)

if (operands.Length > MaxOperands)
{
instruction.MakeInvalid($"Too many operands! We have {operands.Length} but we only allow {MaxOperands}");
instruction.Invalidate($"Too many operands! We have {operands.Length} but we only allow {MaxOperands}");
return;
}

Expand All @@ -90,7 +90,7 @@ public void Validate(InstructionSetIndependentInstruction instruction)
{
if ((operands[i].Type & PermittedOperandTypes[i]) == 0)
{
instruction.MakeInvalid($"Operand {operands[i]} at index {i} (0-based) is of type {operands[i].Type}, which is not permitted for this index of a {Mnemonic} instruction");
instruction.Invalidate($"Operand {operands[i]} at index {i} (0-based) is of type {operands[i].Type}, which is not permitted for this index of a {Mnemonic} instruction");
return;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Cpp2IL.Core/ISIL/IsilBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public void FixJumps()
var target = list.First();

if (target.Equals(tuple.Item1))
tuple.Item1.MakeInvalid("Invalid jump target for instruction: Instruction can't jump to itself");
tuple.Item1.Invalidate("Invalid jump target for instruction: Instruction can't jump to itself");
else
tuple.Item1.Operands = [InstructionSetIndependentOperand.MakeInstruction(target)];
}
else
{
tuple.Item1.MakeInvalid("Jump target not found in method.");
tuple.Item1.Invalidate("Jump target not found in method.");
}
}
}
Expand Down

0 comments on commit b6094e0

Please sign in to comment.