mirror of
https://github.com/ZuneDev/MicrosoftIris.git
synced 2026-07-27 13:13:29 -07:00
Add more information to interpreter entries and objects
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using Microsoft.Iris.Markup;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Iris.Debug.Data;
|
||||
@@ -9,16 +8,16 @@ namespace Microsoft.Iris.Debug.Data;
|
||||
[Serializable]
|
||||
public class InterpreterEntry
|
||||
{
|
||||
public InterpreterEntry(OpCode opCode, uint offset, string loadUri, params OpCodeArgument[] args)
|
||||
public InterpreterEntry(OpCode opCode, uint offset, string loadUri, params InterpreterObject[] args)
|
||||
{
|
||||
OpCode = opCode;
|
||||
Offset = offset;
|
||||
LoadUri = loadUri;
|
||||
|
||||
if (args != null && args.Length > 0)
|
||||
Arguments = args;
|
||||
Parameters = args;
|
||||
else
|
||||
Arguments = new List<OpCodeArgument>();
|
||||
Parameters = new List<InterpreterObject>();
|
||||
}
|
||||
|
||||
public OpCode OpCode { get; }
|
||||
@@ -27,13 +26,13 @@ public class InterpreterEntry
|
||||
|
||||
public string LoadUri { get; }
|
||||
|
||||
public IList<OpCodeArgument> Arguments { get; }
|
||||
public IList<InterpreterObject> Parameters { get; }
|
||||
|
||||
public IList<object> ReturnValues { get; } = new List<object>();
|
||||
public IList<InterpreterObject> ReturnValues { get; } = new List<InterpreterObject>();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new($"[{LoadUri} @ 0x{Offset:X}] {OpCode}({string.Join(", ", Arguments)})");
|
||||
StringBuilder sb = new($"[{LoadUri} @ 0x{Offset:X}] {OpCode}({string.Join(", ", Parameters)})");
|
||||
|
||||
if (ReturnValues.Count > 0)
|
||||
{
|
||||
@@ -48,40 +47,3 @@ public class InterpreterEntry
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class OpCodeArgument : ISerializable
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public Type Type { get; set; }
|
||||
public object Value { get; set; }
|
||||
|
||||
protected bool CanSerializeValue => Value is ISerializable;
|
||||
|
||||
public OpCodeArgument(string name, Type type, object value)
|
||||
{
|
||||
Name = name;
|
||||
Type = type;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
protected OpCodeArgument(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
Name = info.GetString(nameof(Name));
|
||||
Type = Type.GetType(info.GetString(nameof(Type)), false);
|
||||
|
||||
bool canSerializeValue = info.GetBoolean(nameof(CanSerializeValue));
|
||||
Type valueSerializeType = canSerializeValue ? Type : typeof(string);
|
||||
Value = info.GetValue(nameof(Value), valueSerializeType);
|
||||
}
|
||||
|
||||
public override string ToString() => $"{Type} {Value}";
|
||||
|
||||
public void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
info.AddValue(nameof(Name), Name);
|
||||
info.AddValue(nameof(Type), Type.FullName);
|
||||
info.AddValue(nameof(CanSerializeValue), CanSerializeValue);
|
||||
info.AddValue(nameof(Value), CanSerializeValue ? Value : Value?.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user