// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !FULL_AOT_RUNTIME
using System.Reflection;
using System.Reflection.Emit;
using System.Collections;
using System.Globalization;
using System.Runtime.Serialization;
-#if NET_2_0 || BOOTSTRAP_NET_2_0
namespace System.Reflection.Emit
{
[ComVisible (true)]
- public sealed class GenericTypeParameterBuilder : Type
+ [StructLayout (LayoutKind.Sequential)]
+ public sealed class GenericTypeParameterBuilder :
+ TypeInfo
{
#region Sync with reflection.h
private TypeBuilder tbuilder;
private string name;
private int index;
private Type base_type;
+#pragma warning disable 414
private Type[] iface_constraints;
private CustomAttributeBuilder[] cattrs;
private GenericParameterAttributes attrs;
+#pragma warning restore
#endregion
- public void SetBaseTypeConstraint (Type base_type_constraint)
+ public void SetBaseTypeConstraint (Type baseTypeConstraint)
{
- this.base_type = base_type_constraint;
+ this.base_type = baseTypeConstraint ?? typeof (object);
}
[ComVisible (true)]
- public void SetInterfaceConstraints (params Type[] iface_constraints)
+ public void SetInterfaceConstraints (params Type[] interfaceConstraints)
{
- this.iface_constraints = iface_constraints;
+ this.iface_constraints = interfaceConstraints;
}
- public void SetGenericParameterAttributes (GenericParameterAttributes attrs)
+ public void SetGenericParameterAttributes (GenericParameterAttributes genericParameterAttributes)
{
- this.attrs = attrs;
+ this.attrs = genericParameterAttributes;
}
internal GenericTypeParameterBuilder (TypeBuilder tbuilder,
this.mbuilder = mbuilder;
this.name = name;
this.index = index;
+ }
- initialize ();
+ internal override Type InternalResolve ()
+ {
+ if (mbuilder != null)
+ return MethodBase.GetMethodFromHandle (mbuilder.MethodHandleInternal, mbuilder.TypeBuilder.InternalResolve ().TypeHandle).GetGenericArguments () [index];
+ return tbuilder.InternalResolve ().GetGenericArguments () [index];
}
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern void initialize ();
+ internal override Type RuntimeResolve ()
+ {
+ if (mbuilder != null)
+ return MethodBase.GetMethodFromHandle (mbuilder.MethodHandleInternal, mbuilder.TypeBuilder.RuntimeResolve ().TypeHandle).GetGenericArguments () [index];
+ return tbuilder.RuntimeResolve ().GetGenericArguments () [index];
+ }
[ComVisible (true)]
public override bool IsSubclassOf (Type c)
{
- if (BaseType == null)
- return false;
- else
- return BaseType == c || BaseType.IsSubclassOf (c);
+ throw not_supported ();
}
protected override TypeAttributes GetAttributeFlagsImpl ()
throw not_supported ();
}
+ public override bool IsAssignableFrom (TypeInfo typeInfo)
+ {
+ if (typeInfo == null)
+ return false;
+
+ return IsAssignableFrom (typeInfo.AsType ());
+ }
+
+ public override bool IsInstanceOfType (object o)
+ {
+ throw not_supported ();
+ }
+
protected override bool IsArrayImpl ()
{
return false;
}
public override Guid GUID {
- get { return Guid.Empty; }
+ get { throw not_supported (); }
}
public override bool IsDefined (Type attributeType, bool inherit)
public override Type[] GetGenericArguments ()
{
- throw not_supported ();
+ throw new InvalidOperationException ();
}
public override Type GetGenericTypeDefinition ()
{
- throw not_supported ();
+ throw new InvalidOperationException ();
}
public override bool ContainsGenericParameters {
public override GenericParameterAttributes GenericParameterAttributes {
get {
- return attrs;
+ throw new NotSupportedException ();
}
}
public override Type[] GetGenericParameterConstraints ()
{
- if (base_type == null) {
- if (iface_constraints != null)
- return iface_constraints;
-
- return Type.EmptyTypes;
- }
-
- if (iface_constraints == null)
- return new Type[] { base_type };
-
- Type[] ret = new Type [iface_constraints.Length + 1];
- ret [0] = base_type;
- iface_constraints.CopyTo (ret, 1);
- return ret;
+ throw new InvalidOperationException ();
}
public override MethodBase DeclaringMethod {
}
[MonoTODO]
- public override bool Equals (object other)
+ public override bool Equals (object o)
{
- return base.Equals (other);
+ return base.Equals (o);
}
[MonoTODO]
return base.GetHashCode ();
}
- [MonoTODO]
public override Type MakeArrayType ()
{
- return base.MakeArrayType ();
+ return new ArrayType (this, 0);
}
- [MonoTODO]
public override Type MakeArrayType (int rank)
{
- return base.MakeArrayType (rank);
+ if (rank < 1)
+ throw new IndexOutOfRangeException ();
+ return new ArrayType (this, rank);
}
- [MonoTODO]
public override Type MakeByRefType ()
{
- return base.MakeByRefType ();
+ return new ByRefType (this);
}
- [MonoTODO]
- public override Type MakeGenericType (params Type [] typeArguments)
+ public override Type MakeGenericType (params Type[] typeArguments)
{
- return base.MakeGenericType (typeArguments);
+ throw new InvalidOperationException (Environment.GetResourceString ("Arg_NotGenericTypeDefinition"));
}
- [MonoTODO]
public override Type MakePointerType ()
{
- return base.MakePointerType ();
+ return new PointerType (this);
+ }
+
+ internal override bool IsUserType {
+ get {
+ return false;
+ }
}
}
}