More linker fixes for moonlight
authorJb Evain <jbevain@gmail.com>
Tue, 23 Nov 2010 11:14:23 +0000 (12:14 +0100)
committerJb Evain <jbevain@gmail.com>
Tue, 23 Nov 2010 11:14:43 +0000 (12:14 +0100)
mcs/tools/linker/Mono.Linker.Steps/CleanStep.cs
mcs/tools/linker/Mono.Linker.Steps/MarkStep.cs
mcs/tools/linker/Mono.Linker.Steps/ResolveFromAssemblyStep.cs
mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs
mcs/tools/linker/Mono.Linker.Steps/TypeMapStep.cs

index 93cb8571a63874ad93523fb2546c7517eae62a2f..ccc34cb1deda0a2292e352ab3d4e9d55cc99cd20 100644 (file)
@@ -46,25 +46,16 @@ namespace Mono.Linker.Steps {
                                CleanType (type);
                }
 
-               static bool CheckType (ModuleDefinition module, TypeReference reference)
-               {
-                       TypeSpecification spec = reference as TypeSpecification;
-                       if (spec != null)
-                               return CheckType (module, spec.ElementType);
-
-                       TypeDefinition type = reference as TypeDefinition;
-                       if (type == null)
-                               return true;
-
-                       return module.Types.Contains (type);
-               }
-
                static void CleanType (TypeDefinition type)
                {
                        if (type.HasProperties)
                                CleanProperties (type);
                        if (type.HasEvents)
                                CleanEvents (type);
+
+                       if (type.HasNestedTypes)
+                               foreach (var nested in type.NestedTypes)
+                                       CleanType (nested);
                }
 
                static MethodDefinition CheckMethod (TypeDefinition type, MethodDefinition method)
index 29d218599e3c2ae92ebb0710224e9262ca27c43e..f161c156ea997e45a261e19b63508bcc41634cd4 100644 (file)
@@ -85,6 +85,10 @@ namespace Mono.Linker.Steps {
                                InitializeFields (type);
                        if (type.HasMethods)
                                InitializeMethods (type.Methods);
+
+                       if (type.HasNestedTypes)
+                               foreach (var nested in type.NestedTypes)
+                                       InitializeType (nested);
                }
 
                void InitializeFields (TypeDefinition type)
index f9aa7a117b4ad41b442443cb7e3710e4f09db49c..bd615f171862229ea623819e6c60324a211efcf4 100644 (file)
@@ -69,14 +69,21 @@ namespace Mono.Linker.Steps {
                {
                        context.Annotations.SetAction (assembly, AssemblyAction.Copy);
 
-                       foreach (TypeDefinition type in assembly.MainModule.Types) {
-                               context.Annotations.Mark (type);
+                       foreach (TypeDefinition type in assembly.MainModule.Types)
+                               MarkType (context, type);
+               }
 
-                               if (type.HasFields)
-                                       MarkFields (context, type.Fields);
-                               if (type.HasMethods)
-                                       MarkMethods (context, type.Methods);
-                       }
+               static void MarkType (LinkContext context, TypeDefinition type)
+               {
+                       context.Annotations.Mark (type);
+
+                       if (type.HasFields)
+                               MarkFields (context, type.Fields);
+                       if (type.HasMethods)
+                               MarkMethods (context, type.Methods);
+                       if (type.HasNestedTypes)
+                               foreach (var nested in type.NestedTypes)
+                                       MarkType (context, nested);
                }
 
                void ProcessExecutable (AssemblyDefinition assembly)
index 2c41988b348eed9bfb553bfbe5948a9052a7c402..371f0496fa79253b16a7b3921365191fa666d34c 100644 (file)
@@ -65,6 +65,9 @@ namespace Mono.Linker.Steps {
                                        types.Add (type);
                                        continue;
                                }
+
+                               if (type.Name == "<Module>")
+                                       types.Add (type);
                        }
                }
 
@@ -123,7 +126,7 @@ namespace Mono.Linker.Steps {
                                if (Annotations.IsMarked (nested)) {
                                        SweepType (nested);
                                } else {
-                                       //type.NestedTypes.RemoveAt (i--);
+                                       type.NestedTypes.RemoveAt (i--);
                                }
                        }
                }
index 6187c212c60d059b77aa2aa10ef26f452a0f2fd9..8f0d4c1a187b3b8744a4085f105ec0406658efba 100644 (file)
@@ -45,6 +45,12 @@ namespace Mono.Linker.Steps {
                {
                        MapVirtualMethods (type);
                        MapInterfaceMethodsInTypeHierarchy (type);
+
+                       if (!type.HasNestedTypes)
+                               return;
+
+                       foreach (var nested in type.NestedTypes)
+                               MapType (nested);
                }
 
                void MapInterfaceMethodsInTypeHierarchy (TypeDefinition type)