2008-05-14 Jb Evain <jbevain@novell.com>
[mono.git] / mcs / class / System.Core / System.Linq.Expressions / EmitContext.cs
index 5c259473ea614cb31c9c736c2b4e6e133f9e2bec..7a09735a7bb3bfba29debcb9344cd650ece17b7a 100644 (file)
@@ -225,9 +225,6 @@ namespace System.Linq.Expressions {
 
                DynamicMethod method;
 
-               static object mlock = new object ();
-               static int method_count;
-
                public DynamicMethod Method {
                        get { return method; }
                }
@@ -248,17 +245,18 @@ namespace System.Linq.Expressions {
                        return method.CreateDelegate (owner.Type, new ExecutionScope (globals.ToArray ()));
                }
 
-               static string GenerateName ()
+               protected virtual string GenerateName ()
                {
-                       lock (mlock) {
-                               return "lambda_method-" + (method_count++);
-                       }
+                       return "lambda_method";
                }
        }
 
 #if !NET_2_1
        class DebugEmitContext : DynamicEmitContext {
 
+               static object mlock = new object ();
+               static int method_count;
+
                public DebugEmitContext (LambdaExpression lambda)
                        : base (lambda)
                {
@@ -278,6 +276,13 @@ namespace System.Linq.Expressions {
                        type.CreateType ();
                        assembly.Save (file_name);
                }
+
+               protected override string GenerateName ()
+               {
+                       lock (mlock) {
+                               return "lambda_method-" + (method_count++);
+                       }
+               }
        }
 #endif
 }