+ public struct CapturedVariable
+ {
+ #region This is actually written to the symbol file
+ public readonly string Name;
+ public readonly string CapturedName;
+ public readonly CapturedKind Kind;
+ #endregion
+
+ public enum CapturedKind : byte
+ {
+ Local,
+ Parameter,
+ This
+ }
+
+ public CapturedVariable (string name, string captured_name,
+ CapturedKind kind)
+ {
+ this.Name = name;
+ this.CapturedName = captured_name;
+ this.Kind = kind;
+ }
+
+ internal CapturedVariable (MyBinaryReader reader)
+ {
+ Name = reader.ReadString ();
+ CapturedName = reader.ReadString ();
+ Kind = (CapturedKind) reader.ReadByte ();
+ }
+
+ internal void Write (MyBinaryWriter bw)
+ {
+ bw.Write (Name);
+ bw.Write (CapturedName);
+ bw.Write ((byte) Kind);
+ }
+
+ public override string ToString ()
+ {
+ return String.Format ("[CapturedVariable {0}:{1}:{2}]",
+ Name, CapturedName, Kind);
+ }
+ }
+
+ public struct CapturedScope
+ {
+ #region This is actually written to the symbol file
+ public readonly int Scope;
+ public readonly string CapturedName;
+ #endregion
+
+ public CapturedScope (int scope, string captured_name)
+ {
+ this.Scope = scope;
+ this.CapturedName = captured_name;
+ }
+
+ internal CapturedScope (MyBinaryReader reader)
+ {
+ Scope = reader.ReadLeb128 ();
+ CapturedName = reader.ReadString ();
+ }
+
+ internal void Write (MyBinaryWriter bw)
+ {
+ bw.WriteLeb128 (Scope);
+ bw.Write (CapturedName);
+ }
+
+ public override string ToString ()
+ {
+ return String.Format ("[CapturedScope {0}:{1}]",
+ Scope, CapturedName);
+ }
+ }
+
+ public struct ScopeVariable
+ {
+ #region This is actually written to the symbol file
+ public readonly int Scope;
+ public readonly int Index;
+ #endregion
+
+ public ScopeVariable (int scope, int index)
+ {
+ this.Scope = scope;
+ this.Index = index;
+ }
+
+ internal ScopeVariable (MyBinaryReader reader)
+ {
+ Scope = reader.ReadLeb128 ();
+ Index = reader.ReadLeb128 ();
+ }
+
+ internal void Write (MyBinaryWriter bw)
+ {
+ bw.WriteLeb128 (Scope);
+ bw.WriteLeb128 (Index);
+ }
+
+ public override string ToString ()
+ {
+ return String.Format ("[ScopeVariable {0}:{1}]", Scope, Index);
+ }
+ }
+
+ public class AnonymousScopeEntry
+ {
+ #region This is actually written to the symbol file
+ public readonly int ID;
+ #endregion
+
+ List<CapturedVariable> captured_vars = new List<CapturedVariable> ();
+ List<CapturedScope> captured_scopes = new List<CapturedScope> ();
+
+ public AnonymousScopeEntry (int id)
+ {
+ this.ID = id;
+ }
+
+ internal AnonymousScopeEntry (MyBinaryReader reader)
+ {
+ ID = reader.ReadLeb128 ();
+
+ int num_captured_vars = reader.ReadLeb128 ();
+ for (int i = 0; i < num_captured_vars; i++)
+ captured_vars.Add (new CapturedVariable (reader));
+
+ int num_captured_scopes = reader.ReadLeb128 ();
+ for (int i = 0; i < num_captured_scopes; i++)
+ captured_scopes.Add (new CapturedScope (reader));
+ }
+
+ internal void AddCapturedVariable (string name, string captured_name,
+ CapturedVariable.CapturedKind kind)
+ {
+ captured_vars.Add (new CapturedVariable (name, captured_name, kind));
+ }
+
+ public CapturedVariable[] CapturedVariables {
+ get {
+ CapturedVariable[] retval = new CapturedVariable [captured_vars.Count];
+ captured_vars.CopyTo (retval, 0);
+ return retval;
+ }
+ }
+
+ internal void AddCapturedScope (int scope, string captured_name)
+ {
+ captured_scopes.Add (new CapturedScope (scope, captured_name));
+ }
+
+ public CapturedScope[] CapturedScopes {
+ get {
+ CapturedScope[] retval = new CapturedScope [captured_scopes.Count];
+ captured_scopes.CopyTo (retval, 0);
+ return retval;
+ }
+ }
+
+ internal void Write (MyBinaryWriter bw)
+ {
+ bw.WriteLeb128 (ID);
+
+ bw.WriteLeb128 (captured_vars.Count);
+ foreach (CapturedVariable cv in captured_vars)
+ cv.Write (bw);
+
+ bw.WriteLeb128 (captured_scopes.Count);
+ foreach (CapturedScope cs in captured_scopes)
+ cs.Write (bw);
+ }
+
+ public override string ToString ()
+ {
+ return String.Format ("[AnonymousScope {0}]", ID);
+ }
+ }
+
+ public class CompileUnitEntry : ICompileUnit