2011-11-15 21:26:51 +08:00
|
|
|
|
/*
|
2013-01-02 00:03:16 +08:00
|
|
|
|
Copyright (C) 2011-2013 de4dot@gmail.com
|
2011-11-15 21:26:51 +08:00
|
|
|
|
|
|
|
|
|
This file is part of de4dot.
|
|
|
|
|
|
|
|
|
|
de4dot is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
de4dot is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with de4dot. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2012-12-20 09:06:09 +08:00
|
|
|
|
using dnlib.DotNet;
|
|
|
|
|
using dnlib.DotNet.Emit;
|
2011-11-15 21:26:51 +08:00
|
|
|
|
using de4dot.blocks;
|
|
|
|
|
|
2011-12-09 16:02:06 +08:00
|
|
|
|
namespace de4dot.code.renamer.asmmodules {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
enum ObjectType {
|
|
|
|
|
Unknown,
|
|
|
|
|
EventDef,
|
|
|
|
|
FieldDef,
|
|
|
|
|
GenericParam,
|
|
|
|
|
MemberRef,
|
|
|
|
|
MethodDef,
|
|
|
|
|
MethodSpec,
|
|
|
|
|
PropertyDef,
|
|
|
|
|
TypeDef,
|
|
|
|
|
TypeRef,
|
|
|
|
|
TypeSig,
|
|
|
|
|
TypeSpec,
|
|
|
|
|
ExportedType,
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-15 21:26:51 +08:00
|
|
|
|
class MemberRefFinder {
|
2012-03-03 12:49:49 +08:00
|
|
|
|
public Dictionary<CustomAttribute, bool> customAttributes = new Dictionary<CustomAttribute, bool>();
|
2012-11-02 22:57:11 +08:00
|
|
|
|
public Dictionary<EventDef, bool> eventDefs = new Dictionary<EventDef, bool>();
|
|
|
|
|
public Dictionary<FieldDef, bool> fieldDefs = new Dictionary<FieldDef, bool>();
|
|
|
|
|
public Dictionary<GenericParam, bool> genericParams = new Dictionary<GenericParam, bool>();
|
|
|
|
|
public Dictionary<MemberRef, bool> memberRefs = new Dictionary<MemberRef, bool>();
|
|
|
|
|
public Dictionary<MethodDef, bool> methodDefs = new Dictionary<MethodDef, bool>();
|
|
|
|
|
public Dictionary<MethodSpec, bool> methodSpecs = new Dictionary<MethodSpec, bool>();
|
|
|
|
|
public Dictionary<PropertyDef, bool> propertyDefs = new Dictionary<PropertyDef, bool>();
|
|
|
|
|
public Dictionary<TypeDef, bool> typeDefs = new Dictionary<TypeDef, bool>();
|
|
|
|
|
public Dictionary<TypeRef, bool> typeRefs = new Dictionary<TypeRef, bool>();
|
|
|
|
|
public Dictionary<TypeSig, bool> typeSigs = new Dictionary<TypeSig, bool>();
|
|
|
|
|
public Dictionary<TypeSpec, bool> typeSpecs = new Dictionary<TypeSpec, bool>();
|
|
|
|
|
public Dictionary<ExportedType, bool> exportedTypes = new Dictionary<ExportedType, bool>();
|
2011-11-15 21:26:51 +08:00
|
|
|
|
|
2012-11-02 22:57:11 +08:00
|
|
|
|
Stack<object> objectStack;
|
|
|
|
|
ModuleDef validModule;
|
2011-11-15 21:26:51 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
public void RemoveTypeDef(TypeDef td) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (!typeDefs.Remove(td))
|
|
|
|
|
throw new ApplicationException(string.Format("Could not remove TypeDef: {0}", td));
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
public void RemoveEventDef(EventDef ed) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (!eventDefs.Remove(ed))
|
|
|
|
|
throw new ApplicationException(string.Format("Could not remove EventDef: {0}", ed));
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
public void RemoveFieldDef(FieldDef fd) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (!fieldDefs.Remove(fd))
|
|
|
|
|
throw new ApplicationException(string.Format("Could not remove FieldDef: {0}", fd));
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
public void RemoveMethodDef(MethodDef md) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (!methodDefs.Remove(md))
|
|
|
|
|
throw new ApplicationException(string.Format("Could not remove MethodDef: {0}", md));
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
public void RemovePropertyDef(PropertyDef pd) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (!propertyDefs.Remove(pd))
|
|
|
|
|
throw new ApplicationException(string.Format("Could not remove PropertyDef: {0}", pd));
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
public void FindAll(ModuleDef module) {
|
2012-01-08 08:30:57 +08:00
|
|
|
|
validModule = module;
|
|
|
|
|
|
2011-11-15 21:26:51 +08:00
|
|
|
|
// This needs to be big. About 2048 entries should be enough for most though...
|
2012-11-02 22:57:11 +08:00
|
|
|
|
objectStack = new Stack<object>(0x1000);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(module);
|
|
|
|
|
ProcessAll();
|
2011-11-15 21:26:51 +08:00
|
|
|
|
|
2012-11-02 22:57:11 +08:00
|
|
|
|
objectStack = null;
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Push(object mr) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (mr == null)
|
2012-01-08 08:30:57 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
objectStack.Push(mr);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void ProcessAll() {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
while (objectStack.Count > 0) {
|
|
|
|
|
var o = objectStack.Pop();
|
2013-01-19 20:03:57 +08:00
|
|
|
|
switch (GetObjectType(o)) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
case ObjectType.Unknown: break;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
case ObjectType.EventDef: Add((EventDef)o); break;
|
|
|
|
|
case ObjectType.FieldDef: Add((FieldDef)o); break;
|
|
|
|
|
case ObjectType.GenericParam: Add((GenericParam)o); break;
|
|
|
|
|
case ObjectType.MemberRef: Add((MemberRef)o); break;
|
|
|
|
|
case ObjectType.MethodDef: Add((MethodDef)o); break;
|
|
|
|
|
case ObjectType.MethodSpec: Add((MethodSpec)o); break;
|
|
|
|
|
case ObjectType.PropertyDef:Add((PropertyDef)o); break;
|
|
|
|
|
case ObjectType.TypeDef: Add((TypeDef)o); break;
|
|
|
|
|
case ObjectType.TypeRef: Add((TypeRef)o); break;
|
|
|
|
|
case ObjectType.TypeSig: Add((TypeSig)o); break;
|
|
|
|
|
case ObjectType.TypeSpec: Add((TypeSpec)o); break;
|
|
|
|
|
case ObjectType.ExportedType: Add((ExportedType)o); break;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
default: throw new InvalidOperationException(string.Format("Unknown type: {0}", o.GetType()));
|
|
|
|
|
}
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-02 22:57:11 +08:00
|
|
|
|
readonly Dictionary<Type, ObjectType> toObjectType = new Dictionary<Type, ObjectType>();
|
2013-01-19 20:03:57 +08:00
|
|
|
|
ObjectType GetObjectType(object o) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (o == null)
|
|
|
|
|
return ObjectType.Unknown;
|
|
|
|
|
var type = o.GetType();
|
|
|
|
|
ObjectType mrType;
|
|
|
|
|
if (toObjectType.TryGetValue(type, out mrType))
|
|
|
|
|
return mrType;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
mrType = GetObjectType2(o);
|
2012-11-02 22:57:11 +08:00
|
|
|
|
toObjectType[type] = mrType;
|
|
|
|
|
return mrType;
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
static ObjectType GetObjectType2(object o) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (o is EventDef) return ObjectType.EventDef;
|
|
|
|
|
if (o is FieldDef) return ObjectType.FieldDef;
|
|
|
|
|
if (o is GenericParam) return ObjectType.GenericParam;
|
|
|
|
|
if (o is MemberRef) return ObjectType.MemberRef;
|
|
|
|
|
if (o is MethodDef) return ObjectType.MethodDef;
|
|
|
|
|
if (o is MethodSpec) return ObjectType.MethodSpec;
|
|
|
|
|
if (o is PropertyDef) return ObjectType.PropertyDef;
|
|
|
|
|
if (o is TypeDef) return ObjectType.TypeDef;
|
|
|
|
|
if (o is TypeRef) return ObjectType.TypeRef;
|
|
|
|
|
if (o is TypeSig) return ObjectType.TypeSig;
|
|
|
|
|
if (o is TypeSpec) return ObjectType.TypeSpec;
|
|
|
|
|
if (o is ExportedType) return ObjectType.ExportedType;
|
|
|
|
|
return ObjectType.Unknown;
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(ModuleDef mod) {
|
|
|
|
|
Push(mod.ManagedEntryPoint);
|
|
|
|
|
Add(mod.CustomAttributes);
|
|
|
|
|
Add(mod.Types);
|
|
|
|
|
Add(mod.ExportedTypes);
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (mod.IsManifestModule)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(mod.Assembly);
|
|
|
|
|
Add(mod.VTableFixups);
|
2012-11-17 03:52:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(VTableFixups fixups) {
|
2012-11-17 03:52:10 +08:00
|
|
|
|
if (fixups == null)
|
|
|
|
|
return;
|
|
|
|
|
foreach (var fixup in fixups) {
|
|
|
|
|
foreach (var method in fixup)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Push(method);
|
2012-11-17 03:52:10 +08:00
|
|
|
|
}
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(AssemblyDef asm) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (asm == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(asm.DeclSecurities);
|
|
|
|
|
Add(asm.CustomAttributes);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(CallingConventionSig sig) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (sig == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
|
|
|
|
var fs = sig as FieldSig;
|
|
|
|
|
if (fs != null) {
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(fs);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var mbs = sig as MethodBaseSig;
|
|
|
|
|
if (mbs != null) {
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(mbs);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
|
|
|
|
var ls = sig as LocalSig;
|
|
|
|
|
if (ls != null) {
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(ls);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var gims = sig as GenericInstMethodSig;
|
|
|
|
|
if (gims != null) {
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(gims);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
}
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(FieldSig sig) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (sig == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(sig.Type);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(MethodBaseSig sig) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (sig == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(sig.RetType);
|
|
|
|
|
Add(sig.Params);
|
|
|
|
|
Add(sig.ParamsAfterSentinel);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(LocalSig sig) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (sig == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(sig.Locals);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(GenericInstMethodSig sig) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (sig == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(sig.GenericArguments);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<CustomAttribute> cas) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (cas == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var ca in cas)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(ca);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(CustomAttribute ca) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (ca == null || customAttributes.ContainsKey(ca))
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
customAttributes[ca] = true;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Push(ca.Constructor);
|
|
|
|
|
Add(ca.ConstructorArguments);
|
|
|
|
|
Add(ca.NamedArguments);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<CAArgument> args) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (args == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var arg in args)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(arg);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(CAArgument arg) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
// It's a struct so can't be null
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(arg.Type);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<CANamedArgument> args) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (args == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var arg in args)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(arg);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(CANamedArgument arg) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (arg == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(arg.Type);
|
|
|
|
|
Add(arg.Argument);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<DeclSecurity> decls) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (decls == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var decl in decls)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(decl);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(DeclSecurity decl) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (decl == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(decl.CustomAttributes);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<EventDef> eds) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (eds == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var ed in eds)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(ed);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(EventDef ed) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (ed == null || eventDefs.ContainsKey(ed))
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-17 06:50:52 +08:00
|
|
|
|
if (ed.DeclaringType != null && ed.DeclaringType.Module != validModule)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
eventDefs[ed] = true;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Push(ed.EventType);
|
|
|
|
|
Add(ed.CustomAttributes);
|
|
|
|
|
Add(ed.AddMethod);
|
|
|
|
|
Add(ed.InvokeMethod);
|
|
|
|
|
Add(ed.RemoveMethod);
|
|
|
|
|
Add(ed.OtherMethods);
|
|
|
|
|
Add(ed.DeclaringType);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<FieldDef> fds) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (fds == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var fd in fds)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(fd);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(FieldDef fd) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (fd == null || fieldDefs.ContainsKey(fd))
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-17 06:50:52 +08:00
|
|
|
|
if (fd.DeclaringType != null && fd.DeclaringType.Module != validModule)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
fieldDefs[fd] = true;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(fd.CustomAttributes);
|
|
|
|
|
Add(fd.Signature);
|
|
|
|
|
Add(fd.DeclaringType);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<GenericParam> gps) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (gps == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var gp in gps)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(gp);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(GenericParam gp) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (gp == null || genericParams.ContainsKey(gp))
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
genericParams[gp] = true;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Push(gp.Owner);
|
|
|
|
|
Push(gp.Kind);
|
|
|
|
|
Add(gp.GenericParamConstraints);
|
|
|
|
|
Add(gp.CustomAttributes);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<GenericParamConstraint> gpcs) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (gpcs == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var gpc in gpcs)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(gpc);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(GenericParamConstraint gpc) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (gpc == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(gpc.Owner);
|
|
|
|
|
Push(gpc.Constraint);
|
|
|
|
|
Add(gpc.CustomAttributes);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(MemberRef mr) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (mr == null || memberRefs.ContainsKey(mr))
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-17 06:50:52 +08:00
|
|
|
|
if (mr.Module != validModule)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
memberRefs[mr] = true;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Push(mr.Class);
|
|
|
|
|
Add(mr.Signature);
|
|
|
|
|
Add(mr.CustomAttributes);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<MethodDef> methods) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (methods == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var m in methods)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(m);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(MethodDef md) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (md == null || methodDefs.ContainsKey(md))
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-17 06:50:52 +08:00
|
|
|
|
if (md.DeclaringType != null && md.DeclaringType.Module != validModule)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
methodDefs[md] = true;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(md.Signature);
|
|
|
|
|
Add(md.ParamDefs);
|
|
|
|
|
Add(md.GenericParameters);
|
|
|
|
|
Add(md.DeclSecurities);
|
|
|
|
|
Add(md.MethodBody);
|
|
|
|
|
Add(md.CustomAttributes);
|
|
|
|
|
Add(md.Overrides);
|
|
|
|
|
Add(md.DeclaringType);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(MethodBody mb) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
var cb = mb as CilBody;
|
|
|
|
|
if (cb != null)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(cb);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(CilBody cb) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (cb == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(cb.Instructions);
|
|
|
|
|
Add(cb.ExceptionHandlers);
|
|
|
|
|
Add(cb.Variables);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<Instruction> instrs) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (instrs == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-03 03:10:34 +08:00
|
|
|
|
foreach (var instr in instrs) {
|
|
|
|
|
if (instr == null)
|
|
|
|
|
continue;
|
|
|
|
|
switch (instr.OpCode.OperandType) {
|
|
|
|
|
case OperandType.InlineTok:
|
|
|
|
|
case OperandType.InlineType:
|
|
|
|
|
case OperandType.InlineMethod:
|
|
|
|
|
case OperandType.InlineField:
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Push(instr.Operand);
|
2012-11-02 22:57:11 +08:00
|
|
|
|
break;
|
2012-11-03 03:10:34 +08:00
|
|
|
|
|
|
|
|
|
case OperandType.InlineSig:
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(instr.Operand as CallingConventionSig);
|
2012-11-03 03:10:34 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OperandType.InlineVar:
|
|
|
|
|
case OperandType.ShortInlineVar:
|
|
|
|
|
var local = instr.Operand as Local;
|
|
|
|
|
if (local != null) {
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(local);
|
2012-11-03 03:10:34 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
var arg = instr.Operand as Parameter;
|
|
|
|
|
if (arg != null) {
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(arg);
|
2012-11-03 03:10:34 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<ExceptionHandler> ehs) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (ehs == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var eh in ehs)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Push(eh.CatchType);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<Local> locals) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (locals == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var local in locals)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(local);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(Local local) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (local == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(local.Type);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<Parameter> ps) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (ps == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var p in ps)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(p);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(Parameter param) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (param == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(param.Type);
|
|
|
|
|
Add(param.Method);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<ParamDef> pds) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (pds == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var pd in pds)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(pd);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(ParamDef pd) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (pd == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(pd.DeclaringMethod);
|
|
|
|
|
Add(pd.CustomAttributes);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<MethodOverride> mos) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (mos == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var mo in mos)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(mo);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(MethodOverride mo) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
// It's a struct so can't be null
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Push(mo.MethodBody);
|
|
|
|
|
Push(mo.MethodDeclaration);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(MethodSpec ms) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (ms == null || methodSpecs.ContainsKey(ms))
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-17 06:50:52 +08:00
|
|
|
|
if (ms.Method != null && ms.Method.DeclaringType != null && ms.Method.DeclaringType.Module != validModule)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
methodSpecs[ms] = true;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Push(ms.Method);
|
|
|
|
|
Add(ms.Instantiation);
|
|
|
|
|
Add(ms.CustomAttributes);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<PropertyDef> pds) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (pds == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var pd in pds)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(pd);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(PropertyDef pd) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (pd == null || propertyDefs.ContainsKey(pd))
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-17 06:50:52 +08:00
|
|
|
|
if (pd.DeclaringType != null && pd.DeclaringType.Module != validModule)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
propertyDefs[pd] = true;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(pd.Type);
|
|
|
|
|
Add(pd.CustomAttributes);
|
|
|
|
|
Add(pd.GetMethod);
|
|
|
|
|
Add(pd.SetMethod);
|
|
|
|
|
Add(pd.OtherMethods);
|
|
|
|
|
Add(pd.DeclaringType);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<TypeDef> tds) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (tds == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var td in tds)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(td);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(TypeDef td) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (td == null || typeDefs.ContainsKey(td))
|
|
|
|
|
return;
|
2012-11-17 06:50:52 +08:00
|
|
|
|
if (td.Module != validModule)
|
2012-11-02 22:57:11 +08:00
|
|
|
|
return;
|
|
|
|
|
typeDefs[td] = true;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Push(td.BaseType);
|
|
|
|
|
Add(td.Fields);
|
|
|
|
|
Add(td.Methods);
|
|
|
|
|
Add(td.GenericParameters);
|
|
|
|
|
Add(td.Interfaces);
|
|
|
|
|
Add(td.DeclSecurities);
|
|
|
|
|
Add(td.DeclaringType);
|
|
|
|
|
Add(td.Events);
|
|
|
|
|
Add(td.Properties);
|
|
|
|
|
Add(td.NestedTypes);
|
|
|
|
|
Add(td.CustomAttributes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Add(IEnumerable<InterfaceImpl> iis) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (iis == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var ii in iis)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(ii);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(InterfaceImpl ii) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (ii == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Push(ii.Interface);
|
|
|
|
|
Add(ii.CustomAttributes);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(TypeRef tr) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (tr == null || typeRefs.ContainsKey(tr))
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-17 06:50:52 +08:00
|
|
|
|
if (tr.Module != validModule)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
typeRefs[tr] = true;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Push(tr.ResolutionScope);
|
|
|
|
|
Add(tr.CustomAttributes);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<TypeSig> tss) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (tss == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var ts in tss)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(ts);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(TypeSig ts) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (ts == null || typeSigs.ContainsKey(ts))
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-17 06:50:52 +08:00
|
|
|
|
if (ts.Module != validModule)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
typeSigs[ts] = true;
|
|
|
|
|
|
|
|
|
|
for (; ts != null; ts = ts.Next) {
|
|
|
|
|
switch (ts.ElementType) {
|
|
|
|
|
case ElementType.Void:
|
|
|
|
|
case ElementType.Boolean:
|
|
|
|
|
case ElementType.Char:
|
|
|
|
|
case ElementType.I1:
|
|
|
|
|
case ElementType.U1:
|
|
|
|
|
case ElementType.I2:
|
|
|
|
|
case ElementType.U2:
|
|
|
|
|
case ElementType.I4:
|
|
|
|
|
case ElementType.U4:
|
|
|
|
|
case ElementType.I8:
|
|
|
|
|
case ElementType.U8:
|
|
|
|
|
case ElementType.R4:
|
|
|
|
|
case ElementType.R8:
|
|
|
|
|
case ElementType.String:
|
|
|
|
|
case ElementType.ValueType:
|
|
|
|
|
case ElementType.Class:
|
|
|
|
|
case ElementType.TypedByRef:
|
|
|
|
|
case ElementType.I:
|
|
|
|
|
case ElementType.U:
|
|
|
|
|
case ElementType.Object:
|
|
|
|
|
var tdrs = (TypeDefOrRefSig)ts;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Push(tdrs.TypeDefOrRef);
|
2012-11-02 22:57:11 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ElementType.FnPtr:
|
|
|
|
|
var fps = (FnPtrSig)ts;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(fps.Signature);
|
2012-11-02 22:57:11 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ElementType.GenericInst:
|
|
|
|
|
var gis = (GenericInstSig)ts;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(gis.GenericType);
|
|
|
|
|
Add(gis.GenericArguments);
|
2012-11-02 22:57:11 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ElementType.CModReqd:
|
|
|
|
|
case ElementType.CModOpt:
|
|
|
|
|
var ms = (ModifierSig)ts;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Push(ms.Modifier);
|
2012-11-02 22:57:11 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ElementType.End:
|
|
|
|
|
case ElementType.Ptr:
|
|
|
|
|
case ElementType.ByRef:
|
|
|
|
|
case ElementType.Var:
|
|
|
|
|
case ElementType.Array:
|
|
|
|
|
case ElementType.ValueArray:
|
|
|
|
|
case ElementType.R:
|
|
|
|
|
case ElementType.SZArray:
|
|
|
|
|
case ElementType.MVar:
|
|
|
|
|
case ElementType.Internal:
|
|
|
|
|
case ElementType.Module:
|
|
|
|
|
case ElementType.Sentinel:
|
|
|
|
|
case ElementType.Pinned:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(TypeSpec ts) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (ts == null || typeSpecs.ContainsKey(ts))
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-17 06:50:52 +08:00
|
|
|
|
if (ts.Module != validModule)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
typeSpecs[ts] = true;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(ts.TypeSig);
|
|
|
|
|
Add(ts.CustomAttributes);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(IEnumerable<ExportedType> ets) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (ets == null)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
foreach (var et in ets)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(et);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
2012-11-02 22:57:11 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void Add(ExportedType et) {
|
2012-11-02 22:57:11 +08:00
|
|
|
|
if (et == null || exportedTypes.ContainsKey(et))
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-17 06:50:52 +08:00
|
|
|
|
if (et.Module != validModule)
|
2011-11-15 21:26:51 +08:00
|
|
|
|
return;
|
2012-11-02 22:57:11 +08:00
|
|
|
|
exportedTypes[et] = true;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
Add(et.CustomAttributes);
|
|
|
|
|
Push(et.Implementation);
|
2011-11-15 21:26:51 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|