/*
 * internal static byte[] GetLittleEndianBytes(double value);
 */
System_Array *_IL_BitConverter_GetLittleEndianBytes_d
		(ILExecThread *_thread, ILDouble value)
{
	System_Array *array =
		(System_Array *)ILExecThreadNew(_thread, "[B", "(Ti)V", (ILVaInt)8);
	if(array)
	{
		IL_WRITE_DOUBLE((unsigned char *)ArrayToBuffer(array), value);
	}
	return array;
}
Exemple #2
0
/*
 * private static void GetPrivateBinPaths(Object appDomain, ref String[] splitPaths);
 */
void _IL_AppDomainSetup_GetPrivateBinPaths(ILExecThread *thread,
										   ILObject *appDomain,
										   System_Array **splitPaths)
{
	if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
	{
		char **libraryDirs = 0;
		int numLibraryDirs = 0;

		IL_METADATA_RDLOCK((ILExecProcess *)appDomain);

		/* now clear the library dirs */
		ILContextGetLibraryDirs(((ILExecProcess *)appDomain)->context, &libraryDirs, &numLibraryDirs);

		IL_METADATA_UNLOCK((ILExecProcess *)appDomain);

		if (numLibraryDirs > 0)
		{
			System_Array *array;
			ILString **buffer;
			int i; /* loop counter */

			/* create the assembly array */
			array = (System_Array *)ILExecThreadNew(thread,
												"[oSystem.String;",
												"(Ti)V", (ILVaInt)numLibraryDirs);
			if (!array)
			{
				ILExecThreadThrowOutOfMemory(thread);
				return;
			}

			buffer = ArrayToBuffer(array);

			for (i = 0; i < numLibraryDirs; i++)
			{
				buffer[i] = ILStringCreate(thread, libraryDirs[i]);
			}
			/* return the array */
			*splitPaths = array;
		}
		else
		{
			*splitPaths = 0;
		}
	}
}
Exemple #3
0
/*
 * private static Assembly[] GetAssembliesInternal(Object appDomain);
 */
System_Array *_IL_AppDomain_GetAssembliesInternal(ILExecThread *thread,
												  ILObject *appDomain)
{
	if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
	{
		ILContext *context;
		ILImage *image;
		ILInt32 num;
		System_Array *array;
		ILObject **buffer;
		ILImage **images;
		ILImage **ptr;

		IL_METADATA_RDLOCK((ILExecProcess *)appDomain);

		context = ((ILExecProcess *)appDomain)->context;

		/* count out the number of images */
		image = 0;
		num = 0;
		while((image = ILContextNextImage(context, image)) != 0)
		{
			++num;
		}

		/* create the image array */
		if (!(images = (ILImage **)ILMalloc(sizeof(ILImage *)*num)))
		{
			IL_METADATA_UNLOCK((ILExecProcess *)appDomain);
			ILExecThreadThrowOutOfMemory(thread);
			return 0;
		}

		/* fill the image array */
		image = 0;
		ptr = images;
		while((image = ILContextNextImage(context, image)) != 0)
		{
			*ptr = image;
			++ptr;
		}

		IL_METADATA_UNLOCK((ILExecProcess *)appDomain);

		/* create the assembly array */
		array = (System_Array *)ILExecThreadNew(thread,
	                                        "[oSystem.Reflection.Assembly;",
	                                        "(Ti)V", (ILVaInt)num);
		if(!array)
		{
			ILExecThreadThrowOutOfMemory(thread);
			return 0;
		}

		/* fill the assembly array */
		ptr = images;
		buffer = (ILObject **)(ArrayToBuffer(array));
		while(num > 0)
		{
			*buffer = ImageToAssembly(thread, *ptr);
			++buffer;
			++ptr;
			--num;
		}

		/* cleanup */
		ILFree(images);

		/* return the assembly array */
		return array;
	}
	return (System_Array *)0;
}