mirror of
https://github.com/ZuneDev/MicrosoftIris.git
synced 2026-07-27 13:13:29 -07:00
InterpreterEntry refinements
This commit is contained in:
@@ -6,7 +6,7 @@ using System.Text;
|
||||
namespace Microsoft.Iris.Debug.Data;
|
||||
|
||||
[Serializable]
|
||||
public class InterpreterEntry
|
||||
public class InterpreterEntry : IComparable<InterpreterEntry>
|
||||
{
|
||||
public InterpreterEntry() { }
|
||||
|
||||
@@ -23,6 +23,8 @@ public class InterpreterEntry
|
||||
|
||||
public string LoadUri { get; set; }
|
||||
|
||||
public string InstructionString => ToInstructionString();
|
||||
|
||||
public List<InterpreterObject> Parameters { get; } = new();
|
||||
|
||||
public List<InterpreterObject> ReturnValues { get; } = new();
|
||||
@@ -43,4 +45,43 @@ public class InterpreterEntry
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public string ToInstructionString()
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
sb.AppendFormat("0x{0:X4}", Offset);
|
||||
sb.Append('\t');
|
||||
sb.Append(OpCode);
|
||||
sb.Append(' ', 2);
|
||||
|
||||
for (int p = 0; p < Parameters.Count; ++p)
|
||||
{
|
||||
var param = Parameters[p];
|
||||
|
||||
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(']');
|
||||
}
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public int CompareTo(InterpreterEntry other)
|
||||
{
|
||||
int stringCmp = LoadUri.CompareTo(other.LoadUri);
|
||||
return stringCmp != 0
|
||||
? stringCmp
|
||||
: Offset.CompareTo(other.Offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,25 @@ namespace Microsoft.Iris.Debug.Data;
|
||||
[Serializable]
|
||||
public class InterpreterObject
|
||||
{
|
||||
private object _value;
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public Type Type { get; set; }
|
||||
|
||||
public object Value { get; set; }
|
||||
public object Value
|
||||
{
|
||||
get => _value;
|
||||
set
|
||||
{
|
||||
if (Type == typeof(uint))
|
||||
_value = BitConverter.ToUInt32((byte[])value, 0);
|
||||
else if (Type == typeof(ulong))
|
||||
_value = BitConverter.ToUInt64((byte[])value, 0);
|
||||
else
|
||||
_value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public InstructionObjectSource Source { get; set; }
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace Microsoft.Iris.Markup
|
||||
int typeIndex = reader.ReadUInt16();
|
||||
TypeSchema typeSchema = importTables.TypeImports[typeIndex];
|
||||
entry.Parameters.Add(new InterpreterObject("type", typeof(TypeSchema),
|
||||
typeSchema, InstructionObjectSource.TypeImports));
|
||||
typeSchema, InstructionObjectSource.TypeImports, typeIndex));
|
||||
|
||||
object newObj = typeSchema.ConstructDefault();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user