[WIP] Add debug symbol models

This commit is contained in:
Yoshi Askharoun
2025-09-27 02:22:15 -05:00
parent 3307b6ea3c
commit 55815fe59d
2 changed files with 60 additions and 0 deletions
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace Microsoft.Iris.Debug.Symbols;
public class ApplicationDebugSymbols
{
public List<FileDebugSymbols> Files { get; set; }
}
public class FileDebugSymbols
{
public string SourceFileName { get; set; }
public string CompiledFileName { get; set; }
public Dictionary<uint, ScriptDebugSymbols> ScriptSymbols { get; set; }
}
public class ScriptDebugSymbols
{
public string SourceCode { get; set; }
public Dictionary<uint, SourceSpan> SourceMap { get; set; }
}
[DebuggerDisplay("[{Start}..{End}]")]
public class SourceSpan
{
public SourceSpan(int start, int end)
{
if (start > end)
throw new ArgumentException($"Source start index must be at or after end index.");
Start = start;
End = end;
}
public int Start { get; set; }
public int End { get; set; }
public int GetLength() => End - Start;
}
@@ -0,0 +1,14 @@
using Newtonsoft.Json;
namespace Microsoft.Iris.Debug.Symbols;
public static class DebugSymbolsJsonParser
{
public static ApplicationDebugSymbols ParseForApplication(string json) => JsonConvert.DeserializeObject<ApplicationDebugSymbols>(json);
public static FileDebugSymbols ParseForFile(string json) => JsonConvert.DeserializeObject<FileDebugSymbols>(json);
public static string Serialize(ApplicationDebugSymbols symbols) => JsonConvert.SerializeObject(symbols);
public static string Serialize(FileDebugSymbols symbols) => JsonConvert.SerializeObject(symbols);
}