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

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

[Dotgnu-pnet-commits] CVS: pnet/image class.c,1.15,1.16 image.h,1.16,1.1


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/image class.c,1.15,1.16 image.h,1.16,1.17 synthetic.c,1.4,1.5
Date: Tue, 05 Nov 2002 19:53:15 -0500

Update of /cvsroot/dotgnu-pnet/pnet/image
In directory subversions:/tmp/cvs-serv2526/image

Modified Files:
        class.c image.h synthetic.c 
Log Message:


Convert non-array types such as pointer and byref types into synthetic
classes, so that they can be encapsulated during reflection.


Index: class.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/class.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** class.c     5 Oct 2002 04:25:40 -0000       1.15
--- class.c     6 Nov 2002 00:53:13 -0000       1.16
***************
*** 1426,1429 ****
--- 1426,1434 ----
                        return _ILTypeToSyntheticArray(image, type, 0);
                }
+               else
+               {
+                       /* Create some other kind of synthetic type */
+                       return _ILTypeToSyntheticOther(image, type);
+               }
        }
        return 0;

Index: image.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/image.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** image.h     5 Oct 2002 04:25:40 -0000       1.16
--- image.h     6 Nov 2002 00:53:13 -0000       1.17
***************
*** 481,484 ****
--- 481,490 ----
  
  /*
+  * Convert a non-array type into a synthetic class that represents it.
+  * Returns NULL if not possible, or out of memory.
+  */
+ ILClass *_ILTypeToSyntheticOther(ILImage *image, ILType *type);
+ 
+ /*
   * Compact all type and member references in an image to
   * remove tokens that have been replaced with definitions.

Index: synthetic.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/synthetic.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** synthetic.c 13 Jan 2002 11:24:57 -0000      1.4
--- synthetic.c 6 Nov 2002 00:53:13 -0000       1.5
***************
*** 483,486 ****
--- 483,536 ----
  }
  
+ ILClass *_ILTypeToSyntheticOther(ILImage *image, ILType *type)
+ {
+       ILContext *context = ILImageToContext(image);
+       ILImage *synthetic;
+       ILClass *parent, *info;
+       char name[32];
+ 
+       /* See if we already have a synthetic class for this type */
+       info = ILHashFindType(context->syntheticHash, type, ILClass);
+       if(info)
+       {
+               return info;
+       }
+ 
+       /* Bail out if not enough memory to create the synthetic image */
+       synthetic = ILContextGetSynthetic(context);
+       if(!synthetic)
+       {
+               return 0;
+       }
+ 
+       /* Create a unique name for the synthetic class */
+       sprintf(name, "$%lu",
+                       (unsigned long)(synthetic->memStack.currSize -
+                                                       
synthetic->memStack.size +
+                                                       
synthetic->memStack.posn));
+ 
+       /* Inherit the class off "System.ValueType" */
+       parent = ILClassResolveSystem(image, 0, "ValueType", "System");
+       if(!parent)
+       {
+               return 0;
+       }
+       info = CreateSynthetic(synthetic, name, parent, 1);
+       if(!info)
+       {
+               return 0;
+       }
+ 
+       /* Set the "synthetic" member for the class */
+       info->synthetic = type;
+ 
+       /* Add the synthetic class to the synthetic types hash table */
+       if(!ILHashAdd(context->syntheticHash, info))
+       {
+               return 0;
+       }
+       return info;
+ }
+ 
  #ifdef        __cplusplus
  };





reply via email to

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