You've already forked linux-packaging-mono
Imported Upstream version 4.8.0.309
Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
parent
ee1447783b
commit
94b2861243
117
external/cecil/Mono.Cecil/MetadataSystem.cs
vendored
117
external/cecil/Mono.Cecil/MetadataSystem.cs
vendored
@@ -1,34 +1,17 @@
|
||||
//
|
||||
// MetadataSystem.cs
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2011 Jb Evain
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Mono.Cecil.Cil;
|
||||
using Mono.Cecil.Metadata;
|
||||
|
||||
namespace Mono.Cecil {
|
||||
@@ -58,7 +41,7 @@ namespace Mono.Cecil {
|
||||
|
||||
internal Dictionary<uint, uint []> NestedTypes;
|
||||
internal Dictionary<uint, uint> ReverseNestedTypes;
|
||||
internal Dictionary<uint, MetadataToken []> Interfaces;
|
||||
internal Dictionary<uint, Row<uint, MetadataToken> []> Interfaces;
|
||||
internal Dictionary<uint, Row<ushort, uint>> ClassLayouts;
|
||||
internal Dictionary<uint, uint> FieldLayouts;
|
||||
internal Dictionary<uint, uint> FieldRVAs;
|
||||
@@ -74,6 +57,12 @@ namespace Mono.Cecil {
|
||||
internal Dictionary<MetadataToken, Range []> GenericParameters;
|
||||
internal Dictionary<uint, MetadataToken []> GenericConstraints;
|
||||
|
||||
internal Document [] Documents;
|
||||
internal Dictionary<uint, Row<uint, Range, Range, uint, uint, uint> []> LocalScopes;
|
||||
internal ImportDebugInformation [] ImportScopes;
|
||||
internal Dictionary<uint, uint> StateMachineMethods;
|
||||
internal Dictionary<MetadataToken, Row<Guid, uint, uint> []> CustomDebugInformations;
|
||||
|
||||
static Dictionary<string, Row<ElementType, bool>> primitive_value_types;
|
||||
|
||||
static void InitializePrimitives ()
|
||||
@@ -143,23 +132,36 @@ namespace Mono.Cecil {
|
||||
|
||||
public void Clear ()
|
||||
{
|
||||
if (NestedTypes != null) NestedTypes.Clear ();
|
||||
if (ReverseNestedTypes != null) ReverseNestedTypes.Clear ();
|
||||
if (Interfaces != null) Interfaces.Clear ();
|
||||
if (ClassLayouts != null) ClassLayouts.Clear ();
|
||||
if (FieldLayouts != null) FieldLayouts.Clear ();
|
||||
if (FieldRVAs != null) FieldRVAs.Clear ();
|
||||
if (FieldMarshals != null) FieldMarshals.Clear ();
|
||||
if (Constants != null) Constants.Clear ();
|
||||
if (Overrides != null) Overrides.Clear ();
|
||||
if (CustomAttributes != null) CustomAttributes.Clear ();
|
||||
if (SecurityDeclarations != null) SecurityDeclarations.Clear ();
|
||||
if (Events != null) Events.Clear ();
|
||||
if (Properties != null) Properties.Clear ();
|
||||
if (Semantics != null) Semantics.Clear ();
|
||||
if (PInvokes != null) PInvokes.Clear ();
|
||||
if (GenericParameters != null) GenericParameters.Clear ();
|
||||
if (GenericConstraints != null) GenericConstraints.Clear ();
|
||||
if (NestedTypes != null) NestedTypes = new Dictionary<uint, uint []> (capacity: 0);
|
||||
if (ReverseNestedTypes != null) ReverseNestedTypes = new Dictionary<uint, uint> (capacity: 0);
|
||||
if (Interfaces != null) Interfaces = new Dictionary<uint, Row<uint, MetadataToken> []> (capacity: 0);
|
||||
if (ClassLayouts != null) ClassLayouts = new Dictionary<uint, Row<ushort, uint>> (capacity: 0);
|
||||
if (FieldLayouts != null) FieldLayouts = new Dictionary<uint, uint> (capacity: 0);
|
||||
if (FieldRVAs != null) FieldRVAs = new Dictionary<uint, uint> (capacity: 0);
|
||||
if (FieldMarshals != null) FieldMarshals = new Dictionary<MetadataToken, uint> (capacity: 0);
|
||||
if (Constants != null) Constants = new Dictionary<MetadataToken, Row<ElementType, uint>> (capacity: 0);
|
||||
if (Overrides != null) Overrides = new Dictionary<uint, MetadataToken []> (capacity: 0);
|
||||
if (CustomAttributes != null) CustomAttributes = new Dictionary<MetadataToken, Range []> (capacity: 0);
|
||||
if (SecurityDeclarations != null) SecurityDeclarations = new Dictionary<MetadataToken, Range []> (capacity: 0);
|
||||
if (Events != null) Events = new Dictionary<uint, Range> (capacity: 0);
|
||||
if (Properties != null) Properties = new Dictionary<uint, Range> (capacity: 0);
|
||||
if (Semantics != null) Semantics = new Dictionary<uint, Row<MethodSemanticsAttributes, MetadataToken>> (capacity: 0);
|
||||
if (PInvokes != null) PInvokes = new Dictionary<uint, Row<PInvokeAttributes, uint, uint>> (capacity: 0);
|
||||
if (GenericParameters != null) GenericParameters = new Dictionary<MetadataToken, Range []> (capacity: 0);
|
||||
if (GenericConstraints != null) GenericConstraints = new Dictionary<uint, MetadataToken []> (capacity: 0);
|
||||
|
||||
Documents = Empty<Document>.Array;
|
||||
ImportScopes = Empty<ImportDebugInformation>.Array;
|
||||
if (LocalScopes != null) LocalScopes = new Dictionary<uint, Row<uint, Range, Range, uint, uint, uint> []> (capacity: 0);
|
||||
if (StateMachineMethods != null) StateMachineMethods = new Dictionary<uint, uint> (capacity: 0);
|
||||
}
|
||||
|
||||
public AssemblyNameReference GetAssemblyNameReference (uint rid)
|
||||
{
|
||||
if (rid < 1 || rid > AssemblyReferences.Length)
|
||||
return null;
|
||||
|
||||
return AssemblyReferences [rid - 1];
|
||||
}
|
||||
|
||||
public TypeDefinition GetTypeDefinition (uint rid)
|
||||
@@ -249,7 +251,7 @@ namespace Mono.Cecil {
|
||||
|
||||
public void SetReverseNestedTypeMapping (uint nested, uint declaring)
|
||||
{
|
||||
ReverseNestedTypes.Add (nested, declaring);
|
||||
ReverseNestedTypes [nested] = declaring;
|
||||
}
|
||||
|
||||
public void RemoveReverseNestedTypeMapping (TypeDefinition type)
|
||||
@@ -257,12 +259,12 @@ namespace Mono.Cecil {
|
||||
ReverseNestedTypes.Remove (type.token.RID);
|
||||
}
|
||||
|
||||
public bool TryGetInterfaceMapping (TypeDefinition type, out MetadataToken [] mapping)
|
||||
public bool TryGetInterfaceMapping (TypeDefinition type, out Row<uint, MetadataToken> [] mapping)
|
||||
{
|
||||
return Interfaces.TryGetValue (type.token.RID, out mapping);
|
||||
}
|
||||
|
||||
public void SetInterfaceMapping (uint type_rid, MetadataToken [] mapping)
|
||||
public void SetInterfaceMapping (uint type_rid, Row<uint, MetadataToken> [] mapping)
|
||||
{
|
||||
Interfaces [type_rid] = mapping;
|
||||
}
|
||||
@@ -362,6 +364,37 @@ namespace Mono.Cecil {
|
||||
Overrides.Remove (method.token.RID);
|
||||
}
|
||||
|
||||
public Document GetDocument (uint rid)
|
||||
{
|
||||
if (rid < 1 || rid > Documents.Length)
|
||||
return null;
|
||||
|
||||
return Documents [rid - 1];
|
||||
}
|
||||
|
||||
public bool TryGetLocalScopes (MethodDefinition method, out Row<uint, Range, Range, uint, uint, uint> [] scopes)
|
||||
{
|
||||
return LocalScopes.TryGetValue (method.MetadataToken.RID, out scopes);
|
||||
}
|
||||
|
||||
public void SetLocalScopes (uint method_rid, Row<uint, Range, Range, uint, uint, uint> [] records)
|
||||
{
|
||||
LocalScopes [method_rid] = records;
|
||||
}
|
||||
|
||||
public ImportDebugInformation GetImportScope (uint rid)
|
||||
{
|
||||
if (rid < 1 || rid > ImportScopes.Length)
|
||||
return null;
|
||||
|
||||
return ImportScopes [rid - 1];
|
||||
}
|
||||
|
||||
public bool TryGetStateMachineKickOffMethod (MethodDefinition method, out uint rid)
|
||||
{
|
||||
return StateMachineMethods.TryGetValue (method.MetadataToken.RID, out rid);
|
||||
}
|
||||
|
||||
public TypeDefinition GetFieldDeclaringType (uint field_rid)
|
||||
{
|
||||
return BinaryRangeSearch (Types, field_rid, true);
|
||||
|
||||
Reference in New Issue
Block a user