Files
MicrosoftIris/UIX/Microsoft/Iris/Debug/Data/InterpreterEntry.cs
T

64 lines
1.6 KiB
C#
Raw Normal View History

2023-10-09 14:46:51 -05:00
using System;
2022-06-07 14:30:29 -05:00
using System.Collections.Generic;
2023-05-24 16:24:48 -05:00
using System.Text;
2022-06-07 01:00:15 -05:00
2023-05-22 18:04:22 -05:00
namespace Microsoft.Iris.Debug.Data;
[Serializable]
2023-08-22 02:04:19 -05:00
public class InterpreterEntry : IComparable<InterpreterEntry>
2022-06-07 01:00:15 -05:00
{
2023-05-25 21:01:48 -05:00
public InterpreterEntry() { }
public InterpreterEntry(InterpreterInstruction instruction)
2022-06-07 01:00:15 -05:00
{
Instruction = instruction;
2022-06-07 01:00:15 -05:00
}
2023-10-09 14:46:51 -05:00
public InterpreterInstruction Instruction { get; set; }
2023-08-22 02:04:19 -05:00
2023-05-25 21:01:48 -05:00
public List<InterpreterObject> Parameters { get; } = new();
2023-05-24 16:24:48 -05:00
2023-05-25 21:01:48 -05:00
public List<InterpreterObject> ReturnValues { get; } = new();
2023-05-22 18:04:22 -05:00
public override string ToString()
2022-06-07 01:00:15 -05:00
{
2023-10-09 14:46:51 -05:00
StringBuilder sb = new($"[{Instruction.LoadUri} @ 0x{Instruction.Offset:X}] " +
$"{Instruction.OpCode}({string.Join(", ", Parameters)})");
2023-05-24 16:24:48 -05:00
2023-10-09 14:46:51 -05:00
if (ReturnValues.Count <= 0)
return sb.ToString();
sb.Append(" -> ");
2023-05-24 16:24:48 -05:00
2023-10-09 14:46:51 -05:00
if (ReturnValues.Count == 1)
sb.Append(ReturnValues[0]);
else
sb.Append($"[{string.Join(", ", ReturnValues)}]");
2023-05-24 16:24:48 -05:00
return sb.ToString();
2022-06-07 01:00:15 -05:00
}
2023-08-22 02:04:19 -05:00
public string ToInstructionString()
{
StringBuilder sb = new();
sb.AppendFormat("0x{0:X4}", Instruction.Offset);
2023-08-22 02:04:19 -05:00
sb.Append('\t');
sb.Append(Instruction.OpCode);
2023-08-22 02:04:19 -05:00
sb.Append(' ', 2);
for (int p = 0; p < Parameters.Count; ++p)
{
var param = Parameters[p];
if (p != 0)
sb.Append(", ");
param.ToString(sb, false);
2023-08-22 02:04:19 -05:00
}
return sb.ToString();
}
public int CompareTo(InterpreterEntry other) => Instruction.CompareTo(other.Instruction);
2022-06-07 01:00:15 -05:00
}