mirror of
https://github.com/Wack0/IFPSTools.NET.git
synced 2025-06-18 18:55:42 -04:00
libifps: fix loading and saving op2 for InlineCmpValueType (is instruction)
libifps: document is instruction better libifps: document InlineCmpValueType better
This commit is contained in:
parent
6feeac38f7
commit
8aea82c678
@ -29,6 +29,8 @@ namespace IFPSLib.Emit
|
|||||||
|
|
||||||
private List<Operand> m_Operands = new List<Operand>();
|
private List<Operand> m_Operands = new List<Operand>();
|
||||||
|
|
||||||
|
private static readonly Operand s_opU32 = Operand.Create<uint>(0);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the operand at the specified index.
|
/// Gets or sets the operand at the specified index.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -380,6 +382,13 @@ namespace IFPSLib.Emit
|
|||||||
return FixBranchOffset(br, br.Read<uint>());
|
return FixBranchOffset(br, br.Read<uint>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Operand ReadTypeForCmpValueType(BinaryReader br, Script script, ScriptFunction function)
|
||||||
|
{
|
||||||
|
var operand = Operand.LoadValue(br, script, function);
|
||||||
|
if (operand.Type == BytecodeOperandType.Immediate) return Operand.Create(script.Types[(int)operand.ImmediateAs<uint>()]);
|
||||||
|
return operand;
|
||||||
|
}
|
||||||
|
|
||||||
internal static Instruction Load(BinaryReader br, Script script, ScriptFunction function)
|
internal static Instruction Load(BinaryReader br, Script script, ScriptFunction function)
|
||||||
{
|
{
|
||||||
var ret = new Instruction();
|
var ret = new Instruction();
|
||||||
@ -449,7 +458,7 @@ namespace IFPSLib.Emit
|
|||||||
ret.m_Operands = new List<Operand>(3) {
|
ret.m_Operands = new List<Operand>(3) {
|
||||||
Operand.LoadValue(br, script, function),
|
Operand.LoadValue(br, script, function),
|
||||||
Operand.LoadValue(br, script, function),
|
Operand.LoadValue(br, script, function),
|
||||||
Operand.Create(script.Types[(int)br.Read<uint>()])
|
ReadTypeForCmpValueType(br, script, function)
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case OperandType.InlineEH:
|
case OperandType.InlineEH:
|
||||||
@ -565,7 +574,7 @@ namespace IFPSLib.Emit
|
|||||||
ret += m_Operands[0].Size + m_Operands[1].Size + m_Operands[2].Size;
|
ret += m_Operands[0].Size + m_Operands[1].Size + m_Operands[2].Size;
|
||||||
break;
|
break;
|
||||||
case OperandType.InlineCmpValueType:
|
case OperandType.InlineCmpValueType:
|
||||||
ret += m_Operands[0].Size + m_Operands[1].Size + sizeof(int);
|
ret += m_Operands[0].Size + m_Operands[1].Size + (m_Operands[2].Type != BytecodeOperandType.Immediate ? m_Operands[2] : s_opU32).Size;
|
||||||
break;
|
break;
|
||||||
case OperandType.InlineEH:
|
case OperandType.InlineEH:
|
||||||
ret += sizeof(uint) * 4;
|
ret += sizeof(uint) * 4;
|
||||||
@ -664,7 +673,14 @@ namespace IFPSLib.Emit
|
|||||||
case OperandType.InlineCmpValueType:
|
case OperandType.InlineCmpValueType:
|
||||||
m_Operands[0].Save(bw, ctx);
|
m_Operands[0].Save(bw, ctx);
|
||||||
m_Operands[1].Save(bw, ctx);
|
m_Operands[1].Save(bw, ctx);
|
||||||
bw.Write<int>(ctx.GetTypeIndex(m_Operands[2].ImmediateAs<IType>()));
|
if (m_Operands[2].Type == BytecodeOperandType.Immediate)
|
||||||
|
{
|
||||||
|
Operand.Create((uint)ctx.GetTypeIndex(m_Operands[2].ImmediateAs<IType>())).Save(bw, ctx);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_Operands[2].Save(bw, ctx);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case OperandType.InlineEH:
|
case OperandType.InlineEH:
|
||||||
bw.Write<uint>(GetEHOffset(m_Operands[0], table));
|
bw.Write<uint>(GetEHOffset(m_Operands[0], table));
|
||||||
|
@ -186,6 +186,7 @@ namespace IFPSLib.Emit
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Operand 1 must be a <see cref="Types.ClassType"/>, operand 2 is a <see cref="Types.TypeType"/> that must be a <see cref="Types.ClassType"/>
|
/// Operand 1 must be a <see cref="Types.ClassType"/>, operand 2 is a <see cref="Types.TypeType"/> that must be a <see cref="Types.ClassType"/>
|
||||||
/// Checks if operand 1 is of the <see cref="Types.ClassType"/> referenced by operand 2.
|
/// Checks if operand 1 is of the <see cref="Types.ClassType"/> referenced by operand 2.
|
||||||
|
/// Operand 2 can also be a variable of type <see cref="UInt32"/> containing the index of the type to compare against.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly OpCode Is = new OpCode("is", Code.Is, OperandType.InlineCmpValueType, FlowControl.Next, OpCodeType.Macro);
|
public static readonly OpCode Is = new OpCode("is", Code.Is, OperandType.InlineCmpValueType, FlowControl.Next, OpCodeType.Macro);
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ namespace IFPSLib.Emit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
InlineCmpValue,
|
InlineCmpValue,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Two <see cref="InlineValue"/>s followed by <see cref="InlineType"/>
|
/// Three <see cref="InlineValue"/>s where the last is a <see cref="UInt32"/> type index
|
||||||
/// </summary>
|
/// </summary>
|
||||||
InlineCmpValueType,
|
InlineCmpValueType,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user