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

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

[Dotgnu-pnet-commits] CVS: pnet/engine lib_emit.c,1.7,1.8


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/engine lib_emit.c,1.7,1.8
Date: Tue, 03 Jun 2003 02:17:12 -0400

Update of /cvsroot/dotgnu-pnet/pnet/engine
In directory subversions:/tmp/cvs-serv26014/engine

Modified Files:
        lib_emit.c 
Log Message:


Implement some of the Reflection.Emit internalcalls.


Index: lib_emit.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/lib_emit.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** lib_emit.c  28 Mar 2003 01:05:33 -0000      1.7
--- lib_emit.c  3 Jun 2003 06:17:10 -0000       1.8
***************
*** 28,34 ****
  #ifdef IL_CONFIG_REFLECTION
  
- /* TODO: all of these methods must be synchronized with the metadata
-    lock to ensure that user-level apps cannot circumvent heap security */
- 
  /*
   * private static IntPtr ClrAssemblyCreate(String name, int v1, int v2,
--- 28,31 ----
***************
*** 40,48 ****
                (ILExecThread *_thread, ILString *name, ILInt32 v1,
                 ILInt32 v2, ILInt32 v3, ILInt32 v4, ILInt32 access,
!                ILNativeInt *writer)
  {
!       /* TODO */
!       *writer = 0;
!       return 0;
  }
  
--- 37,124 ----
                (ILExecThread *_thread, ILString *name, ILInt32 v1,
                 ILInt32 v2, ILInt32 v3, ILInt32 v4, ILInt32 access,
!                ILNativeInt *writerReturn)
  {
!       const char *utf8Name;
!       ILContext *context;
!       ILImage *image;
!       ILWriter *writer;
!       int createdContext;
! 
!       /* Convert the name into a UTF8 string */
!       utf8Name = ILStringToUTF8(_thread, name);
!       if(!utf8Name)
!       {
!               return 0;
!       }
! 
!       /* Lock the metadata system while we do this */
!       IL_METADATA_WRLOCK(_thread);
! 
!       /* Determine which context to use: internal or external */
!       if((access & 1) != 0)
!       {
!               /* The assembly needs to be runnable in the current domain */
!               context = _thread->process->context;
!               createdContext = 0;
!       }
!       else
!       {
!               /* Create a new context outside the domain for a "Save" 
assembly */
!               context = ILContextCreate();
!               if(!context)
!               {
!                       IL_METADATA_UNLOCK(_thread);
!                       ILExecThreadThrowOutOfMemory(_thread);
!                       return 0;
!               }
!               createdContext = 1;
!       }
! 
!       /* Create a new ILImage structure for the assembly */
!       image = ILImageCreate(context);
!       if(!image)
!       {
!               if(createdContext)
!               {
!                       ILContextDestroy(context);
!               }
!               IL_METADATA_UNLOCK(_thread);
!               ILExecThreadThrowOutOfMemory(_thread);
!               return 0;
!       }
! 
!       /* Create a new ILWriter structure for the assembly.  We assume
!          that we are building a DLL, until we know otherwise later */
!       writer = ILWriterCreate(0, 0, IL_IMAGETYPE_DLL, 0);
!       if(!writer)
!       {
!               ILImageDestroy(image);
!               if(createdContext)
!               {
!                       ILContextDestroy(context);
!               }
!               IL_METADATA_UNLOCK(_thread);
!               ILExecThreadThrowOutOfMemory(_thread);
!               return 0;
!       }
! 
!       /* Create the initial ILAssembly structure in the image */
!       if(!ILAssemblyCreate(image, 0, utf8Name, 0))
!       {
!               ILWriterDestroy(writer);
!               ILImageDestroy(image);
!               if(createdContext)
!               {
!                       ILContextDestroy(context);
!               }
!               IL_METADATA_UNLOCK(_thread);
!               ILExecThreadThrowOutOfMemory(_thread);
!               return 0;
!       }
! 
!       /* Unlock and return the information to the caller */
!       IL_METADATA_UNLOCK(_thread);
!       *writerReturn = (ILNativeInt)writer;
!       return (ILNativeInt)image;
  }
  
***************
*** 156,160 ****
                                                                                
ILNativeInt item, ILInt32 offset)
  {
!       /* TODO */
  }
  
--- 232,255 ----
                                                                                
ILNativeInt item, ILInt32 offset)
  {
!       ILFieldLayout *layout;
!       IL_METADATA_WRLOCK(_thread);
!       if(item)
!       {
!               layout = ILFieldLayoutGetFromOwner((ILField *)item);
!               if(layout)
!               {
!                       ILFieldLayoutSetOffset(layout, (ILUInt32)offset);
!               }
!               else
!               {
!                       if(!ILFieldLayoutCreate(ILProgramItem_Image(item), 0,
!                                                                       
(ILField *)item, (ILUInt32)offset))
!                       {
!                               IL_METADATA_UNLOCK(_thread);
!                               ILExecThreadThrowOutOfMemory(_thread);
!                       }
!               }
!       }
!       IL_METADATA_UNLOCK(_thread);
  }
  
***************
*** 165,169 ****
                                                                         
ILNativeInt item, ILInt32 rva)
  {
!       /* TODO */
  }
  
--- 260,283 ----
                                                                         
ILNativeInt item, ILInt32 rva)
  {
!       ILFieldRVA *rvainfo;
!       IL_METADATA_WRLOCK(_thread);
!       if(item)
!       {
!               rvainfo = ILFieldRVAGetFromOwner((ILField *)item);
!               if(rvainfo)
!               {
!                       ILFieldRVASetRVA(rvainfo, (ILUInt32)rva);
!               }
!               else
!               {
!                       if(!ILFieldRVACreate(ILProgramItem_Image(item), 0,
!                                                                (ILField 
*)item, (ILUInt32)rva))
!                       {
!                               IL_METADATA_UNLOCK(_thread);
!                               ILExecThreadThrowOutOfMemory(_thread);
!                       }
!               }
!       }
!       IL_METADATA_UNLOCK(_thread);
  }
  
***************
*** 275,279 ****
                                                                                
   ILInt32 packingSize)
  {
!       /* TODO */
  }
  
--- 389,413 ----
                                                                                
   ILInt32 packingSize)
  {
!       ILClassLayout *layout;
!       IL_METADATA_WRLOCK(_thread);
!       if(classInfo)
!       {
!               layout = ILClassLayoutGetFromOwner((ILClass *)classInfo);
!               if(layout)
!               {
!                       ILClassLayoutSetPackingSize(layout, 
(ILUInt32)packingSize);
!               }
!               else
!               {
!                       if(!ILClassLayoutCreate(ILProgramItem_Image(classInfo), 
0,
!                                                                       
(ILClass *)classInfo,
!                                                                       
(ILUInt32)packingSize, 0))
!                       {
!                               IL_METADATA_UNLOCK(_thread);
!                               ILExecThreadThrowOutOfMemory(_thread);
!                       }
!               }
!       }
!       IL_METADATA_UNLOCK(_thread);
  }
  
***************
*** 285,289 ****
                                                                                
 ILInt32 classSize)
  {
!       /* TODO */
  }
  
--- 419,443 ----
                                                                                
 ILInt32 classSize)
  {
!       ILClassLayout *layout;
!       IL_METADATA_WRLOCK(_thread);
!       if(classInfo)
!       {
!               layout = ILClassLayoutGetFromOwner((ILClass *)classInfo);
!               if(layout)
!               {
!                       ILClassLayoutSetClassSize(layout, (ILUInt32)classSize);
!               }
!               else
!               {
!                       if(!ILClassLayoutCreate(ILProgramItem_Image(classInfo), 
0,
!                                                                       
(ILClass *)classInfo,
!                                                                       0, 
(ILUInt32)classSize))
!                       {
!                               IL_METADATA_UNLOCK(_thread);
!                               ILExecThreadThrowOutOfMemory(_thread);
!                       }
!               }
!       }
!       IL_METADATA_UNLOCK(_thread);
  }
  
***************
*** 304,309 ****
                                                                                
          ILNativeInt classInfo)
  {
!       /* TODO */
!       return 0;
  }
  
--- 458,474 ----
                                                                                
          ILNativeInt classInfo)
  {
!       ILInt32 size = 0;
!       ILClassLayout *layout;
!       IL_METADATA_WRLOCK(_thread);
!       if(classInfo)
!       {
!               layout = ILClassLayoutGetFromOwner((ILClass *)classInfo);
!               if(layout)
!               {
!                       size = (ILInt32)(ILClassLayoutGetPackingSize(layout));
!               }
!       }
!       IL_METADATA_UNLOCK(_thread);
!       return size;
  }
  
***************
*** 314,319 ****
                                                                                
        ILNativeInt classInfo)
  {
!       /* TODO */
!       return 0;
  }
  
--- 479,495 ----
                                                                                
        ILNativeInt classInfo)
  {
!       ILInt32 size = 0;
!       ILClassLayout *layout;
!       IL_METADATA_WRLOCK(_thread);
!       if(classInfo)
!       {
!               layout = ILClassLayoutGetFromOwner((ILClass *)classInfo);
!               if(layout)
!               {
!                       size = (ILInt32)(ILClassLayoutGetClassSize(layout));
!               }
!       }
!       IL_METADATA_UNLOCK(_thread);
!       return size;
  }
  
***************
*** 440,449 ****
                                                                                
                   ILNativeInt returnType)
  {
!       /* TODO */
!       return 0;
  }
  
  /*
!  * private static IntPtr ClrSigCreateMethod(IntPtr context, IntPtr 
returnType);
   */
  ILNativeInt _IL_SignatureHelper_ClrSigCreateProperty(ILExecThread *_thread,
--- 616,639 ----
                                                                                
                   ILNativeInt returnType)
  {
!       ILType *type = 0;
!       IL_METADATA_WRLOCK(_thread);
!       if(context)
!       {
!               type = ILTypeCreateMethod((ILContext *)context, (ILType 
*)returnType);
!               if(!type)
!               {
!                       IL_METADATA_UNLOCK(_thread);
!                       ILExecThreadThrowOutOfMemory(_thread);
!                       return 0;
!               }
!               ILTypeSetCallConv(type, (ILUInt32)callConv);
!       }
!       IL_METADATA_UNLOCK(_thread);
!       return (ILNativeInt)type;
  }
  
  /*
!  * private static IntPtr ClrSigCreateProperty
!  *            (IntPtr context, IntPtr returnType);
   */
  ILNativeInt _IL_SignatureHelper_ClrSigCreateProperty(ILExecThread *_thread,
***************
*** 451,456 ****
                                                                                
                         ILNativeInt returnType)
  {
!       /* TODO */
!       return 0;
  }
  
--- 641,658 ----
                                                                                
                         ILNativeInt returnType)
  {
!       ILType *type = 0;
!       IL_METADATA_WRLOCK(_thread);
!       if(context)
!       {
!               type = ILTypeCreateProperty((ILContext *)context, (ILType 
*)returnType);
!               if(!type)
!               {
!                       IL_METADATA_UNLOCK(_thread);
!                       ILExecThreadThrowOutOfMemory(_thread);
!                       return 0;
!               }
!       }
!       IL_METADATA_UNLOCK(_thread);
!       return (ILNativeInt)type;
  }
  
***************
*** 479,484 ****
                                                                                
                          ILObject *type)
  {
!       /* TODO */
!       return 0;
  }
  
--- 681,693 ----
                                                                                
                          ILObject *type)
  {
!       ILClass *classInfo = _ILGetClrClass(_thread, type);
!       if(classInfo)
!       {
!               return (ILNativeInt)(ILClassToType(classInfo));
!       }
!       else
!       {
!               return (ILNativeInt)ILType_Invalid;
!       }
  }
  
***************
*** 492,497 ****
                                                                                
                  ILNativeInt elemType)
  {
!       /* TODO */
!       return 0;
  }
  
--- 701,720 ----
                                                                                
                  ILNativeInt elemType)
  {
!       ILType *type = 0;
!       IL_METADATA_WRLOCK(_thread);
!       if(context)
!       {
!               type = ILTypeCreateArray
!                       ((ILContext *)context, (unsigned long)(long)rank,
!                        (ILType *)elemType);
!               if(!type)
!               {
!                       IL_METADATA_UNLOCK(_thread);
!                       ILExecThreadThrowOutOfMemory(_thread);
!                       return 0;
!               }
!       }
!       IL_METADATA_UNLOCK(_thread);
!       return (ILNativeInt)type;
  }
  
***************
*** 503,508 ****
                                                                                
                        ILNativeInt elemType)
  {
!       /* TODO */
!       return 0;
  }
  
--- 726,744 ----
                                                                                
                        ILNativeInt elemType)
  {
!       ILType *type = 0;
!       IL_METADATA_WRLOCK(_thread);
!       if(context)
!       {
!               type = ILTypeCreateRef
!                       ((ILContext *)context, IL_TYPE_COMPLEX_PTR, (ILType 
*)elemType);
!               if(!type)
!               {
!                       IL_METADATA_UNLOCK(_thread);
!                       ILExecThreadThrowOutOfMemory(_thread);
!                       return 0;
!               }
!       }
!       IL_METADATA_UNLOCK(_thread);
!       return (ILNativeInt)type;
  }
  
***************
*** 514,519 ****
                                                                                
                  ILNativeInt elemType)
  {
!       /* TODO */
!       return 0;
  }
  
--- 750,768 ----
                                                                                
                  ILNativeInt elemType)
  {
!       ILType *type = 0;
!       IL_METADATA_WRLOCK(_thread);
!       if(context)
!       {
!               type = ILTypeCreateRef
!                       ((ILContext *)context, IL_TYPE_COMPLEX_BYREF, (ILType 
*)elemType);
!               if(!type)
!               {
!                       IL_METADATA_UNLOCK(_thread);
!                       ILExecThreadThrowOutOfMemory(_thread);
!                       return 0;
!               }
!       }
!       IL_METADATA_UNLOCK(_thread);
!       return (ILNativeInt)type;
  }
  
***************
*** 572,577 ****
                                                                                
                  ILNativeInt context)
  {
!       /* TODO */
!       return 0;
  }
  
--- 821,838 ----
                                                                                
                  ILNativeInt context)
  {
!       ILType *type = 0;
!       IL_METADATA_WRLOCK(_thread);
!       if(context)
!       {
!               type = ILTypeCreateLocalList((ILContext *)context);
!               if(!type)
!               {
!                       IL_METADATA_UNLOCK(_thread);
!                       ILExecThreadThrowOutOfMemory(_thread);
!                       return 0;
!               }
!       }
!       IL_METADATA_UNLOCK(_thread);
!       return (ILNativeInt)type;
  }
  
***************
*** 585,590 ****
                                                                                
         ILNativeInt arg)
  {
!       /* TODO */
!       return 1;
  }
  
--- 846,879 ----
                                                                                
         ILNativeInt arg)
  {
!       int result = 0;
!       IL_METADATA_WRLOCK(_thread);
!       if(context && sig)
!       {
!               if(ILType_IsComplex((ILType *)sig) &&
!                  ILType_Kind((ILType *)sig) == IL_TYPE_COMPLEX_LOCALS)
!               {
!                       if(!ILTypeAddLocal((ILContext *)context,
!                                                          (ILType *)sig, 
(ILType *)arg))
!                       {
!                               IL_METADATA_UNLOCK(_thread);
!                               ILExecThreadThrowOutOfMemory(_thread);
!                               return 0;
!                       }
!                       result = 1;
!               }
!               else
!               {
!                       if(!ILTypeAddParam((ILContext *)context,
!                                                          (ILType *)sig, 
(ILType *)arg))
!                       {
!                               IL_METADATA_UNLOCK(_thread);
!                               ILExecThreadThrowOutOfMemory(_thread);
!                               return 0;
!                       }
!                       result = 1;
!               }
!       }
!       IL_METADATA_UNLOCK(_thread);
!       return (ILBool)result;
  }
  
***************
*** 596,601 ****
                                                                                
         ILNativeInt sig)
  {
!       /* TODO */
!       return 1;
  }
  
--- 885,902 ----
                                                                                
         ILNativeInt sig)
  {
!       int result = 0;
!       IL_METADATA_WRLOCK(_thread);
!       if(context && sig)
!       {
!               if(!ILTypeAddSentinel((ILContext *)context, (ILType *)sig))
!               {
!                       IL_METADATA_UNLOCK(_thread);
!                       ILExecThreadThrowOutOfMemory(_thread);
!                       return 0;
!               }
!               result = 1;
!       }
!       IL_METADATA_UNLOCK(_thread);
!       return (ILBool)result;
  }
  





reply via email to

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