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
8
external/cecil/Mono.Cecil.Cil/PortablePdb.cs
vendored
8
external/cecil/Mono.Cecil.Cil/PortablePdb.cs
vendored
@@ -248,7 +248,13 @@ namespace Mono.Cecil.Cil {
|
||||
if (IsEmbedded)
|
||||
return;
|
||||
|
||||
WritePdbFile ();
|
||||
}
|
||||
|
||||
void WritePdbFile ()
|
||||
{
|
||||
WritePdbHeap ();
|
||||
|
||||
WriteTableHeap ();
|
||||
|
||||
writer.BuildMetadataTextMap ();
|
||||
@@ -291,6 +297,8 @@ namespace Mono.Cecil.Cil {
|
||||
|
||||
void WriteTableHeap ()
|
||||
{
|
||||
pdb_metadata.table_heap.string_offsets = pdb_metadata.string_heap.WriteStrings ();
|
||||
pdb_metadata.table_heap.ComputeTableInformations ();
|
||||
pdb_metadata.table_heap.WriteTableHeap ();
|
||||
}
|
||||
}
|
||||
|
163
external/cecil/Mono.Cecil.Cil/Symbols.cs
vendored
163
external/cecil/Mono.Cecil.Cil/Symbols.cs
vendored
@@ -630,16 +630,69 @@ namespace Mono.Cecil.Cil {
|
||||
}
|
||||
|
||||
#if !PCL
|
||||
public class DefaultSymbolReaderProvider : ISymbolReaderProvider {
|
||||
|
||||
readonly bool throw_if_no_symbol;
|
||||
|
||||
public DefaultSymbolReaderProvider ()
|
||||
: this (throwIfNoSymbol: true)
|
||||
{
|
||||
}
|
||||
|
||||
public DefaultSymbolReaderProvider (bool throwIfNoSymbol)
|
||||
{
|
||||
throw_if_no_symbol = throwIfNoSymbol;
|
||||
}
|
||||
|
||||
public ISymbolReader GetSymbolReader (ModuleDefinition module, string fileName)
|
||||
{
|
||||
if (module.Image.HasDebugTables ())
|
||||
return null;
|
||||
|
||||
var pdb_file_name = Mixin.GetPdbFileName (fileName);
|
||||
|
||||
if (File.Exists (pdb_file_name))
|
||||
return Mixin.IsPortablePdb (Mixin.GetPdbFileName (fileName))
|
||||
? new PortablePdbReaderProvider ().GetSymbolReader (module, fileName)
|
||||
: SymbolProvider.GetReaderProvider (SymbolKind.NativePdb).GetSymbolReader (module, fileName);
|
||||
|
||||
var mdb_file_name = Mixin.GetMdbFileName (fileName);
|
||||
if (File.Exists (mdb_file_name))
|
||||
return SymbolProvider.GetReaderProvider (SymbolKind.Mdb).GetSymbolReader (module, fileName);
|
||||
|
||||
if (throw_if_no_symbol)
|
||||
throw new FileNotFoundException (string.Format ("No symbol found for file: {0}", fileName));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream)
|
||||
{
|
||||
throw new NotSupportedException ();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !PCL
|
||||
enum SymbolKind {
|
||||
NativePdb,
|
||||
PortablePdb,
|
||||
Mdb,
|
||||
}
|
||||
|
||||
static class SymbolProvider {
|
||||
|
||||
static readonly string symbol_kind = Type.GetType ("Mono.Runtime") != null ? "Mdb" : "Pdb";
|
||||
|
||||
static SR.AssemblyName GetPlatformSymbolAssemblyName ()
|
||||
static SR.AssemblyName GetSymbolAssemblyName (SymbolKind kind)
|
||||
{
|
||||
if (kind == SymbolKind.PortablePdb)
|
||||
throw new ArgumentException ();
|
||||
|
||||
var suffix = GetSymbolNamespace (kind);
|
||||
|
||||
var cecil_name = typeof (SymbolProvider).GetAssembly ().GetName ();
|
||||
|
||||
var name = new SR.AssemblyName {
|
||||
Name = "Mono.Cecil." + symbol_kind,
|
||||
Name = cecil_name.Name + "." + suffix,
|
||||
Version = cecil_name.Version,
|
||||
};
|
||||
|
||||
@@ -648,13 +701,13 @@ namespace Mono.Cecil.Cil {
|
||||
return name;
|
||||
}
|
||||
|
||||
static Type GetPlatformType (string fullname)
|
||||
static Type GetSymbolType (SymbolKind kind, string fullname)
|
||||
{
|
||||
var type = Type.GetType (fullname);
|
||||
if (type != null)
|
||||
return type;
|
||||
|
||||
var assembly_name = GetPlatformSymbolAssemblyName ();
|
||||
var assembly_name = GetSymbolAssemblyName (kind);
|
||||
|
||||
type = Type.GetType (fullname + ", " + assembly_name.FullName);
|
||||
if (type != null)
|
||||
@@ -671,39 +724,60 @@ namespace Mono.Cecil.Cil {
|
||||
return null;
|
||||
}
|
||||
|
||||
static ISymbolReaderProvider reader_provider;
|
||||
|
||||
public static ISymbolReaderProvider GetPlatformReaderProvider ()
|
||||
public static ISymbolReaderProvider GetReaderProvider (SymbolKind kind)
|
||||
{
|
||||
if (reader_provider != null)
|
||||
return reader_provider;
|
||||
if (kind == SymbolKind.PortablePdb)
|
||||
return new PortablePdbReaderProvider ();
|
||||
|
||||
var type = GetPlatformType (GetProviderTypeName ("ReaderProvider"));
|
||||
var providerName = GetSymbolTypeName (kind, "ReaderProvider");
|
||||
var type = GetSymbolType (kind, providerName);
|
||||
if (type == null)
|
||||
return null;
|
||||
throw new TypeLoadException ("Could not find symbol provider type " + providerName);
|
||||
|
||||
return reader_provider = (ISymbolReaderProvider) Activator.CreateInstance (type);
|
||||
return (ISymbolReaderProvider) Activator.CreateInstance (type);
|
||||
}
|
||||
|
||||
static string GetProviderTypeName (string name)
|
||||
static string GetSymbolTypeName (SymbolKind kind, string name)
|
||||
{
|
||||
return "Mono.Cecil." + symbol_kind + "." + symbol_kind + name;
|
||||
return "Mono.Cecil" + "." + GetSymbolNamespace (kind) + "." + kind + name;
|
||||
}
|
||||
|
||||
static string GetSymbolNamespace (SymbolKind kind)
|
||||
{
|
||||
if (kind == SymbolKind.PortablePdb)
|
||||
return "Cil";
|
||||
if (kind == SymbolKind.NativePdb)
|
||||
return "Pdb";
|
||||
if (kind == SymbolKind.Mdb)
|
||||
return "Mdb";
|
||||
|
||||
throw new ArgumentException ();
|
||||
}
|
||||
|
||||
#if !READ_ONLY
|
||||
|
||||
static ISymbolWriterProvider writer_provider;
|
||||
|
||||
public static ISymbolWriterProvider GetPlatformWriterProvider ()
|
||||
public static ISymbolWriterProvider GetWriterProvider (SymbolKind kind)
|
||||
{
|
||||
if (writer_provider != null)
|
||||
return writer_provider;
|
||||
if (kind == SymbolKind.PortablePdb)
|
||||
return new PortablePdbWriterProvider ();
|
||||
|
||||
var type = GetPlatformType (GetProviderTypeName ("WriterProvider"));
|
||||
var type = GetSymbolType (kind, GetSymbolTypeName (kind, "WriterProvider"));
|
||||
if (type == null)
|
||||
return null;
|
||||
|
||||
return writer_provider = (ISymbolWriterProvider) Activator.CreateInstance (type);
|
||||
return (ISymbolWriterProvider) Activator.CreateInstance (type);
|
||||
}
|
||||
|
||||
public static SymbolKind GetSymbolKind (Type type)
|
||||
{
|
||||
if (type.Name.Contains (SymbolKind.PortablePdb.ToString ()))
|
||||
return SymbolKind.PortablePdb;
|
||||
if (type.Name.Contains (SymbolKind.NativePdb.ToString ()))
|
||||
return SymbolKind.NativePdb;
|
||||
if (type.Name.Contains (SymbolKind.Mdb.ToString ()))
|
||||
return SymbolKind.Mdb;
|
||||
|
||||
throw new ArgumentException ();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -726,6 +800,29 @@ namespace Mono.Cecil.Cil {
|
||||
ISymbolWriter GetSymbolWriter (ModuleDefinition module, Stream symbolStream);
|
||||
}
|
||||
|
||||
#if !PCL
|
||||
public class DefaultSymbolWriterProvider : ISymbolWriterProvider {
|
||||
|
||||
public ISymbolWriter GetSymbolWriter (ModuleDefinition module, string fileName)
|
||||
{
|
||||
var reader = module.SymbolReader;
|
||||
if (reader == null)
|
||||
throw new InvalidOperationException ();
|
||||
|
||||
if (module.Image != null && module.Image.HasDebugTables ())
|
||||
return null;
|
||||
|
||||
var reader_kind = SymbolProvider.GetSymbolKind (reader.GetType ());
|
||||
return SymbolProvider.GetWriterProvider (reader_kind).GetSymbolWriter (module, fileName);
|
||||
}
|
||||
|
||||
public ISymbolWriter GetSymbolWriter (ModuleDefinition module, Stream symbolStream)
|
||||
{
|
||||
throw new NotSupportedException ();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -744,6 +841,26 @@ namespace Mono.Cecil {
|
||||
{
|
||||
return assemblyFileName + ".mdb";
|
||||
}
|
||||
|
||||
public static bool IsPortablePdb (string fileName)
|
||||
{
|
||||
using (var file = new FileStream (fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
return IsPortablePdb (file);
|
||||
}
|
||||
|
||||
public static bool IsPortablePdb (Stream stream)
|
||||
{
|
||||
const uint ppdb_signature = 0x424a5342;
|
||||
|
||||
var position = stream.Position;
|
||||
try {
|
||||
var reader = new BinaryReader (stream);
|
||||
return reader.ReadUInt32 () == ppdb_signature;
|
||||
} finally {
|
||||
stream.Position = position;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
115
external/cecil/Mono.Cecil.Metadata/Buffers.cs
vendored
115
external/cecil/Mono.Cecil.Metadata/Buffers.cs
vendored
@@ -25,7 +25,8 @@ namespace Mono.Cecil.Metadata {
|
||||
readonly ModuleDefinition module;
|
||||
readonly MetadataBuilder metadata;
|
||||
|
||||
internal MetadataTable [] tables = new MetadataTable [Mixin.TableCount];
|
||||
readonly internal TableInformation [] table_infos = new TableInformation [Mixin.TableCount];
|
||||
readonly internal MetadataTable [] tables = new MetadataTable [Mixin.TableCount];
|
||||
|
||||
bool large_string;
|
||||
bool large_blob;
|
||||
@@ -34,6 +35,8 @@ namespace Mono.Cecil.Metadata {
|
||||
readonly int [] coded_index_sizes = new int [Mixin.CodedIndexCount];
|
||||
readonly Func<Table, int> counter;
|
||||
|
||||
internal uint [] string_offsets;
|
||||
|
||||
public override bool IsEmpty {
|
||||
get { return false; }
|
||||
}
|
||||
@@ -48,8 +51,7 @@ namespace Mono.Cecil.Metadata {
|
||||
|
||||
int GetTableLength (Table table)
|
||||
{
|
||||
var md_table = tables [(int) table];
|
||||
return md_table != null ? md_table.Length : 0;
|
||||
return (int) table_infos [(int) table].Length;
|
||||
}
|
||||
|
||||
public TTable GetTable<TTable> (Table table) where TTable : MetadataTable, new ()
|
||||
@@ -81,7 +83,7 @@ namespace Mono.Cecil.Metadata {
|
||||
|
||||
public void WriteString (uint @string)
|
||||
{
|
||||
WriteBySize (@string, large_string);
|
||||
WriteBySize (string_offsets [@string], large_string);
|
||||
}
|
||||
|
||||
public void WriteBlob (uint blob)
|
||||
@@ -96,8 +98,7 @@ namespace Mono.Cecil.Metadata {
|
||||
|
||||
public void WriteRID (uint rid, Table table)
|
||||
{
|
||||
var md_table = tables [(int) table];
|
||||
WriteBySize (rid, md_table == null ? false : md_table.IsLarge);
|
||||
WriteBySize (rid, table_infos [(int) table].IsLarge);
|
||||
}
|
||||
|
||||
int GetCodedIndexSize (CodedIndex coded_index)
|
||||
@@ -167,6 +168,24 @@ namespace Mono.Cecil.Metadata {
|
||||
return valid;
|
||||
}
|
||||
|
||||
public void ComputeTableInformations ()
|
||||
{
|
||||
if (metadata.metadata_builder != null)
|
||||
ComputeTableInformations (metadata.metadata_builder.table_heap);
|
||||
|
||||
ComputeTableInformations (metadata.table_heap);
|
||||
}
|
||||
|
||||
void ComputeTableInformations (TableHeapBuffer table_heap)
|
||||
{
|
||||
var tables = table_heap.tables;
|
||||
for (int i = 0; i < tables.Length; i++) {
|
||||
var table = tables [i];
|
||||
if (table != null && table.Length > 0)
|
||||
table_infos [i].Length = (uint) table.Length;
|
||||
}
|
||||
}
|
||||
|
||||
byte GetHeapSizes ()
|
||||
{
|
||||
byte heap_sizes = 0;
|
||||
@@ -299,7 +318,7 @@ namespace Mono.Cecil.Metadata {
|
||||
|
||||
class StringHeapBuffer : HeapBuffer {
|
||||
|
||||
readonly Dictionary<string, uint> strings = new Dictionary<string, uint> (StringComparer.Ordinal);
|
||||
protected Dictionary<string, uint> strings = new Dictionary<string, uint> (StringComparer.Ordinal);
|
||||
|
||||
public sealed override bool IsEmpty {
|
||||
get { return length <= 1; }
|
||||
@@ -311,23 +330,87 @@ namespace Mono.Cecil.Metadata {
|
||||
WriteByte (0);
|
||||
}
|
||||
|
||||
public uint GetStringIndex (string @string)
|
||||
public virtual uint GetStringIndex (string @string)
|
||||
{
|
||||
uint index;
|
||||
if (strings.TryGetValue (@string, out index))
|
||||
return index;
|
||||
|
||||
index = (uint) base.position;
|
||||
WriteString (@string);
|
||||
index = (uint) strings.Count + 1;
|
||||
strings.Add (@string, index);
|
||||
return index;
|
||||
}
|
||||
|
||||
public uint [] WriteStrings ()
|
||||
{
|
||||
var sorted = SortStrings (strings);
|
||||
strings = null;
|
||||
|
||||
// Add 1 for empty string whose index and offset are both 0
|
||||
var string_offsets = new uint [sorted.Count + 1];
|
||||
string_offsets [0] = 0;
|
||||
|
||||
// Find strings that can be folded
|
||||
var previous = string.Empty;
|
||||
foreach (var entry in sorted) {
|
||||
var @string = entry.Key;
|
||||
var index = entry.Value;
|
||||
var position = base.position;
|
||||
|
||||
if (previous.EndsWith (@string, StringComparison.Ordinal) && !IsLowSurrogateChar (entry.Key [0])) {
|
||||
// Map over the tail of prev string. Watch for null-terminator of prev string.
|
||||
string_offsets [index] = (uint) (position - (Encoding.UTF8.GetByteCount (entry.Key) + 1));
|
||||
} else {
|
||||
string_offsets [index] = (uint) position;
|
||||
WriteString (@string);
|
||||
}
|
||||
|
||||
previous = entry.Key;
|
||||
}
|
||||
|
||||
return string_offsets;
|
||||
}
|
||||
|
||||
static List<KeyValuePair<string, uint>> SortStrings (Dictionary<string, uint> strings)
|
||||
{
|
||||
var sorted = new List<KeyValuePair<string, uint>> (strings);
|
||||
sorted.Sort (new SuffixSort ());
|
||||
return sorted;
|
||||
}
|
||||
|
||||
static bool IsLowSurrogateChar (int c)
|
||||
{
|
||||
return unchecked((uint)(c - 0xDC00)) <= 0xDFFF - 0xDC00;
|
||||
}
|
||||
|
||||
protected virtual void WriteString (string @string)
|
||||
{
|
||||
WriteBytes (Encoding.UTF8.GetBytes (@string));
|
||||
WriteByte (0);
|
||||
}
|
||||
|
||||
// Sorts strings such that a string is followed immediately by all strings
|
||||
// that are a suffix of it.
|
||||
private class SuffixSort : IComparer<KeyValuePair<string, uint>> {
|
||||
|
||||
public int Compare(KeyValuePair<string, uint> xPair, KeyValuePair<string, uint> yPair)
|
||||
{
|
||||
var x = xPair.Key;
|
||||
var y = yPair.Key;
|
||||
|
||||
for (int i = x.Length - 1, j = y.Length - 1; i >= 0 & j >= 0; i--, j--) {
|
||||
if (x [i] < y [j]) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (x [i] > y [j]) {
|
||||
return +1;
|
||||
}
|
||||
}
|
||||
|
||||
return y.Length.CompareTo (x.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sealed class BlobHeapBuffer : HeapBuffer {
|
||||
@@ -365,6 +448,18 @@ namespace Mono.Cecil.Metadata {
|
||||
|
||||
sealed class UserStringHeapBuffer : StringHeapBuffer {
|
||||
|
||||
public override uint GetStringIndex (string @string)
|
||||
{
|
||||
uint index;
|
||||
if (strings.TryGetValue (@string, out index))
|
||||
return index;
|
||||
|
||||
index = (uint) base.position;
|
||||
WriteString (@string);
|
||||
strings.Add (@string, index);
|
||||
return index;
|
||||
}
|
||||
|
||||
protected override void WriteString (string @string)
|
||||
{
|
||||
WriteCompressedUInt32 ((uint) @string.Length * 2 + 1);
|
||||
|
@@ -74,6 +74,10 @@ namespace Mono.Cecil.Metadata {
|
||||
public uint Offset;
|
||||
public uint Length;
|
||||
public uint RowSize;
|
||||
|
||||
public bool IsLarge {
|
||||
get { return Length > ushort.MaxValue; }
|
||||
}
|
||||
}
|
||||
|
||||
sealed class TableHeap : Heap {
|
||||
|
1
external/cecil/Mono.Cecil.PE/Image.cs
vendored
1
external/cecil/Mono.Cecil.PE/Image.cs
vendored
@@ -33,6 +33,7 @@ namespace Mono.Cecil.PE {
|
||||
public Section MetadataSection;
|
||||
|
||||
public uint EntryPointToken;
|
||||
public uint TimeStamp;
|
||||
public ModuleAttributes Attributes;
|
||||
|
||||
public DataDirectory Debug;
|
||||
|
20
external/cecil/Mono.Cecil.PE/ImageReader.cs
vendored
20
external/cecil/Mono.Cecil.PE/ImageReader.cs
vendored
@@ -70,10 +70,11 @@ namespace Mono.Cecil.PE {
|
||||
ushort sections = ReadUInt16 ();
|
||||
|
||||
// TimeDateStamp 4
|
||||
image.TimeStamp = ReadUInt32 ();
|
||||
// PointerToSymbolTable 4
|
||||
// NumberOfSymbols 4
|
||||
// OptionalHeaderSize 2
|
||||
Advance (14);
|
||||
Advance (10);
|
||||
|
||||
// Characteristics 2
|
||||
ushort characteristics = ReadUInt16 ();
|
||||
@@ -318,11 +319,11 @@ namespace Mono.Cecil.PE {
|
||||
for (int i = 0; i < streams; i++)
|
||||
ReadMetadataStream (section);
|
||||
|
||||
if (image.TableHeap != null)
|
||||
ReadTableHeap ();
|
||||
|
||||
if (image.PdbHeap != null)
|
||||
ReadPdbHeap ();
|
||||
|
||||
if (image.TableHeap != null)
|
||||
ReadTableHeap ();
|
||||
}
|
||||
|
||||
void ReadMetadataStream (Section section)
|
||||
@@ -393,6 +394,15 @@ namespace Mono.Cecil.PE {
|
||||
// Sorted 8
|
||||
heap.Sorted = ReadInt64 ();
|
||||
|
||||
if (image.PdbHeap != null) {
|
||||
for (int i = 0; i < Mixin.TableCount; i++) {
|
||||
if (!image.PdbHeap.HasTable ((Table) i))
|
||||
continue;
|
||||
|
||||
heap.Tables [i].Length = image.PdbHeap.TypeSystemTableRows [i];
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < Mixin.TableCount; i++) {
|
||||
if (!heap.HasTable ((Table) i))
|
||||
continue;
|
||||
@@ -430,7 +440,7 @@ namespace Mono.Cecil.PE {
|
||||
uint offset = (uint) BaseStream.Position - table_heap_offset - image.MetadataSection.PointerToRawData; // header
|
||||
|
||||
int stridx_size = image.StringHeap.IndexSize;
|
||||
int guididx_size = image.GuidHeap.IndexSize;
|
||||
int guididx_size = image.GuidHeap != null ? image.GuidHeap.IndexSize : 2;
|
||||
int blobidx_size = image.BlobHeap != null ? image.BlobHeap.IndexSize : 2;
|
||||
|
||||
var heap = image.TableHeap;
|
||||
|
4
external/cecil/Mono.Cecil.PE/ImageWriter.cs
vendored
4
external/cecil/Mono.Cecil.PE/ImageWriter.cs
vendored
@@ -108,7 +108,7 @@ namespace Mono.Cecil.PE {
|
||||
|
||||
public static ImageWriter CreateDebugWriter (ModuleDefinition module, MetadataBuilder metadata, Disposable<Stream> stream)
|
||||
{
|
||||
var writer = new ImageWriter (module, "PDB V1.0", metadata, stream, metadataOnly: true);
|
||||
var writer = new ImageWriter (module, "PDB v1.0", metadata, stream, metadataOnly: true);
|
||||
var length = metadata.text_map.GetLength ();
|
||||
writer.text = new Section { SizeOfRawData = length, VirtualSize = length };
|
||||
return writer;
|
||||
@@ -526,7 +526,7 @@ namespace Mono.Cecil.PE {
|
||||
1 // #~
|
||||
+ 1 // #Strings
|
||||
+ (metadata.user_string_heap.IsEmpty ? 0 : 1) // #US
|
||||
+ 1 // GUID
|
||||
+ (metadata.guid_heap.IsEmpty ? 0 : 1) // GUID
|
||||
+ (metadata.blob_heap.IsEmpty ? 0 : 1)
|
||||
+ (metadata.pdb_heap == null ? 0 : 1)); // #Blob
|
||||
}
|
||||
|
2
external/cecil/Mono.Cecil/AssemblyInfo.cs
vendored
2
external/cecil/Mono.Cecil/AssemblyInfo.cs
vendored
@@ -12,7 +12,7 @@ using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle ("Mono.Cecil")]
|
||||
[assembly: AssemblyTitle (Consts.AssemblyName)]
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
[assembly: Guid ("fd225bb4-fa53-44b2-a6db-85f5e48dcb54")]
|
||||
|
@@ -238,8 +238,7 @@ namespace Mono.Cecil {
|
||||
|
||||
public AssemblyNameReference (string name, Version version)
|
||||
{
|
||||
if (name == null)
|
||||
throw new ArgumentNullException ("name");
|
||||
Mixin.CheckName (name);
|
||||
|
||||
this.name = name;
|
||||
this.version = Mixin.CheckVersion (version);
|
||||
|
23
external/cecil/Mono.Cecil/AssemblyReader.cs
vendored
23
external/cecil/Mono.Cecil/AssemblyReader.cs
vendored
@@ -99,7 +99,7 @@ namespace Mono.Cecil {
|
||||
|
||||
#if !PCL
|
||||
if (symbol_reader_provider == null && parameters.ReadSymbols)
|
||||
symbol_reader_provider = SymbolProvider.GetPlatformReaderProvider ();
|
||||
symbol_reader_provider = new DefaultSymbolReaderProvider ();
|
||||
#endif
|
||||
|
||||
if (symbol_reader_provider != null) {
|
||||
@@ -115,7 +115,8 @@ namespace Mono.Cecil {
|
||||
var reader = symbol_reader_provider.GetSymbolReader (module, parameters.SymbolStream);
|
||||
#endif
|
||||
|
||||
module.ReadSymbols (reader);
|
||||
if (reader != null)
|
||||
module.ReadSymbols (reader);
|
||||
}
|
||||
|
||||
if (module.Image.HasDebugTables ())
|
||||
@@ -417,7 +418,7 @@ namespace Mono.Cecil {
|
||||
for (int i = 0; i < methods.Count; i++) {
|
||||
var method = methods [i];
|
||||
|
||||
if (method.HasBody && method.debug_info == null)
|
||||
if (method.HasBody && method.token.RID != 0 && method.debug_info == null)
|
||||
method.debug_info = symbol_reader.Read (method);
|
||||
}
|
||||
}
|
||||
@@ -2859,10 +2860,15 @@ namespace Mono.Cecil {
|
||||
InitializeDocuments ();
|
||||
|
||||
if (!MoveTo (Table.MethodDebugInformation, method.MetadataToken.RID))
|
||||
return new Collection<SequencePoint> ();
|
||||
return new Collection<SequencePoint> (0);
|
||||
|
||||
var document = metadata.GetDocument (ReadTableIndex (Table.Document));
|
||||
var reader = ReadSignature (ReadBlobIndex ());
|
||||
var document_index = ReadTableIndex (Table.Document);
|
||||
var signature = ReadBlobIndex ();
|
||||
if (signature == 0)
|
||||
return new Collection<SequencePoint> (0);
|
||||
|
||||
var document = metadata.GetDocument (document_index);
|
||||
var reader = ReadSignature (signature);
|
||||
|
||||
return reader.ReadSequencePoints (document);
|
||||
}
|
||||
@@ -2991,13 +2997,13 @@ namespace Mono.Cecil {
|
||||
value = Encoding.Unicode.GetString (bytes, 0, bytes.Length);
|
||||
} else
|
||||
value = null;
|
||||
} else if (type.etype == ElementType.Object) {
|
||||
value = null;
|
||||
} else if (type.IsTypeOf ("System", "Decimal")) {
|
||||
var b = signature.ReadByte ();
|
||||
value = new decimal (signature.ReadInt32 (), signature.ReadInt32 (), signature.ReadInt32 (), (b & 0x80) != 0, (byte) (b & 0x7f));
|
||||
} else if (type.IsTypeOf ("System", "DateTime")) {
|
||||
value = new DateTime (signature.ReadInt64());
|
||||
} else if (type.etype == ElementType.Object || type.etype == ElementType.None || type.etype == ElementType.Class) {
|
||||
value = null;
|
||||
} else
|
||||
value = signature.ReadConstantSignature (type.etype);
|
||||
|
||||
@@ -3055,7 +3061,6 @@ namespace Mono.Cecil {
|
||||
byte [] blob;
|
||||
int index, count;
|
||||
|
||||
|
||||
GetBlobView (signature, out blob, out index, out count);
|
||||
if (count == 0)
|
||||
return string.Empty;
|
||||
|
34
external/cecil/Mono.Cecil/AssemblyWriter.cs
vendored
34
external/cecil/Mono.Cecil/AssemblyWriter.cs
vendored
@@ -93,7 +93,7 @@ namespace Mono.Cecil {
|
||||
var symbol_writer_provider = parameters.SymbolWriterProvider;
|
||||
#if !PCL && !NET_CORE
|
||||
if (symbol_writer_provider == null && parameters.WriteSymbols)
|
||||
symbol_writer_provider = SymbolProvider.GetPlatformWriterProvider ();
|
||||
symbol_writer_provider = new DefaultSymbolWriterProvider ();
|
||||
#endif
|
||||
var symbol_writer = GetSymbolWriter (module, fq_name, symbol_writer_provider, parameters);
|
||||
|
||||
@@ -110,6 +110,7 @@ namespace Mono.Cecil {
|
||||
|
||||
var writer = ImageWriter.CreateWriter (module, metadata, stream);
|
||||
|
||||
stream.value.SetLength (0);
|
||||
writer.WriteImage ();
|
||||
|
||||
if (metadata.symbol_writer != null)
|
||||
@@ -157,7 +158,7 @@ namespace Mono.Cecil {
|
||||
public abstract int Length { get; }
|
||||
|
||||
public bool IsLarge {
|
||||
get { return Length > 65535; }
|
||||
get { return Length > ushort.MaxValue; }
|
||||
}
|
||||
|
||||
public abstract void Write (TableHeapBuffer buffer);
|
||||
@@ -866,7 +867,7 @@ namespace Mono.Cecil {
|
||||
this.module = module;
|
||||
this.text_map = CreateTextMap ();
|
||||
this.fq_name = fq_name;
|
||||
this.time_stamp = (uint) DateTime.UtcNow.Subtract (new DateTime (1970, 1, 1)).TotalSeconds;
|
||||
this.time_stamp = module.timestamp;
|
||||
this.symbol_writer_provider = symbol_writer_provider;
|
||||
|
||||
if (symbol_writer == null && module.HasImage && module.Image.HasDebugTables ()) {
|
||||
@@ -1007,6 +1008,8 @@ namespace Mono.Cecil {
|
||||
{
|
||||
BuildModule ();
|
||||
|
||||
table_heap.string_offsets = string_heap.WriteStrings ();
|
||||
table_heap.ComputeTableInformations ();
|
||||
table_heap.WriteTableHeap ();
|
||||
}
|
||||
|
||||
@@ -1265,7 +1268,7 @@ namespace Mono.Cecil {
|
||||
return;
|
||||
|
||||
AttachTokens ();
|
||||
AddTypeDefs ();
|
||||
AddTypes ();
|
||||
AddGenericParameters ();
|
||||
}
|
||||
|
||||
@@ -1274,33 +1277,33 @@ namespace Mono.Cecil {
|
||||
var types = module.Types;
|
||||
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
AttachTypeDefToken (types [i]);
|
||||
AttachTypeToken (types [i]);
|
||||
}
|
||||
|
||||
void AttachTypeDefToken (TypeDefinition type)
|
||||
void AttachTypeToken (TypeDefinition type)
|
||||
{
|
||||
type.token = new MetadataToken (TokenType.TypeDef, type_rid++);
|
||||
type.fields_range.Start = field_rid;
|
||||
type.methods_range.Start = method_rid;
|
||||
|
||||
if (type.HasFields)
|
||||
AttachFieldsDefToken (type);
|
||||
AttachFieldsToken (type);
|
||||
|
||||
if (type.HasMethods)
|
||||
AttachMethodsDefToken (type);
|
||||
AttachMethodsToken (type);
|
||||
|
||||
if (type.HasNestedTypes)
|
||||
AttachNestedTypesDefToken (type);
|
||||
AttachNestedTypesToken (type);
|
||||
}
|
||||
|
||||
void AttachNestedTypesDefToken (TypeDefinition type)
|
||||
void AttachNestedTypesToken (TypeDefinition type)
|
||||
{
|
||||
var nested_types = type.NestedTypes;
|
||||
for (int i = 0; i < nested_types.Count; i++)
|
||||
AttachTypeDefToken (nested_types [i]);
|
||||
AttachTypeToken (nested_types [i]);
|
||||
}
|
||||
|
||||
void AttachFieldsDefToken (TypeDefinition type)
|
||||
void AttachFieldsToken (TypeDefinition type)
|
||||
{
|
||||
var fields = type.Fields;
|
||||
type.fields_range.Length = (uint) fields.Count;
|
||||
@@ -1308,7 +1311,7 @@ namespace Mono.Cecil {
|
||||
fields [i].token = new MetadataToken (TokenType.Field, field_rid++);
|
||||
}
|
||||
|
||||
void AttachMethodsDefToken (TypeDefinition type)
|
||||
void AttachMethodsToken (TypeDefinition type)
|
||||
{
|
||||
var methods = type.Methods;
|
||||
type.methods_range.Length = (uint) methods.Count;
|
||||
@@ -1413,7 +1416,7 @@ namespace Mono.Cecil {
|
||||
return token;
|
||||
}
|
||||
|
||||
void AddTypeDefs ()
|
||||
void AddTypes ()
|
||||
{
|
||||
var types = module.Types;
|
||||
|
||||
@@ -2140,6 +2143,7 @@ namespace Mono.Cecil {
|
||||
case ElementType.SzArray:
|
||||
case ElementType.Class:
|
||||
case ElementType.Object:
|
||||
case ElementType.None:
|
||||
case ElementType.Var:
|
||||
case ElementType.MVar:
|
||||
signature.WriteInt32 (0);
|
||||
@@ -3216,7 +3220,7 @@ namespace Mono.Cecil {
|
||||
|
||||
#endif
|
||||
|
||||
static partial class Mixin {
|
||||
static partial class Mixin {
|
||||
|
||||
public static bool TryGetUniqueDocument (this MethodDebugInformation info, out Document document)
|
||||
{
|
||||
|
@@ -83,19 +83,6 @@ namespace Mono.Cecil {
|
||||
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 ()
|
||||
@@ -118,10 +105,8 @@ namespace Mono.Cecil {
|
||||
|
||||
public virtual AssemblyDefinition Resolve (AssemblyNameReference name, ReaderParameters parameters)
|
||||
{
|
||||
if (name == null)
|
||||
throw new ArgumentNullException ("name");
|
||||
if (parameters == null)
|
||||
parameters = new ReaderParameters ();
|
||||
Mixin.CheckName (name);
|
||||
Mixin.CheckParameters (parameters);
|
||||
|
||||
var assembly = SearchDirectory (name, directories, parameters);
|
||||
if (assembly != null)
|
||||
@@ -171,8 +156,13 @@ namespace Mono.Cecil {
|
||||
foreach (var directory in directories) {
|
||||
foreach (var extension in extensions) {
|
||||
string file = Path.Combine (directory, name.Name + extension);
|
||||
if (File.Exists (file))
|
||||
if (!File.Exists (file))
|
||||
continue;
|
||||
try {
|
||||
return GetAssembly (file, parameters);
|
||||
} catch (System.BadImageFormatException) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
4
external/cecil/Mono.Cecil/Consts.cs
vendored
Normal file
4
external/cecil/Mono.Cecil/Consts.cs
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
static class Consts
|
||||
{
|
||||
public const string AssemblyName = "Mono.Cecil";
|
||||
}
|
11
external/cecil/Mono.Cecil/CustomAttribute.cs
vendored
11
external/cecil/Mono.Cecil/CustomAttribute.cs
vendored
@@ -200,15 +200,4 @@ namespace Mono.Cecil {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -26,8 +26,7 @@ namespace Mono.Cecil {
|
||||
|
||||
public override AssemblyDefinition Resolve (AssemblyNameReference name)
|
||||
{
|
||||
if (name == null)
|
||||
throw new ArgumentNullException ("name");
|
||||
Mixin.CheckName (name);
|
||||
|
||||
AssemblyDefinition assembly;
|
||||
if (cache.TryGetValue (name.FullName, out assembly))
|
||||
|
4
external/cecil/Mono.Cecil/EventReference.cs
vendored
4
external/cecil/Mono.Cecil/EventReference.cs
vendored
@@ -28,9 +28,7 @@ namespace Mono.Cecil {
|
||||
protected EventReference (string name, TypeReference eventType)
|
||||
: base (name)
|
||||
{
|
||||
if (eventType == null)
|
||||
throw new ArgumentNullException ("eventType");
|
||||
|
||||
Mixin.CheckType (eventType, Mixin.Argument.eventType);
|
||||
event_type = eventType;
|
||||
}
|
||||
|
||||
|
6
external/cecil/Mono.Cecil/FieldReference.cs
vendored
6
external/cecil/Mono.Cecil/FieldReference.cs
vendored
@@ -37,8 +37,7 @@ namespace Mono.Cecil {
|
||||
public FieldReference (string name, TypeReference fieldType)
|
||||
: base (name)
|
||||
{
|
||||
if (fieldType == null)
|
||||
throw new ArgumentNullException ("fieldType");
|
||||
Mixin.CheckType (fieldType, Mixin.Argument.fieldType);
|
||||
|
||||
this.field_type = fieldType;
|
||||
this.token = new MetadataToken (TokenType.MemberRef);
|
||||
@@ -47,8 +46,7 @@ namespace Mono.Cecil {
|
||||
public FieldReference (string name, TypeReference fieldType, TypeReference declaringType)
|
||||
: this (name, fieldType)
|
||||
{
|
||||
if (declaringType == null)
|
||||
throw new ArgumentNullException("declaringType");
|
||||
Mixin.CheckType (declaringType, Mixin.Argument.declaringType);
|
||||
|
||||
this.DeclaringType = declaringType;
|
||||
}
|
||||
|
@@ -188,8 +188,7 @@ namespace Mono.Cecil {
|
||||
internal GenericParameter (int position, GenericParameterType type, ModuleDefinition module)
|
||||
: base (string.Empty, string.Empty)
|
||||
{
|
||||
if (module == null)
|
||||
throw new ArgumentNullException ();
|
||||
Mixin.CheckModule (module);
|
||||
|
||||
this.position = position;
|
||||
this.type = type;
|
||||
|
2
external/cecil/Mono.Cecil/Import.cs
vendored
2
external/cecil/Mono.Cecil/Import.cs
vendored
@@ -740,7 +740,7 @@ namespace Mono.Cecil {
|
||||
public static void CheckModule (ModuleDefinition module)
|
||||
{
|
||||
if (module == null)
|
||||
throw new ArgumentNullException ("module");
|
||||
throw new ArgumentNullException (Argument.module.ToString ());
|
||||
}
|
||||
|
||||
public static bool TryGetAssemblyNameReference (this ModuleDefinition module, AssemblyNameReference name_reference, out AssemblyNameReference assembly_reference)
|
||||
|
12
external/cecil/Mono.Cecil/MetadataResolver.cs
vendored
12
external/cecil/Mono.Cecil/MetadataResolver.cs
vendored
@@ -17,9 +17,6 @@ namespace Mono.Cecil {
|
||||
public interface IAssemblyResolver : IDisposable {
|
||||
AssemblyDefinition Resolve (AssemblyNameReference name);
|
||||
AssemblyDefinition Resolve (AssemblyNameReference name, ReaderParameters parameters);
|
||||
|
||||
AssemblyDefinition Resolve (string fullName);
|
||||
AssemblyDefinition Resolve (string fullName, ReaderParameters parameters);
|
||||
}
|
||||
|
||||
public interface IMetadataResolver {
|
||||
@@ -90,8 +87,7 @@ namespace Mono.Cecil {
|
||||
|
||||
public virtual TypeDefinition Resolve (TypeReference type)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException ("type");
|
||||
Mixin.CheckType (type);
|
||||
|
||||
type = type.GetElementType ();
|
||||
|
||||
@@ -162,8 +158,7 @@ namespace Mono.Cecil {
|
||||
|
||||
public virtual FieldDefinition Resolve (FieldReference field)
|
||||
{
|
||||
if (field == null)
|
||||
throw new ArgumentNullException ("field");
|
||||
Mixin.CheckField (field);
|
||||
|
||||
var type = Resolve (field.DeclaringType);
|
||||
if (type == null)
|
||||
@@ -210,8 +205,7 @@ namespace Mono.Cecil {
|
||||
|
||||
public virtual MethodDefinition Resolve (MethodReference method)
|
||||
{
|
||||
if (method == null)
|
||||
throw new ArgumentNullException ("method");
|
||||
Mixin.CheckMethod (method);
|
||||
|
||||
var type = Resolve (method.DeclaringType);
|
||||
if (type == null)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user