mirror of
https://github.com/ZuneDev/MicrosoftIris.git
synced 2026-07-27 13:13:29 -07:00
Split generic instruction info into separate class
This commit is contained in:
@@ -10,25 +10,19 @@ public class InterpreterEntry : IComparable<InterpreterEntry>
|
||||
{
|
||||
public InterpreterEntry() { }
|
||||
|
||||
public InterpreterEntry(OpCode opCode, uint offset, string loadUri)
|
||||
public InterpreterEntry(InterpreterInstruction instruction)
|
||||
{
|
||||
OpCode = opCode;
|
||||
Offset = offset;
|
||||
LoadUri = loadUri;
|
||||
Instruction = instruction;
|
||||
}
|
||||
|
||||
public OpCode OpCode { get; set; }
|
||||
|
||||
public uint Offset { get; set; }
|
||||
|
||||
public string LoadUri { get; set; }
|
||||
|
||||
public string InstructionString => ToInstructionString();
|
||||
public InterpreterInstruction Instruction { get; }
|
||||
|
||||
public List<InterpreterObject> Parameters { get; } = new();
|
||||
|
||||
public List<InterpreterObject> ReturnValues { get; } = new();
|
||||
|
||||
public string InstructionString => ToInstructionString();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new($"[{LoadUri} @ 0x{Offset:X}] {OpCode}({string.Join(", ", Parameters)})");
|
||||
@@ -49,9 +43,9 @@ public class InterpreterEntry : IComparable<InterpreterEntry>
|
||||
public string ToInstructionString()
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
sb.AppendFormat("0x{0:X4}", Offset);
|
||||
sb.AppendFormat("0x{0:X4}", Instruction.Offset);
|
||||
sb.Append('\t');
|
||||
sb.Append(OpCode);
|
||||
sb.Append(Instruction.OpCode);
|
||||
sb.Append(' ', 2);
|
||||
|
||||
for (int p = 0; p < Parameters.Count; ++p)
|
||||
@@ -61,27 +55,11 @@ public class InterpreterEntry : IComparable<InterpreterEntry>
|
||||
if (p != 0)
|
||||
sb.Append(", ");
|
||||
|
||||
if (param.Source == InstructionObjectSource.Inline)
|
||||
sb.Append(param.Value ?? "NULL");
|
||||
else
|
||||
sb.Append(param.Source);
|
||||
|
||||
if (param.TableIndex != -1)
|
||||
{
|
||||
sb.Append('[');
|
||||
sb.Append(param.TableIndex);
|
||||
sb.Append(']');
|
||||
}
|
||||
param.ToString(sb, false);
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public int CompareTo(InterpreterEntry other)
|
||||
{
|
||||
int stringCmp = LoadUri.CompareTo(other.LoadUri);
|
||||
return stringCmp != 0
|
||||
? stringCmp
|
||||
: Offset.CompareTo(other.Offset);
|
||||
}
|
||||
public int CompareTo(InterpreterEntry other) => Instruction.CompareTo(other.Instruction);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using Microsoft.Iris.Markup;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.Debug.Data;
|
||||
|
||||
[Serializable]
|
||||
public class InterpreterInstruction : IComparable<InterpreterInstruction>
|
||||
{
|
||||
public InterpreterInstruction(OpCode opCode, uint offset, string loadUri)
|
||||
{
|
||||
OpCode = opCode;
|
||||
Offset = offset;
|
||||
LoadUri = loadUri;
|
||||
}
|
||||
|
||||
public OpCode OpCode { get; set; }
|
||||
|
||||
public uint Offset { get; set; }
|
||||
|
||||
public string LoadUri { get; set; }
|
||||
|
||||
public int CompareTo(InterpreterInstruction other)
|
||||
{
|
||||
int stringCmp = LoadUri.CompareTo(other.LoadUri);
|
||||
return stringCmp != 0
|
||||
? stringCmp
|
||||
: Offset.CompareTo(other.Offset);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Iris.Debug.Data;
|
||||
|
||||
@@ -49,7 +50,33 @@ public class InterpreterObject
|
||||
|
||||
public InterpreterObject() { }
|
||||
|
||||
public override string ToString() => string.Join(" ", Type?.Name, Value?.ToString() ?? "NULL");
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
ToString(sb, true);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public void ToString(StringBuilder sb, bool includeType = false)
|
||||
{
|
||||
if (includeType)
|
||||
{
|
||||
sb.Append(Type?.Name);
|
||||
sb.Append(' ');
|
||||
}
|
||||
|
||||
if (Source == InstructionObjectSource.Inline)
|
||||
sb.Append(Value ?? "NULL");
|
||||
else
|
||||
sb.Append(Source);
|
||||
|
||||
if (TableIndex != -1)
|
||||
{
|
||||
sb.Append('[');
|
||||
sb.Append(TableIndex);
|
||||
sb.Append(']');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user