Check whether parent struct field is assigned when assigning to child field. Fixes...
[mono.git] / mcs / mcs / symbolwriter.cs
index 4d411db9953e79b6cdcc178143bd532f668e7abc..ce19cfc492acb6c54b129d1e6a6d915c8e7d134b 100644 (file)
 //
 
 using System;
+
+#if STATIC
+using IKVM.Reflection;
+using IKVM.Reflection.Emit;
+#else
 using System.Reflection;
 using System.Reflection.Emit;
+#endif
 
 using Mono.CompilerServices.SymbolWriter;
 
@@ -20,14 +26,14 @@ namespace Mono.CSharp
 {
        static class SymbolWriter
        {
-#if !NET_4_0
+#if !NET_4_0 && !STATIC
                delegate int GetILOffsetFunc (ILGenerator ig);
                static GetILOffsetFunc get_il_offset_func;
 
                delegate Guid GetGuidFunc (ModuleBuilder mb);
                static GetGuidFunc get_guid_func;
 
-               static SymbolWriter ()
+               static void Initialize ()
                {
                        var mi = typeof (ILGenerator).GetMethod (
                                "Mono_GetCurrentOffset",
@@ -51,18 +57,24 @@ namespace Mono.CSharp
 
                static int GetILOffset (ILGenerator ig)
                {
-#if NET_4_0
+#if NET_4_0 || STATIC
                        return ig.ILOffset;
 #else
+                       if (get_il_offset_func == null)
+                               Initialize ();
+
                        return get_il_offset_func (ig);
 #endif
                }
 
                public static Guid GetGuid (ModuleBuilder module)
                {
-#if NET_4_0
+#if NET_4_0 || STATIC
                        return module.ModuleVersionId;
 #else
+                       if (get_guid_func == null)
+                               Initialize ();
+
                        return get_guid_func (module);
 #endif
                }