Better exception for unmarked labels
authorMarek Safar <marek.safar@gmail.com>
Wed, 3 Jul 2013 12:41:29 +0000 (14:41 +0200)
committerMarek Safar <marek.safar@gmail.com>
Wed, 3 Jul 2013 12:57:40 +0000 (14:57 +0200)
mcs/class/corlib/System.Reflection.Emit/ConstructorBuilder.cs
mcs/class/corlib/System.Reflection.Emit/DynamicMethod.cs
mcs/class/corlib/System.Reflection.Emit/ILGenerator.cs
mcs/class/corlib/System.Reflection.Emit/MethodBuilder.cs

index b0e6747bedfb9c6b0fbc0b6d5adfe86683fbcb3a..f9222cf88f210eceb921f7255b4bf33418e01f58 100644 (file)
@@ -351,7 +351,7 @@ namespace System.Reflection.Emit {
                                throw new InvalidOperationException ("Method '" + Name + "' does not have a method body.");
                        }
                        if (ilgen != null)
-                               ilgen.label_fixup ();
+                               ilgen.label_fixup (this);
                }
                
                internal void GenerateDebugInfo (ISymbolWriter symbolWriter)
index 5805c00c31df77d87aeacf23ed517c1f777c0fc4..b4915cced0454f49d01a199c18d40c1de134a084 100644 (file)
@@ -138,7 +138,7 @@ namespace System.Reflection.Emit {
                                if (ilgen == null || ilgen.ILOffset == 0)
                                        throw new InvalidOperationException ("Method '" + name + "' does not have a method body.");
 
-                               ilgen.label_fixup ();
+                               ilgen.label_fixup (this);
 
                                // Have to create all DynamicMethods referenced by this one
                                try {
index 1c9c3f4c3d16840e8c7dc1fd7d48788961204aa6..b939ab6cffeba64c1c1cd0188b2dbf493841631d 100644 (file)
@@ -988,11 +988,11 @@ namespace System.Reflection.Emit {
                        throw new NotImplementedException ();
                }
 
-               internal void label_fixup ()
+               internal void label_fixup (MethodBase mb)
                {
                        for (int i = 0; i < num_fixups; ++i) {
                                if (labels [fixups [i].label_idx].addr < 0)
-                                       throw new ArgumentException ("Label not marked");
+                                       throw new ArgumentException (string.Format ("Label #{0} is not marked in method `{1}'", fixups [i].label_idx + 1, mb.Name));
                                // Diff is the offset from the end of the jump instruction to the address of the label
                                int diff = labels [fixups [i].label_idx].addr - (fixups [i].pos + fixups [i].offset);
                                if (fixups [i].offset == 1) {
index f898bce399eb886a6b859be14904151e1e607c7a..2ea94ea525373b6bf179a3b623cfb462e071a136 100644 (file)
@@ -354,7 +354,7 @@ namespace System.Reflection.Emit
                                                                                            DeclaringType.FullName, Name));
                        }
                        if (ilgen != null)
-                               ilgen.label_fixup ();
+                               ilgen.label_fixup (this);
                }
                
                internal void GenerateDebugInfo (ISymbolWriter symbolWriter)