mirror of
https://github.com/ZuneDev/MicrosoftIris.git
synced 2026-07-27 13:13:29 -07:00
Merge branch 'master' of https://github.com/ZuneDev/MicrosoftIris
This commit is contained in:
@@ -33,7 +33,7 @@ internal class Program
|
|||||||
|
|
||||||
private static void Debugger_DispatcherStep(string obj)
|
private static void Debugger_DispatcherStep(string obj)
|
||||||
{
|
{
|
||||||
Console.WriteLine(obj);
|
Console.WriteLine($"[Dispatcher] {obj}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Debugger_InterpreterStep(object? sender, InterpreterEntry e)
|
private static void Debugger_InterpreterStep(object? sender, InterpreterEntry e)
|
||||||
|
|||||||
@@ -1,31 +1,49 @@
|
|||||||
using Microsoft.Iris.Markup;
|
using Microsoft.Iris.Markup;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace Microsoft.Iris.Debug.Data;
|
namespace Microsoft.Iris.Debug.Data;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class InterpreterEntry
|
public class InterpreterEntry
|
||||||
{
|
{
|
||||||
public InterpreterEntry(OpCode opCode, params OpCodeArgument[] args)
|
public InterpreterEntry(OpCode opCode, uint offset, string loadUri, params OpCodeArgument[] args)
|
||||||
{
|
{
|
||||||
OpCode = opCode;
|
OpCode = opCode;
|
||||||
|
Offset = offset;
|
||||||
|
LoadUri = loadUri;
|
||||||
|
|
||||||
if (args != null && args.Length > 0)
|
if (args != null && args.Length > 0)
|
||||||
Arguments = args;
|
Arguments = args;
|
||||||
else
|
|
||||||
Arguments = new List<OpCodeArgument>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OpCode OpCode { get; }
|
public OpCode OpCode { get; }
|
||||||
|
|
||||||
|
public uint Offset { get; }
|
||||||
|
|
||||||
|
public string LoadUri { get; }
|
||||||
|
|
||||||
public IList<OpCodeArgument> Arguments { get; }
|
public IList<OpCodeArgument> Arguments { get; }
|
||||||
|
|
||||||
public IList<object> ReturnValues { get; } = new List<object>();
|
public IList<object> ReturnValues { get; } = new List<object>();
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return $"{OpCode}({string.Join(", ", Arguments)}) -> [{string.Join(", ", ReturnValues)}]";
|
StringBuilder sb = new($"[{LoadUri} @ 0x{Offset:X}] {OpCode}({string.Join(", ", Arguments)})");
|
||||||
|
|
||||||
|
if (ReturnValues.Count > 0)
|
||||||
|
{
|
||||||
|
sb.Append(" -> ");
|
||||||
|
|
||||||
|
if (ReturnValues.Count == 1)
|
||||||
|
sb.Append(ReturnValues[0]);
|
||||||
|
else
|
||||||
|
sb.Append($"[{string.Join(", ", ReturnValues)}]");
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
while (!errorsDetected)
|
while (!errorsDetected)
|
||||||
{
|
{
|
||||||
OpCode opCode = (OpCode)reader.ReadByte();
|
OpCode opCode = (OpCode)reader.ReadByte();
|
||||||
Debug.Data.InterpreterEntry entry = new(opCode);
|
Debug.Data.InterpreterEntry entry = new(opCode, reader.CurrentOffset, loadResult.Uri);
|
||||||
|
|
||||||
// Fetch line and column numbers from the table
|
// Fetch line and column numbers from the table
|
||||||
if (debugging && context.LoadResult.LineNumberTable.TryLookup(reader.CurrentOffset, out int line, out int column))
|
if (debugging && context.LoadResult.LineNumberTable.TryLookup(reader.CurrentOffset, out int line, out int column))
|
||||||
@@ -700,7 +700,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Application.Debugger?.LogInterpreterOpCode(opCode, entry);
|
Application.Debugger?.LogInterpreterOpCode(context, entry);
|
||||||
}
|
}
|
||||||
while (stack.Count > count)
|
while (stack.Count > count)
|
||||||
{
|
{
|
||||||
@@ -922,7 +922,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
while (!flag)
|
while (!flag)
|
||||||
{
|
{
|
||||||
OpCode opCode = (OpCode)reader.ReadByte();
|
OpCode opCode = (OpCode)reader.ReadByte();
|
||||||
var entry = new Debug.Data.InterpreterEntry(opCode);
|
var entry = new Debug.Data.InterpreterEntry(opCode, reader.CurrentOffset, loadResult.Uri);
|
||||||
|
|
||||||
switch (opCode)
|
switch (opCode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,15 +18,15 @@ namespace Microsoft.Iris.Markup
|
|||||||
private uint _initialBytecodeOffset;
|
private uint _initialBytecodeOffset;
|
||||||
private ParameterContext _parameterContext;
|
private ParameterContext _parameterContext;
|
||||||
private Map<object, object> _scopedLocals;
|
private Map<object, object> _scopedLocals;
|
||||||
private static Stack s_cache = new Stack();
|
private static Stack s_cache = new();
|
||||||
|
|
||||||
private InterpreterContext()
|
private InterpreterContext()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
string IErrorContextSource.GetErrorContextDescription() => _type.Owner.ErrorContextUri;
|
public string GetErrorContextDescription() => _type.Owner.ErrorContextUri;
|
||||||
|
|
||||||
void IErrorContextSource.GetErrorPosition(ref int line, ref int column)
|
public void GetErrorPosition(ref int line, ref int column)
|
||||||
{
|
{
|
||||||
uint currentOffset = _loadResult.ObjectSection.CurrentOffset;
|
uint currentOffset = _loadResult.ObjectSection.CurrentOffset;
|
||||||
if (currentOffset > 0U)
|
if (currentOffset > 0U)
|
||||||
@@ -65,8 +65,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
switch (symbolRef.Origin)
|
switch (symbolRef.Origin)
|
||||||
{
|
{
|
||||||
case SymbolOrigin.ScopedLocal:
|
case SymbolOrigin.ScopedLocal:
|
||||||
if (_scopedLocals == null)
|
_scopedLocals ??= new Map<object, object>();
|
||||||
_scopedLocals = new Map<object, object>();
|
|
||||||
_scopedLocals[symbolRef.Symbol] = value;
|
_scopedLocals[symbolRef.Symbol] = value;
|
||||||
break;
|
break;
|
||||||
case SymbolOrigin.Parameter:
|
case SymbolOrigin.Parameter:
|
||||||
@@ -94,8 +93,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
InterpreterContext interpreterContext = null;
|
InterpreterContext interpreterContext = null;
|
||||||
if (s_cache.Count != 0)
|
if (s_cache.Count != 0)
|
||||||
interpreterContext = (InterpreterContext)s_cache.Pop();
|
interpreterContext = (InterpreterContext)s_cache.Pop();
|
||||||
if (interpreterContext == null)
|
interpreterContext ??= new InterpreterContext();
|
||||||
interpreterContext = new InterpreterContext();
|
|
||||||
interpreterContext._instance = instance;
|
interpreterContext._instance = instance;
|
||||||
interpreterContext._initialBytecodeOffset = initialBytecodeOffset;
|
interpreterContext._initialBytecodeOffset = initialBytecodeOffset;
|
||||||
interpreterContext._type = type;
|
interpreterContext._type = type;
|
||||||
@@ -120,8 +118,8 @@ namespace Microsoft.Iris.Markup
|
|||||||
{
|
{
|
||||||
int line = 0;
|
int line = 0;
|
||||||
int column = 0;
|
int column = 0;
|
||||||
((IErrorContextSource)this).GetErrorPosition(ref line, ref column);
|
GetErrorPosition(ref line, ref column);
|
||||||
return string.Format("{0} ({1}, {2})", ((IErrorContextSource)this).GetErrorContextDescription(), line, column);
|
return $"{GetErrorContextDescription()} ({line}, {column})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user