Allow imported members cache to be setup in 2 phases as compiled one is to deal with...
[mono.git] / mcs / mcs / symbolwriter.cs
index 83f53610c691cbc58f6055e20df2ea14891d8c2a..38e69963a3f75eaa7e0a8d6b98d1f9e3f7bbc68e 100644 (file)
@@ -9,7 +9,6 @@
 //
 
 using System;
-using System.Collections;
 using System.Reflection;
 using System.Reflection.Emit;
 
@@ -25,11 +24,13 @@ namespace Mono.CSharp {
                private static SymbolWriterImpl symwriter;
 
                class SymbolWriterImpl : MonoSymbolWriter {
+#if !NET_4_0
                        delegate int GetILOffsetFunc (ILGenerator ig);
-                       delegate Guid GetGuidFunc (ModuleBuilder mb);
-
                        GetILOffsetFunc get_il_offset_func;
+
+                       delegate Guid GetGuidFunc (ModuleBuilder mb);
                        GetGuidFunc get_guid_func;
+#endif
 
                        ModuleBuilder module_builder;
 
@@ -41,18 +42,30 @@ namespace Mono.CSharp {
 
                        public int GetILOffset (ILGenerator ig)
                        {
+#if NET_4_0
+                               return ig.ILOffset;
+#else
                                return get_il_offset_func (ig);
+#endif
                        }
 
                        public void WriteSymbolFile ()
                        {
-                               Guid guid = get_guid_func (module_builder);
+                               Guid guid;
+#if NET_4_0
+                               guid = module_builder.ModuleVersionId;
+#else
+                               guid = get_guid_func (module_builder);
+#endif
                                WriteSymbolFile (guid);
                        }
 
                        public bool Initialize ()
                        {
-                               MethodInfo mi = typeof (ILGenerator).GetMethod (
+#if !NET_4_0
+                               MethodInfo mi;
+
+                               mi = typeof (ILGenerator).GetMethod (
                                        "Mono_GetCurrentOffset",
                                        BindingFlags.Static | BindingFlags.NonPublic);
                                if (mi == null)
@@ -69,9 +82,9 @@ namespace Mono.CSharp {
 
                                get_guid_func = (GetGuidFunc) System.Delegate.CreateDelegate (
                                        typeof (GetGuidFunc), mi);
+#endif
 
                                Location.DefineSymbolDocuments (this);
-
                                return true;
                        }
                }
@@ -84,10 +97,13 @@ namespace Mono.CSharp {
                        }
                }
 
-               public static void OpenMethod (ICompileUnit file, ISourceMethod method)
+               public static SourceMethodBuilder OpenMethod (ICompileUnit file, int ns_id,
+                                                             IMethodDef method)
                {
                        if (symwriter != null)
-                               symwriter.OpenMethod (file, method);
+                               return symwriter.OpenMethod (file, ns_id, method);
+                       else
+                               return null;
                }
 
                public static void CloseMethod ()
@@ -170,63 +186,50 @@ namespace Mono.CSharp {
                                symwriter.DefineCapturedScope (scope_id, id, captured_name);
                }
 
-               public static void SetRealMethodName (string name)
-               {
-                       if (symwriter != null)
-                               symwriter.SetRealMethodName (name);
-               }
-
-               [Obsolete ("Duplicates corlib infrastructure")]
-               public static void SetCompilerGenerated ()
-               {
-                       if (symwriter != null)
-                               symwriter.SetCompilerGenerated ();
-               }
-
-               public static void OpenCompilerGeneratedBlock (ILGenerator ig)
+               public static void OpenCompilerGeneratedBlock (EmitContext ec)
                {
                        if (symwriter != null) {
-                               int offset = symwriter.GetILOffset (ig);
+                               int offset = symwriter.GetILOffset (ec.ig);
                                symwriter.OpenCompilerGeneratedBlock (offset);
                        }
                }
 
-               public static void CloseCompilerGeneratedBlock (ILGenerator ig)
+               public static void CloseCompilerGeneratedBlock (EmitContext ec)
                {
                        if (symwriter != null) {
-                               int offset = symwriter.GetILOffset (ig);
+                               int offset = symwriter.GetILOffset (ec.ig);
                                symwriter.CloseCompilerGeneratedBlock (offset);
                        }
                }
 
-               public static void StartIteratorBody (ILGenerator ig)
+               public static void StartIteratorBody (EmitContext ec)
                {
                        if (symwriter != null) {
-                               int offset = symwriter.GetILOffset (ig);
+                               int offset = symwriter.GetILOffset (ec.ig);
                                symwriter.StartIteratorBody (offset);
                        }
                }
 
-               public static void EndIteratorBody (ILGenerator ig)
+               public static void EndIteratorBody (EmitContext ec)
                {
                        if (symwriter != null) {
-                               int offset = symwriter.GetILOffset (ig);
+                               int offset = symwriter.GetILOffset (ec.ig);
                                symwriter.EndIteratorBody (offset);
                        }
                }
 
-               public static void StartIteratorDispatcher (ILGenerator ig)
+               public static void StartIteratorDispatcher (EmitContext ec)
                {
                        if (symwriter != null) {
-                               int offset = symwriter.GetILOffset (ig);
+                               int offset = symwriter.GetILOffset (ec.ig);
                                symwriter.StartIteratorDispatcher (offset);
                        }
                }
 
-               public static void EndIteratorDispatcher (ILGenerator ig)
+               public static void EndIteratorDispatcher (EmitContext ec)
                {
                        if (symwriter != null) {
-                               int offset = symwriter.GetILOffset (ig);
+                               int offset = symwriter.GetILOffset (ec.ig);
                                symwriter.EndIteratorDispatcher (offset);
                        }
                }
@@ -235,9 +238,10 @@ namespace Mono.CSharp {
                public static void MarkSequencePoint (ILGenerator ig, Location loc)
                {
                        if (symwriter != null) {
+                               SourceFileEntry file = loc.SourceFile.SourceFileEntry;
                                int offset = symwriter.GetILOffset (ig);
                                symwriter.MarkSequencePoint (
-                                       offset, loc.File, loc.Row, loc.Column, loc.Hidden);
+                                       offset, file, loc.Row, loc.Column, loc.Hidden);
                        }
                }
 
@@ -257,5 +261,10 @@ namespace Mono.CSharp {
 
                        return true;
                }
+
+               public static void Reset ()
+               {
+                       symwriter = null;
+               }
        }
 }