dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnet ChangeLog csdoc/doc_load.c csdoc/doc_valil...


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] pnet ChangeLog csdoc/doc_load.c csdoc/doc_valil...
Date: Mon, 12 Nov 2007 19:06:48 +0000

CVSROOT:        /cvsroot/dotgnu-pnet
Module name:    pnet
Changes by:     Klaus Treichel <ktreichel>      07/11/12 19:06:48

Modified files:
        .              : ChangeLog 
        csdoc          : doc_load.c doc_valil.c il2doc.c 
        dumpasm        : dump_string.c dump_type.c 
        include        : il_dumpasm.h il_program.h 
        image          : class.c meta_types.c 

Log message:
        Add support for nested classes in il2doc and csdocvalil.
        Fix output of types with xml quoting in dumpasm.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3514&r2=1.3515
http://cvs.savannah.gnu.org/viewcvs/pnet/csdoc/doc_load.c?cvsroot=dotgnu-pnet&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/pnet/csdoc/doc_valil.c?cvsroot=dotgnu-pnet&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/pnet/csdoc/il2doc.c?cvsroot=dotgnu-pnet&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/pnet/dumpasm/dump_string.c?cvsroot=dotgnu-pnet&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/pnet/dumpasm/dump_type.c?cvsroot=dotgnu-pnet&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/pnet/include/il_dumpasm.h?cvsroot=dotgnu-pnet&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/pnet/include/il_program.h?cvsroot=dotgnu-pnet&r1=1.61&r2=1.62
http://cvs.savannah.gnu.org/viewcvs/pnet/image/class.c?cvsroot=dotgnu-pnet&r1=1.42&r2=1.43
http://cvs.savannah.gnu.org/viewcvs/pnet/image/meta_types.c?cvsroot=dotgnu-pnet&r1=1.21&r2=1.22

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3514
retrieving revision 1.3515
diff -u -b -r1.3514 -r1.3515
--- ChangeLog   7 Nov 2007 16:39:40 -0000       1.3514
+++ ChangeLog   12 Nov 2007 19:06:46 -0000      1.3515
@@ -1,3 +1,31 @@
+2007-11-12  Klaus Treichel  <address@hidden>
+
+       * csdoc/doc_load.c: Add support for parsing matadata attributes 
consisting
+       of two parts like 'nested public'.
+ 
+       * csdoc/doc_valil.c: Add support for generics. Add support for nested
+       classes. Don't check the 'has secutity' flag in the attributes when
+       comparing them. Add the GenericParameter attribute target. Handle 'out'
+       and 'param' parameters in the signature. 
+
+       * csdoc/il2doc.c: Add support for nested classes. Add the 
GenericParameter
+       attribute target. Don't destroy only the image. This causes invalid
+       values in the context's hash tables if more than one assembly is 
processed.
+
+       * dumpasm/dump_string.c, include/il_dumpasm.h: Add the functions
+       ILDumpXmlStringLen and ILDumpXmlString for dumping strings with
+       xml quoting.
+
+       * dumpasm/dump_type.c: Use the new functions for dumping type names if
+       IL_DUMP_XML_QUOTING is set in the flags when dumping type names.
+
+       * image/class.c, include/il_program.h: Add the function
+       ILClassToPrimitiveType for trying to convert a class to a primitive 
type.
+
+       * image/meta_types.c: Try to convert a class to a primitive type first
+       before setting an array element or the return/parameter type in a
+       signature or with type.
+
 2007-11-07  Klaus Treichel  <address@hidden>
 
        * codegen/cg_decls.tc: Add the GenDiscard operations for

Index: csdoc/doc_load.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/csdoc/doc_load.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- csdoc/doc_load.c    1 Apr 2003 02:43:40 -0000       1.10
+++ csdoc/doc_load.c    12 Nov 2007 19:06:47 -0000      1.11
@@ -246,11 +246,32 @@
                temp = flags;
                while(temp->name != 0)
                {
-                       if(!strncmp(temp->name, value, len) && temp->name[len] 
== '\0')
+                       if(!strncmp(temp->name, value, len))
+                       {
+                               if(temp->name[len] == '\0')
                        {
                                attrs |= temp->flag;
                                break;
                        }
+                               else if((temp->name[len] == ' ') &&
+                                               (value[len] == ' ') && 
+                                               (strlen(temp->name) > len))
+                               {
+                                       int tempLen = len + 1; /* skip the 
space */
+
+                                       while(value[tempLen] != '\0' && 
value[tempLen] != ' ')
+                                       {
+                                               ++tempLen;
+                                       }
+                                       if(!strncmp(temp->name, value, tempLen) 
&&
+                                          (temp->name[tempLen] == '\0'))
+                                       {
+                                               attrs |= temp->flag;
+                                               len = tempLen;
+                                               break;
+                                       }
+                               }
+                       }
                        ++temp;
                }
 

Index: csdoc/doc_valil.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/csdoc/doc_valil.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- csdoc/doc_valil.c   12 Sep 2003 11:02:10 -0000      1.12
+++ csdoc/doc_valil.c   12 Nov 2007 19:06:47 -0000      1.13
@@ -81,17 +81,226 @@
 }
 
 /*
+ * Append two strings.
+ */
+static char *AppendString(char *str1, const char *str2)
+{
+       str1 = (char *)ILRealloc(str1, strlen(str1) + strlen(str2) + 1);
+       if(!str1)
+       {
+               ILDocOutOfMemory(0);
+       }
+       strcat(str1, str2);
+       return str1;
+}
+
+/*
+ * Concatenate two strings omittint the generic arity of the source string.
+ */
+static char *StrCatOmitArity(char *dest, const char *src,
+                                                       ILUInt32 *numGenParams)
+{
+       if(src && (*src != '\0'))
+       {
+               char *destPtr = dest + strlen(dest);
+               char ch;
+
+               while((ch = *src) != '\0')
+               {
+                       if(ch != '`')
+                       {
+                               *destPtr = *src;
+                               ++destPtr;
+                               ++src;
+                       }
+                       else
+                       {
+                               if(numGenParams != 0)
+                               {
+                                       ILUInt32 arity = 0;
+
+                                       src++;
+                                       while((ch = *src) != '\0')
+                                       {
+                                               /* We can do it this way 
because classnames are UTF8 */
+                                               if(ch >= '0' && ch <= '9')
+                                               {
+                                                       arity = arity * 10 + 
(ch - '0');
+                                               }
+                                               else
+                                               {
+                                                       /* invalid gereric 
arity */
+                                                       arity = 0;
+                                                       break;
+                                               }
+                                               ++src;
+                                       }
+                                       *numGenParams = arity;
+                               }
+                               break;
+                       }
+               }
+               *destPtr = '\0';
+       }
+       return dest;
+}
+
+#if IL_VERSION_MAJOR > 1
+/*
+ * Append the generic parameters to the name.
+ */
+static char *AppendGenericParams(char *name, ILProgramItem *item,
+                                                                ILUInt32 
*firstGenParam)
+{
+       ILUInt32 current = *firstGenParam;
+       ILGenericPar *genPar;
+
+       while((genPar = ILGenericParGetFromOwner(item, current)) != 0)
+       {
+               const char *genParName = ILGenericParGetName(genPar);
+
+               if(current == *firstGenParam)
+               {                       
+                       char *tempName;
+
+                       tempName = (char *)ILMalloc(strlen(genParName) +
+                                                                               
strlen(name) + 2);
+                       if(!tempName)
+                       {
+                               ILDocOutOfMemory(0);
+                       }
+                       strcpy(tempName, name);
+                       strcat(tempName, "<");
+                       strcat(tempName, genParName);
+                       ILFree(name);
+                       name = tempName;
+               }
+               else
+               {
+                       const char *genParName = ILGenericParGetName(genPar);
+                       char *tempName;
+
+                       tempName = (char *)ILMalloc(strlen(genParName) +
+                                                                               
strlen(name) + 2);
+                       if(!tempName)
+                       {
+                               ILDocOutOfMemory(0);
+                       }
+                       strcpy(tempName, name);
+                       strcat(tempName, ",");
+                       strcat(tempName, genParName);
+                       ILFree(name);
+                       name = tempName;
+               }
+               current++;
+       }
+       if(current > *firstGenParam)
+       {
+               char *tempName;
+
+               tempName = (char *)ILMalloc(strlen(name) + 2);
+               if(!tempName)
+               {
+                       ILDocOutOfMemory(0);
+               }
+               strcpy(tempName, name);
+               strcat(tempName, ">");
+               ILFree(name);
+               name = tempName;
+               *firstGenParam = current;
+       }
+       return name;
+}
+#endif /* IL_VERSION_MAJOR > 1 */
+
+/*
+ * Inner function for retrieving the class name including generic parameters.
+ */
+static char *GetClassNameInner(ILClass *classInfo, ILUInt32 *firstGenParam)
+{
+       ILClass *nestedParent = ILClassGetNestedParent(classInfo);
+       char *name;
+
+       if(nestedParent)
+       {
+               name = GetClassNameInner(nestedParent, firstGenParam);
+               char *tempName;
+
+               tempName = (char *)ILMalloc(strlen(name) +
+                                                                       
strlen(ILClass_Name(classInfo)) + 2);
+               if(!tempName)
+               {
+                       ILDocOutOfMemory(0);
+               }
+               strcpy(tempName, name);
+               strcat(tempName, ".");
+               StrCatOmitArity(tempName, ILClass_Name(classInfo), 0);
+               ILFree(name);
+               name = tempName;
+       }
+       else
+       {
+               char *tempName;
+
+               tempName = (char *)ILMalloc(strlen(ILClass_Name(classInfo)) + 
1);
+               if(!tempName)
+               {
+                       ILDocOutOfMemory(0);
+               }
+               *tempName = '\0';
+               StrCatOmitArity(tempName, ILClass_Name(classInfo), 0);
+               name = tempName;
+       }
+#if IL_VERSION_MAJOR > 1
+       if(firstGenParam)
+       {
+               name = AppendGenericParams(name, ILToProgramItem(classInfo),
+                                                                  
firstGenParam);
+       }
+#endif
+       return name;
+}
+
+/*
+ * Get the class name including generic parameters.
+ */
+static char *GetClassName(ILClass *classInfo, int inclGenParams)
+{
+       if(inclGenParams)
+       {
+               ILUInt32 nextGenPar = 0;
+
+               return GetClassNameInner(classInfo, &nextGenPar);
+       }
+       else
+       {
+               return GetClassNameInner(classInfo, 0);
+       }
+}
+
+static const char *GetClassNamespace(ILClass *classInfo)
+{
+       ILClass *nestedParent;
+
+       while((nestedParent = ILClass_NestedParent(classInfo)) != 0)
+       {
+               classInfo = nestedParent;
+       }
+       return ILClass_Namespace(classInfo);
+}
+
+/*
  * Get the full name of an image class.
  */
 static char *GetFullClassName(ILClass *classInfo)
 {
-       const char *name = ILClass_Name(classInfo);
-       const char *namespace = ILClass_Namespace(classInfo);
-       char *parentName;
-       char *fullName;
-       ILClass *parent;
+       char *name = GetClassName(classInfo, 1);
+       const char *namespace = GetClassNamespace(classInfo);
+
        if(namespace)
        {
+               char *fullName;
+
                fullName = (char *)ILMalloc(strlen(namespace) +
                                                                        
strlen(name) + 2);
                if(!fullName)
@@ -101,30 +310,136 @@
                strcpy(fullName, namespace);
                strcat(fullName, ".");
                strcat(fullName, name);
+               return fullName;
        }
-       else if((parent = ILClass_NestedParent(classInfo)) != 0)
+       else
        {
-               parentName = GetFullClassName(parent);
-               fullName = (char *)ILMalloc(strlen(parentName) + strlen(name) + 
2);
-               if(!fullName)
+               return name;
+       }
+}
+
+/*
+ * Resolve a class from a classname.
+ */
+static ILClass *ResolveClass(ILContext *context, const char *name, const char 
*namespace)
+{
+       if(name)
                {
-                       ILDocOutOfMemory(0);
+               ILClass *classInfo = 0;
+               const char *ptr = name;
+               const char *nameEnd = 0;
+               ILUInt32 numGen = 0;
+               char ch;
+
+               while((ch = *ptr) != '\0')
+               {
+                       if(ch == '<')
+                       {
+                               /* Start of generic parameters */
+                               numGen = 1;
+                               nameEnd = ptr;
+
+                               while((ch = *ptr) != '\0')
+                               {
+                                       if(ch == ',')
+                                       {
+                                               ++numGen;
                }
-               strcpy(fullName, parentName);
-               strcat(fullName, ".");
-               strcat(fullName, name);
-               ILFree(parentName);
+                                       else if(ch == '>')
+                                       {
+                                               break;
+                                       }
+                                       ++ptr;
+                               }
+                       }
+                       else if(ch == '.')
+                       {
+                               /* Looks like a nested class */
+                               if(numGen == 0)
+                               {
+                                       char *tempName = ILDupNString(name, ptr 
- name);
+
+                                       if(classInfo)
+                                       {
+                                               classInfo = 
ILClassLookup(ILToProgramItem(classInfo),
+                                                                               
                  tempName, 0);
        }
        else
        {
-               fullName = (char *)ILMalloc(strlen(name) + 1);
-               if(!fullName)
+                                               classInfo = 
ILClassLookupGlobal(context, tempName, namespace);
+                                       }
+                                       ILFree(tempName);
+                               }
+                               else
                {
-                       ILDocOutOfMemory(0);
+                                       char *tempName = ILDupNString(name, 
nameEnd - name);
+                                       char buffer[261];
+
+                                       sprintf(buffer, "%s`%i", tempName, 
numGen);
+                                       if(classInfo)
+                                       {
+                                               classInfo = 
ILClassLookup(ILToProgramItem(classInfo),
+                                                                               
                  buffer, 0);
+                                       }
+                                       else
+                                       {
+                                               classInfo = 
ILClassLookupGlobal(context, buffer, namespace);
                }
-               strcpy(fullName, name);
+                                       ILFree(tempName);
+                                       numGen = 0;
        }
-       return fullName;
+                               if(classInfo)
+                               {
+                                       /* Set the start of the mext name to 
the character
+                                          following the period. */
+                                       name = ptr + 1;
+                               }
+                               else
+                               {
+                                       /* Failed to resolve the class */
+                                       return 0;
+                               }
+                       }               
+                       ++ptr;
+               }
+               if(ptr > name)
+               {
+                       if(numGen == 0)
+                       {
+                               char *tempName = ILDupNString(name, ptr - name);
+
+                               if(classInfo)
+                               {
+                                       classInfo = 
ILClassLookup(ILToProgramItem(classInfo),
+                                                                               
          tempName, 0);
+                               }
+                               else
+                               {
+                                       classInfo = 
ILClassLookupGlobal(context, tempName, namespace);
+                               }
+                               ILFree(tempName);
+                       }
+                       else
+                       {
+                               char *tempName = ILDupNString(name, nameEnd - 
name);
+                               char buffer[261];
+
+                               sprintf(buffer, "%s`%i", tempName, numGen);
+                               if(classInfo)
+                               {
+                                       classInfo = 
ILClassLookup(ILToProgramItem(classInfo),
+                                                                               
          buffer, 0);
+                               }
+                               else
+                               {
+                                       classInfo = 
ILClassLookupGlobal(context, buffer, namespace);
+                               }
+                               ILFree(tempName);
+                       }
+                       return classInfo;               
+               }
+       }
+       return 0;
 }
 
 /*
@@ -154,6 +469,7 @@
  * Type attribute flags that are relevant during comparisons.
  */
 #define        VALID_TYPE_FLAGS        (IL_META_TYPEDEF_VALID_BITS & \
+                                                        
~IL_META_TYPEDEF_HAS_SECURITY & \
                                                     
~IL_META_TYPEDEF_BEFORE_FIELD_INIT & \
                                                         
~IL_META_TYPEDEF_SERIALIZABLE)
 
@@ -161,18 +477,23 @@
  * Field attribute flags that are relevant during comparisons.
  */
 #define        VALID_FIELD_FLAGS       (0x7FFF & \
+                                                        
~IL_META_FIELDDEF_HAS_SECURITY & \
                                                         
~IL_META_FIELDDEF_INIT_ONLY)
 
 /*
  * Method attribute flags that are relevant during comparisons.
  */
 #define        VALID_METHOD_FLAGS      (0x7FFF & \
+                                                        
~IL_META_METHODDEF_PINVOKE_IMPL & \
+                                                        
~IL_META_METHODDEF_HAS_SECURITY & \
                                                         
~IL_META_METHODDEF_NEW_SLOT)
 
 /*
  * Constructor attribute flags that are relevant during comparisons.
  */
 #define        VALID_CTOR_FLAGS        (0x7FFF & \
+                                                        
~IL_META_METHODDEF_PINVOKE_IMPL & \
+                                                        
~IL_META_METHODDEF_HAS_SECURITY & \
                                                         
~IL_META_METHODDEF_HIDE_BY_SIG & \
                                                         
~IL_META_METHODDEF_RT_SPECIAL_NAME)
 
@@ -180,22 +501,66 @@
  * Event attribute flags that are relevant during comparisons.
  */
 #define        VALID_EVENT_FLAGS       (0x7FFF & \
+                                                        
~IL_META_METHODDEF_HAS_SECURITY & \
                                                         
~IL_META_METHODDEF_HIDE_BY_SIG & \
                                                         
~IL_META_METHODDEF_SPECIAL_NAME)
 
+#if IL_VERSION_MAJOR > 1
+/*
+ * Inner function for retrieving the class name including generic parameters.
+ */
+static char *WithTypeToName(ILType *withType, int shortForm,
+                                                       ILProgramItem *scope);
+#endif /* IL_VERSION_MAJOR > 1 */
+
 /*
  * Convert an image type into a type name.
  */
-static char *TypeToName(ILType *type, int shortForm)
+static char *TypeToName(ILType *type, int shortForm, ILParameter *parameter,
+                                               ILProgramItem *scope)
 {
        char *name;
        ILClass *classInfo;
-       const char *suffix;
-       char buffer[128];
        int posn, kind;
 
+       /* Try to convert class or value types to their primitive form first. */
+       if(ILType_IsClass(type) || ILType_IsValueType(type))
+       {
+               ILType *tempType = ILClassToPrimitiveType(ILType_ToClass(type));
+
+               if(tempType)
+               {
+                       type = tempType;
+               }
+       }
        if(ILType_IsPrimitive(type))
        {
+               if(shortForm)
+               {
+                       switch(ILType_ToElement(type))
+                       {
+                               case IL_META_ELEMTYPE_VOID:             name = 
"void"; break;
+                               case IL_META_ELEMTYPE_BOOLEAN:  name = "bool"; 
break;
+                               case IL_META_ELEMTYPE_I1:               name = 
"sbyte"; break;
+                               case IL_META_ELEMTYPE_U1:               name = 
"byte"; break;
+                               case IL_META_ELEMTYPE_I2:               name = 
"short"; break;
+                               case IL_META_ELEMTYPE_U2:               name = 
"ushort"; break;
+                               case IL_META_ELEMTYPE_CHAR:             name = 
"char"; break;
+                               case IL_META_ELEMTYPE_I4:               name = 
"int"; break;
+                               case IL_META_ELEMTYPE_U4:               name = 
"uint"; break;
+                               case IL_META_ELEMTYPE_I8:               name = 
"long"; break;
+                               case IL_META_ELEMTYPE_U8:               name = 
"ulong"; break;
+                               case IL_META_ELEMTYPE_I:                name = 
"IntPtr"; break;
+                               case IL_META_ELEMTYPE_U:                name = 
"UIntPtr"; break;
+                               case IL_META_ELEMTYPE_R4:               name = 
"float"; break;
+                               case IL_META_ELEMTYPE_R8:               name = 
"double"; break;
+                               case IL_META_ELEMTYPE_TYPEDBYREF:
+                                                               name = 
"TypedReference"; break;
+                               default:                                        
        name = "*Unknown*"; break;
+                       }
+               }
+               else
+               {
                switch(ILType_ToElement(type))
                {
                        case IL_META_ELEMTYPE_VOID:             name = 
"System.Void"; break;
@@ -217,9 +582,6 @@
                                                        name = 
"System.TypedReference"; break;
                        default:                                                
name = "*Unknown*"; break;
                }
-               if(shortForm && name[0] == 'S')
-               {
-                       name += 7;
                }
                name = ILDupString(name);
        }
@@ -228,7 +590,7 @@
                classInfo = ILType_ToClass(type);
                if(shortForm)
                {
-                       name = ILDupString(ILClass_Name(classInfo));
+                       name = GetClassName(classInfo, 0);
                }
                else
                {
@@ -237,24 +599,71 @@
        }
        else if(type != 0 && ILType_IsComplex(type))
        {
+               const char *prefix = 0;
+               const char *suffix = 0;
+               char buffer[128];
+
                kind = ILType_Kind(type);
                if(kind == IL_TYPE_COMPLEX_BYREF)
                {
-                       name = TypeToName(ILType_Ref(type), shortForm);
-                       suffix = "&";
+                       name = TypeToName(ILType_Ref(type), shortForm, 
parameter, scope);
+                       if(parameter && ILParameter_IsOut(parameter))
+                       {
+                               prefix = "out ";
+                       }
+                       else
+                       {
+                               prefix = "ref ";
+                       }
                }
                else if(kind == IL_TYPE_COMPLEX_PTR)
                {
-                       name = TypeToName(ILType_Ref(type), shortForm);
+                       name = TypeToName(ILType_Ref(type), shortForm, 
parameter, scope);
                        suffix = "*";
                }
                else if(kind == IL_TYPE_COMPLEX_ARRAY)
                {
-                       name = TypeToName(ILType_Ref(type), shortForm);
+                       if(parameter)
+                       {
+                               /* Look for the "ParamArrayAttribute" marker */
+                               ILAttribute *attr = 0;
+                               ILMethod *ctor;
+                               while((attr = ILProgramItemNextAttribute
+                                                       
(ILToProgramItem(parameter), attr)) != 0)
+                               {
+                                       ctor = ILProgramItemToMethod
+                                               (ILAttribute_TypeAsItem(attr));
+                                       if(ctor && 
!strcmp(ILClass_Name(ILMethod_Owner(ctor)),
+                                                                          
"ParamArrayAttribute"))
+                                       {
+                                               prefix = "params ";
+                                       }
+                               }
+                               parameter = 0;
+                       }
+                       name = TypeToName(ILType_Ref(type), shortForm, 
parameter, scope);
                        suffix = "[]";
                }
                else if(kind == IL_TYPE_COMPLEX_ARRAY_CONTINUE)
                {
+                       if(parameter)
+                       {
+                               /* Look for the "ParamArrayAttribute" marker */
+                               ILAttribute *attr = 0;
+                               ILMethod *ctor;
+                               while((attr = ILProgramItemNextAttribute
+                                                       
(ILToProgramItem(parameter), attr)) != 0)
+                               {
+                                       ctor = ILProgramItemToMethod
+                                               (ILAttribute_TypeAsItem(attr));
+                                       if(ctor && 
!strcmp(ILClass_Name(ILMethod_Owner(ctor)),
+                                                                          
"ParamArrayAttribute"))
+                                       {
+                                               prefix = "params ";
+                                       }
+                               }
+                               parameter = 0;
+                       }
                        buffer[0] = '[';
                        posn = 1;
                        while(type != 0 && ILType_IsComplex(type) &&
@@ -270,7 +679,27 @@
                        if(type != 0 && ILType_IsComplex(type) &&
                           ILType_Kind(type) == IL_TYPE_COMPLEX_ARRAY)
                        {
-                               name = TypeToName(ILType_ElemType(type), 
shortForm);
+                               name = TypeToName(ILType_ElemType(type), 
shortForm, parameter, scope);
+                       }
+                       else
+                       {
+                               name = ILDupString("*Unknown*");
+                       }
+               }
+       #if IL_VERSION_MAJOR > 1
+               else if(kind == IL_TYPE_COMPLEX_MVAR)
+               {
+                       ILMethod *method = ILProgramItemToMethod(scope);
+
+                       if(method)
+                       {
+                               ILUInt32 paramNum = ILType_VarNum(type);
+                               ILGenericPar *genPar;
+
+                               genPar = ILGenericParGetFromOwner(scope, 
paramNum);
+                               if(genPar)
+                               {
+                                       name = 
ILDupString(ILGenericParGetName(genPar));
                        }
                        else
                        {
@@ -280,9 +709,88 @@
                else
                {
                        name = ILDupString("*Unknown*");
+                       }
+               }
+               else if(kind == IL_TYPE_COMPLEX_VAR)
+               {
+                       ILMethod *method = ILProgramItemToMethod(scope);
+
+                       if(method)
+                       {
+                               ILUInt32 paramNum = ILType_VarNum(type);
+                               ILGenericPar *genPar;
+
+                               genPar = ILGenericParGetFromOwner
+                                                       
(ILToProgramItem(ILMethod_Owner(method)),
+                                                        paramNum);
+                               if(genPar)
+                               {
+                                       name = 
ILDupString(ILGenericParGetName(genPar));
+                               }
+                               else
+                               {
+                                       name = ILDupString("*Unknown*");
+                               }
+                       }
+                       else
+                       {
+                               ILClass *classInfo = 
ILProgramItemToClass(scope);
+
+                               if(classInfo)
+                               {
+                                       ILUInt32 paramNum = ILType_VarNum(type);
+                                       ILGenericPar *genPar;
+
+                                       genPar = 
ILGenericParGetFromOwner(scope, paramNum);
+                                       if(genPar)
+                                       {
+                                               name = 
ILDupString(ILGenericParGetName(genPar));
+                                       }
+                                       else
+                                       {
+                                               name = ILDupString("*Unknown*");
+                                       }
+                               }
+                               else
+                               {
+                                       name = ILDupString("*Unknown*");
+                               }
+                       }
+               }
+               else if(kind == IL_TYPE_COMPLEX_WITH)
+               {
+                       name = WithTypeToName(type, shortForm, scope);
+               }
+       #endif /* IL_VERSION_MAJOR > 1 */
+               else
+               {
+                       name = ILDupString("*Unknown*");
                        suffix = "";
                }
-               if(*suffix != '\0')
+               if(prefix)
+               {
+                       int len = strlen(prefix) + strlen(name) + 1;
+                       char *tempName;
+
+                       if(suffix)
+                       {
+                               len += strlen(suffix);
+                       }
+                       tempName = (char *)ILMalloc(len);
+                       if(!tempName)
+                       {
+                               ILDocOutOfMemory(0);
+                       }
+                       strcpy(tempName, prefix);
+                       strcat(tempName, name);
+                       if(suffix)
+                       {
+                               strcat(tempName, suffix);
+                       }
+                       ILFree(name);
+                       name = tempName;
+               }
+               else if(suffix)
                {
                        name = (char *)ILRealloc(name, strlen(name) + 
strlen(suffix) + 1);
                        if(!name)
@@ -303,13 +811,121 @@
        return name;
 }
 
+#if IL_VERSION_MAJOR > 1
+/*
+ * Inner function for retrieving the class name including generic parameters.
+ */
+static char *WithTypeToNameInner(ILClass *classInfo, int shortForm,
+                                                                ILProgramItem 
*scope,
+                                                                ILUInt32 
*first,
+                                                                ILType 
*withType)
+{
+       ILClass *nestedParent = ILClassGetNestedParent(classInfo);
+       ILUInt32 arity = 0;
+       char *name;
+
+       if(nestedParent)
+       {
+               name = WithTypeToNameInner(nestedParent, shortForm, scope, 
first,
+                                                                  withType);
+               char *tempName;
+
+               tempName = (char *)ILMalloc(strlen(name) +
+                                                                       
strlen(ILClass_Name(classInfo)) + 2);
+               if(!tempName)
+               {
+                       ILDocOutOfMemory(0);
+               }
+               strcpy(tempName, name);
+               strcat(tempName, ".");
+               StrCatOmitArity(tempName, ILClass_Name(classInfo), &arity);
+               ILFree(name);
+               name = tempName;
+       }
+       else
+       {
+               char *tempName;
+
+               tempName = (char *)ILMalloc(strlen(ILClass_Name(classInfo)) + 
1);
+               if(!tempName)
+               {
+                       ILDocOutOfMemory(0);
+               }
+               *tempName = '\0';
+               StrCatOmitArity(tempName, ILClass_Name(classInfo), &arity);
+               name = tempName;
+       }
+       if(arity > 0)
+       {
+               ILUInt32 current = *first;
+               ILUInt32 firstGeneric = current;
+               ILType *type;
+
+               *first += arity;
+               while(arity > 0 &&
+                         (type = ILTypeGetWithParamWithPrefixes(withType, 
current + 1)) != 0)
+               {
+                       char *tempName;
+
+                       if(current == firstGeneric)
+                       {
+                               name = AppendString(name, "<");
+                       }
+                       else
+                       {
+                               name = AppendString(name, ",");
+                       }
+                       tempName = TypeToName(type, shortForm, 0, scope);
+                       name = AppendString(name, tempName);
+                       ILFree(tempName);
+                       ++current;
+                       --arity;
+               }
+               if(current > firstGeneric)
+               {
+                       name = AppendString(name, ">");
+               }
+       }
+       return name;
+}
+
+static char *WithTypeToName(ILType *withType, int shortForm,
+                                                       ILProgramItem *scope)
+{
+       ILType *mainType = ILTypeGetWithMain(withType);
+
+       if(ILType_IsClass(mainType) || ILType_IsValueType(mainType))
+       {
+               ILClass *classInfo = ILType_ToClass(mainType);
+               ILUInt32 first = 0;
+               char *typeName;
+
+               typeName = WithTypeToNameInner(classInfo, shortForm, scope, 
&first,
+                                                                          
withType);
+
+               if(!shortForm)
+               {
+                       char *name = ILDupString(GetClassNamespace(classInfo));
+
+                       name = AppendString(name, ".");
+                       name = AppendString(name, typeName);
+                       ILFree(typeName);
+                       typeName = name;
+               }
+               return typeName;
+       }
+       return 0;
+}
+#endif /* IL_VERSION_MAJOR > 1 */
+
 /*
  * Match an image type against a name from an XML file.
  * Returns zero if the types do not match.
  */
-static int MatchType(ILType *type, const char *typeName)
+static int MatchType(ILType *type, const char *typeName,
+                                        ILParameter *parameter, ILProgramItem 
*scope)
 {
-       char *name = TypeToName(type, 1);
+       char *name = TypeToName(type, 1, parameter, scope);
        if(!strcmp(name, typeName))
        {
                ILFree(name);
@@ -319,7 +935,7 @@
        {
                /* Try again with the long form of the name */
                ILFree(name);
-               name = TypeToName(type, 0);
+               name = TypeToName(type, 0, parameter, scope);
                if(!strcmp(name, typeName))
                {
                        ILFree(name);
@@ -333,14 +949,26 @@
 /*
  * Match a method parameter signature.
  */
-static int MatchSignature(ILType *signature, ILDocMember *member)
+static int MatchSignature(ILMethod *method, ILDocMember *member)
 {
        ILDocParameter *param = member->parameters;
+       ILType *signature = ILMethod_Signature(method);
        unsigned numParams = ILTypeNumParams(signature);
        unsigned paramNum = 1;
        while(param != 0 && paramNum <= numParams)
        {
-               if(!MatchType(ILTypeGetParam(signature, paramNum), param->type))
+               ILParameter *parameter = 0;
+
+               while((parameter = ILMethodNextParam(method, parameter)) != 0)
+               {
+                       if(ILParameterGetNum(parameter) == paramNum)
+                       {
+                               break;
+                       }
+               }
+
+               if(!MatchType(ILTypeGetParam(signature, paramNum), param->type,
+                                         parameter, ILToProgramItem(method)))
                {
                        return 0;
                }
@@ -355,7 +983,8 @@
           !strcmp(member->name, "op_Implicit"))
        {
                /* The return type is part of the signature of a conversion */
-               if(!MatchType(ILTypeGetReturn(signature), member->returnType))
+               if(!MatchType(ILTypeGetReturn(signature), member->returnType, 0,
+                                         ILToProgramItem(method)))
                {
                        return 0;
                }
@@ -366,15 +995,27 @@
 /*
  * Match a property parameter signature.
  */
-static int MatchPropertySignature(ILType *signature,
+static int MatchPropertySignature(ILMethod *method,
                                                                  ILDocMember 
*member, int isSet)
 {
        ILDocParameter *param = member->parameters;
+       ILType *signature = ILMethod_Signature(method);
        unsigned numParams = ILTypeNumParams(signature);
        unsigned paramNum = 1;
        while(param != 0 && paramNum <= numParams)
        {
-               if(!MatchType(ILTypeGetParam(signature, paramNum), param->type))
+               ILParameter *parameter = 0;
+
+               while((parameter = ILMethodNextParam(method, parameter)) != 0)
+               {
+                       if(ILParameterGetNum(parameter) == paramNum)
+                       {
+                               break;
+                       }
+               }
+
+               if(!MatchType(ILTypeGetParam(signature, paramNum), param->type,
+                                         parameter, ILToProgramItem(method)))
                {
                        return 0;
                }
@@ -445,9 +1086,10 @@
 /*
  * Print the name of an image type.
  */
-static void PrintType(FILE *stream, ILType *type)
+static void PrintType(FILE *stream, ILType *type, ILParameter *parameter,
+                                         ILProgramItem *scope)
 {
-       char *name = TypeToName(type, 0);
+       char *name = TypeToName(type, 0, parameter, scope);
        PrintString(name, stream);
        ILFree(name);
 }
@@ -526,12 +1168,17 @@
                if(xmlOutput && !typeNameWritten)
                {
                        fputs("\t<class name=\"", stream);
-                       PrintString(type->fullName, stream);
+                       PrintString(type->name, stream);
                        if(type->assembly)
                        {
                                fputs("\" assembly=\"", stream);
                                PrintString(type->assembly, stream);
                        }
+                       fputs("\" namespace=\"", stream);
+                       if(type->namespace)
+                       {
+                               PrintString(type->namespace->name, stream);
+                       }
                        fputs("\">\n", stream);
                        typeNameWritten = 1;
                }
@@ -679,12 +1326,17 @@
                        if(!typeNameWritten)
                        {
                                fputs("\t<class name=\"", stream);
-                               PrintString(type->fullName, stream);
+                               PrintString(type->name, stream);
                                if(type->assembly)
                                {
                                        fputs("\" assembly=\"", stream);
                                        PrintString(type->assembly, stream);
                                }
+                               fputs("\" namespace=\"", stream);
+                               if(type->namespace)
+                               {
+                                       PrintString(type->namespace->name, 
stream);
+                               }
                                fputs("\">\n", stream);
                                typeNameWritten = 1;
                        }
@@ -762,17 +1414,32 @@
 /*
  * Print the parameter signature for a method from an IL image.
  */
-static void PrintILSignature(FILE *stream, ILType *signature,
-                                                        const char *memberName)
+static void PrintILSignature(FILE *stream, ILMember *member)
 {
+       ILType *signature = ILMember_Signature(member);
+       const char *memberName = ILMember_Name(member);
        unsigned numParams = ILTypeNumParams(signature);
        unsigned paramNum;
        ILType *paramType;
        putc('(', stream);
        for(paramNum = 1; paramNum <= numParams; ++paramNum)
        {
+               ILParameter *parameter = 0;
+               ILMethod *method = 
ILProgramItemToMethod(ILToProgramItem(member));
+
+               if(method)
+               {
+                       while((parameter = ILMethodNextParam(method, 
parameter)) != 0)
+                       {
+                               if(ILParameterGetNum(parameter) == paramNum)
+                               {
+                                       break;
+                               }
+                       }
+               }
+
                paramType = ILTypeGetParam(signature, paramNum);
-               PrintType(stream, paramType);
+               PrintType(stream, paramType, parameter, 
ILToProgramItem(member));
                if(paramNum != numParams)
                {
                        fputs(", ", stream);
@@ -784,7 +1451,8 @@
        {
                /* Report the return type too for conversion operators */
                fputs(" : ", stream);
-               PrintType(stream, ILTypeGetReturn(signature));
+               PrintType(stream, ILTypeGetReturn(signature), 0,
+                                 ILToProgramItem(member));
        }
 }
 
@@ -809,8 +1477,7 @@
                                                {
                                                        fputs("\t\t<ctor 
signature=\"", stream);
                                                        
PrintString(type->fullName, stream);
-                                                       
PrintILSignature(stream, ILMember_Signature(member),
-                                                                               
         ILMember_Name(member));
+                                                       
PrintILSignature(stream, member);
                                                        fputs("\">\n", stream);
                                                        memberNameWritten = 1;
                                                }
@@ -818,8 +1485,7 @@
                                        else
                                        {
                                                fputs(type->fullName, stream);
-                                               PrintILSignature(stream, 
ILMember_Signature(member),
-                                                                               
 ILMember_Name(member));
+                                               PrintILSignature(stream, 
member);
                                                fputs(" constructor ", stream);
                                        }
                                }
@@ -837,12 +1503,12 @@
                                                        {
                                                                fputs("static 
", stream);
                                                        }
-                                                       PrintType(stream, 
ILTypeGetReturn
-                                                               
(ILMember_Signature(member)));
+                                                       PrintType(stream,
+                                                               
ILTypeGetReturn(ILMember_Signature(member)),
+                                                               0, 
ILToProgramItem(member));
                                                        putc(' ', stream);
                                                        
PrintString(ILMember_Name(member), stream);
-                                                       
PrintILSignature(stream, ILMember_Signature(member),
-                                                                               
         ILMember_Name(member));
+                                                       
PrintILSignature(stream, member);
                                                        fputs("\">\n", stream);
                                                        memberNameWritten = 1;
                                                }
@@ -856,8 +1522,7 @@
                                                fputs(type->fullName, stream);
                                                fputs("::", stream);
                                                fputs(ILMember_Name(member), 
stream);
-                                               PrintILSignature(stream, 
ILMember_Signature(member),
-                                                                               
 ILMember_Name(member));
+                                               PrintILSignature(stream, 
member);
                                                fputs(" method ", stream);
                                        }
                                }
@@ -874,7 +1539,8 @@
                                                fputs("\t\t<field name=\"", 
stream);
                                                
PrintString(ILMember_Name(member), stream);
                                                fputs("\" type=\"", stream);
-                                               PrintType(stream, 
ILField_Type((ILField *)member));
+                                               PrintType(stream, 
ILField_Type((ILField *)member), 0,
+                                                                 
ILToProgramItem(ILMember_Owner(member)));
                                                fputs("\">\n", stream);
                                                memberNameWritten = 1;
                                        }
@@ -899,8 +1565,9 @@
                                                fputs("\t\t<property name=\"", 
stream);
                                                
PrintString(ILMember_Name(member), stream);
                                                fputs("\" type=\"", stream);
-                                               PrintType(stream, 
ILTypeGetReturn
-                                                       
(ILMember_Signature(member)));
+                                               PrintType(stream, 
+                                                       
ILTypeGetReturn(ILMember_Signature(member)),
+                                                       0, 
ILToProgramItem(ILMember_Owner(member)));
                                                fputs("\">\n", stream);
                                                memberNameWritten = 1;
                                        }
@@ -1014,20 +1681,6 @@
 }
 
 /*
- * Append two strings.
- */
-static char *AppendString(char *str1, const char *str2)
-{
-       str1 = (char *)ILRealloc(str1, strlen(str1) + strlen(str2) + 1);
-       if(!str1)
-       {
-               ILDocOutOfMemory(0);
-       }
-       strcat(str1, str2);
-       return str1;
-}
-
-/*
  * Attribute usage flags.
  */
 #define        AttrUsage_Assembly              0x0001
@@ -1044,7 +1697,12 @@
 #define        AttrUsage_Parameter             0x0800
 #define        AttrUsage_Delegate              0x1000
 #define        AttrUsage_ReturnValue   0x2000
+#if IL_VERSION_MAJOR > 1
+#define        AttrUsage_GenericParameter      0x4000
+#define        AttrUsage_All                   0x7FFF
+#else /* IL_VERSION_MAJOR == 1 */
 #define        AttrUsage_All                   0x3FFF
+#endif /* IL_VERSION_MAJOR == 1 */
 #define        AttrUsage_ClassMembers  0x17FC
 
 /*
@@ -1090,6 +1748,9 @@
        AttrUsage(AttrUsage_Parameter, "Parameter");
        AttrUsage(AttrUsage_Delegate, "Delegate");
        AttrUsage(AttrUsage_ReturnValue, "ReturnValue");
+#if IL_VERSION_MAJOR > 1
+       AttrUsage(AttrUsage_GenericParameter, "GenericParameter");
+#endif /* IL_VERSION_MAJOR > 1 */
        return name;
 }
 
@@ -1543,7 +2204,7 @@
                                 IL_META_MEMBERKIND_METHOD)) != 0)
        {
                if(ILMethod_IsConstructor(method) &&
-                  MatchSignature(ILMethod_Signature(method), member))
+                  MatchSignature(method, member))
                {
                        break;
                }
@@ -1618,14 +2279,27 @@
                                (classInfo, (ILMember *)method,
                                 IL_META_MEMBERKIND_METHOD)) != 0)
        {
-               if(!strcmp(ILMethod_Name(method), member->name) &&
-                  MatchSignature(ILMethod_Signature(method), member))
+       #if IL_VERSION_MAJOR > 1
+               char *name = ILDupString(ILMethod_Name(method));
+               ILUInt32 firstGenParam = 0;
+
+               name = AppendGenericParams(name, ILToProgramItem(method),
+                                                                  
&firstGenParam);
+       #else /* IL_VERSION_MAJOR == 1 */
+               const char *name = ILMethod_Name(method);
+       #endif /* IL_VERSION_MAJOR == 1 */
+
+               if(!strcmp(name, member->name) &&
+                  MatchSignature(method, member))
                {
                        /* Check the static vs instance state */
                        if(ILMethod_IsStatic(method))
                        {
                                if((member->memberAttrs & 
IL_META_METHODDEF_STATIC) != 0)
                                {
+                               #if IL_VERSION_MAJOR > 1
+                                       ILFree(name);
+                               #endif /* IL_VERSION_MAJOR > 1 */
                                        break;
                                }
                        }
@@ -1633,10 +2307,16 @@
                        {
                                if((member->memberAttrs & 
IL_META_METHODDEF_STATIC) == 0)
                                {
+                               #if IL_VERSION_MAJOR > 1
+                                       ILFree(name);
+                               #endif /* IL_VERSION_MAJOR > 1 */
                                        break;
                                }
                        }
                }
+       #if IL_VERSION_MAJOR > 1
+               ILFree(name);
+       #endif /* IL_VERSION_MAJOR > 1 */
        }
        if(!method)
        {
@@ -1682,7 +2362,7 @@
 
        /* Match the return type */
        if(!MatchType(ILTypeGetReturn(ILMethod_Signature(method)),
-                                 member->returnType))
+                                 member->returnType, 0, 
ILToProgramItem(method)))
        {
                PrintName(stream, type, member);
                if(xmlOutput)
@@ -1692,7 +2372,8 @@
                PrintString("should have return type `", stream);
                PrintString(member->returnType, stream);
                PrintString("', but has `", stream);
-               PrintType(stream, ILTypeGetReturn(ILMethod_Signature(method)));
+               PrintType(stream, ILTypeGetReturn(ILMethod_Signature(method)),
+                                 0, ILToProgramItem(method));
                PrintString("' instead", stream);
                if(xmlOutput)
                {
@@ -1778,7 +2459,8 @@
        }
 
        /* Match the field type */
-       if(!MatchType(ILField_Type(field), member->returnType))
+       if(!MatchType(ILField_Type(field), member->returnType, 0,
+                                 ILToProgramItem(ILField_Owner(field))))
        {
                PrintName(stream, type, member);
                if(xmlOutput)
@@ -1788,7 +2470,8 @@
                PrintString("should have type `", stream);
                PrintString(member->returnType, stream);
                PrintString("', but has `", stream);
-               PrintType(stream, ILField_Type(field));
+               PrintType(stream, ILField_Type(field), 0,
+                                 ILToProgramItem(ILField_Owner(field)));
                PrintString("' instead", stream);
                if(xmlOutput)
                {
@@ -1869,7 +2552,7 @@
                }
 
                /* Match the property signature */
-               if(MatchPropertySignature(ILMethod_Signature(accessor), member, 
isSet))
+               if(MatchPropertySignature(accessor, member, isSet))
                {
                        break;
                }
@@ -1917,7 +2600,8 @@
        }
 
        /* Match the property type */
-       if(!MatchType(propertyType, member->returnType))
+       if(!MatchType(propertyType, member->returnType, 0,
+                                 ILToProgramItem(ILProperty_Owner(property))))
        {
                PrintName(stream, type, member);
                if(xmlOutput)
@@ -1927,7 +2611,8 @@
                PrintString("should have type `", stream);
                PrintString(member->returnType, stream);
                PrintString("', but has `", stream);
-               PrintType(stream, propertyType);
+               PrintType(stream, propertyType, 0,
+                                 ILToProgramItem(ILProperty_Owner(property)));
                PrintString("' instead", stream);
                if(xmlOutput)
                {
@@ -2242,7 +2927,7 @@
        ILDocMember *member;
 
        /* Find the type and the image in which is resides */
-       classInfo = ILClassLookupGlobal(context, type->name, 
type->namespace->name);
+       classInfo = ResolveClass(context, type->name, type->namespace->name);
        if(!classInfo)
        {
                /* Report that the class is missing */

Index: csdoc/il2doc.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/csdoc/il2doc.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- csdoc/il2doc.c      7 Nov 2007 16:39:41 -0000       1.7
+++ csdoc/il2doc.c      12 Nov 2007 19:06:47 -0000      1.8
@@ -231,6 +231,7 @@
 #define DUMP_SP                                                256
 #define DUMP_NAME_ONLY                         512
 #define DUMP_CS_STYLE                          1024
+#define DUMP_OMIT_NAMESPACE                    2048
 
 #define DUMP_STYLE_ILASM                       (0)
 #define DUMP_STYLE_ILASM_CLASS         (IL_DUMP_GENERIC_PARAMS | 
DUMP_NAME_ONLY)
@@ -239,12 +240,10 @@
                                                                        | 
DUMP_CS_STYLE | DUMP_NAME_ONLY)
 #define DUMP_STYLE_CSHARP_METHOD       (IL_DUMP_GENERIC_PARAMS | 
DUMP_OMIT_ARITY \
                                                                        | 
DUMP_CS_STYLE)
-#define DUMP_STYLE_NAME                                (IL_DUMP_GENERIC_PARAMS 
| DUMP_OMIT_ARITY \
-                                                                       | 
DUMP_OMIT_CONSTRAINTS | DUMP_NAME_ONLY)
 #define DUMP_STYLE_FULLNAME                    (IL_DUMP_GENERIC_PARAMS | 
DUMP_OMIT_ARITY \
-                                                                       | 
DUMP_OMIT_CONSTRAINTS)
-#define DUMP_STYLE_FULLNAMESP          (IL_DUMP_GENERIC_PARAMS | 
DUMP_OMIT_ARITY \
-                                                                       | 
DUMP_OMIT_CONSTRAINTS | DUMP_SP)
+                                                                       | 
DUMP_OMIT_CONSTRAINTS | DUMP_CS_STYLE)
+#define DUMP_STYLE_NAME                                (DUMP_STYLE_FULLNAME | 
DUMP_OMIT_NAMESPACE)
+#define DUMP_STYLE_FULLNAMESP          (DUMP_STYLE_FULLNAME | DUMP_SP)
 
 static void _ILDumpMethodType(FILE *stream, ILImage *image, ILType *type,
                                                          int flags, ILClass 
*info, const char *methodName,
@@ -482,7 +481,7 @@
                }
                else
                {
-                       fputs(", ", stream);
+                       putc(',', stream);
                }
                if((flags & (DUMP_OMIT_CONSTRAINTS | DUMP_CS_STYLE)) == 0)
                {
@@ -498,6 +497,67 @@
 }
 #endif /* IL_VERSION_MAJOR > 1 */
 
+static int NestedClassIsAccessible(ILClass *classInfo)
+{
+       if(classInfo)
+       {
+               ILUInt32 attrs = ILClassGetAttrs(classInfo);
+
+               switch(attrs & IL_META_TYPEDEF_VISIBILITY_MASK)
+               {
+                       case IL_META_TYPEDEF_NOT_PUBLIC:
+                       case IL_META_TYPEDEF_NESTED_ASSEMBLY:
+                       {
+                               /* The class is only accessible in the same 
image */
+                               return 0;
+                       }
+                       break;
+
+                       case IL_META_TYPEDEF_PUBLIC:
+                       {
+                               return 1;
+                       }
+                       /* Not reached */
+
+                       case IL_META_TYPEDEF_NESTED_PUBLIC:
+                       {
+                               /* The parent is accessible so the child is 
accessible too */
+                               return 1;
+                       }
+                       /* Not reached */
+
+                       case IL_META_TYPEDEF_NESTED_PRIVATE:
+                       {
+                               /* Nested class accessible from parent, 
siblings, or children */
+                               return 0;
+                       }
+                       /* Not reached */
+
+                       case IL_META_TYPEDEF_NESTED_FAMILY:
+                       {
+                               /* Accessible to private or inherited scopes */
+                               return 1;
+                       }
+                       /* Not reached */
+
+                       case IL_META_TYPEDEF_NESTED_FAM_AND_ASSEM:
+                       {
+                               /* Is not accessible from an other image */
+                               return 0;
+                       }
+                       break;
+
+                       case IL_META_TYPEDEF_NESTED_FAM_OR_ASSEM:
+                       {
+                               /* Can be inherited from a class in an other 
image */
+                               return 1;
+                       }
+                       break;
+               }
+       }
+       return 0;
+}
+
 static void _ILDumpType(FILE *stream, ILImage *image, ILType *type, int flags)
 {
        ILType *elem;
@@ -763,7 +823,7 @@
                                {
                                        if(param != 1)
                                        {
-                                               fputs(", ", stream);
+                                               putc(',', stream);
                                        }
                                        _ILDumpType(stream, image,
                                                           
ILTypeGetWithParamWithPrefixes(type, param),
@@ -869,7 +929,8 @@
                        if(type)
                        {
                                fputs(" marshal(", stream);
-                               ILDumpNativeType(stream, type, typeLen, flags);
+                               ILDumpNativeType(stream, type, typeLen,
+                                                                flags | 
IL_DUMP_XML_QUOTING);
                                putc(')', stream);
                        }
                }
@@ -1033,7 +1094,7 @@
                {
                        if(withParam != 1)
                        {
-                               fputs(", ", stream);
+                               putc(',', stream);
                        }
                        _ILDumpType(stream, image,
                                           ILTypeGetParam(withTypes, 
withParam), flags);
@@ -1095,7 +1156,12 @@
 #define        AttrUsage_Parameter             0x0800
 #define        AttrUsage_Delegate              0x1000
 #define        AttrUsage_ReturnValue   0x2000
+#if IL_VERSION_MAJOR > 1
+#define        AttrUsage_GenericParameter      0x4000
+#define        AttrUsage_All                   0x7FFF
+#else /* IL_VERSION_MAJOR == 1 */
 #define        AttrUsage_All                   0x3FFF
+#endif /* IL_VERSION_MAJOR == 1 */
 #define        AttrUsage_ClassMembers  0x17FC
 
 /*
@@ -1479,15 +1545,15 @@
 /*
  * Print a string with XML quoting and an optional SP / omit arity flag.
  */
-static void PrintStringWithFlags(const char *str, int flags)
+static void PrintStringLenWithFlags(const char *str, int len, int flags)
 {
        int ch;
-       if(!str)
-       {
-               return;
-       }
-       while((ch = *str) != '\0')
+       int current = 0;
+
+       while(current < len)
        {
+               ch = *str;
+
                if(ch == '.' && ((flags & DUMP_SP) != 0))
                {
                        putc('_', stdout);
@@ -1514,11 +1580,12 @@
                }
                else if(ch == '`' && ((flags & DUMP_OMIT_ARITY) != 0))
                {
-                       /* Skip until the end of the string or a period is 
encountered. */
+                       /* Skip until the end of the string or a period or 
space is
+                          encountered. */
                        ++str;
                        while((ch = *str) != '\0')
                        {
-                               if(ch == '.')
+                               if((ch == '.') || (ch == ' '))
                                {
                                        --str;
                                        break;
@@ -1536,7 +1603,20 @@
                        putc(ch, stdout);
                }
                ++str;
+               ++current;
+       }
+}
+
+static void PrintStringWithFlags(const char *str, int flags)
+{
+       int len;
+
+       if(!str)
+       {
+               return;
        }
+       len = strlen(str);
+       PrintStringLenWithFlags(str, len, flags);
 }
 #define        PrintString(str)        PrintStringWithFlags((str), 0)
 
@@ -1554,7 +1634,7 @@
                }
                else
                {
-                       fputs(", ", stdout);
+                       putc(',', stdout);
                }
                PrintType(ILTypeGetWithParamWithPrefixes(withType, current + 1),
                                  (flags & DUMP_CS_STYLE), 0, scope);
@@ -1598,6 +1678,8 @@
                }
                else
                {
+                       if((flags & DUMP_OMIT_NAMESPACE) == 0)
+                       {
                        const char *nspace;
 
                        nspace = ILClass_Namespace(classInfo);
@@ -1606,6 +1688,7 @@
                                PrintStringWithFlags(nspace, flags);
                                putc((((flags & DUMP_SP) != 0) ? '_' : '.'), 
stdout);
                        }
+                       }
                        PrintStringWithFlags(ILClass_Name(classInfo), flags);
                }
        }
@@ -2277,6 +2360,11 @@
        /* Dump the name */
        fputs("<Member MemberName=\"", stdout);
        PrintString(ILMethod_Name(method));
+#if IL_VERSION_MAJOR > 1
+       _ILDumpGenericParms(stdout, ILToProgramItem(method),
+                                               0, 
ILType_NumGen(ILMethod_Signature(method)),
+                                               DUMP_STYLE_CSHARP_METHOD);
+#endif /* IL_VERSION_MAJOR > 1 */
        fputs("\">\n", stdout);
 
        /* Dump the signature information */
@@ -2346,6 +2434,11 @@
        /* Dump the name */
        fputs("<Member MemberName=\"", stdout);
        PrintString(ILMethod_Name(method));
+#if IL_VERSION_MAJOR > 1
+       _ILDumpGenericParms(stdout, ILToProgramItem(method),
+                                               0, 
ILType_NumGen(ILMethod_Signature(method)),
+                                               DUMP_STYLE_CSHARP_METHOD);
+#endif /* IL_VERSION_MAJOR > 1 */
        fputs("\">\n", stdout);
 
        /* Dump the signature information */
@@ -2675,6 +2768,7 @@
        int isDelegate;
        ILMethod *delegateMethod;
        ILType *delegateSignature;
+       ILNestedInfo *nestedInfo;
 
        /* Print the header information */
        fputs("<Type Name=\"", stdout);
@@ -2842,11 +2936,20 @@
        }
        fputs("</Members>\n", stdout);
 
-       /* Output the public nested classes, if any */
-       /* TODO */
-
        /* Print the footer information */
        fputs("</Type>\n", stdout);
+
+       /* Output the public nested classes, if any */
+       nestedInfo = 0;
+       while((nestedInfo = ILClassNextNested(classInfo, nestedInfo)) != 0)
+       {
+               ILClass *nestedClass = ILNestedInfoGetChild(nestedInfo);
+
+               if(nestedClass && NestedClassIsAccessible(nestedClass))
+               {
+                       DumpClass(nestedClass);
+               }
+       }
 }
 
 /*
@@ -2877,7 +2980,11 @@
        }
 
        /* Clean up and exit */
+       /* We can't destroy only the image if we want to dump more than one
+          assembly. We'd have to destroy the whole context and recreate it. */
+       /*
        ILImageDestroy(image);
+       */
        return 0;
 }
 

Index: dumpasm/dump_string.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/dumpasm/dump_string.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- dumpasm/dump_string.c       24 Sep 2001 07:19:49 -0000      1.2
+++ dumpasm/dump_string.c       12 Nov 2007 19:06:47 -0000      1.3
@@ -107,6 +107,47 @@
        putc('"', stream);
 }
 
+void ILDumpXmlString(FILE *stream, const char *str)
+{
+       ILDumpXmlStringLen(stream, str, strlen(str));
+}
+
+void ILDumpXmlStringLen(FILE *stream, const char *str, int len)
+{
+       int ch;
+       fputs("&quot;", stream);
+       while(len > 0)
+       {
+               ch = (*str++ & 0xFF);
+               if(ch == '<')
+               {
+                       fputs("&lt;", stdout);
+               }
+               else if(ch == '>')
+               {
+                       fputs("&gt;", stdout);
+               }
+               else if(ch == '&')
+               {
+                       fputs("&amp;", stdout);
+               }
+               else if(ch == '"')
+               {
+                       fputs("&quot;", stdout);
+               }
+               else if(ch == '\'')
+               {
+                       fputs("&apos;", stdout);
+               }
+               else
+               {
+                       putc(ch, stream);
+               }
+               --len;
+       }
+       fputs("&quot;", stream);
+}
+
 #ifdef __cplusplus
 };
 #endif

Index: dumpasm/dump_type.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/dumpasm/dump_type.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- dumpasm/dump_type.c 20 Sep 2007 20:04:17 -0000      1.17
+++ dumpasm/dump_type.c 12 Nov 2007 19:06:47 -0000      1.18
@@ -1392,8 +1392,16 @@
                        value = ILMetaUncompressData(reader);
                        if(!(reader->error) && value <= reader->len)
                        {
+                               if((flags & IL_DUMP_XML_QUOTING) != 0)
+                               {
+                                       ILDumpXmlStringLen(stream, (const char 
*)(reader->data),
+                                                                          
(int)value);
+                               }
+                               else
+                               {
                                ILDumpStringLen(stream, (const char 
*)(reader->data),
                                                                (int)value);
+                               }
                                reader->data += value;
                                reader->len -= value;
                        }
@@ -1406,8 +1414,16 @@
                        value = ILMetaUncompressData(reader);
                        if(!(reader->error) && value <= reader->len)
                        {
+                               if((flags & IL_DUMP_XML_QUOTING) != 0)
+                               {
+                                       ILDumpXmlStringLen(stream, (const char 
*)(reader->data),
+                                                                          
(int)value);
+                               }
+                               else
+                               {
                                ILDumpStringLen(stream, (const char 
*)(reader->data),
                                                                (int)value);
+                               }
                                reader->data += value;
                                reader->len -= value;
                        }
@@ -1420,8 +1436,16 @@
                        value = ILMetaUncompressData(reader);
                        if(!(reader->error) && value <= reader->len)
                        {
+                               if((flags & IL_DUMP_XML_QUOTING) != 0)
+                               {
+                                       ILDumpXmlStringLen(stream, (const char 
*)(reader->data),
+                                                                          
(int)value);
+                               }
+                               else
+                               {
                                ILDumpStringLen(stream, (const char 
*)(reader->data),
                                                                (int)value);
+                               }
                                reader->data += value;
                                reader->len -= value;
                        }
@@ -1434,8 +1458,16 @@
                        value = ILMetaUncompressData(reader);
                        if(!(reader->error) && value <= reader->len)
                        {
+                               if((flags & IL_DUMP_XML_QUOTING) != 0)
+                               {
+                                       ILDumpXmlStringLen(stream, (const char 
*)(reader->data),
+                                                                          
(int)value);
+                               }
+                               else
+                               {
                                ILDumpStringLen(stream, (const char 
*)(reader->data),
                                                                (int)value);
+                               }
                                reader->data += value;
                                reader->len -= value;
                        }

Index: include/il_dumpasm.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/include/il_dumpasm.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- include/il_dumpasm.h        20 Sep 2007 20:04:17 -0000      1.13
+++ include/il_dumpasm.h        12 Nov 2007 19:06:47 -0000      1.14
@@ -126,6 +126,16 @@
                                                 unsigned long numChars);
 
 /*
+ * Dump a length-specified string to the output stream using xml quoting.
+ */
+void ILDumpXmlStringLen(FILE *stream, const char *str, int len);
+
+/*
+ * Dump a simple NUL-terminated string to the output stream using xml quoting.
+ */
+void ILDumpXmlString(FILE *stream, const char *str);
+
+/*
  * Dump a GUID to an output stream.
  */
 void ILDumpGUID(FILE *stream, const unsigned char *guid);

Index: include/il_program.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/include/il_program.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- include/il_program.h        30 Oct 2007 17:35:24 -0000      1.61
+++ include/il_program.h        12 Nov 2007 19:06:47 -0000      1.62
@@ -751,6 +751,12 @@
 int ILClassIsValueType(ILClass *info);
 
 /*
+ * Convert a class information block into a primitive type.
+ * If the class doesn't correspond to a primitive type 0 is returned.
+ */
+ILType *ILClassToPrimitiveType(ILClass *info);
+
+/*
  * Convert a class information block into a type, with
  * the correct class or value type qualifiers.  If the
  * class is one of the builtin value types, it will be

Index: image/class.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/class.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- image/class.c       7 Nov 2007 16:39:41 -0000       1.42
+++ image/class.c       12 Nov 2007 19:06:48 -0000      1.43
@@ -1580,13 +1580,15 @@
        }
 }
 
-ILType *ILClassToType(ILClass *info)
+ILType *ILClassToPrimitiveType(ILClass *info)
 {
-       /* If the class has a synthetic type, then return that */
        if(info->synthetic)
        {
+               if(ILType_IsPrimitive(info->synthetic))
+               {
                return info->synthetic;
        }
+       }
 
        /* Check for system classes with primitive equivalents */
        if(info->className->namespace &&
@@ -1659,8 +1661,7 @@
                }
        }
 
-       /* Convert into either a value type or a class type */
-       return ILClassToTypeDirect(info);
+       return 0;
 }
 
 ILType *ILClassToTypeDirect(ILClass *info)
@@ -1675,6 +1676,29 @@
        }
 }
 
+ILType *ILClassToType(ILClass *info)
+{
+       /* If the class has a synthetic type, then return that */
+       if(info->synthetic)
+       {
+               return info->synthetic;
+       }
+       else
+       {
+               /* Check if the class corresponds to a primitive type */
+               ILType *type = ILClassToPrimitiveType(info);
+
+               if(type)
+               {
+                       /* Return the primitive type */
+                       return type;
+               }
+       }
+
+       /* Convert into either a value type or a class type */
+       return ILClassToTypeDirect(info);
+}
+
 ILClass *ILClassFromType(ILImage *image, void *data, ILType *type,
                                                 ILSystemTypeResolver func)
 {

Index: image/meta_types.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/meta_types.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- image/meta_types.c  30 Oct 2007 17:35:23 -0000      1.21
+++ image/meta_types.c  12 Nov 2007 19:06:48 -0000      1.22
@@ -198,6 +198,18 @@
                num -= 4;
        }
 
+       /* Try to convert the type to a primitive type */
+       /* only value types are primitive types in dotGNU */
+       if(ILType_IsValueType(type))
+       {
+               ILType *tempType = 
ILClassToPrimitiveType(ILType_ToValueType(type));
+
+               if(tempType)
+               {
+                       type = tempType;
+               }
+       }
+
        /* Will it fit in the current block? */
        if(locals)
        {
@@ -258,6 +270,20 @@
        {
                type->kind__ = IL_TYPE_COMPLEX_METHOD;
                type->num__ = 0;
+
+               /* Try to convert the return type to a primitive type */
+               /* only value types are primitive types in dotGNU */
+               if(ILType_IsValueType(returnType))
+               {
+                       ILType *tempType;
+
+                       tempType = 
ILClassToPrimitiveType(ILType_ToValueType(returnType));
+                       if(tempType)
+                       {
+                               returnType = tempType;
+                       }
+               }
+
                type->un.method__.retType__ = returnType;
        }
        return type;
@@ -270,6 +296,20 @@
        {
                type->kind__ = IL_TYPE_COMPLEX_PROPERTY;
                type->num__ = 0;
+
+               /* Try to convert the property type to a primitive type */
+               /* only value types are primitive types in dotGNU */
+               if(ILType_IsValueType(propType))
+               {
+                       ILType *tempType;
+
+                       tempType = 
ILClassToPrimitiveType(ILType_ToValueType(propType));
+                       if(tempType)
+                       {
+                               propType = tempType;
+                       }
+               }
+
                type->un.method__.retType__ = propType;
        }
        return type;
@@ -281,6 +321,19 @@
        ILType **end;
        ILType *start;
 
+       /* Try to convert the parameter type to a primitive type */
+       /* only value types are primitive types in dotGNU */
+       if(ILType_IsValueType(paramType))
+       {
+               ILType *tempType;
+
+               tempType = 
ILClassToPrimitiveType(ILType_ToValueType(paramType));
+               if(tempType)
+               {
+                       paramType = tempType;
+               }
+       }
+
        /* Put the parameter in the method block if it will fit */
        if(method->num__ < 3)
        {
@@ -396,6 +449,19 @@
 {
        if(ILType_IsMethod(type) || ILType_IsProperty(type))
        {
+               /* Try to convert the return type to a primitive type */
+               /* only value types are primitive types in dotGNU */
+               if(ILType_IsValueType(retType))
+               {
+                       ILType *tempType;
+
+                       tempType = 
ILClassToPrimitiveType(ILType_ToValueType(retType));
+                       if(tempType)
+                       {
+                               retType = tempType;
+                       }
+               }
+
                type->un.method__.retType__ = retType;
        }
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]