+ #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
+ {
+ #region This is actually written to the symbol file
+ public readonly int Index;
+ int DataOffset;