Imported Upstream version 4.2.0.179

Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
Xamarin Public Jenkins
2015-08-26 07:17:56 -04:00
committed by Jo Shields
parent 183bba2c9a
commit 6992685b86
7507 changed files with 90259 additions and 657307 deletions

View File

@@ -527,8 +527,9 @@ namespace IKVM.Reflection
name = null;
return false;
}
ns = Constructor.DeclaringType.__Namespace;
name = Constructor.DeclaringType.__Name;
TypeName typeName = AttributeType.TypeName;
ns = typeName.Namespace;
name = typeName.Name;
return true;
}

View File

@@ -668,5 +668,85 @@ namespace IKVM.Reflection.Emit
bw.WriteCustomAttributeBlob();
return bb.ToArray();
}
internal KnownCA KnownCA
{
get
{
TypeName typeName = con.DeclaringType.TypeName;
switch (typeName.Namespace)
{
case "System":
switch (typeName.Name)
{
case "SerializableAttribute":
return KnownCA.SerializableAttribute;
case "NonSerializedAttribute":
return KnownCA.NonSerializedAttribute;
}
break;
case "System.Runtime.CompilerServices":
switch (typeName.Name)
{
case "MethodImplAttribute":
return KnownCA.MethodImplAttribute;
case "SpecialNameAttribute":
return KnownCA.SpecialNameAttribute;
}
break;
case "System.Runtime.InteropServices":
switch (typeName.Name)
{
case "DllImportAttribute":
return KnownCA.DllImportAttribute;
case "ComImportAttribute":
return KnownCA.ComImportAttribute;
case "MarshalAsAttribute":
return KnownCA.MarshalAsAttribute;
case "PreserveSigAttribute":
return KnownCA.PreserveSigAttribute;
case "InAttribute":
return KnownCA.InAttribute;
case "OutAttribute":
return KnownCA.OutAttribute;
case "OptionalAttribute":
return KnownCA.OptionalAttribute;
case "StructLayoutAttribute":
return KnownCA.StructLayoutAttribute;
case "FieldOffsetAttribute":
return KnownCA.FieldOffsetAttribute;
}
break;
}
if (typeName.Matches("System.Security.SuppressUnmanagedCodeSecurityAttribute"))
{
return KnownCA.SuppressUnmanagedCodeSecurityAttribute;
}
return KnownCA.Unknown;
}
}
}
// These are the pseudo-custom attributes that are recognized by name by the runtime (i.e. the type identity is not considered).
// The corresponding list in the runtime is at https://github.com/dotnet/coreclr/blob/1afe5ce4f45045d724a4e129df4b816655d486fb/src/md/compiler/custattr_emit.cpp#L38
// Note that we only need to handle a subset of the types, since we don't need the ones that are only used for validation by the runtime.
enum KnownCA
{
Unknown,
DllImportAttribute,
ComImportAttribute,
SerializableAttribute,
NonSerializedAttribute,
MethodImplAttribute,
MarshalAsAttribute,
PreserveSigAttribute,
InAttribute,
OutAttribute,
OptionalAttribute,
StructLayoutAttribute,
FieldOffsetAttribute,
SpecialNameAttribute,
// the following is not part of the runtime known custom attributes, but we handle it here for efficiency and convenience
SuppressUnmanagedCodeSecurityAttribute,
}
}

View File

@@ -39,14 +39,9 @@ namespace IKVM.Reflection.Emit
this.fieldBuilder = fieldBuilder;
}
public override string __Name
internal override TypeName TypeName
{
get { return typeBuilder.__Name; }
}
public override string __Namespace
{
get { return typeBuilder.__Namespace; }
get { return typeBuilder.TypeName; }
}
public override string Name

View File

@@ -97,8 +97,7 @@ namespace IKVM.Reflection.Emit
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
{
Universe u = typeBuilder.ModuleBuilder.universe;
if (customBuilder.Constructor.DeclaringType == u.System_Runtime_CompilerServices_SpecialNameAttribute)
if (customBuilder.KnownCA == KnownCA.SpecialNameAttribute)
{
attributes |= EventAttributes.SpecialName;
}

View File

@@ -124,28 +124,24 @@ namespace IKVM.Reflection.Emit
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
{
Universe u = this.Module.universe;
if (customBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_FieldOffsetAttribute)
switch (customBuilder.KnownCA)
{
customBuilder = customBuilder.DecodeBlob(this.Module.Assembly);
SetOffset((int)customBuilder.GetConstructorArgument(0));
}
else if (customBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_MarshalAsAttribute)
{
FieldMarshal.SetMarshalAsAttribute(typeBuilder.ModuleBuilder, pseudoToken, customBuilder);
attribs |= FieldAttributes.HasFieldMarshal;
}
else if (customBuilder.Constructor.DeclaringType == u.System_NonSerializedAttribute)
{
attribs |= FieldAttributes.NotSerialized;
}
else if (customBuilder.Constructor.DeclaringType == u.System_Runtime_CompilerServices_SpecialNameAttribute)
{
attribs |= FieldAttributes.SpecialName;
}
else
{
typeBuilder.ModuleBuilder.SetCustomAttribute(pseudoToken, customBuilder);
case KnownCA.FieldOffsetAttribute:
SetOffset((int)customBuilder.DecodeBlob(this.Module.Assembly).GetConstructorArgument(0));
break;
case KnownCA.MarshalAsAttribute:
FieldMarshal.SetMarshalAsAttribute(typeBuilder.ModuleBuilder, pseudoToken, customBuilder);
attribs |= FieldAttributes.HasFieldMarshal;
break;
case KnownCA.NonSerializedAttribute:
attribs |= FieldAttributes.NotSerialized;
break;
case KnownCA.SpecialNameAttribute:
attribs |= FieldAttributes.SpecialName;
break;
default:
typeBuilder.ModuleBuilder.SetCustomAttribute(pseudoToken, customBuilder);
break;
}
}

View File

@@ -255,32 +255,27 @@ namespace IKVM.Reflection.Emit
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
{
Universe u = this.ModuleBuilder.universe;
Type type = customBuilder.Constructor.DeclaringType;
if (type == u.System_Runtime_InteropServices_DllImportAttribute)
switch (customBuilder.KnownCA)
{
attributes |= MethodAttributes.PinvokeImpl;
SetDllImportPseudoCustomAttribute(customBuilder.DecodeBlob(this.Module.Assembly));
}
else if (type == u.System_Runtime_CompilerServices_MethodImplAttribute)
{
SetMethodImplAttribute(customBuilder.DecodeBlob(this.Module.Assembly));
}
else if (type == u.System_Runtime_InteropServices_PreserveSigAttribute)
{
implFlags |= MethodImplAttributes.PreserveSig;
}
else if (type == u.System_Runtime_CompilerServices_SpecialNameAttribute)
{
attributes |= MethodAttributes.SpecialName;
}
else
{
if (type == u.System_Security_SuppressUnmanagedCodeSecurityAttribute)
{
case KnownCA.DllImportAttribute:
SetDllImportPseudoCustomAttribute(customBuilder.DecodeBlob(this.Module.Assembly));
attributes |= MethodAttributes.PinvokeImpl;
break;
case KnownCA.MethodImplAttribute:
SetMethodImplAttribute(customBuilder.DecodeBlob(this.Module.Assembly));
break;
case KnownCA.PreserveSigAttribute:
implFlags |= MethodImplAttributes.PreserveSig;
break;
case KnownCA.SpecialNameAttribute:
attributes |= MethodAttributes.SpecialName;
break;
case KnownCA.SuppressUnmanagedCodeSecurityAttribute:
attributes |= MethodAttributes.HasSecurity;
}
this.ModuleBuilder.SetCustomAttribute(pseudoToken, customBuilder);
goto default;
default:
this.ModuleBuilder.SetCustomAttribute(pseudoToken, customBuilder);
break;
}
}
@@ -382,7 +377,7 @@ namespace IKVM.Reflection.Emit
gtpb = new GenericTypeParameterBuilder[names.Length];
for (int i = 0; i < names.Length; i++)
{
gtpb[i] = new GenericTypeParameterBuilder(names[i], null, this, i);
gtpb[i] = new GenericTypeParameterBuilder(names[i], this, i);
}
return (GenericTypeParameterBuilder[])gtpb.Clone();
}

View File

@@ -468,9 +468,7 @@ namespace IKVM.Reflection.Emit
// HACK we should *not* set the TypeDefId in this case, but 2.0 and 3.5 peverify gives a warning if it is missing (4.5 doesn't)
rec.TypeDefId = type.MetadataToken;
}
rec.TypeName = this.Strings.Add(type.__Name);
string ns = type.__Namespace;
rec.TypeNamespace = ns == null ? 0 : this.Strings.Add(ns);
SetTypeNameAndTypeNamespace(type.TypeName, out rec.TypeName, out rec.TypeNamespace);
if (type.IsNested)
{
rec.Flags = 0;
@@ -484,6 +482,12 @@ namespace IKVM.Reflection.Emit
return 0x27000000 | this.ExportedType.FindOrAddRecord(rec);
}
private void SetTypeNameAndTypeNamespace(TypeName name, out int typeName, out int typeNamespace)
{
typeName = this.Strings.Add(name.Name);
typeNamespace = name.Namespace == null ? 0 : this.Strings.Add(name.Namespace);
}
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute));
@@ -650,7 +654,7 @@ namespace IKVM.Reflection.Emit
{
foreach (Type type in types)
{
if (type.__Namespace == name.Namespace && type.__Name == name.Name)
if (type.TypeName == name)
{
return type;
}
@@ -662,7 +666,7 @@ namespace IKVM.Reflection.Emit
{
foreach (Type type in types)
{
if (new TypeName(type.__Namespace, type.__Name).ToLowerInvariant() == lowerCaseName)
if (type.TypeName.ToLowerInvariant() == lowerCaseName)
{
return type;
}
@@ -908,9 +912,7 @@ namespace IKVM.Reflection.Emit
{
rec.ResolutionScope = ImportAssemblyRef(type.Assembly);
}
rec.TypeName = this.Strings.Add(type.__Name);
string ns = type.__Namespace;
rec.TypeNameSpace = ns == null ? 0 : this.Strings.Add(ns);
SetTypeNameAndTypeNamespace(type.TypeName, out rec.TypeName, out rec.TypeNamespace);
token = 0x01000000 | this.TypeRef.AddRecord(rec);
}
typeTokens.Add(type, token);
@@ -1220,9 +1222,7 @@ namespace IKVM.Reflection.Emit
rec.Flags = (int)type.Attributes;
// LAMESPEC ECMA says that TypeDefId is a row index, but it should be a token
rec.TypeDefId = type.MetadataToken;
rec.TypeName = this.Strings.Add(type.__Name);
string ns = type.__Namespace;
rec.TypeNamespace = ns == null ? 0 : this.Strings.Add(ns);
SetTypeNameAndTypeNamespace(type.TypeName, out rec.TypeName, out rec.TypeNamespace);
if (type.IsNested)
{
rec.Implementation = declaringTypes[type.DeclaringType];
@@ -1604,8 +1604,7 @@ namespace IKVM.Reflection.Emit
{
TypeRefTable.Record rec = new TypeRefTable.Record();
rec.ResolutionScope = resolutionScope;
rec.TypeName = this.Strings.Add(name);
rec.TypeNameSpace = ns == null ? 0 : this.Strings.Add(ns);
SetTypeNameAndTypeNamespace(new TypeName(ns, name), out rec.TypeName, out rec.TypeNamespace);
return 0x01000000 | this.TypeRef.AddRecord(rec);
}

View File

@@ -96,27 +96,24 @@ namespace IKVM.Reflection.Emit
public void SetCustomAttribute(CustomAttributeBuilder customAttributeBuilder)
{
Universe u = moduleBuilder.universe;
if (customAttributeBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_InAttribute)
switch (customAttributeBuilder.KnownCA)
{
flags |= (short)ParameterAttributes.In;
}
else if (customAttributeBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_OutAttribute)
{
flags |= (short)ParameterAttributes.Out;
}
else if (customAttributeBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_OptionalAttribute)
{
flags |= (short)ParameterAttributes.Optional;
}
else if (customAttributeBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_MarshalAsAttribute)
{
FieldMarshal.SetMarshalAsAttribute(moduleBuilder, PseudoToken, customAttributeBuilder);
flags |= (short)ParameterAttributes.HasFieldMarshal;
}
else
{
moduleBuilder.SetCustomAttribute(PseudoToken, customAttributeBuilder);
case KnownCA.InAttribute:
flags |= (short)ParameterAttributes.In;
break;
case KnownCA.OutAttribute:
flags |= (short)ParameterAttributes.Out;
break;
case KnownCA.OptionalAttribute:
flags |= (short)ParameterAttributes.Optional;
break;
case KnownCA.MarshalAsAttribute:
FieldMarshal.SetMarshalAsAttribute(moduleBuilder, PseudoToken, customAttributeBuilder);
flags |= (short)ParameterAttributes.HasFieldMarshal;
break;
default:
moduleBuilder.SetCustomAttribute(PseudoToken, customAttributeBuilder);
break;
}
}

View File

@@ -94,8 +94,7 @@ namespace IKVM.Reflection.Emit
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
{
Universe u = typeBuilder.ModuleBuilder.universe;
if (customBuilder.Constructor.DeclaringType == u.System_Runtime_CompilerServices_SpecialNameAttribute)
if (customBuilder.KnownCA == KnownCA.SpecialNameAttribute)
{
attributes |= PropertyAttributes.SpecialName;
}

View File

@@ -42,7 +42,18 @@ namespace IKVM.Reflection.Emit
private Type baseType;
private GenericParameterAttributes attr;
internal GenericTypeParameterBuilder(string name, TypeBuilder type, MethodBuilder method, int position)
internal GenericTypeParameterBuilder(string name, TypeBuilder type, int position)
: this(name, type, null, position, Signature.ELEMENT_TYPE_VAR)
{
}
internal GenericTypeParameterBuilder(string name, MethodBuilder method, int position)
: this(name, null, method, position, Signature.ELEMENT_TYPE_MVAR)
{
}
private GenericTypeParameterBuilder(string name, TypeBuilder type, MethodBuilder method, int position, byte sigElementType)
: base(sigElementType)
{
this.name = name;
this.type = type;
@@ -111,11 +122,6 @@ namespace IKVM.Reflection.Emit
get { return ModuleBuilder; }
}
public override bool IsGenericParameter
{
get { return true; }
}
public override int GenericParameterPosition
{
get { return position; }
@@ -277,7 +283,7 @@ namespace IKVM.Reflection.Emit
this.name = name;
this.typeNameSpace = ns == null ? 0 : this.ModuleBuilder.Strings.Add(ns);
this.typeName = this.ModuleBuilder.Strings.Add(name);
MarkEnumOrValueType(ns, name);
MarkKnownType(ns, name);
}
public ConstructorBuilder DefineDefaultConstructor(MethodAttributes attributes)
@@ -611,31 +617,26 @@ namespace IKVM.Reflection.Emit
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
{
Universe u = this.ModuleBuilder.universe;
Type type = customBuilder.Constructor.DeclaringType;
if (type == u.System_Runtime_InteropServices_StructLayoutAttribute)
switch (customBuilder.KnownCA)
{
SetStructLayoutPseudoCustomAttribute(customBuilder.DecodeBlob(this.Assembly));
}
else if (type == u.System_SerializableAttribute)
{
attribs |= TypeAttributes.Serializable;
}
else if (type == u.System_Runtime_InteropServices_ComImportAttribute)
{
attribs |= TypeAttributes.Import;
}
else if (type == u.System_Runtime_CompilerServices_SpecialNameAttribute)
{
attribs |= TypeAttributes.SpecialName;
}
else
{
if (type == u.System_Security_SuppressUnmanagedCodeSecurityAttribute)
{
case KnownCA.StructLayoutAttribute:
SetStructLayoutPseudoCustomAttribute(customBuilder.DecodeBlob(this.Assembly));
break;
case KnownCA.SerializableAttribute:
attribs |= TypeAttributes.Serializable;
break;
case KnownCA.ComImportAttribute:
attribs |= TypeAttributes.Import;
break;
case KnownCA.SpecialNameAttribute:
attribs |= TypeAttributes.SpecialName;
break;
case KnownCA.SuppressUnmanagedCodeSecurityAttribute:
attribs |= TypeAttributes.HasSecurity;
}
this.ModuleBuilder.SetCustomAttribute(token, customBuilder);
goto default;
default:
this.ModuleBuilder.SetCustomAttribute(token, customBuilder);
break;
}
}
@@ -663,7 +664,7 @@ namespace IKVM.Reflection.Emit
gtpb = new GenericTypeParameterBuilder[names.Length];
for (int i = 0; i < names.Length; i++)
{
gtpb[i] = new GenericTypeParameterBuilder(names[i], this, null, i);
gtpb[i] = new GenericTypeParameterBuilder(names[i], this, i);
}
return (GenericTypeParameterBuilder[])gtpb.Clone();
}
@@ -810,14 +811,9 @@ namespace IKVM.Reflection.Emit
}
}
public override string __Name
internal override TypeName TypeName
{
get { return name; }
}
public override string __Namespace
{
get { return ns; }
get { return new TypeName(ns, name); }
}
public override string Name
@@ -1088,14 +1084,9 @@ namespace IKVM.Reflection.Emit
get { return underlyingType.BaseType; }
}
public override string __Name
internal override TypeName TypeName
{
get { return underlyingType.__Name; }
}
public override string __Namespace
{
get { return underlyingType.__Namespace; }
get { return underlyingType.TypeName; }
}
public override string Name

View File

@@ -618,7 +618,7 @@ namespace IKVM.Reflection.Metadata
{
internal int ResolutionScope;
internal int TypeName;
internal int TypeNameSpace;
internal int TypeNamespace;
}
internal override void Read(MetadataReader mr)
@@ -627,7 +627,7 @@ namespace IKVM.Reflection.Metadata
{
records[i].ResolutionScope = mr.ReadResolutionScope();
records[i].TypeName = mr.ReadStringIndex();
records[i].TypeNameSpace = mr.ReadStringIndex();
records[i].TypeNamespace = mr.ReadStringIndex();
}
}
@@ -637,7 +637,7 @@ namespace IKVM.Reflection.Metadata
{
mw.WriteResolutionScope(records[i].ResolutionScope);
mw.WriteStringIndex(records[i].TypeName);
mw.WriteStringIndex(records[i].TypeNameSpace);
mw.WriteStringIndex(records[i].TypeNamespace);
}
}

View File

@@ -109,18 +109,7 @@ namespace IKVM.Reflection
public bool __TryGetImplMap(out ImplMapFlags mappingFlags, out string importName, out string importScope)
{
Module module = this.Module;
foreach (int i in module.ImplMap.Filter(GetCurrentToken()))
{
mappingFlags = (ImplMapFlags)(ushort)module.ImplMap.records[i].MappingFlags;
importName = module.GetString(module.ImplMap.records[i].ImportName);
importScope = module.GetString(module.ModuleRef.records[(module.ImplMap.records[i].ImportScope & 0xFFFFFF) - 1]);
return true;
}
mappingFlags = 0;
importName = null;
importScope = null;
return false;
return Module.__TryGetImplMap(GetCurrentToken(), out mappingFlags, out importName, out importScope);
}
public ConstructorInfo __AsConstructorInfo()

View File

@@ -406,7 +406,7 @@ namespace IKVM.Reflection
this.declaringType = declaringType;
this.ns = ns;
this.name = name;
MarkEnumOrValueType(ns, name);
MarkKnownType(ns, name);
// HACK we need to handle the Windows Runtime projected types that change from ValueType to Class or v.v.
if (WindowsRuntimeProjection.IsProjectedValueType(ns, name, module))
@@ -454,14 +454,9 @@ namespace IKVM.Reflection
get { return declaringType; }
}
public override string __Name
internal override TypeName TypeName
{
get { return name; }
}
public override string __Namespace
{
get { return ns; }
get { return new TypeName(ns, name); }
}
public override string Name
@@ -648,7 +643,18 @@ namespace IKVM.Reflection
private readonly MemberInfo owner;
private readonly int index;
internal MissingTypeParameter(MemberInfo owner, int index)
internal MissingTypeParameter(Type owner, int index)
: this(owner, index, Signature.ELEMENT_TYPE_VAR)
{
}
internal MissingTypeParameter(MethodInfo owner, int index)
: this(owner, index, Signature.ELEMENT_TYPE_MVAR)
{
}
private MissingTypeParameter(MemberInfo owner, int index, byte sigElementType)
: base(sigElementType)
{
this.owner = owner;
this.index = index;

View File

@@ -568,6 +568,21 @@ namespace IKVM.Reflection
return CustomAttributeData.GetCustomAttributesImpl(new List<CustomAttributeData>(), this, token, null);
}
public bool __TryGetImplMap(int token, out ImplMapFlags mappingFlags, out string importName, out string importScope)
{
foreach (int i in ImplMap.Filter(token))
{
mappingFlags = (ImplMapFlags)(ushort)ImplMap.records[i].MappingFlags;
importName = GetString(ImplMap.records[i].ImportName);
importScope = GetString(ModuleRef.records[(ImplMap.records[i].ImportScope & 0xFFFFFF) - 1]);
return true;
}
mappingFlags = 0;
importName = null;
importScope = null;
return false;
}
#if !NO_AUTHENTICODE
public virtual System.Security.Cryptography.X509Certificates.X509Certificate GetSignerCertificate()
{

View File

@@ -208,7 +208,7 @@ namespace IKVM.Reflection
if (mapping != null)
{
typeRefs[i].ResolutionScope = assemblyRefTokens[(int)mapping.Assembly];
typeRefs[i].TypeNameSpace = GetString(mapping.TypeNamespace);
typeRefs[i].TypeNamespace = GetString(mapping.TypeNamespace);
typeRefs[i].TypeName = GetString(mapping.TypeName);
projectedTypeRefs[i] = true;
}
@@ -432,7 +432,7 @@ namespace IKVM.Reflection
private TypeName GetTypeRefName(int index)
{
return new TypeName(module.GetString(module.TypeRef.records[index].TypeNameSpace), module.GetString(module.TypeRef.records[index].TypeName));
return new TypeName(module.GetString(module.TypeRef.records[index].TypeNamespace), module.GetString(module.TypeRef.records[index].TypeName));
}
private TypeName GetTypeDefName(int index)

View File

@@ -30,6 +30,11 @@ namespace IKVM.Reflection.Reader
{
abstract class TypeParameterType : TypeInfo
{
protected TypeParameterType(byte sigElementType)
: base(sigElementType)
{
}
public sealed override string AssemblyQualifiedName
{
get { return null; }
@@ -83,11 +88,6 @@ namespace IKVM.Reflection.Reader
return this.Name;
}
public sealed override bool IsGenericParameter
{
get { return true; }
}
protected sealed override bool ContainsMissingTypeImpl
{
get { return ContainsMissingType(GetGenericParameterConstraints()); }
@@ -183,6 +183,7 @@ namespace IKVM.Reflection.Reader
}
private UnboundGenericMethodParameter(int position)
: base(Signature.ELEMENT_TYPE_MVAR)
{
this.position = position;
}
@@ -259,7 +260,8 @@ namespace IKVM.Reflection.Reader
private readonly ModuleReader module;
private readonly int index;
internal GenericTypeParameter(ModuleReader module, int index)
internal GenericTypeParameter(ModuleReader module, int index, byte sigElementType)
: base(sigElementType)
{
this.module = module;
this.index = index;

View File

@@ -194,7 +194,7 @@ namespace IKVM.Reflection.Reader
int len = module.GenericParam.records.Length;
for (int i = first; i < len && module.GenericParam.records[i].Owner == token; i++)
{
list.Add(new GenericTypeParameter(module, i));
list.Add(new GenericTypeParameter(module, i, Signature.ELEMENT_TYPE_MVAR));
}
typeArgs = list.ToArray();
}

View File

@@ -279,7 +279,7 @@ namespace IKVM.Reflection.Reader
}
else if (!type.IsNestedByFlags)
{
types.Add(new TypeName(type.__Namespace, type.__Name), type);
types.Add(type.TypeName, type);
}
}
// add forwarded types to forwardedTypes dictionary (because Module.GetType(string) should return them)
@@ -402,14 +402,14 @@ namespace IKVM.Reflection.Reader
case AssemblyRefTable.Index:
{
Assembly assembly = ResolveAssemblyRef((scope & 0xFFFFFF) - 1);
TypeName typeName = GetTypeName(TypeRef.records[index].TypeNameSpace, TypeRef.records[index].TypeName);
TypeName typeName = GetTypeName(TypeRef.records[index].TypeNamespace, TypeRef.records[index].TypeName);
typeRefs[index] = assembly.ResolveType(this, typeName);
break;
}
case TypeRefTable.Index:
{
Type outer = ResolveType(scope, null);
TypeName typeName = GetTypeName(TypeRef.records[index].TypeNameSpace, TypeRef.records[index].TypeName);
TypeName typeName = GetTypeName(TypeRef.records[index].TypeNamespace, TypeRef.records[index].TypeName);
typeRefs[index] = outer.ResolveNestedType(this, typeName);
break;
}
@@ -432,7 +432,7 @@ namespace IKVM.Reflection.Reader
{
module = ResolveModuleRef(ModuleRef.records[(scope & 0xFFFFFF) - 1]);
}
TypeName typeName = GetTypeName(TypeRef.records[index].TypeNameSpace, TypeRef.records[index].TypeName);
TypeName typeName = GetTypeName(TypeRef.records[index].TypeNamespace, TypeRef.records[index].TypeName);
typeRefs[index] = module.FindType(typeName) ?? module.universe.GetMissingTypeOrThrow(this, module, null, typeName);
break;
}
@@ -583,7 +583,7 @@ namespace IKVM.Reflection.Reader
PopulateTypeDef();
foreach (Type type in types.Values)
{
if (new TypeName(type.__Namespace, type.__Name).ToLowerInvariant() == lowerCaseName)
if (type.TypeName.ToLowerInvariant() == lowerCaseName)
{
return type;
}
@@ -1241,7 +1241,7 @@ namespace IKVM.Reflection.Reader
if ((CustomAttribute.records[i].Parent >> 24) == TypeRefTable.Index)
{
int index = (CustomAttribute.records[i].Parent & 0xFFFFFF) - 1;
if (typeName == GetTypeName(TypeRef.records[index].TypeNameSpace, TypeRef.records[index].TypeName))
if (typeName == GetTypeName(TypeRef.records[index].TypeNamespace, TypeRef.records[index].TypeName))
{
list.Add(new CustomAttributeData(this, i));
}

View File

@@ -43,7 +43,7 @@ namespace IKVM.Reflection.Reader
this.index = index;
this.typeName = module.GetString(module.TypeDef.records[index].TypeName);
this.typeNamespace = module.GetString(module.TypeDef.records[index].TypeNamespace);
MarkEnumOrValueType(typeNamespace, typeName);
MarkKnownType(typeNamespace, typeName);
}
public override Type BaseType
@@ -218,14 +218,9 @@ namespace IKVM.Reflection.Reader
return Empty<PropertyInfo>.Array;
}
public override string __Name
internal override TypeName TypeName
{
get { return typeName; }
}
public override string __Namespace
{
get { return typeNamespace; }
get { return new TypeName(typeNamespace, typeName); }
}
public override string Name
@@ -265,7 +260,7 @@ namespace IKVM.Reflection.Reader
int len = module.GenericParam.records.Length;
for (int i = first; i < len && module.GenericParam.records[i].Owner == token; i++)
{
list.Add(new GenericTypeParameter(module, i));
list.Add(new GenericTypeParameter(module, i, Signature.ELEMENT_TYPE_VAR));
}
typeArgs = list.ToArray();
}

View File

@@ -340,18 +340,14 @@ namespace IKVM.Reflection
{
while (type.HasElementType)
{
if (type.__IsVector)
byte sigElementType = type.SigElementType;
bb.Write(sigElementType);
if (sigElementType == ELEMENT_TYPE_ARRAY)
{
bb.Write(ELEMENT_TYPE_SZARRAY);
}
else if (type.IsArray)
{
int rank = type.GetArrayRank();
bb.Write(ELEMENT_TYPE_ARRAY);
// LAMESPEC the Type production (23.2.12) doesn't include CustomMod* for arrays, but the verifier allows it and ildasm also supports it
WriteCustomModifiers(module, bb, type.__GetCustomModifiers());
WriteType(module, bb, type.GetElementType());
bb.WriteCompressedUInt(rank);
bb.WriteCompressedUInt(type.GetArrayRank());
int[] sizes = type.__GetArraySizes();
bb.WriteCompressedUInt(sizes.Length);
for (int i = 0; i < sizes.Length; i++)
@@ -366,100 +362,16 @@ namespace IKVM.Reflection
}
return;
}
else if (type.IsByRef)
{
bb.Write(ELEMENT_TYPE_BYREF);
}
else if (type.IsPointer)
{
bb.Write(ELEMENT_TYPE_PTR);
}
WriteCustomModifiers(module, bb, type.__GetCustomModifiers());
type = type.GetElementType();
}
Universe u = module.universe;
if (type == u.System_Void)
if (type.__IsBuiltIn)
{
bb.Write(ELEMENT_TYPE_VOID);
}
else if (type == u.System_Int32)
{
bb.Write(ELEMENT_TYPE_I4);
}
else if (type == u.System_Boolean)
{
bb.Write(ELEMENT_TYPE_BOOLEAN);
}
else if (type == u.System_String)
{
bb.Write(ELEMENT_TYPE_STRING);
}
else if (type == u.System_Char)
{
bb.Write(ELEMENT_TYPE_CHAR);
}
else if (type == u.System_SByte)
{
bb.Write(ELEMENT_TYPE_I1);
}
else if (type == u.System_Byte)
{
bb.Write(ELEMENT_TYPE_U1);
}
else if (type == u.System_Int16)
{
bb.Write(ELEMENT_TYPE_I2);
}
else if (type == u.System_UInt16)
{
bb.Write(ELEMENT_TYPE_U2);
}
else if (type == u.System_UInt32)
{
bb.Write(ELEMENT_TYPE_U4);
}
else if (type == u.System_Int64)
{
bb.Write(ELEMENT_TYPE_I8);
}
else if (type == u.System_UInt64)
{
bb.Write(ELEMENT_TYPE_U8);
}
else if (type == u.System_Single)
{
bb.Write(ELEMENT_TYPE_R4);
}
else if (type == u.System_Double)
{
bb.Write(ELEMENT_TYPE_R8);
}
else if (type == u.System_IntPtr)
{
bb.Write(ELEMENT_TYPE_I);
}
else if (type == u.System_UIntPtr)
{
bb.Write(ELEMENT_TYPE_U);
}
else if (type == u.System_TypedReference)
{
bb.Write(ELEMENT_TYPE_TYPEDBYREF);
}
else if (type == u.System_Object)
{
bb.Write(ELEMENT_TYPE_OBJECT);
bb.Write(type.SigElementType);
}
else if (type.IsGenericParameter)
{
if (type is UnboundGenericMethodParameter || type.DeclaringMethod != null)
{
bb.Write(ELEMENT_TYPE_MVAR);
}
else
{
bb.Write(ELEMENT_TYPE_VAR);
}
bb.Write(type.SigElementType);
bb.WriteCompressedUInt(type.GenericParameterPosition);
}
else if (!type.__IsMissing && type.IsGenericType)
@@ -666,26 +578,14 @@ namespace IKVM.Reflection
}
foreach (Type type in args)
{
if (type == MarkerType.ModOpt)
{
bb.Write(ELEMENT_TYPE_CMOD_OPT);
}
else if (type == MarkerType.ModReq)
{
bb.Write(ELEMENT_TYPE_CMOD_REQD);
}
else if (type == MarkerType.Sentinel)
{
bb.Write(SENTINEL);
}
else if (type == MarkerType.Pinned)
{
bb.Write(ELEMENT_TYPE_PINNED);
}
else if (type == null)
if (type == null)
{
bb.Write(ELEMENT_TYPE_VOID);
}
else if (type is MarkerType)
{
bb.Write(type.SigElementType);
}
else
{
WriteType(module, bb, type);

Some files were not shown because too many files have changed in this diff Show More