diff --git a/UIX/Microsoft/Iris/Debug/Data/InterpreterEntry.cs b/UIX/Microsoft/Iris/Debug/Data/InterpreterEntry.cs index f9a135c..005ad6a 100644 --- a/UIX/Microsoft/Iris/Debug/Data/InterpreterEntry.cs +++ b/UIX/Microsoft/Iris/Debug/Data/InterpreterEntry.cs @@ -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(); + Parameters = new List(); } public OpCode OpCode { get; } @@ -27,13 +26,13 @@ public class InterpreterEntry public string LoadUri { get; } - public IList Arguments { get; } + public IList Parameters { get; } - public IList ReturnValues { get; } = new List(); + public IList ReturnValues { get; } = new List(); 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()); - } -} diff --git a/UIX/Microsoft/Iris/Debug/Data/InterpreterObject.cs b/UIX/Microsoft/Iris/Debug/Data/InterpreterObject.cs new file mode 100644 index 0000000..6c3fb26 --- /dev/null +++ b/UIX/Microsoft/Iris/Debug/Data/InterpreterObject.cs @@ -0,0 +1,80 @@ +using System; +using System.Runtime.Serialization; + +namespace Microsoft.Iris.Debug.Data; + +[Serializable] +public class InterpreterObject : ISerializable +{ + public string Name { get; set; } + + public Type Type { get; set; } + + public object Value { get; set; } + + public InstructionObjectSource Source { get; set; } + + public int TableIndex { get; set; } = -1; + + protected bool CanSerializeValue => Value is ISerializable; + + public InterpreterObject(string name, Type type, object value, InstructionObjectSource source, int tableIndex = -1) + { + Name = name; + Type = type; + Value = value; + Source = source; + TableIndex = tableIndex; + } + + public InterpreterObject(object value) : this(null, value?.GetType() ?? typeof(object), value, InstructionObjectSource.Dynamic) + { + } + + protected InterpreterObject(SerializationInfo info, StreamingContext context) + { + Name = info.GetString(nameof(Name)); + Type = Type.GetType(info.GetString(nameof(Type)), false); + Source = (InstructionObjectSource)info.GetByte(nameof(Source)); + TableIndex = info.GetInt32(nameof(TableIndex)); + + 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(Source), (byte)Source); + info.AddValue(nameof(TableIndex), TableIndex); + info.AddValue(nameof(CanSerializeValue), CanSerializeValue); + info.AddValue(nameof(Value), CanSerializeValue ? Value : Value?.ToString()); + } +} + +/// +/// Indicates where the argument value came from. +/// +public enum InstructionObjectSource : byte +{ + Dynamic, + Stack, + Inline, + Exports, + Alias, + DataMappings, + BinaryData, + Constants, + SymbolReference, + + Imports = 1 << 4, + TypeImports = Imports | 1, + ConstructorImports = Imports | 2, + PropertyImports = Imports | 3, + MethodImports = Imports | 4, + EventImports = Imports | 5, +}