[mtouch/mmp] Move some code to be shared.

This commit is contained in:
Rolf Bjarne Kvinge 2018-02-13 10:22:29 +01:00
Родитель 1c77da63cf
Коммит 8485e7f4bb
2 изменённых файлов: 19 добавлений и 18 удалений

Просмотреть файл

@ -1,11 +1,13 @@
// Copyright 2012-2013, 2015 Xamarin Inc. All rights reserved.
using System;
using System.Collections;
using System.Collections.Generic;
using Mono.Cecil;
using Mono.Linker;
using Mono.Linker.Steps;
using Xamarin.Tuner;
namespace Xamarin.Linker {
// MobileMarkStep process a bit more data and that can be used to sweep
@ -18,6 +20,12 @@ namespace Xamarin.Linker {
{
}
protected DerivedLinkContext LinkContext {
get {
return (DerivedLinkContext) base.Context;
}
}
public AssemblyAction CurrentAction { get; private set; }
protected override void Process ()
@ -54,5 +62,15 @@ namespace Xamarin.Linker {
if (main.HasModuleReferences && (CurrentAction == AssemblyAction.Link))
SweepCollection (main.ModuleReferences);
}
protected override void InterfaceRemoved (TypeDefinition type, InterfaceImplementation iface)
{
base.InterfaceRemoved (type, iface);
// The static registrar needs access to the interfaces for protocols, so keep them around.
if (!LinkContext.ProtocolImplementations.TryGetValue (type, out var list))
LinkContext.ProtocolImplementations [type] = list = new List<TypeDefinition> ();
list.Add (iface.InterfaceType.Resolve ());
}
}
}

Просмотреть файл

@ -5,7 +5,6 @@ using System.Collections.Generic;
using Mono.Cecil;
using Mono.Tuner;
using Xamarin.Linker;
using Xamarin.Tuner;
namespace MonoTouch.Tuner {
@ -16,12 +15,6 @@ namespace MonoTouch.Tuner {
{
}
protected DerivedLinkContext LinkContext {
get {
return (DerivedLinkContext) base.Context;
}
}
protected override void SweepAssembly (AssemblyDefinition assembly)
{
base.SweepAssembly (assembly);
@ -57,15 +50,5 @@ namespace MonoTouch.Tuner {
attributes.RemoveAt (i--);
}
}
protected override void InterfaceRemoved (TypeDefinition type, InterfaceImplementation iface)
{
base.InterfaceRemoved (type, iface);
// The static registrar needs access to the interfaces for protocols, so keep them around.
if (!LinkContext.ProtocolImplementations.TryGetValue (type, out var list))
LinkContext.ProtocolImplementations [type] = list = new List<TypeDefinition> ();
list.Add (iface.InterfaceType.Resolve ());
}
}
}