[mono/mono] [2 commits] 2641fde1: anonymous: move counters to TypeContainer

"Marek Safar ([email protected])" <[email protected]>
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <000001419d268eba-a930df96-abc2-4983-90bf-4cba36735c0f-000000@email.amazonses.com>
   Branch: refs/heads/pr/773
     Home: https://github.com/mono/mono
  Compare: https://github.com/mono/mono/compare/2641fde17285^...4542963477d5

   Commit: 2641fde172854e924e7effa999cbb3d00f1bbd84
   Author: Aaron Bockover <[email protected]> (abock)
     Date: 2013-10-07 21:03:12 GMT
      URL: https://github.com/mono/mono/commit/2641fde172854e924e7effa999cbb3d00f1bbd84

anonymous: move counters to TypeContainer

With the anonymous counters on ModuleContainer,
anonymous method and type names will be generated
in a way that depends on the order of the sources
passed to mcs. This can cause undesirable API
and IL differences.

Moving the counters to TypeContainer instead
avoids this issue.

Changed paths:
  M mcs/mcs/anonymous.cs
  M mcs/mcs/class.cs
  M mcs/mcs/module.cs

Modified: mcs/mcs/anonymous.cs
===================================================================
@@ -244,11 +244,11 @@ protected override void CloneTo (CloneContext clonectx, Statement target)
 		AnonymousMethodStorey hoisted_this_parent;
 
 		public AnonymousMethodStorey (ExplicitBlock block, TypeDefinition parent, MemberBase host, TypeParameters tparams, string name, MemberKind kind)
-			: base (parent, MakeMemberName (host, name, parent.Module.CounterAnonymousContainers, tparams, block.StartLocation),
+			: base (parent, MakeMemberName (host, name, parent.PartialContainer.CounterAnonymousContainers, tparams, block.StartLocation),
 				tparams, 0, kind)
 		{
 			OriginalSourceBlock = block;
-			ID = parent.Module.CounterAnonymousContainers++;
+			ID = parent.PartialContainer.CounterAnonymousContainers++;
 		}
 
 		public void AddCapturedThisField (EmitContext ec, AnonymousMethodStorey parent)
@@ -1714,7 +1714,7 @@ AnonymousMethodMethod DoCreateMethodHost (EmitContext ec)
 				parent = ec.CurrentTypeDefinition.Parent.PartialContainer;
 
 			string name = CompilerGeneratedContainer.MakeName (parent != storey ? block_name : null,
-				"m", null, ec.Module.CounterAnonymousMethods++);
+				"m", null, parent.PartialContainer.CounterAnonymousMethods++);
 
 			MemberName member_name;
 			if (storey == null && ec.CurrentTypeParameters != null) {
@@ -1902,7 +1902,7 @@ private AnonymousTypeClass (ModuleContainer parent, MemberName name, IList<Anony
 
 		public static AnonymousTypeClass Create (TypeContainer parent, IList<AnonymousTypeParameter> parameters, Location loc)
 		{
-			string name = ClassNamePrefix + parent.Module.CounterAnonymousTypes++;
+			string name = ClassNamePrefix + parent.PartialContainer.CounterAnonymousTypes++;
 
 			ParametersCompiled all_parameters;
 			TypeParameters tparams = null;

Modified: mcs/mcs/class.cs
===================================================================
@@ -53,6 +53,11 @@ public abstract class TypeContainer : MemberCore
 
 		protected bool is_defined;
 
+		public int CounterAnonymousTypes { get; set; }
+		public int CounterAnonymousMethods { get; set; }
+		public int CounterAnonymousContainers { get; set; }
+		public int CounterSwitchTypes { get; set; }
+
 		protected TypeContainer (TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind)
 			: base (parent, name, attrs)
 		{

Modified: mcs/mcs/module.cs
===================================================================
@@ -186,11 +186,6 @@ public ModuleContainer (CompilerContext context)
 			}
 		}
 
-		public int CounterAnonymousTypes { get; set; }
-		public int CounterAnonymousMethods { get; set; }
-		public int CounterAnonymousContainers { get; set; }
-		public int CounterSwitchTypes { get; set; }
-
 		public AssemblyDefinition DeclaringAssembly {
 			get {
 				return assembly;

   Commit: 4542963477d522ec943714253e2fc9992d5d114d
   Author: Marek Safar <[email protected]> (marek-safar)
     Date: 2013-10-09 12:14:51 GMT
      URL: https://github.com/mono/mono/commit/4542963477d522ec943714253e2fc9992d5d114d

Tests update

Changed paths:
  M mcs/tests/ver-il-net_4_5.xml

Modified: mcs/tests/ver-il-net_4_5.xml
===================================================================



_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.