protected override void Process ()
{
- if (_assembly != null) {
- Context.SafeLoadSymbols (_assembly);
+ if (_assembly != null)
Context.Resolver.CacheAssembly (_assembly);
- }
AssemblyDefinition assembly = _assembly ?? Context.Resolve (_file);
switch (assembly.MainModule.Kind) {
case ModuleKind.Dll:
ProcessLibrary (Context, assembly);
- return;
+ break;
default:
ProcessExecutable (assembly);
- return;
+ break;
}
}
+ static void SetAction (LinkContext context, AssemblyDefinition assembly, AssemblyAction action)
+ {
+ TryReadSymbols (context, assembly);
+
+ context.Annotations.SetAction (assembly, action);
+ }
+
+ static void TryReadSymbols (LinkContext context, AssemblyDefinition assembly)
+ {
+ context.SafeReadSymbols (assembly);
+ }
+
public static void ProcessLibrary (LinkContext context, AssemblyDefinition assembly)
{
- context.Annotations.SetAction (assembly, AssemblyAction.Copy);
+ SetAction (context, assembly, AssemblyAction.Copy);
- foreach (TypeDefinition type in assembly.MainModule.Types) {
- context.Annotations.Mark (type);
+ context.Annotations.Push (assembly);
- if (type.HasFields)
- MarkFields (context, type.Fields);
- if (type.HasMethods)
- MarkMethods (context, type.Methods);
- }
+ foreach (TypeDefinition type in assembly.MainModule.Types)
+ MarkType (context, type);
+
+ context.Annotations.Pop ();
+ }
+
+ static void MarkType (LinkContext context, TypeDefinition type)
+ {
+ context.Annotations.Mark (type);
+
+ context.Annotations.Push (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);
+
+ context.Annotations.Pop ();
}
void ProcessExecutable (AssemblyDefinition assembly)
{
- Annotations.SetAction (assembly, AssemblyAction.Link);
+ SetAction (Context, assembly, AssemblyAction.Link);
+
+ Annotations.Push (assembly);
Annotations.Mark (assembly.EntryPoint.DeclaringType);
MarkMethod (Context, assembly.EntryPoint, MethodAction.Parse);
+
+ Annotations.Pop ();
}
static void MarkFields (LinkContext context, ICollection fields)