You've already forked linux-packaging-mono
Imported Upstream version 5.0.0.42
Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
parent
1190d13a04
commit
6bdd276d05
141
external/linker/cecil/Mono.Cecil/ArrayType.cs
vendored
Normal file
141
external/linker/cecil/Mono.Cecil/ArrayType.cs
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using Mono.Collections.Generic;
|
||||
using MD = Mono.Cecil.Metadata;
|
||||
|
||||
namespace Mono.Cecil {
|
||||
|
||||
public struct ArrayDimension {
|
||||
|
||||
int? lower_bound;
|
||||
int? upper_bound;
|
||||
|
||||
public int? LowerBound {
|
||||
get { return lower_bound; }
|
||||
set { lower_bound = value; }
|
||||
}
|
||||
|
||||
public int? UpperBound {
|
||||
get { return upper_bound; }
|
||||
set { upper_bound = value; }
|
||||
}
|
||||
|
||||
public bool IsSized {
|
||||
get { return lower_bound.HasValue || upper_bound.HasValue; }
|
||||
}
|
||||
|
||||
public ArrayDimension (int? lowerBound, int? upperBound)
|
||||
{
|
||||
this.lower_bound = lowerBound;
|
||||
this.upper_bound = upperBound;
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return !IsSized
|
||||
? string.Empty
|
||||
: lower_bound + "..." + upper_bound;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ArrayType : TypeSpecification {
|
||||
|
||||
Collection<ArrayDimension> dimensions;
|
||||
|
||||
public Collection<ArrayDimension> Dimensions {
|
||||
get {
|
||||
if (dimensions != null)
|
||||
return dimensions;
|
||||
|
||||
dimensions = new Collection<ArrayDimension> ();
|
||||
dimensions.Add (new ArrayDimension ());
|
||||
return dimensions;
|
||||
}
|
||||
}
|
||||
|
||||
public int Rank {
|
||||
get { return dimensions == null ? 1 : dimensions.Count; }
|
||||
}
|
||||
|
||||
public bool IsVector {
|
||||
get {
|
||||
if (dimensions == null)
|
||||
return true;
|
||||
|
||||
if (dimensions.Count > 1)
|
||||
return false;
|
||||
|
||||
var dimension = dimensions [0];
|
||||
|
||||
return !dimension.IsSized;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsValueType {
|
||||
get { return false; }
|
||||
set { throw new InvalidOperationException (); }
|
||||
}
|
||||
|
||||
public override string Name {
|
||||
get { return base.Name + Suffix; }
|
||||
}
|
||||
|
||||
public override string FullName {
|
||||
get { return base.FullName + Suffix; }
|
||||
}
|
||||
|
||||
string Suffix {
|
||||
get {
|
||||
if (IsVector)
|
||||
return "[]";
|
||||
|
||||
var suffix = new StringBuilder ();
|
||||
suffix.Append ("[");
|
||||
for (int i = 0; i < dimensions.Count; i++) {
|
||||
if (i > 0)
|
||||
suffix.Append (",");
|
||||
|
||||
suffix.Append (dimensions [i].ToString ());
|
||||
}
|
||||
suffix.Append ("]");
|
||||
|
||||
return suffix.ToString ();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsArray {
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public ArrayType (TypeReference type)
|
||||
: base (type)
|
||||
{
|
||||
Mixin.CheckType (type);
|
||||
this.etype = MD.ElementType.Array;
|
||||
}
|
||||
|
||||
public ArrayType (TypeReference type, int rank)
|
||||
: this (type)
|
||||
{
|
||||
Mixin.CheckType (type);
|
||||
|
||||
if (rank == 1)
|
||||
return;
|
||||
|
||||
dimensions = new Collection<ArrayDimension> (rank);
|
||||
for (int i = 0; i < rank; i++)
|
||||
dimensions.Add (new ArrayDimension ());
|
||||
this.etype = MD.ElementType.Array;
|
||||
}
|
||||
}
|
||||
}
|
||||
198
external/linker/cecil/Mono.Cecil/AssemblyDefinition.cs
vendored
Normal file
198
external/linker/cecil/Mono.Cecil/AssemblyDefinition.cs
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using Mono.Collections.Generic;
|
||||
|
||||
namespace Mono.Cecil {
|
||||
|
||||
public sealed class AssemblyDefinition : ICustomAttributeProvider, ISecurityDeclarationProvider, IDisposable {
|
||||
|
||||
AssemblyNameDefinition name;
|
||||
|
||||
internal ModuleDefinition main_module;
|
||||
Collection<ModuleDefinition> modules;
|
||||
Collection<CustomAttribute> custom_attributes;
|
||||
Collection<SecurityDeclaration> security_declarations;
|
||||
|
||||
public AssemblyNameDefinition Name {
|
||||
get { return name; }
|
||||
set { name = value; }
|
||||
}
|
||||
|
||||
public string FullName {
|
||||
get { return name != null ? name.FullName : string.Empty; }
|
||||
}
|
||||
|
||||
public MetadataToken MetadataToken {
|
||||
get { return new MetadataToken (TokenType.Assembly, 1); }
|
||||
set { }
|
||||
}
|
||||
|
||||
public Collection<ModuleDefinition> Modules {
|
||||
get {
|
||||
if (modules != null)
|
||||
return modules;
|
||||
|
||||
if (main_module.HasImage)
|
||||
return main_module.Read (ref modules, this, (_, reader) => reader.ReadModules ());
|
||||
|
||||
return modules = new Collection<ModuleDefinition> (1) { main_module };
|
||||
}
|
||||
}
|
||||
|
||||
public ModuleDefinition MainModule {
|
||||
get { return main_module; }
|
||||
}
|
||||
|
||||
public MethodDefinition EntryPoint {
|
||||
get { return main_module.EntryPoint; }
|
||||
set { main_module.EntryPoint = value; }
|
||||
}
|
||||
|
||||
public bool HasCustomAttributes {
|
||||
get {
|
||||
if (custom_attributes != null)
|
||||
return custom_attributes.Count > 0;
|
||||
|
||||
return this.GetHasCustomAttributes (main_module);
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<CustomAttribute> CustomAttributes {
|
||||
get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, main_module)); }
|
||||
}
|
||||
|
||||
public bool HasSecurityDeclarations {
|
||||
get {
|
||||
if (security_declarations != null)
|
||||
return security_declarations.Count > 0;
|
||||
|
||||
return this.GetHasSecurityDeclarations (main_module);
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<SecurityDeclaration> SecurityDeclarations {
|
||||
get { return security_declarations ?? (this.GetSecurityDeclarations (ref security_declarations, main_module)); }
|
||||
}
|
||||
|
||||
internal AssemblyDefinition ()
|
||||
{
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
if (this.modules == null) {
|
||||
main_module.Dispose ();
|
||||
return;
|
||||
}
|
||||
|
||||
var modules = this.Modules;
|
||||
for (int i = 0; i < modules.Count; i++)
|
||||
modules [i].Dispose ();
|
||||
}
|
||||
|
||||
#if !READ_ONLY
|
||||
public static AssemblyDefinition CreateAssembly (AssemblyNameDefinition assemblyName, string moduleName, ModuleKind kind)
|
||||
{
|
||||
return CreateAssembly (assemblyName, moduleName, new ModuleParameters { Kind = kind });
|
||||
}
|
||||
|
||||
public static AssemblyDefinition CreateAssembly (AssemblyNameDefinition assemblyName, string moduleName, ModuleParameters parameters)
|
||||
{
|
||||
if (assemblyName == null)
|
||||
throw new ArgumentNullException ("assemblyName");
|
||||
if (moduleName == null)
|
||||
throw new ArgumentNullException ("moduleName");
|
||||
Mixin.CheckParameters (parameters);
|
||||
if (parameters.Kind == ModuleKind.NetModule)
|
||||
throw new ArgumentException ("kind");
|
||||
|
||||
var assembly = ModuleDefinition.CreateModule (moduleName, parameters).Assembly;
|
||||
assembly.Name = assemblyName;
|
||||
|
||||
return assembly;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !PCL
|
||||
public static AssemblyDefinition ReadAssembly (string fileName)
|
||||
{
|
||||
return ReadAssembly (ModuleDefinition.ReadModule (fileName));
|
||||
}
|
||||
|
||||
public static AssemblyDefinition ReadAssembly (string fileName, ReaderParameters parameters)
|
||||
{
|
||||
return ReadAssembly (ModuleDefinition.ReadModule (fileName, parameters));
|
||||
}
|
||||
#endif
|
||||
|
||||
public static AssemblyDefinition ReadAssembly (Stream stream)
|
||||
{
|
||||
return ReadAssembly (ModuleDefinition.ReadModule (stream));
|
||||
}
|
||||
|
||||
public static AssemblyDefinition ReadAssembly (Stream stream, ReaderParameters parameters)
|
||||
{
|
||||
return ReadAssembly (ModuleDefinition.ReadModule (stream, parameters));
|
||||
}
|
||||
|
||||
static AssemblyDefinition ReadAssembly (ModuleDefinition module)
|
||||
{
|
||||
var assembly = module.Assembly;
|
||||
if (assembly == null)
|
||||
throw new ArgumentException ();
|
||||
|
||||
return assembly;
|
||||
}
|
||||
|
||||
#if !READ_ONLY
|
||||
|
||||
#if !PCL
|
||||
public void Write (string fileName)
|
||||
{
|
||||
Write (fileName, new WriterParameters ());
|
||||
}
|
||||
|
||||
public void Write (string fileName, WriterParameters parameters)
|
||||
{
|
||||
main_module.Write (fileName, parameters);
|
||||
}
|
||||
#endif
|
||||
|
||||
public void Write ()
|
||||
{
|
||||
main_module.Write ();
|
||||
}
|
||||
|
||||
public void Write (WriterParameters parameters)
|
||||
{
|
||||
main_module.Write (parameters);
|
||||
}
|
||||
|
||||
public void Write (Stream stream)
|
||||
{
|
||||
Write (stream, new WriterParameters ());
|
||||
}
|
||||
|
||||
public void Write (Stream stream, WriterParameters parameters)
|
||||
{
|
||||
main_module.Write (stream, parameters);
|
||||
}
|
||||
#endif
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return this.FullName;
|
||||
}
|
||||
}
|
||||
}
|
||||
24
external/linker/cecil/Mono.Cecil/AssemblyFlags.cs
vendored
Normal file
24
external/linker/cecil/Mono.Cecil/AssemblyFlags.cs
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace Mono.Cecil {
|
||||
|
||||
[Flags]
|
||||
public enum AssemblyAttributes : uint {
|
||||
PublicKey = 0x0001,
|
||||
SideBySideCompatible = 0x0000,
|
||||
Retargetable = 0x0100,
|
||||
WindowsRuntime = 0x0200,
|
||||
DisableJITCompileOptimizer = 0x4000,
|
||||
EnableJITCompileTracking = 0x8000,
|
||||
}
|
||||
}
|
||||
18
external/linker/cecil/Mono.Cecil/AssemblyHashAlgorithm.cs
vendored
Normal file
18
external/linker/cecil/Mono.Cecil/AssemblyHashAlgorithm.cs
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
namespace Mono.Cecil {
|
||||
|
||||
public enum AssemblyHashAlgorithm : uint {
|
||||
None = 0x0000,
|
||||
Reserved = 0x8003, // MD5
|
||||
SHA1 = 0x8004
|
||||
}
|
||||
}
|
||||
24
external/linker/cecil/Mono.Cecil/AssemblyInfo.cs
vendored
Normal file
24
external/linker/cecil/Mono.Cecil/AssemblyInfo.cs
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle ("Mono.Cecil")]
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
[assembly: Guid ("fd225bb4-fa53-44b2-a6db-85f5e48dcb54")]
|
||||
#endif
|
||||
|
||||
[assembly: InternalsVisibleTo ("Mono.Cecil.Pdb, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
|
||||
[assembly: InternalsVisibleTo ("Mono.Cecil.Mdb, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
|
||||
[assembly: InternalsVisibleTo ("Mono.Cecil.Rocks, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
|
||||
[assembly: InternalsVisibleTo ("Mono.Cecil.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
|
||||
39
external/linker/cecil/Mono.Cecil/AssemblyLinkedResource.cs
vendored
Normal file
39
external/linker/cecil/Mono.Cecil/AssemblyLinkedResource.cs
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace Mono.Cecil {
|
||||
|
||||
public sealed class AssemblyLinkedResource : Resource {
|
||||
|
||||
AssemblyNameReference reference;
|
||||
|
||||
public AssemblyNameReference Assembly {
|
||||
get { return reference; }
|
||||
set { reference = value; }
|
||||
}
|
||||
|
||||
public override ResourceType ResourceType {
|
||||
get { return ResourceType.AssemblyLinked; }
|
||||
}
|
||||
|
||||
public AssemblyLinkedResource (string name, ManifestResourceAttributes flags)
|
||||
: base (name, flags)
|
||||
{
|
||||
}
|
||||
|
||||
public AssemblyLinkedResource (string name, ManifestResourceAttributes flags, AssemblyNameReference reference)
|
||||
: base (name, flags)
|
||||
{
|
||||
this.reference = reference;
|
||||
}
|
||||
}
|
||||
}
|
||||
32
external/linker/cecil/Mono.Cecil/AssemblyNameDefinition.cs
vendored
Normal file
32
external/linker/cecil/Mono.Cecil/AssemblyNameDefinition.cs
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace Mono.Cecil {
|
||||
|
||||
public sealed class AssemblyNameDefinition : AssemblyNameReference {
|
||||
|
||||
public override byte [] Hash {
|
||||
get { return Empty<byte>.Array; }
|
||||
}
|
||||
|
||||
internal AssemblyNameDefinition ()
|
||||
{
|
||||
this.token = new MetadataToken (TokenType.Assembly, 1);
|
||||
}
|
||||
|
||||
public AssemblyNameDefinition (string name, Version version)
|
||||
: base (name, version)
|
||||
{
|
||||
this.token = new MetadataToken (TokenType.Assembly, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
274
external/linker/cecil/Mono.Cecil/AssemblyNameReference.cs
vendored
Normal file
274
external/linker/cecil/Mono.Cecil/AssemblyNameReference.cs
vendored
Normal file
@@ -0,0 +1,274 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Cecil {
|
||||
|
||||
public class AssemblyNameReference : IMetadataScope {
|
||||
|
||||
string name;
|
||||
string culture;
|
||||
Version version;
|
||||
uint attributes;
|
||||
byte [] public_key;
|
||||
byte [] public_key_token;
|
||||
AssemblyHashAlgorithm hash_algorithm;
|
||||
byte [] hash;
|
||||
|
||||
internal MetadataToken token;
|
||||
|
||||
string full_name;
|
||||
|
||||
public string Name {
|
||||
get { return name; }
|
||||
set {
|
||||
name = value;
|
||||
full_name = null;
|
||||
}
|
||||
}
|
||||
|
||||
public string Culture {
|
||||
get { return culture; }
|
||||
set {
|
||||
culture = value;
|
||||
full_name = null;
|
||||
}
|
||||
}
|
||||
|
||||
public Version Version {
|
||||
get { return version; }
|
||||
set {
|
||||
version = Mixin.CheckVersion (value);
|
||||
full_name = null;
|
||||
}
|
||||
}
|
||||
|
||||
public AssemblyAttributes Attributes {
|
||||
get { return (AssemblyAttributes) attributes; }
|
||||
set { attributes = (uint) value; }
|
||||
}
|
||||
|
||||
public bool HasPublicKey {
|
||||
get { return attributes.GetAttributes ((uint) AssemblyAttributes.PublicKey); }
|
||||
set { attributes = attributes.SetAttributes ((uint) AssemblyAttributes.PublicKey, value); }
|
||||
}
|
||||
|
||||
public bool IsSideBySideCompatible {
|
||||
get { return attributes.GetAttributes ((uint) AssemblyAttributes.SideBySideCompatible); }
|
||||
set { attributes = attributes.SetAttributes ((uint) AssemblyAttributes.SideBySideCompatible, value); }
|
||||
}
|
||||
|
||||
public bool IsRetargetable {
|
||||
get { return attributes.GetAttributes ((uint) AssemblyAttributes.Retargetable); }
|
||||
set { attributes = attributes.SetAttributes ((uint) AssemblyAttributes.Retargetable, value); }
|
||||
}
|
||||
|
||||
public bool IsWindowsRuntime {
|
||||
get { return attributes.GetAttributes ((uint) AssemblyAttributes.WindowsRuntime); }
|
||||
set { attributes = attributes.SetAttributes ((uint) AssemblyAttributes.WindowsRuntime, value); }
|
||||
}
|
||||
|
||||
public byte [] PublicKey {
|
||||
get { return public_key ?? Empty<byte>.Array; }
|
||||
set {
|
||||
public_key = value;
|
||||
HasPublicKey = !public_key.IsNullOrEmpty ();
|
||||
public_key_token = Empty<byte>.Array;
|
||||
full_name = null;
|
||||
}
|
||||
}
|
||||
|
||||
public byte [] PublicKeyToken {
|
||||
get {
|
||||
if (public_key_token.IsNullOrEmpty () && !public_key.IsNullOrEmpty ()) {
|
||||
var hash = HashPublicKey ();
|
||||
// we need the last 8 bytes in reverse order
|
||||
var local_public_key_token = new byte [8];
|
||||
Array.Copy (hash, (hash.Length - 8), local_public_key_token, 0, 8);
|
||||
Array.Reverse (local_public_key_token, 0, 8);
|
||||
public_key_token = local_public_key_token; // publish only once finished (required for thread-safety)
|
||||
}
|
||||
return public_key_token ?? Empty<byte>.Array;
|
||||
}
|
||||
set {
|
||||
public_key_token = value;
|
||||
full_name = null;
|
||||
}
|
||||
}
|
||||
|
||||
byte [] HashPublicKey ()
|
||||
{
|
||||
#if !PCL
|
||||
HashAlgorithm algorithm;
|
||||
|
||||
switch (hash_algorithm) {
|
||||
case AssemblyHashAlgorithm.Reserved:
|
||||
algorithm = MD5.Create ();
|
||||
break;
|
||||
default:
|
||||
// None default to SHA1
|
||||
algorithm = SHA1.Create ();
|
||||
break;
|
||||
}
|
||||
|
||||
using (algorithm)
|
||||
return algorithm.ComputeHash (public_key);
|
||||
#else
|
||||
if (hash_algorithm != AssemblyHashAlgorithm.SHA1)
|
||||
throw new NotSupportedException ();
|
||||
|
||||
return new SHA1Managed ().ComputeHash (public_key);
|
||||
#endif
|
||||
}
|
||||
|
||||
public virtual MetadataScopeType MetadataScopeType {
|
||||
get { return MetadataScopeType.AssemblyNameReference; }
|
||||
}
|
||||
|
||||
public string FullName {
|
||||
get {
|
||||
if (full_name != null)
|
||||
return full_name;
|
||||
|
||||
const string sep = ", ";
|
||||
|
||||
var builder = new StringBuilder ();
|
||||
builder.Append (name);
|
||||
builder.Append (sep);
|
||||
builder.Append ("Version=");
|
||||
builder.Append (version.ToString (fieldCount: 4));
|
||||
builder.Append (sep);
|
||||
builder.Append ("Culture=");
|
||||
builder.Append (string.IsNullOrEmpty (culture) ? "neutral" : culture);
|
||||
builder.Append (sep);
|
||||
builder.Append ("PublicKeyToken=");
|
||||
|
||||
var pk_token = PublicKeyToken;
|
||||
if (!pk_token.IsNullOrEmpty () && pk_token.Length > 0) {
|
||||
for (int i = 0 ; i < pk_token.Length ; i++) {
|
||||
builder.Append (pk_token [i].ToString ("x2"));
|
||||
}
|
||||
} else
|
||||
builder.Append ("null");
|
||||
|
||||
if (IsRetargetable) {
|
||||
builder.Append (sep);
|
||||
builder.Append ("Retargetable=Yes");
|
||||
}
|
||||
|
||||
return full_name = builder.ToString ();
|
||||
}
|
||||
}
|
||||
|
||||
public static AssemblyNameReference Parse (string fullName)
|
||||
{
|
||||
if (fullName == null)
|
||||
throw new ArgumentNullException ("fullName");
|
||||
if (fullName.Length == 0)
|
||||
throw new ArgumentException ("Name can not be empty");
|
||||
|
||||
var name = new AssemblyNameReference ();
|
||||
var tokens = fullName.Split (',');
|
||||
for (int i = 0; i < tokens.Length; i++) {
|
||||
var token = tokens [i].Trim ();
|
||||
|
||||
if (i == 0) {
|
||||
name.Name = token;
|
||||
continue;
|
||||
}
|
||||
|
||||
var parts = token.Split ('=');
|
||||
if (parts.Length != 2)
|
||||
throw new ArgumentException ("Malformed name");
|
||||
|
||||
switch (parts [0].ToLowerInvariant ()) {
|
||||
case "version":
|
||||
name.Version = new Version (parts [1]);
|
||||
break;
|
||||
case "culture":
|
||||
name.Culture = parts [1] == "neutral" ? "" : parts [1];
|
||||
break;
|
||||
case "publickeytoken":
|
||||
var pk_token = parts [1];
|
||||
if (pk_token == "null")
|
||||
break;
|
||||
|
||||
name.PublicKeyToken = new byte [pk_token.Length / 2];
|
||||
for (int j = 0; j < name.PublicKeyToken.Length; j++)
|
||||
name.PublicKeyToken [j] = Byte.Parse (pk_token.Substring (j * 2, 2), NumberStyles.HexNumber);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public AssemblyHashAlgorithm HashAlgorithm {
|
||||
get { return hash_algorithm; }
|
||||
set { hash_algorithm = value; }
|
||||
}
|
||||
|
||||
public virtual byte [] Hash {
|
||||
get { return hash; }
|
||||
set { hash = value; }
|
||||
}
|
||||
|
||||
public MetadataToken MetadataToken {
|
||||
get { return token; }
|
||||
set { token = value; }
|
||||
}
|
||||
|
||||
internal AssemblyNameReference ()
|
||||
{
|
||||
this.version = Mixin.ZeroVersion;
|
||||
this.token = new MetadataToken (TokenType.AssemblyRef);
|
||||
}
|
||||
|
||||
public AssemblyNameReference (string name, Version version)
|
||||
{
|
||||
if (name == null)
|
||||
throw new ArgumentNullException ("name");
|
||||
|
||||
this.name = name;
|
||||
this.version = Mixin.CheckVersion (version);
|
||||
this.hash_algorithm = AssemblyHashAlgorithm.None;
|
||||
this.token = new MetadataToken (TokenType.AssemblyRef);
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return this.FullName;
|
||||
}
|
||||
}
|
||||
|
||||
partial class Mixin {
|
||||
|
||||
public static Version ZeroVersion = new Version (0, 0, 0 ,0);
|
||||
|
||||
public static Version CheckVersion (Version version)
|
||||
{
|
||||
if (version == null)
|
||||
return ZeroVersion;
|
||||
|
||||
if (version.Build == -1)
|
||||
return new Version (version.Major, version.Minor, 0, 0);
|
||||
|
||||
if (version.Revision == -1)
|
||||
return new Version (version.Major, version.Minor, version.Build, 0);
|
||||
|
||||
return version;
|
||||
}
|
||||
}
|
||||
}
|
||||
3809
external/linker/cecil/Mono.Cecil/AssemblyReader.cs
vendored
Normal file
3809
external/linker/cecil/Mono.Cecil/AssemblyReader.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3234
external/linker/cecil/Mono.Cecil/AssemblyWriter.cs
vendored
Normal file
3234
external/linker/cecil/Mono.Cecil/AssemblyWriter.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
356
external/linker/cecil/Mono.Cecil/BaseAssemblyResolver.cs
vendored
Normal file
356
external/linker/cecil/Mono.Cecil/BaseAssemblyResolver.cs
vendored
Normal file
@@ -0,0 +1,356 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
using Mono.Collections.Generic;
|
||||
|
||||
namespace Mono.Cecil {
|
||||
|
||||
public delegate AssemblyDefinition AssemblyResolveEventHandler (object sender, AssemblyNameReference reference);
|
||||
|
||||
public sealed class AssemblyResolveEventArgs : EventArgs {
|
||||
|
||||
readonly AssemblyNameReference reference;
|
||||
|
||||
public AssemblyNameReference AssemblyReference {
|
||||
get { return reference; }
|
||||
}
|
||||
|
||||
public AssemblyResolveEventArgs (AssemblyNameReference reference)
|
||||
{
|
||||
this.reference = reference;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class AssemblyResolutionException : FileNotFoundException {
|
||||
|
||||
readonly AssemblyNameReference reference;
|
||||
|
||||
public AssemblyNameReference AssemblyReference {
|
||||
get { return reference; }
|
||||
}
|
||||
|
||||
public AssemblyResolutionException (AssemblyNameReference reference)
|
||||
: base (string.Format ("Failed to resolve assembly: '{0}'", reference))
|
||||
{
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
AssemblyResolutionException (
|
||||
System.Runtime.Serialization.SerializationInfo info,
|
||||
System.Runtime.Serialization.StreamingContext context)
|
||||
: base (info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class BaseAssemblyResolver : IAssemblyResolver {
|
||||
|
||||
static readonly bool on_mono = Type.GetType ("Mono.Runtime") != null;
|
||||
|
||||
readonly Collection<string> directories;
|
||||
|
||||
Collection<string> gac_paths;
|
||||
|
||||
public void AddSearchDirectory (string directory)
|
||||
{
|
||||
directories.Add (directory);
|
||||
}
|
||||
|
||||
public void RemoveSearchDirectory (string directory)
|
||||
{
|
||||
directories.Remove (directory);
|
||||
}
|
||||
|
||||
public string [] GetSearchDirectories ()
|
||||
{
|
||||
var directories = new string [this.directories.size];
|
||||
Array.Copy (this.directories.items, directories, directories.Length);
|
||||
return directories;
|
||||
}
|
||||
|
||||
public virtual AssemblyDefinition Resolve (string fullName)
|
||||
{
|
||||
return Resolve (fullName, new ReaderParameters ());
|
||||
}
|
||||
|
||||
public virtual AssemblyDefinition Resolve (string fullName, ReaderParameters parameters)
|
||||
{
|
||||
if (fullName == null)
|
||||
throw new ArgumentNullException ("fullName");
|
||||
|
||||
return Resolve (AssemblyNameReference.Parse (fullName), parameters);
|
||||
}
|
||||
|
||||
public event AssemblyResolveEventHandler ResolveFailure;
|
||||
|
||||
protected BaseAssemblyResolver ()
|
||||
{
|
||||
directories = new Collection<string> (2) { ".", "bin" };
|
||||
}
|
||||
|
||||
AssemblyDefinition GetAssembly (string file, ReaderParameters parameters)
|
||||
{
|
||||
if (parameters.AssemblyResolver == null)
|
||||
parameters.AssemblyResolver = this;
|
||||
|
||||
return ModuleDefinition.ReadModule (file, parameters).Assembly;
|
||||
}
|
||||
|
||||
public virtual AssemblyDefinition Resolve (AssemblyNameReference name)
|
||||
{
|
||||
return Resolve (name, new ReaderParameters ());
|
||||
}
|
||||
|
||||
public virtual AssemblyDefinition Resolve (AssemblyNameReference name, ReaderParameters parameters)
|
||||
{
|
||||
if (name == null)
|
||||
throw new ArgumentNullException ("name");
|
||||
if (parameters == null)
|
||||
parameters = new ReaderParameters ();
|
||||
|
||||
var assembly = SearchDirectory (name, directories, parameters);
|
||||
if (assembly != null)
|
||||
return assembly;
|
||||
|
||||
if (name.IsRetargetable) {
|
||||
// if the reference is retargetable, zero it
|
||||
name = new AssemblyNameReference (name.Name, Mixin.ZeroVersion) {
|
||||
PublicKeyToken = Empty<byte>.Array,
|
||||
};
|
||||
}
|
||||
|
||||
var framework_dir = Path.GetDirectoryName (typeof (object).Module.FullyQualifiedName);
|
||||
|
||||
if (IsZero (name.Version)) {
|
||||
assembly = SearchDirectory (name, new [] { framework_dir }, parameters);
|
||||
if (assembly != null)
|
||||
return assembly;
|
||||
}
|
||||
|
||||
if (name.Name == "mscorlib") {
|
||||
assembly = GetCorlib (name, parameters);
|
||||
if (assembly != null)
|
||||
return assembly;
|
||||
}
|
||||
|
||||
assembly = GetAssemblyInGac (name, parameters);
|
||||
if (assembly != null)
|
||||
return assembly;
|
||||
|
||||
assembly = SearchDirectory (name, new [] { framework_dir }, parameters);
|
||||
if (assembly != null)
|
||||
return assembly;
|
||||
|
||||
if (ResolveFailure != null) {
|
||||
assembly = ResolveFailure (this, name);
|
||||
if (assembly != null)
|
||||
return assembly;
|
||||
}
|
||||
|
||||
throw new AssemblyResolutionException (name);
|
||||
}
|
||||
|
||||
AssemblyDefinition SearchDirectory (AssemblyNameReference name, IEnumerable<string> directories, ReaderParameters parameters)
|
||||
{
|
||||
var extensions = name.IsWindowsRuntime ? new [] { ".winmd", ".dll" } : new [] { ".exe", ".dll" };
|
||||
foreach (var directory in directories) {
|
||||
foreach (var extension in extensions) {
|
||||
string file = Path.Combine (directory, name.Name + extension);
|
||||
if (File.Exists (file))
|
||||
return GetAssembly (file, parameters);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static bool IsZero (Version version)
|
||||
{
|
||||
return version.Major == 0 && version.Minor == 0 && version.Build == 0 && version.Revision == 0;
|
||||
}
|
||||
|
||||
AssemblyDefinition GetCorlib (AssemblyNameReference reference, ReaderParameters parameters)
|
||||
{
|
||||
var version = reference.Version;
|
||||
var corlib = typeof (object).Assembly.GetName ();
|
||||
|
||||
if (corlib.Version == version || IsZero (version))
|
||||
return GetAssembly (typeof (object).Module.FullyQualifiedName, parameters);
|
||||
|
||||
var path = Directory.GetParent (
|
||||
Directory.GetParent (
|
||||
typeof (object).Module.FullyQualifiedName).FullName
|
||||
).FullName;
|
||||
|
||||
if (on_mono) {
|
||||
if (version.Major == 1)
|
||||
path = Path.Combine (path, "1.0");
|
||||
else if (version.Major == 2) {
|
||||
if (version.MajorRevision == 5)
|
||||
path = Path.Combine (path, "2.1");
|
||||
else
|
||||
path = Path.Combine (path, "2.0");
|
||||
} else if (version.Major == 4)
|
||||
path = Path.Combine (path, "4.0");
|
||||
else
|
||||
throw new NotSupportedException ("Version not supported: " + version);
|
||||
} else {
|
||||
switch (version.Major) {
|
||||
case 1:
|
||||
if (version.MajorRevision == 3300)
|
||||
path = Path.Combine (path, "v1.0.3705");
|
||||
else
|
||||
path = Path.Combine (path, "v1.0.5000.0");
|
||||
break;
|
||||
case 2:
|
||||
path = Path.Combine (path, "v2.0.50727");
|
||||
break;
|
||||
case 4:
|
||||
path = Path.Combine (path, "v4.0.30319");
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException ("Version not supported: " + version);
|
||||
}
|
||||
}
|
||||
|
||||
var file = Path.Combine (path, "mscorlib.dll");
|
||||
if (File.Exists (file))
|
||||
return GetAssembly (file, parameters);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static Collection<string> GetGacPaths ()
|
||||
{
|
||||
if (on_mono)
|
||||
return GetDefaultMonoGacPaths ();
|
||||
|
||||
var paths = new Collection<string> (2);
|
||||
var windir = Environment.GetEnvironmentVariable ("WINDIR");
|
||||
if (windir == null)
|
||||
return paths;
|
||||
|
||||
paths.Add (Path.Combine (windir, "assembly"));
|
||||
paths.Add (Path.Combine (windir, Path.Combine ("Microsoft.NET", "assembly")));
|
||||
return paths;
|
||||
}
|
||||
|
||||
static Collection<string> GetDefaultMonoGacPaths ()
|
||||
{
|
||||
var paths = new Collection<string> (1);
|
||||
var gac = GetCurrentMonoGac ();
|
||||
if (gac != null)
|
||||
paths.Add (gac);
|
||||
|
||||
var gac_paths_env = Environment.GetEnvironmentVariable ("MONO_GAC_PREFIX");
|
||||
if (string.IsNullOrEmpty (gac_paths_env))
|
||||
return paths;
|
||||
|
||||
var prefixes = gac_paths_env.Split (Path.PathSeparator);
|
||||
foreach (var prefix in prefixes) {
|
||||
if (string.IsNullOrEmpty (prefix))
|
||||
continue;
|
||||
|
||||
var gac_path = Path.Combine (Path.Combine (Path.Combine (prefix, "lib"), "mono"), "gac");
|
||||
if (Directory.Exists (gac_path) && !paths.Contains (gac))
|
||||
paths.Add (gac_path);
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
static string GetCurrentMonoGac ()
|
||||
{
|
||||
return Path.Combine (
|
||||
Directory.GetParent (
|
||||
Path.GetDirectoryName (typeof (object).Module.FullyQualifiedName)).FullName,
|
||||
"gac");
|
||||
}
|
||||
|
||||
AssemblyDefinition GetAssemblyInGac (AssemblyNameReference reference, ReaderParameters parameters)
|
||||
{
|
||||
if (reference.PublicKeyToken == null || reference.PublicKeyToken.Length == 0)
|
||||
return null;
|
||||
|
||||
if (gac_paths == null)
|
||||
gac_paths = GetGacPaths ();
|
||||
|
||||
if (on_mono)
|
||||
return GetAssemblyInMonoGac (reference, parameters);
|
||||
|
||||
return GetAssemblyInNetGac (reference, parameters);
|
||||
}
|
||||
|
||||
AssemblyDefinition GetAssemblyInMonoGac (AssemblyNameReference reference, ReaderParameters parameters)
|
||||
{
|
||||
for (int i = 0; i < gac_paths.Count; i++) {
|
||||
var gac_path = gac_paths [i];
|
||||
var file = GetAssemblyFile (reference, string.Empty, gac_path);
|
||||
if (File.Exists (file))
|
||||
return GetAssembly (file, parameters);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
AssemblyDefinition GetAssemblyInNetGac (AssemblyNameReference reference, ReaderParameters parameters)
|
||||
{
|
||||
var gacs = new [] { "GAC_MSIL", "GAC_32", "GAC_64", "GAC" };
|
||||
var prefixes = new [] { string.Empty, "v4.0_" };
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int j = 0; j < gacs.Length; j++) {
|
||||
var gac = Path.Combine (gac_paths [i], gacs [j]);
|
||||
var file = GetAssemblyFile (reference, prefixes [i], gac);
|
||||
if (Directory.Exists (gac) && File.Exists (file))
|
||||
return GetAssembly (file, parameters);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static string GetAssemblyFile (AssemblyNameReference reference, string prefix, string gac)
|
||||
{
|
||||
var gac_folder = new StringBuilder ()
|
||||
.Append (prefix)
|
||||
.Append (reference.Version)
|
||||
.Append ("__");
|
||||
|
||||
for (int i = 0; i < reference.PublicKeyToken.Length; i++)
|
||||
gac_folder.Append (reference.PublicKeyToken [i].ToString ("x2"));
|
||||
|
||||
return Path.Combine (
|
||||
Path.Combine (
|
||||
Path.Combine (gac, reference.Name), gac_folder.ToString ()),
|
||||
reference.Name + ".dll");
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
Dispose (true);
|
||||
GC.SuppressFinalize (this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose (bool disposing)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
106
external/linker/cecil/Mono.Cecil/CallSite.cs
vendored
Normal file
106
external/linker/cecil/Mono.Cecil/CallSite.cs
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
using Mono.Collections.Generic;
|
||||
|
||||
namespace Mono.Cecil {
|
||||
|
||||
public sealed class CallSite : IMethodSignature {
|
||||
|
||||
readonly MethodReference signature;
|
||||
|
||||
public bool HasThis {
|
||||
get { return signature.HasThis; }
|
||||
set { signature.HasThis = value; }
|
||||
}
|
||||
|
||||
public bool ExplicitThis {
|
||||
get { return signature.ExplicitThis; }
|
||||
set { signature.ExplicitThis = value; }
|
||||
}
|
||||
|
||||
public MethodCallingConvention CallingConvention {
|
||||
get { return signature.CallingConvention; }
|
||||
set { signature.CallingConvention = value; }
|
||||
}
|
||||
|
||||
public bool HasParameters {
|
||||
get { return signature.HasParameters; }
|
||||
}
|
||||
|
||||
public Collection<ParameterDefinition> Parameters {
|
||||
get { return signature.Parameters; }
|
||||
}
|
||||
|
||||
public TypeReference ReturnType {
|
||||
get { return signature.MethodReturnType.ReturnType; }
|
||||
set { signature.MethodReturnType.ReturnType = value; }
|
||||
}
|
||||
|
||||
public MethodReturnType MethodReturnType {
|
||||
get { return signature.MethodReturnType; }
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get { return string.Empty; }
|
||||
set { throw new InvalidOperationException (); }
|
||||
}
|
||||
|
||||
public string Namespace {
|
||||
get { return string.Empty; }
|
||||
set { throw new InvalidOperationException (); }
|
||||
}
|
||||
|
||||
public ModuleDefinition Module {
|
||||
get { return ReturnType.Module; }
|
||||
}
|
||||
|
||||
public IMetadataScope Scope {
|
||||
get { return signature.ReturnType.Scope; }
|
||||
}
|
||||
|
||||
public MetadataToken MetadataToken {
|
||||
get { return signature.token; }
|
||||
set { signature.token = value; }
|
||||
}
|
||||
|
||||
public string FullName {
|
||||
get {
|
||||
var signature = new StringBuilder ();
|
||||
signature.Append (ReturnType.FullName);
|
||||
this.MethodSignatureFullName (signature);
|
||||
return signature.ToString ();
|
||||
}
|
||||
}
|
||||
|
||||
internal CallSite ()
|
||||
{
|
||||
this.signature = new MethodReference ();
|
||||
this.signature.token = new MetadataToken (TokenType.Signature, 0);
|
||||
}
|
||||
|
||||
public CallSite (TypeReference returnType)
|
||||
: this ()
|
||||
{
|
||||
if (returnType == null)
|
||||
throw new ArgumentNullException ("returnType");
|
||||
|
||||
this.signature.ReturnType = returnType;
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return FullName;
|
||||
}
|
||||
}
|
||||
}
|
||||
214
external/linker/cecil/Mono.Cecil/CustomAttribute.cs
vendored
Normal file
214
external/linker/cecil/Mono.Cecil/CustomAttribute.cs
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
using Mono.Collections.Generic;
|
||||
|
||||
namespace Mono.Cecil {
|
||||
|
||||
public struct CustomAttributeArgument {
|
||||
|
||||
readonly TypeReference type;
|
||||
readonly object value;
|
||||
|
||||
public TypeReference Type {
|
||||
get { return type; }
|
||||
}
|
||||
|
||||
public object Value {
|
||||
get { return value; }
|
||||
}
|
||||
|
||||
public CustomAttributeArgument (TypeReference type, object value)
|
||||
{
|
||||
Mixin.CheckType (type);
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public struct CustomAttributeNamedArgument {
|
||||
|
||||
readonly string name;
|
||||
readonly CustomAttributeArgument argument;
|
||||
|
||||
public string Name {
|
||||
get { return name; }
|
||||
}
|
||||
|
||||
public CustomAttributeArgument Argument {
|
||||
get { return argument; }
|
||||
}
|
||||
|
||||
public CustomAttributeNamedArgument (string name, CustomAttributeArgument argument)
|
||||
{
|
||||
Mixin.CheckName (name);
|
||||
this.name = name;
|
||||
this.argument = argument;
|
||||
}
|
||||
}
|
||||
|
||||
public interface ICustomAttribute {
|
||||
|
||||
TypeReference AttributeType { get; }
|
||||
|
||||
bool HasFields { get; }
|
||||
bool HasProperties { get; }
|
||||
Collection<CustomAttributeNamedArgument> Fields { get; }
|
||||
Collection<CustomAttributeNamedArgument> Properties { get; }
|
||||
}
|
||||
|
||||
public sealed class CustomAttribute : ICustomAttribute {
|
||||
|
||||
internal CustomAttributeValueProjection projection;
|
||||
readonly internal uint signature;
|
||||
internal bool resolved;
|
||||
MethodReference constructor;
|
||||
byte [] blob;
|
||||
internal Collection<CustomAttributeArgument> arguments;
|
||||
internal Collection<CustomAttributeNamedArgument> fields;
|
||||
internal Collection<CustomAttributeNamedArgument> properties;
|
||||
|
||||
public MethodReference Constructor {
|
||||
get { return constructor; }
|
||||
set { constructor = value; }
|
||||
}
|
||||
|
||||
public TypeReference AttributeType {
|
||||
get { return constructor.DeclaringType; }
|
||||
}
|
||||
|
||||
public bool IsResolved {
|
||||
get { return resolved; }
|
||||
}
|
||||
|
||||
public bool HasConstructorArguments {
|
||||
get {
|
||||
Resolve ();
|
||||
|
||||
return !arguments.IsNullOrEmpty ();
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<CustomAttributeArgument> ConstructorArguments {
|
||||
get {
|
||||
Resolve ();
|
||||
|
||||
return arguments ?? (arguments = new Collection<CustomAttributeArgument> ());
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasFields {
|
||||
get {
|
||||
Resolve ();
|
||||
|
||||
return !fields.IsNullOrEmpty ();
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<CustomAttributeNamedArgument> Fields {
|
||||
get {
|
||||
Resolve ();
|
||||
|
||||
return fields ?? (fields = new Collection<CustomAttributeNamedArgument> ());
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasProperties {
|
||||
get {
|
||||
Resolve ();
|
||||
|
||||
return !properties.IsNullOrEmpty ();
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<CustomAttributeNamedArgument> Properties {
|
||||
get {
|
||||
Resolve ();
|
||||
|
||||
return properties ?? (properties = new Collection<CustomAttributeNamedArgument> ());
|
||||
}
|
||||
}
|
||||
|
||||
internal bool HasImage {
|
||||
get { return constructor != null && constructor.HasImage; }
|
||||
}
|
||||
|
||||
internal ModuleDefinition Module {
|
||||
get { return constructor.Module; }
|
||||
}
|
||||
|
||||
internal CustomAttribute (uint signature, MethodReference constructor)
|
||||
{
|
||||
this.signature = signature;
|
||||
this.constructor = constructor;
|
||||
this.resolved = false;
|
||||
}
|
||||
|
||||
public CustomAttribute (MethodReference constructor)
|
||||
{
|
||||
this.constructor = constructor;
|
||||
this.resolved = true;
|
||||
}
|
||||
|
||||
public CustomAttribute (MethodReference constructor, byte [] blob)
|
||||
{
|
||||
this.constructor = constructor;
|
||||
this.resolved = false;
|
||||
this.blob = blob;
|
||||
}
|
||||
|
||||
public byte [] GetBlob ()
|
||||
{
|
||||
if (blob != null)
|
||||
return blob;
|
||||
|
||||
if (!HasImage)
|
||||
throw new NotSupportedException ();
|
||||
|
||||
return Module.Read (ref blob, this, (attribute, reader) => reader.ReadCustomAttributeBlob (attribute.signature));
|
||||
}
|
||||
|
||||
void Resolve ()
|
||||
{
|
||||
if (resolved || !HasImage)
|
||||
return;
|
||||
|
||||
Module.Read (this, (attribute, reader) => {
|
||||
try {
|
||||
reader.ReadCustomAttributeSignature (attribute);
|
||||
resolved = true;
|
||||
} catch (ResolutionException) {
|
||||
if (arguments != null)
|
||||
arguments.Clear ();
|
||||
if (fields != null)
|
||||
fields.Clear ();
|
||||
if (properties != null)
|
||||
properties.Clear ();
|
||||
|
||||
resolved = false;
|
||||
}
|
||||
return this;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static partial class Mixin {
|
||||
|
||||
public static void CheckName (string name)
|
||||
{
|
||||
if (name == null)
|
||||
throw new ArgumentNullException ("name");
|
||||
if (name.Length == 0)
|
||||
throw new ArgumentException ("Empty name");
|
||||
}
|
||||
}
|
||||
}
|
||||
66
external/linker/cecil/Mono.Cecil/DefaultAssemblyResolver.cs
vendored
Normal file
66
external/linker/cecil/Mono.Cecil/DefaultAssemblyResolver.cs
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Mono.Cecil {
|
||||
|
||||
public class DefaultAssemblyResolver : BaseAssemblyResolver {
|
||||
|
||||
readonly IDictionary<string, AssemblyDefinition> cache;
|
||||
|
||||
public DefaultAssemblyResolver ()
|
||||
{
|
||||
cache = new Dictionary<string, AssemblyDefinition> (StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
public override AssemblyDefinition Resolve (AssemblyNameReference name)
|
||||
{
|
||||
if (name == null)
|
||||
throw new ArgumentNullException ("name");
|
||||
|
||||
AssemblyDefinition assembly;
|
||||
if (cache.TryGetValue (name.FullName, out assembly))
|
||||
return assembly;
|
||||
|
||||
assembly = base.Resolve (name);
|
||||
cache [name.FullName] = assembly;
|
||||
|
||||
return assembly;
|
||||
}
|
||||
|
||||
protected void RegisterAssembly (AssemblyDefinition assembly)
|
||||
{
|
||||
if (assembly == null)
|
||||
throw new ArgumentNullException ("assembly");
|
||||
|
||||
var name = assembly.Name.FullName;
|
||||
if (cache.ContainsKey (name))
|
||||
return;
|
||||
|
||||
cache [name] = assembly;
|
||||
}
|
||||
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
foreach (var assembly in cache.Values)
|
||||
assembly.Dispose ();
|
||||
|
||||
cache.Clear ();
|
||||
|
||||
base.Dispose (disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
98
external/linker/cecil/Mono.Cecil/EmbeddedResource.cs
vendored
Normal file
98
external/linker/cecil/Mono.Cecil/EmbeddedResource.cs
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Mono.Cecil {
|
||||
|
||||
public sealed class EmbeddedResource : Resource {
|
||||
|
||||
readonly MetadataReader reader;
|
||||
|
||||
uint? offset;
|
||||
byte [] data;
|
||||
Stream stream;
|
||||
|
||||
public override ResourceType ResourceType {
|
||||
get { return ResourceType.Embedded; }
|
||||
}
|
||||
|
||||
public EmbeddedResource (string name, ManifestResourceAttributes attributes, byte [] data) :
|
||||
base (name, attributes)
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public EmbeddedResource (string name, ManifestResourceAttributes attributes, Stream stream) :
|
||||
base (name, attributes)
|
||||
{
|
||||
this.stream = stream;
|
||||
}
|
||||
|
||||
internal EmbeddedResource (string name, ManifestResourceAttributes attributes, uint offset, MetadataReader reader)
|
||||
: base (name, attributes)
|
||||
{
|
||||
this.offset = offset;
|
||||
this.reader = reader;
|
||||
}
|
||||
|
||||
public Stream GetResourceStream ()
|
||||
{
|
||||
if (stream != null)
|
||||
return stream;
|
||||
|
||||
if (data != null)
|
||||
return new MemoryStream (data);
|
||||
|
||||
if (offset.HasValue)
|
||||
return new MemoryStream (reader.GetManagedResource (offset.Value));
|
||||
|
||||
throw new InvalidOperationException ();
|
||||
}
|
||||
|
||||
public byte [] GetResourceData ()
|
||||
{
|
||||
if (stream != null)
|
||||
return ReadStream (stream);
|
||||
|
||||
if (data != null)
|
||||
return data;
|
||||
|
||||
if (offset.HasValue)
|
||||
return reader.GetManagedResource (offset.Value);
|
||||
|
||||
throw new InvalidOperationException ();
|
||||
}
|
||||
|
||||
static byte [] ReadStream (Stream stream)
|
||||
{
|
||||
int read;
|
||||
|
||||
if (stream.CanSeek) {
|
||||
var length = (int) stream.Length;
|
||||
var data = new byte [length];
|
||||
int offset = 0;
|
||||
|
||||
while ((read = stream.Read (data, offset, length - offset)) > 0)
|
||||
offset += read;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var buffer = new byte [1024 * 8];
|
||||
var memory = new MemoryStream ();
|
||||
while ((read = stream.Read (buffer, 0, buffer.Length)) > 0)
|
||||
memory.Write (buffer, 0, read);
|
||||
|
||||
return memory.ToArray ();
|
||||
}
|
||||
}
|
||||
}
|
||||
21
external/linker/cecil/Mono.Cecil/EventAttributes.cs
vendored
Normal file
21
external/linker/cecil/Mono.Cecil/EventAttributes.cs
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace Mono.Cecil {
|
||||
|
||||
[Flags]
|
||||
public enum EventAttributes : ushort {
|
||||
None = 0x0000,
|
||||
SpecialName = 0x0200, // Event is special
|
||||
RTSpecialName = 0x0400 // CLI provides 'special' behavior, depending upon the name of the event
|
||||
}
|
||||
}
|
||||
155
external/linker/cecil/Mono.Cecil/EventDefinition.cs
vendored
Normal file
155
external/linker/cecil/Mono.Cecil/EventDefinition.cs
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using Mono.Collections.Generic;
|
||||
|
||||
namespace Mono.Cecil {
|
||||
|
||||
public sealed class EventDefinition : EventReference, IMemberDefinition {
|
||||
|
||||
ushort attributes;
|
||||
|
||||
Collection<CustomAttribute> custom_attributes;
|
||||
|
||||
internal MethodDefinition add_method;
|
||||
internal MethodDefinition invoke_method;
|
||||
internal MethodDefinition remove_method;
|
||||
internal Collection<MethodDefinition> other_methods;
|
||||
|
||||
public EventAttributes Attributes {
|
||||
get { return (EventAttributes) attributes; }
|
||||
set { attributes = (ushort) value; }
|
||||
}
|
||||
|
||||
public MethodDefinition AddMethod {
|
||||
get {
|
||||
if (add_method != null)
|
||||
return add_method;
|
||||
|
||||
InitializeMethods ();
|
||||
return add_method;
|
||||
}
|
||||
set { add_method = value; }
|
||||
}
|
||||
|
||||
public MethodDefinition InvokeMethod {
|
||||
get {
|
||||
if (invoke_method != null)
|
||||
return invoke_method;
|
||||
|
||||
InitializeMethods ();
|
||||
return invoke_method;
|
||||
}
|
||||
set { invoke_method = value; }
|
||||
}
|
||||
|
||||
public MethodDefinition RemoveMethod {
|
||||
get {
|
||||
if (remove_method != null)
|
||||
return remove_method;
|
||||
|
||||
InitializeMethods ();
|
||||
return remove_method;
|
||||
}
|
||||
set { remove_method = value; }
|
||||
}
|
||||
|
||||
public bool HasOtherMethods {
|
||||
get {
|
||||
if (other_methods != null)
|
||||
return other_methods.Count > 0;
|
||||
|
||||
InitializeMethods ();
|
||||
return !other_methods.IsNullOrEmpty ();
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<MethodDefinition> OtherMethods {
|
||||
get {
|
||||
if (other_methods != null)
|
||||
return other_methods;
|
||||
|
||||
InitializeMethods ();
|
||||
|
||||
if (other_methods != null)
|
||||
return other_methods;
|
||||
|
||||
return other_methods = new Collection<MethodDefinition> ();
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasCustomAttributes {
|
||||
get {
|
||||
if (custom_attributes != null)
|
||||
return custom_attributes.Count > 0;
|
||||
|
||||
return this.GetHasCustomAttributes (Module);
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<CustomAttribute> CustomAttributes {
|
||||
get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, Module)); }
|
||||
}
|
||||
|
||||
#region EventAttributes
|
||||
|
||||
public bool IsSpecialName {
|
||||
get { return attributes.GetAttributes ((ushort) EventAttributes.SpecialName); }
|
||||
set { attributes = attributes.SetAttributes ((ushort) EventAttributes.SpecialName, value); }
|
||||
}
|
||||
|
||||
public bool IsRuntimeSpecialName {
|
||||
get { return attributes.GetAttributes ((ushort) EventAttributes.RTSpecialName); }
|
||||
set { attributes = attributes.SetAttributes ((ushort) EventAttributes.RTSpecialName, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public new TypeDefinition DeclaringType {
|
||||
get { return (TypeDefinition) base.DeclaringType; }
|
||||
set { base.DeclaringType = value; }
|
||||
}
|
||||
|
||||
public override bool IsDefinition {
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public EventDefinition (string name, EventAttributes attributes, TypeReference eventType)
|
||||
: base (name, eventType)
|
||||
{
|
||||
this.attributes = (ushort) attributes;
|
||||
this.token = new MetadataToken (TokenType.Event);
|
||||
}
|
||||
|
||||
void InitializeMethods ()
|
||||
{
|
||||
var module = this.Module;
|
||||
if (module == null)
|
||||
return;
|
||||
|
||||
lock (module.SyncRoot) {
|
||||
if (add_method != null
|
||||
|| invoke_method != null
|
||||
|| remove_method != null)
|
||||
return;
|
||||
|
||||
if (!module.HasImage ())
|
||||
return;
|
||||
|
||||
module.Read (this, (@event, reader) => reader.ReadMethods (@event));
|
||||
}
|
||||
}
|
||||
|
||||
public override EventDefinition Resolve ()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
44
external/linker/cecil/Mono.Cecil/EventReference.cs
vendored
Normal file
44
external/linker/cecil/Mono.Cecil/EventReference.cs
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace Mono.Cecil {
|
||||
|
||||
public abstract class EventReference : MemberReference {
|
||||
|
||||
TypeReference event_type;
|
||||
|
||||
public TypeReference EventType {
|
||||
get { return event_type; }
|
||||
set { event_type = value; }
|
||||
}
|
||||
|
||||
public override string FullName {
|
||||
get { return event_type.FullName + " " + MemberFullName (); }
|
||||
}
|
||||
|
||||
protected EventReference (string name, TypeReference eventType)
|
||||
: base (name)
|
||||
{
|
||||
if (eventType == null)
|
||||
throw new ArgumentNullException ("eventType");
|
||||
|
||||
event_type = eventType;
|
||||
}
|
||||
|
||||
protected override IMemberDefinition ResolveDefinition ()
|
||||
{
|
||||
return this.Resolve ();
|
||||
}
|
||||
|
||||
public new abstract EventDefinition Resolve ();
|
||||
}
|
||||
}
|
||||
232
external/linker/cecil/Mono.Cecil/ExportedType.cs
vendored
Normal file
232
external/linker/cecil/Mono.Cecil/ExportedType.cs
vendored
Normal file
@@ -0,0 +1,232 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace Mono.Cecil {
|
||||
|
||||
public sealed class ExportedType : IMetadataTokenProvider {
|
||||
|
||||
string @namespace;
|
||||
string name;
|
||||
uint attributes;
|
||||
IMetadataScope scope;
|
||||
ModuleDefinition module;
|
||||
int identifier;
|
||||
ExportedType declaring_type;
|
||||
internal MetadataToken token;
|
||||
|
||||
public string Namespace {
|
||||
get { return @namespace; }
|
||||
set { @namespace = value; }
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get { return name; }
|
||||
set { name = value; }
|
||||
}
|
||||
|
||||
public TypeAttributes Attributes {
|
||||
get { return (TypeAttributes) attributes; }
|
||||
set { attributes = (uint) value; }
|
||||
}
|
||||
|
||||
public IMetadataScope Scope {
|
||||
get {
|
||||
if (declaring_type != null)
|
||||
return declaring_type.Scope;
|
||||
|
||||
return scope;
|
||||
}
|
||||
}
|
||||
|
||||
public ExportedType DeclaringType {
|
||||
get { return declaring_type; }
|
||||
set { declaring_type = value; }
|
||||
}
|
||||
|
||||
public MetadataToken MetadataToken {
|
||||
get { return token; }
|
||||
set { token = value; }
|
||||
}
|
||||
|
||||
public int Identifier {
|
||||
get { return identifier; }
|
||||
set { identifier = value; }
|
||||
}
|
||||
|
||||
#region TypeAttributes
|
||||
|
||||
public bool IsNotPublic {
|
||||
get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NotPublic); }
|
||||
set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NotPublic, value); }
|
||||
}
|
||||
|
||||
public bool IsPublic {
|
||||
get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.Public); }
|
||||
set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.Public, value); }
|
||||
}
|
||||
|
||||
public bool IsNestedPublic {
|
||||
get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPublic); }
|
||||
set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPublic, value); }
|
||||
}
|
||||
|
||||
public bool IsNestedPrivate {
|
||||
get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPrivate); }
|
||||
set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPrivate, value); }
|
||||
}
|
||||
|
||||
public bool IsNestedFamily {
|
||||
get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamily); }
|
||||
set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamily, value); }
|
||||
}
|
||||
|
||||
public bool IsNestedAssembly {
|
||||
get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedAssembly); }
|
||||
set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedAssembly, value); }
|
||||
}
|
||||
|
||||
public bool IsNestedFamilyAndAssembly {
|
||||
get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamANDAssem); }
|
||||
set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamANDAssem, value); }
|
||||
}
|
||||
|
||||
public bool IsNestedFamilyOrAssembly {
|
||||
get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamORAssem); }
|
||||
set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamORAssem, value); }
|
||||
}
|
||||
|
||||
public bool IsAutoLayout {
|
||||
get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.AutoLayout); }
|
||||
set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.AutoLayout, value); }
|
||||
}
|
||||
|
||||
public bool IsSequentialLayout {
|
||||
get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.SequentialLayout); }
|
||||
set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.SequentialLayout, value); }
|
||||
}
|
||||
|
||||
public bool IsExplicitLayout {
|
||||
get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.ExplicitLayout); }
|
||||
set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.ExplicitLayout, value); }
|
||||
}
|
||||
|
||||
public bool IsClass {
|
||||
get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Class); }
|
||||
set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Class, value); }
|
||||
}
|
||||
|
||||
public bool IsInterface {
|
||||
get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Interface); }
|
||||
set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Interface, value); }
|
||||
}
|
||||
|
||||
public bool IsAbstract {
|
||||
get { return attributes.GetAttributes ((uint) TypeAttributes.Abstract); }
|
||||
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Abstract, value); }
|
||||
}
|
||||
|
||||
public bool IsSealed {
|
||||
get { return attributes.GetAttributes ((uint) TypeAttributes.Sealed); }
|
||||
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Sealed, value); }
|
||||
}
|
||||
|
||||
public bool IsSpecialName {
|
||||
get { return attributes.GetAttributes ((uint) TypeAttributes.SpecialName); }
|
||||
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.SpecialName, value); }
|
||||
}
|
||||
|
||||
public bool IsImport {
|
||||
get { return attributes.GetAttributes ((uint) TypeAttributes.Import); }
|
||||
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Import, value); }
|
||||
}
|
||||
|
||||
public bool IsSerializable {
|
||||
get { return attributes.GetAttributes ((uint) TypeAttributes.Serializable); }
|
||||
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Serializable, value); }
|
||||
}
|
||||
|
||||
public bool IsAnsiClass {
|
||||
get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AnsiClass); }
|
||||
set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AnsiClass, value); }
|
||||
}
|
||||
|
||||
public bool IsUnicodeClass {
|
||||
get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.UnicodeClass); }
|
||||
set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.UnicodeClass, value); }
|
||||
}
|
||||
|
||||
public bool IsAutoClass {
|
||||
get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AutoClass); }
|
||||
set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AutoClass, value); }
|
||||
}
|
||||
|
||||
public bool IsBeforeFieldInit {
|
||||
get { return attributes.GetAttributes ((uint) TypeAttributes.BeforeFieldInit); }
|
||||
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.BeforeFieldInit, value); }
|
||||
}
|
||||
|
||||
public bool IsRuntimeSpecialName {
|
||||
get { return attributes.GetAttributes ((uint) TypeAttributes.RTSpecialName); }
|
||||
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.RTSpecialName, value); }
|
||||
}
|
||||
|
||||
public bool HasSecurity {
|
||||
get { return attributes.GetAttributes ((uint) TypeAttributes.HasSecurity); }
|
||||
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.HasSecurity, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public bool IsForwarder {
|
||||
get { return attributes.GetAttributes ((uint) TypeAttributes.Forwarder); }
|
||||
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Forwarder, value); }
|
||||
}
|
||||
|
||||
public string FullName {
|
||||
get {
|
||||
var fullname = string.IsNullOrEmpty (@namespace)
|
||||
? name
|
||||
: @namespace + '.' + name;
|
||||
|
||||
if (declaring_type != null)
|
||||
return declaring_type.FullName + "/" + fullname;
|
||||
|
||||
return fullname;
|
||||
}
|
||||
}
|
||||
|
||||
public ExportedType (string @namespace, string name, ModuleDefinition module, IMetadataScope scope)
|
||||
{
|
||||
this.@namespace = @namespace;
|
||||
this.name = name;
|
||||
this.scope = scope;
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return FullName;
|
||||
}
|
||||
|
||||
public TypeDefinition Resolve ()
|
||||
{
|
||||
return module.Resolve (CreateReference ());
|
||||
}
|
||||
|
||||
internal TypeReference CreateReference ()
|
||||
{
|
||||
return new TypeReference (@namespace, name, module, scope) {
|
||||
DeclaringType = declaring_type != null ? declaring_type.CreateReference () : null,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
41
external/linker/cecil/Mono.Cecil/FieldAttributes.cs
vendored
Normal file
41
external/linker/cecil/Mono.Cecil/FieldAttributes.cs
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace Mono.Cecil {
|
||||
|
||||
[Flags]
|
||||
public enum FieldAttributes : ushort {
|
||||
FieldAccessMask = 0x0007,
|
||||
CompilerControlled = 0x0000, // Member not referenceable
|
||||
Private = 0x0001, // Accessible only by the parent type
|
||||
FamANDAssem = 0x0002, // Accessible by sub-types only in this assembly
|
||||
Assembly = 0x0003, // Accessible by anyone in the Assembly
|
||||
Family = 0x0004, // Accessible only by type and sub-types
|
||||
FamORAssem = 0x0005, // Accessible by sub-types anywhere, plus anyone in the assembly
|
||||
Public = 0x0006, // Accessible by anyone who has visibility to this scope field contract attributes
|
||||
|
||||
Static = 0x0010, // Defined on type, else per instance
|
||||
InitOnly = 0x0020, // Field may only be initialized, not written after init
|
||||
Literal = 0x0040, // Value is compile time constant
|
||||
NotSerialized = 0x0080, // Field does not have to be serialized when type is remoted
|
||||
SpecialName = 0x0200, // Field is special
|
||||
|
||||
// Interop Attributes
|
||||
PInvokeImpl = 0x2000, // Implementation is forwarded through PInvoke
|
||||
|
||||
// Additional flags
|
||||
RTSpecialName = 0x0400, // CLI provides 'special' behavior, depending upon the name of the field
|
||||
HasFieldMarshal = 0x1000, // Field has marshalling information
|
||||
HasDefault = 0x8000, // Field has default
|
||||
HasFieldRVA = 0x0100 // Field has RVA
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user