# Patch created by root
# Date: Sat Jun 16 23:54:12 EDT 2007
# Repository: pnet
# Comments:
# ildasm now handle generics including multiple constraints and special constraints.
# 
#### End of Preamble ####

#### Patch data follows ####
Index: csdoc/il2doc.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/csdoc/il2doc.c,v
retrieving revision 1.4
diff -c -r1.4 il2doc.c
*** csdoc/il2doc.c	4 Sep 2003 23:40:35 -0000	1.4
--- csdoc/il2doc.c	17 Jun 2007 15:29:08 -0000
***************
*** 698,703 ****
--- 698,704 ----
  	int dumpGenerics;
  	ILUInt32 genericNum;
  	ILGenericPar *genPar;
+ 	ILGenericConstraint *genConstr;
  	const char *name;
  	ILProgramItem *constraint;
  	ILTypeSpec *spec;
***************
*** 760,779 ****
  				{
  					fputs(", ", stream);
  				}
! 				constraint = ILGenericPar_Constraint(genPar);
! 				if(constraint)
! 				{
  					putc('(', stream);
! 					spec = ILProgramItemToTypeSpec(constraint);
! 					if(spec)
! 					{
! 						_ILDumpType(stream, image,
! 								   ILTypeSpec_Type(spec), flags);
! 					}
! 					else
  					{
! 						_ILDumpType(stream, image,
! 							   	   ILClassToType((ILClass *)constraint), flags);
  					}
  					putc(')', stream);
  				}
--- 761,785 ----
  				{
  					fputs(", ", stream);
  				}
! 				genConstr = ILGenericParNextConstraint(genPar, 0);
! 				if(genConstr)
! 				{					
  					putc('(', stream);
! 					while (genConstr)
  					{
! 						constraint = ILConstraint_Type(genConstr);
! 						spec = ILProgramItemToTypeSpec(constraint);
! 						if(spec)
! 						{
! 							_ILDumpType(stream, image,
! 									   ILTypeSpec_Type(spec), flags);
! 						}
! 						else
! 						{
! 							_ILDumpType(stream, image,
! 							   		   ILClassToType((ILClass *)constraint), flags);
! 						}
! 						genConstr = ILGenericParNextConstraint(genPar, genConstr);
  					}
  					putc(')', stream);
  				}
Index: dumpasm/dump_class.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/dumpasm/dump_class.c,v
retrieving revision 1.2
diff -c -r1.2 dump_class.c
*** dumpasm/dump_class.c	11 Feb 2007 16:12:27 -0000	1.2
--- dumpasm/dump_class.c	17 Jun 2007 15:29:17 -0000
***************
*** 352,359 ****
  						  ILClass *info, int flags, int withNamespace)
  {
  	ILType *type;
! 	ILUInt32 genericNum;
  	ILGenericPar *genPar;
  	const char *name;
  	ILProgramItem *constraint;
  	ILTypeSpec *spec;
--- 352,360 ----
  						  ILClass *info, int flags, int withNamespace)
  {
  	ILType *type;
! 	ILUInt32 genericNum, genParFlags;
  	ILGenericPar *genPar;
+ 	ILGenericConstraint *genConstr;
  	const char *name;
  	ILProgramItem *constraint;
  	ILTypeSpec *spec;
***************
*** 388,406 ****
  			{
  				fputs(", ", outstream);
  			}
! 			constraint = ILGenericPar_Constraint(genPar);
! 			if(constraint)
  			{
! 				putc('(', outstream);
! 				spec = ILProgramItemToTypeSpec(constraint);
! 				if(spec)
  				{
! 					ILDumpType(outstream, image, ILTypeSpec_Type(spec), flags);
  				}
! 				else
  				{
! 					ILDumpType(outstream, image,
! 							   ILClassToType((ILClass *)constraint), flags);
  				}
  				putc(')', outstream);
  			}
--- 389,431 ----
  			{
  				fputs(", ", outstream);
  			}
! 			genParFlags = ILGenericParGetFlags(genPar);
! 			if ((genParFlags & IL_META_GENPARAM_SPECIAL_CONST_MASK) != 0)
  			{
! 				/* This generic parameter has special constraints */
! 				if (genParFlags & IL_META_GENPARAM_CTOR_CONST)
! 				{
! 					fputs(".ctor ", outstream);
! 				}
! 				if (genParFlags & IL_META_GENPARAM_CLASS_CONST)
! 				{
! 					fputs("class ", outstream);
! 				}
! 				if (genParFlags & IL_META_GENPARAM_VALUETYPE_CONST)
  				{
! 					fputs("valuetype ", outstream);
  				}
! 			}
! 			genConstr = ILGenericParNextConstraint(genPar, 0);
! 			if(genConstr)
! 			{
! 				putc('(', outstream);
! 				while(genConstr)
  				{
! 					constraint = ILConstraint_Type(genConstr);
! 					spec = ILProgramItemToTypeSpec(constraint);
! 					if(spec)
! 					{
! 						ILDumpType(outstream, image, ILTypeSpec_Type(spec), flags);
! 					}
! 					else
! 					{
! 						ILDumpType(outstream, image,
! 								   ILClassToType((ILClass *)constraint), flags);
! 					}
! 					genConstr = ILGenericParNextConstraint(genPar, genConstr);
! 					if(genConstr)
! 						fputs(", ", outstream);
  				}
  				putc(')', outstream);
  			}
Index: dumpasm/dump_data.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/dumpasm/dump_data.c,v
retrieving revision 1.1
diff -c -r1.1 dump_data.c
*** dumpasm/dump_data.c	9 Feb 2007 21:54:16 -0000	1.1
--- dumpasm/dump_data.c	17 Jun 2007 15:29:30 -0000
***************
*** 85,90 ****
--- 85,92 ----
  	unsigned long posn2;
  	unsigned long temp;
  	ILFieldRVA *rva;
+ 	ILField *fld;
+ 	ILType *type;
  	void *dataAddr;
  	unsigned long dataRVA;
  	unsigned long dataLen;
***************
*** 111,116 ****
--- 113,120 ----
  						(image, IL_META_TOKEN_FIELD_RVA, rva)) != 0)
  			{
  				fieldRVAs[posn++] = ILFieldRVA_RVA(rva);
+ 				fld = ILFieldRVA_Owner(rva);
+ 				type = ILFieldGetType(fld);
  			}
  		}
  	}
Index: dumpasm/dump_method.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/dumpasm/dump_method.c,v
retrieving revision 1.2
diff -c -r1.2 dump_method.c
*** dumpasm/dump_method.c	11 Feb 2007 14:48:54 -0000	1.2
--- dumpasm/dump_method.c	17 Jun 2007 15:29:44 -0000
***************
*** 99,105 ****
   */
  static void DumpToken(ILImage *image, FILE *outstream,
  					  int flags, unsigned long token,
! 					  int prefixWithKind)
  {
  	ILClass *info;
  	ILField *field;
--- 99,105 ----
   */
  static void DumpToken(ILImage *image, FILE *outstream,
  					  int flags, unsigned long token,
! 					  int prefixWithKind)  
  {
  	ILClass *info;
  	ILField *field;
Index: dumpasm/dump_type.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/dumpasm/dump_type.c,v
retrieving revision 1.15
diff -c -r1.15 dump_type.c
*** dumpasm/dump_type.c	6 Mar 2004 09:47:38 -0000	1.15
--- dumpasm/dump_type.c	17 Jun 2007 15:29:57 -0000
***************
*** 675,680 ****
--- 675,681 ----
  	int dumpGenerics;
  	ILUInt32 genericNum;
  	ILGenericPar *genPar;
+ 	ILGenericConstraint *genConstr;
  	const char *name;
  	ILProgramItem *constraint;
  	ILTypeSpec *spec;
***************
*** 745,764 ****
  				{
  					fputs(", ", stream);
  				}
! 				constraint = ILGenericPar_Constraint(genPar);
! 				if(constraint)
  				{
  					putc('(', stream);
! 					spec = ILProgramItemToTypeSpec(constraint);
! 					if(spec)
  					{
! 						ILDumpType(stream, image,
! 								   ILTypeSpec_Type(spec), flags);
! 					}
! 					else
! 					{
! 						ILDumpType(stream, image,
! 							   	   ILClassToType((ILClass *)constraint), flags);
  					}
  					putc(')', stream);
  				}
--- 746,772 ----
  				{
  					fputs(", ", stream);
  				}
! 				genConstr = ILGenericParNextConstraint(genPar, 0);
! 				if(genConstr)
  				{
  					putc('(', stream);
! 					while(genConstr)
  					{
! 						constraint = ILConstraint_Type(genConstr);
! 						spec = ILProgramItemToTypeSpec(constraint);
! 						if(spec)
! 						{
! 							ILDumpType(stream, image,
! 									   ILTypeSpec_Type(spec), flags);
! 						}
! 						else
! 						{
! 							ILDumpType(stream, image,
! 							   		   ILClassToType((ILClass *)constraint), flags);
! 						}
! 						genConstr = ILGenericParNextConstraint(genPar, genConstr);
! 						if(genConstr)
! 							fputs(", ", stream);
  					}
  					putc(')', stream);
  				}
Index: ilalink/link_class.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/ilalink/link_class.c,v
retrieving revision 1.14
diff -c -r1.14 link_class.c
*** ilalink/link_class.c	6 Mar 2004 11:04:45 -0000	1.14
--- ilalink/link_class.c	17 Jun 2007 15:30:09 -0000
***************
*** 46,51 ****
--- 46,52 ----
  	ILUInt32 genericNum;
  	ILGenericPar *genPar;
  	ILGenericPar *newGenPar;
+ 	ILGenericConstraint *genConstr;
  	ILProgramItem *constraint;
  	ILTypeSpec *spec;
  
***************
*** 248,272 ****
  			_ILLinkerOutOfMemory(linker);
  			return 0;
  		}
! 		constraint = ILGenericPar_Constraint(genPar);
! 		if(constraint)
  		{
! 			spec = ILProgramItemToTypeSpec(constraint);
! 			if(spec)
  			{
! 				constraint = ILToProgramItem
! 					(_ILLinkerConvertTypeSpec(linker, ILTypeSpec_Type(spec)));
! 			}
! 			else
! 			{
! 				constraint = ILToProgramItem
! 					(_ILLinkerConvertClassRef(linker, (ILClass *)constraint));
! 			}
! 			if(!constraint)
! 			{
! 				return 0;
  			}
- 			ILGenericParSetConstraint(newGenPar, constraint);
  		}
  		++genericNum;
  	}
--- 249,281 ----
  			_ILLinkerOutOfMemory(linker);
  			return 0;
  		}
! 		genConstr = ILGenericParNextConstraint(genPar, 0);
! 		if(genConstr)
  		{
! 			while (genConstr)
  			{
! 				constraint = ILConstraint_Type(genConstr);
! 				spec = ILProgramItemToTypeSpec(constraint);
! 				if(spec)
! 				{
! 					constraint = ILToProgramItem
! 						(_ILLinkerConvertTypeSpec(linker, ILTypeSpec_Type(spec)));
! 				}
! 				else
! 				{
! 					constraint = ILToProgramItem
! 						(_ILLinkerConvertClassRef(linker, (ILClass *)constraint));
! 				}
! 				if(!constraint)
! 				{
! 					return 0;
! 				}
! 				if (!ILGenericParAddConstraint(newGenPar, constraint))
! 				{
! 					return 0;
! 				}
! 				genConstr = ILGenericParNextConstraint(genPar, genConstr);
  			}
  		}
  		++genericNum;
  	}
Index: ilalink/link_method.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/ilalink/link_method.c,v
retrieving revision 1.29
diff -c -r1.29 link_method.c
*** ilalink/link_method.c	5 May 2007 15:56:42 -0000	1.29
--- ilalink/link_method.c	17 Jun 2007 15:30:25 -0000
***************
*** 603,608 ****
--- 603,609 ----
  	ILUInt32 genericNum;
  	ILGenericPar *genPar;
  	ILGenericPar *newGenPar;
+ 	ILGenericConstraint *genConstr;
  	ILProgramItem *constraint;
  	ILTypeSpec *spec;
  
***************
*** 845,869 ****
  			_ILLinkerOutOfMemory(linker);
  			return 0;
  		}
! 		constraint = ILGenericPar_Constraint(genPar);
! 		if(constraint)
  		{
! 			spec = ILProgramItemToTypeSpec(constraint);
! 			if(spec)
  			{
! 				constraint = ILToProgramItem
! 					(_ILLinkerConvertTypeSpec(linker, ILTypeSpec_Type(spec)));
  			}
- 			else
- 			{
- 				constraint = ILToProgramItem
- 					(_ILLinkerConvertClassRef(linker, (ILClass *)constraint));
- 			}
- 			if(!constraint)
- 			{
- 				return 0;
- 			}
- 			ILGenericParSetConstraint(newGenPar, constraint);
  		}
  		++genericNum;
  	}
--- 846,878 ----
  			_ILLinkerOutOfMemory(linker);
  			return 0;
  		}
! 		genConstr = ILGenericParNextConstraint(genPar, 0);
! 		if(genConstr)
  		{
! 			while (genConstr)
  			{
! 				constraint = ILConstraint_Type(genConstr);
! 				spec = ILProgramItemToTypeSpec(constraint);
! 				if(spec)
! 				{
! 					constraint = ILToProgramItem
! 						(_ILLinkerConvertTypeSpec(linker, ILTypeSpec_Type(spec)));
! 				}
! 				else
! 				{
! 					constraint = ILToProgramItem
! 						(_ILLinkerConvertClassRef(linker, (ILClass *)constraint));
! 				}
! 				if(!constraint)
! 				{
! 					return 0;
! 				}
! 				if (!ILGenericParAddConstraint(newGenPar, constraint))
! 				{
! 					return 0;
! 				}
! 				genConstr = ILGenericParNextConstraint(genPar, genConstr);
  			}
  		}
  		++genericNum;
  	}
Index: ilasm/ilasm_build.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/ilasm/ilasm_build.c,v
retrieving revision 1.26
diff -c -r1.26 ilasm_build.c
*** ilasm/ilasm_build.c	5 May 2007 18:15:17 -0000	1.26
--- ilasm/ilasm_build.c	17 Jun 2007 15:30:35 -0000
***************
*** 371,377 ****
  				}
  				constraint = ILToProgramItem(spec);
  			}
! 			ILGenericParSetConstraint(genPar, constraint);
  		}
  		ILFree(genericParams);
  		genericParams = nextGeneric;
--- 371,377 ----
  				}
  				constraint = ILToProgramItem(spec);
  			}
! 			ILGenericParAddConstraint(genPar, constraint);
  		}
  		ILFree(genericParams);
  		genericParams = nextGeneric;
Index: ilasm/ilasm_grammar.y
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/ilasm/ilasm_grammar.y,v
retrieving revision 1.44
diff -c -r1.44 ilasm_grammar.y
*** ilasm/ilasm_grammar.y	5 May 2007 15:56:42 -0000	1.44
--- ilasm/ilasm_grammar.y	17 Jun 2007 15:30:49 -0000
***************
*** 2098,2104 ****
  							}
  							constraint = ILToProgramItem(spec);
  						}
! 						ILGenericParSetConstraint(genPar, constraint);
  					}
  					ILFree(genericParams);
  					genericParams = nextGeneric;
--- 2098,2104 ----
  							}
  							constraint = ILToProgramItem(spec);
  						}
! 						ILGenericParAddConstraint(genPar, constraint);
  					}
  					ILFree(genericParams);
  					genericParams = nextGeneric;
Index: image/generic.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/image/generic.c,v
retrieving revision 1.4
diff -c -r1.4 generic.c
*** image/generic.c	26 Feb 2003 00:07:26 -0000	1.4
--- image/generic.c	17 Jun 2007 15:31:00 -0000
***************
*** 43,50 ****
  	genPar->number = (ILUInt16)number;
  	genPar->flags = 0;
  	genPar->name = 0;
! 	genPar->kind = 0;
! 	genPar->constraint = 0;
  
  	/* Assign a token code to the GenericPar information block */
  	if(!_ILImageSetToken(image, &(genPar->ownedItem.programItem), token,
--- 43,49 ----
  	genPar->number = (ILUInt16)number;
  	genPar->flags = 0;
  	genPar->name = 0;
! 	genPar->firstConstraint = 0;
  
  	/* Assign a token code to the GenericPar information block */
  	if(!_ILImageSetToken(image, &(genPar->ownedItem.programItem), token,
***************
*** 96,119 ****
  	return (genPar->name != 0);
  }
  
! ILProgramItem *ILGenericParGetKind(ILGenericPar *genPar)
  {
! 	return genPar->kind;
  }
  
! void ILGenericParSetKind(ILGenericPar *genPar, ILProgramItem *type)
  {
! 	genPar->kind = type;
  }
  
! ILProgramItem *ILGenericParGetConstraint(ILGenericPar *genPar)
  {
! 	return genPar->constraint;
  }
  
! void ILGenericParSetConstraint(ILGenericPar *genPar, ILProgramItem *type)
  {
! 	genPar->constraint = type;
  }
  
  /*
--- 95,146 ----
  	return (genPar->name != 0);
  }
  
! ILGenericConstraint *ILGenericParNextConstraint(ILGenericPar *genPar, ILGenericConstraint *last)
  {
! 	if(last)
! 	{
! 		return last->nextConstraint;
! 	}
! 	else if(genPar)
! 	{
! 		return genPar->firstConstraint;
! 	}
! 	else
! 	{
! 		return 0;
! 	}
  }
  
! ILGenericConstraint *ILGenericParAddConstraint(ILGenericPar *genPar, ILProgramItem *constraint)
  {
! 	ILGenericConstraint **last = &(genPar->firstConstraint);
! 
! 	while (*last != 0)
! 	{
! 		last = &((*last)->nextConstraint);
! 	}
! 	(*last) = ILMemStackAlloc(&(constraint->image->memStack), ILGenericConstraint);
! 	if(!(*last))
! 	{
! 		return 0;
! 	}
! 
! 	(*last)->ownedItem = genPar->ownedItem; /* Is this really needed? */
! 	(*last)->parameter = genPar;
! 	(*last)->constraint = constraint;
! 	(*last)->nextConstraint = 0;
! 
! 	return (*last);
  }
  
! ILGenericPar *ILConstraintGetParam(ILGenericConstraint *constraint)
  {
! 	return constraint->parameter;
  }
  
! ILProgramItem *ILConstraintGetType(ILGenericConstraint *constraint)
  {
! 	return constraint->constraint;
  }
  
  /*
Index: image/meta_build.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/image/meta_build.c,v
retrieving revision 1.46
diff -c -r1.46 meta_build.c
*** image/meta_build.c	9 Jun 2005 07:59:59 -0000	1.46
--- image/meta_build.c	17 Jun 2007 15:31:15 -0000
***************
*** 1013,1019 ****
   * Load a reference to a type definition token that is
   * further along in the file from where we currently are.
   */
! static int LoadForwardTypeDef(ILImage *image, ILToken token)
  {
  	ILUInt32 values[IL_IMAGE_TOKEN_COLUMNS];
  	ILUInt32 valuesNext[IL_IMAGE_TOKEN_COLUMNS];
--- 1013,1019 ----
   * Load a reference to a type definition token that is
   * further along in the file from where we currently are.
   */
! int LoadForwardTypeDef(ILImage *image, ILToken token)
  {
  	ILUInt32 values[IL_IMAGE_TOKEN_COLUMNS];
  	ILUInt32 valuesNext[IL_IMAGE_TOKEN_COLUMNS];
***************
*** 3243,3260 ****
  	{
  		return IL_LOADERR_MEMORY;
  	}
- 	if(values[IL_OFFSET_GENERICPAR_KIND])
- 	{
- 		ILGenericParSetKind(genPar, ILProgramItem_FromToken
- 				(image, values[IL_OFFSET_GENERICPAR_KIND]));
- 	}
- 
- 	/* Note: in Gyro, the constraint is stored in the GenericPar
- 	   table, but in the .NET Framework SDK 2.0 beta it is stored
- 	   in a separate GenericConstraint table.  This code handles
- 	   the Gyro case.  See "Load_GenericConstraint" for the other */
- 	ILGenericParSetConstraint(genPar, ILProgramItem_FromToken
- 			(image, values[IL_OFFSET_GENERICPAR_CONSTRAINT]));
  
  	/* Done */
  	return 0;
--- 3243,3248 ----
***************
*** 3277,3285 ****
  		return IL_LOADERR_BAD_META;
  	}
  
! 	/* Set the record's properties */
! 	ILGenericParSetConstraint(genPar, ILProgramItem_FromToken
! 			(image, values[IL_OFFSET_GENERICCON_CONSTRAINT]));
  
  	/* Done */
  	return 0;
--- 3265,3276 ----
  		return IL_LOADERR_BAD_META;
  	}
  
! 	/* Add the generic constraint to the parameter */
! 	if (!ILGenericParAddConstraint(genPar, ILProgramItem_FromToken (image, 
! 										values[IL_OFFSET_GENERICCON_CONSTRAINT])))
! 	{
! 		return IL_LOADERR_MEMORY;
! 	}
  
  	/* Done */
  	return 0;
Index: image/meta_writer.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/image/meta_writer.c,v
retrieving revision 1.15
diff -c -r1.15 meta_writer.c
*** image/meta_writer.c	1 Jun 2007 07:35:35 -0000	1.15
--- image/meta_writer.c	17 Jun 2007 15:31:31 -0000
***************
*** 701,710 ****
  	values[IL_OFFSET_GENERICPAR_FLAGS] = genPar->flags;
  	values[IL_OFFSET_GENERICPAR_OWNER] = genPar->ownedItem.owner->token;
  	values[IL_OFFSET_GENERICPAR_NAME] = GetPersistString(image, genPar->name);
- 	values[IL_OFFSET_GENERICPAR_KIND] =
- 			(genPar->kind ? genPar->kind->token : 0);
- 	values[IL_OFFSET_GENERICPAR_CONSTRAINT] =
- 			(genPar->constraint ? genPar->constraint->token : 0);
  }
  
  /*
--- 701,706 ----
***************
*** 715,721 ****
  									 ILGenericConstraint *genCon)
  {
  	values[IL_OFFSET_GENERICCON_PARAM] =
! 			(genCon->parameter ? genCon->parameter->token : 0);
  	values[IL_OFFSET_GENERICCON_CONSTRAINT] =
  			(genCon->constraint ? genCon->constraint->token : 0);
  }
--- 711,717 ----
  									 ILGenericConstraint *genCon)
  {
  	values[IL_OFFSET_GENERICCON_PARAM] =
! 			(genCon->parameter ? ((ILProgramItem *)genCon->parameter)->token : 0);
  	values[IL_OFFSET_GENERICCON_CONSTRAINT] =
  			(genCon->constraint ? genCon->constraint->token : 0);
  }
Index: image/program.h
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/image/program.h,v
retrieving revision 1.23
diff -c -r1.23 program.h
*** image/program.h	16 Jan 2007 06:46:08 -0000	1.23
--- image/program.h	17 Jun 2007 15:31:43 -0000
***************
*** 677,697 ****
  	ILUInt16		number;				/* Parameter number */
  	ILUInt16		flags;				/* Parameter flags */
  	const char     *name;				/* Parameter name */
! 	ILProgramItem  *kind;				/* Parameter kind */
! 	ILProgramItem  *constraint;			/* Parameter constraint */
! 
  };
  
  /*
   * Information about a generic constraint.
   */
- typedef struct _tagILGenericConstraint ILGenericConstraint;
  struct _tagILGenericConstraint
  {
  	ILOwnedItem		ownedItem;			/* Parent class fields */
  	ILProgramItem  *parameter;			/* Generic parameter to modify */
  	ILProgramItem  *constraint;			/* Constraint to apply */
! 
  };
  
  /*
--- 677,696 ----
  	ILUInt16		number;				/* Parameter number */
  	ILUInt16		flags;				/* Parameter flags */
  	const char     *name;				/* Parameter name */
! 	ILGenericConstraint  *firstConstraint;	/* Parameter constraints */
! 	
  };
  
  /*
   * Information about a generic constraint.
   */
  struct _tagILGenericConstraint
  {
  	ILOwnedItem		ownedItem;			/* Parent class fields */
  	ILProgramItem  *parameter;			/* Generic parameter to modify */
  	ILProgramItem  *constraint;			/* Constraint to apply */
! 	ILGenericConstraint *nextConstraint;    /* Next constraint for this parameter */
! 	
  };
  
  /*
Index: image/sig_parse.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/image/sig_parse.c,v
retrieving revision 1.9
diff -c -r1.9 sig_parse.c
*** image/sig_parse.c	1 Mar 2004 04:21:12 -0000	1.9
--- image/sig_parse.c	17 Jun 2007 15:31:55 -0000
***************
*** 122,127 ****
--- 122,128 ----
  							  ILMetaDataRead *reader, int *kind,
  							  int depth);
  
+ int LoadForwardTypeDef(ILImage *image, ILToken token);
  /*
   * Parse an element type.  "depth" is used to control the
   * recursion depth so that malicious parties cannot cause
***************
*** 266,271 ****
--- 267,286 ----
  			if(value != 0)
  			{
  				info = (ILClass *)ILImageTokenInfo(image, value);
+ 				if(info == 0)
+ 				{
+ 					int error;
+ 					/* 
+ 					 * When this class is referenced as a actual generic parameter for a base class,
+ 					 * and it is not already loaded we can get to this point.
+ 					 */
+ 					error = LoadForwardTypeDef(image, value);
+ 					if(error != 0)
+ 					{
+ 						return 0;
+ 					}
+ 					info = (ILClass *)ILImageTokenInfo(image, value);
+ 				}
  				if(info != 0)
  				{
  					type = ILType_FromClass(info);
Index: include/il_meta.h
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/include/il_meta.h,v
retrieving revision 1.12
diff -c -r1.12 il_meta.h
*** include/il_meta.h	20 Oct 2006 19:30:54 -0000	1.12
--- include/il_meta.h	17 Jun 2007 15:32:08 -0000
***************
*** 301,306 ****
--- 301,318 ----
  #define	IL_META_FILE_WRITEABLE					0x0002
  
  /*
+  * Generic parameters flags.
+  */
+ #define	IL_META_GENPARAM_VARIANCE_MASK			0x0003
+ #define	IL_META_GENPARAM_NONE					0x0000
+ #define	IL_META_GENPARAM_COVARIANT				0x0001
+ #define	IL_META_GENPARAM_CONTRAVARIANT			0x0002
+ #define	IL_META_GENPARAM_SPECIAL_CONST_MASK		0x001C
+ #define	IL_META_GENPARAM_CLASS_CONST			0x0004
+ #define	IL_META_GENPARAM_VALUETYPE_CONST		0x0008
+ #define	IL_META_GENPARAM_CTOR_CONST				0x0010
+ 
+ /*
   * Element types.
   */
  #define	IL_META_ELEMTYPE_END					0x00
Index: include/il_program.h
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/include/il_program.h,v
retrieving revision 1.54
diff -c -r1.54 il_program.h
*** include/il_program.h	20 Oct 2006 19:30:54 -0000	1.54
--- include/il_program.h	17 Jun 2007 15:32:26 -0000
***************
*** 62,67 ****
--- 62,68 ----
  typedef struct _tagILManifestRes	ILManifestRes;
  typedef struct _tagILExportedType	ILExportedType;
  typedef struct _tagILGenericPar		ILGenericPar;
+ typedef struct _tagILGenericConstraint ILGenericConstraint;
  typedef struct _tagILMethodSpec		ILMethodSpec;
  
  /*
***************
*** 2321,2344 ****
  int ILGenericParSetName(ILGenericPar *genPar, const char *name);
  
  /*
!  * Get the kind associated with a generic parameter.
   */
! ILProgramItem *ILGenericParGetKind(ILGenericPar *genPar);
  
  /*
!  * Set the kind associated with a generic parameter.
   */
! void ILGenericParSetKind(ILGenericPar *genPar, ILProgramItem *type);
! 
! /*
!  * Get the constraint associated with a generic parameter.
!  */
! ILProgramItem *ILGenericParGetConstraint(ILGenericPar *genPar);
! 
! /*
!  * Set the constraint associated with a generic parameter.
!  */
! void ILGenericParSetConstraint(ILGenericPar *genPar, ILProgramItem *type);
  
  /*
   * Get a generic parameter record for a particular owner and number.
--- 2322,2335 ----
  int ILGenericParSetName(ILGenericPar *genPar, const char *name);
  
  /*
!  * Get the next constraint associated with generic parameter.
   */
! ILGenericConstraint *ILGenericParNextConstraint(ILGenericPar *genPar, ILGenericConstraint *last);
  
  /*
!  * Add a constraint to a generic parameter.
   */
! ILGenericConstraint *ILGenericParAddConstraint(ILGenericPar *genPar, ILProgramItem *constraint);
  
  /*
   * Get a generic parameter record for a particular owner and number.
***************
*** 2361,2368 ****
  #define	ILGenericPar_Flags(genPar)		(ILGenericParGetFlags((genPar)))
  #define	ILGenericPar_Owner(genPar)		(ILGenericParGetOwner((genPar)))
  #define	ILGenericPar_Name(genPar)		(ILGenericParGetName((genPar)))
! #define	ILGenericPar_Kind(genPar)		(ILGenericParGetKind((genPar)))
! #define	ILGenericPar_Constraint(genPar)	(ILGenericParGetConstraint((genPar)))
  
  /*
   * Create a method specification record.
--- 2352,2373 ----
  #define	ILGenericPar_Flags(genPar)		(ILGenericParGetFlags((genPar)))
  #define	ILGenericPar_Owner(genPar)		(ILGenericParGetOwner((genPar)))
  #define	ILGenericPar_Name(genPar)		(ILGenericParGetName((genPar)))
! 
! /*
!  * Return the associated Parameter to the generic constraint
!  */
! ILGenericPar *ILConstraintGetParam(ILGenericConstraint *constraint);
! 
! /*
!  * Return the type associated specified by the generic constraint
!  */
! ILProgramItem *ILConstraintGetType(ILGenericConstraint *constraint);
! 
! /*
!  * Helper macros for querying information about generic constraints.
!  */
! #define ILConstraint_Param(constraint) (ILConstraintGetParam(constraint))
! #define ILConstraint_Type(constraint) (ILConstraintGetType(constraint))
  
  /*
   * Create a method specification record.
#### End of Patch data ####
