Beispiel #1
0
/*
 * private static void SetRelativeSearchPathInternal(Object appDomain, String appRelativePath);
 */
void _IL_AppDomain_SetRelativeSearchPathInternal(ILExecThread *thread,
												 ILObject *appDomain,
												 ILString *appRelativePath)
{
	if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
	{
		if(appRelativePath)
		{
			char *path = _ToAnsiString(thread, appRelativePath);

			if(!path)
			{
				ILExecThreadThrowOutOfMemory(thread);
				return;
			}	
		
			IL_METADATA_WRLOCK((ILExecProcess *)appDomain);

			ILContextSetRelativeSearchDir(((ILExecProcess *)appDomain)->context, path);
		}
		else
		{
			IL_METADATA_WRLOCK((ILExecProcess *)appDomain);

			ILContextSetRelativeSearchDir(((ILExecProcess *)appDomain)->context, 0);
		}
		IL_METADATA_UNLOCK((ILExecProcess *)appDomain);
	}
}
Beispiel #2
0
/*
 * private static void SetFriendlyNameInternal(Object appDomain, String friendlyName);
 */
void _IL_AppDomain_SetFriendlyNameInternal(ILExecThread *thread, ILObject *appDomain, ILString *friendlyName)
{
	if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
	{
		if(friendlyName)
		{
			char *name = _ToAnsiString(thread, friendlyName);

			if(!name)
			{
				ILExecThreadThrowOutOfMemory(thread);
				return;
			}	
		
			IL_METADATA_WRLOCK((ILExecProcess *)appDomain);

			ILExecProcessSetFriendlyName((ILExecProcess *)appDomain, name);
		}
		else
		{
			IL_METADATA_WRLOCK((ILExecProcess *)appDomain);

			ILExecProcessSetFriendlyName((ILExecProcess *)appDomain, 0);
		}
		IL_METADATA_UNLOCK((ILExecProcess *)appDomain);
	}
}
Beispiel #3
0
/*
 * private static void SetBaseDirectoryInternal(Object appDomain, String baseDirectory);
 */
void _IL_AppDomain_SetBaseDirectoryInternal(ILExecThread *thread, ILObject *appDomain, ILString *baseDirectory)
{
	if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
	{
		if(baseDirectory)
		{
			char *path = _ToAnsiString(thread, baseDirectory);

			if(!path)
			{
				ILExecThreadThrowOutOfMemory(thread);
				return;
			}	
		
			IL_METADATA_WRLOCK((ILExecProcess *)appDomain);

			ILContextSetApplicationBaseDir(((ILExecProcess *)appDomain)->context, path);
		}
		else
		{
			IL_METADATA_WRLOCK((ILExecProcess *)appDomain);

			ILContextSetApplicationBaseDir(((ILExecProcess *)appDomain)->context, 0);
		}
		IL_METADATA_UNLOCK((ILExecProcess *)appDomain);
	}
}
Beispiel #4
0
/*
 * private static void SetPrivateBinPaths(Object appDomain, String[] splitPaths);
 */
void _IL_AppDomainSetup_SetPrivateBinPaths(ILExecThread *thread,
										   ILObject *appDomain,
										   System_Array *splitPaths)
{
	if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
	{
		if (splitPaths && (ArrayLength(splitPaths) > 0))
		{
			char **libraryDirs = 0;
			int numLibraryDirs = 0;
			System_String **buffer = (System_String **)ArrayToBuffer(splitPaths);
			int i;  /* loop counter */

			/* allocate the array for the the new directories */
			if (!(libraryDirs = (char **)ILMalloc(sizeof(char *) * ArrayLength(splitPaths))))
			{
				ILExecThreadThrowOutOfMemory(thread);
				return;
			}
		
			/* now append the dirs */
			for (i = 0; i < ArrayLength(splitPaths); i++)
			{
				if (buffer[i] && buffer[i]->length)
				{
					libraryDirs[numLibraryDirs] = _ToAnsiString(thread, (ILString *)buffer[i]);
					numLibraryDirs++;
				}
			}

			IL_METADATA_WRLOCK((ILExecProcess *)appDomain);

			/* now set the new library dirs */
			ILContextSetLibraryDirs(((ILExecProcess *)appDomain)->context, libraryDirs, numLibraryDirs);

			IL_METADATA_UNLOCK((ILExecProcess *)appDomain);
		}
		else
		{

			IL_METADATA_WRLOCK((ILExecProcess *)appDomain);

			/* now clear the library dirs */
			ILContextClearLibraryDirs(((ILExecProcess *)appDomain)->context);

			IL_METADATA_UNLOCK((ILExecProcess *)appDomain);
		}
	}
}
Beispiel #5
0
/*
 * private static void ClearShadowCopyPathInternal(Object appDomain);
 */
void _IL_AppDomain_ClearShadowCopyPathInternal(ILExecThread *thread, ILObject *appDomain)
{
	if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
	{
		IL_METADATA_WRLOCK((ILExecProcess *)appDomain);

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

		IL_METADATA_UNLOCK((ILExecProcess *)appDomain);
	}
}
ILObject *_ILGetClrType(ILExecThread *thread, ILClass *classInfo)
{
	ILObject *obj;

	classInfo = ILClassResolve(classInfo);

	if(!classInfo)
	{
		thread->thrownException = _ILSystemException
			(thread, "System.TypeInitializationException");
		return 0;
	}

	/* Make sure that the class has been laid out */
	IL_METADATA_WRLOCK(_ILExecThreadProcess(thread));
	if(!_ILLayoutClass(_ILExecThreadProcess(thread), classInfo))
	{
		IL_METADATA_UNLOCK(_ILExecThreadProcess(thread));
		thread->thrownException = _ILSystemException
			(thread, "System.TypeInitializationException");
		return 0;
	}
	IL_METADATA_UNLOCK(_ILExecThreadProcess(thread));

	/* Does the class already have a "ClrType" instance? */
	if(((ILClassPrivate *)(classInfo->userData))->clrType)
	{
		return ((ILClassPrivate *)(classInfo->userData))->clrType;
	}

	/* Create a new "ClrType" instance */
	if(!(thread->process->clrTypeClass))
	{
		thread->thrownException = _ILSystemException
			(thread, "System.TypeInitializationException");
		return 0;
	}
	obj = _ILEngineAllocObject(thread, thread->process->clrTypeClass);
	if(!obj)
	{
		return 0;
	}

	/* Fill in the object with the class information */
	((System_Reflection *)obj)->privateData = classInfo;

	/* Attach the object to the class so that it will be returned
	   for future calls to this function */
	((ILClassPrivate *)(classInfo->userData))->clrType = obj;

	/* Return the object to the caller */
	return obj;
}
Beispiel #7
0
/*
 * private static void SetShadowCopyFilesInternal(Object appDomain, ILBool shadowCopyFiles);
 */
void _IL_AppDomain_SetShadowCopyFilesInternal(ILExecThread *thread,
											  ILObject *appDomain,
											  ILBool shadowCopyFiles)
{
	if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
	{
		IL_METADATA_WRLOCK((ILExecProcess *)appDomain);

		ILContextSetShadowCopyFiles(((ILExecProcess *)appDomain)->context, (int)shadowCopyFiles);

		IL_METADATA_UNLOCK((ILExecProcess *)appDomain);
	}
}
Beispiel #8
0
/*
 * private static void AppendPrivatePathInternal(Object appDomain, String[] splitPaths);
 */
void _IL_AppDomain_AppendPrivatePathsInternal(ILExecThread *thread, ILObject *appDomain, System_Array *splitPaths)
{
	if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
	{
		if (splitPaths && (ArrayLength(splitPaths) > 0))
		{
			char **libraryDirs;
			int numLibraryDirs;
			char **newLibraryDirs;
			System_String **buffer = (System_String **)ArrayToBuffer(splitPaths);
			int i;  /* loop counter */

			IL_METADATA_WRLOCK((ILExecProcess *)appDomain);

			ILContextGetLibraryDirs(((ILExecProcess *)appDomain)->context, &libraryDirs, &numLibraryDirs);

			/* allocate the array for the old + the new directories */
			if (!(newLibraryDirs = (char **)ILMalloc(sizeof(char *) * (numLibraryDirs + ArrayLength(splitPaths)))))
			{
				IL_METADATA_UNLOCK((ILExecProcess *)appDomain);
				ILExecThreadThrowOutOfMemory(thread);
				return;
			}
		
			/* copy over the old directories */
			for (i = 0; i < numLibraryDirs; i++)
			{
				newLibraryDirs[i] = libraryDirs[i];
			}

			/* now append the new dirs */
			for (i = 0; i < ArrayLength(splitPaths); i++)
			{
				if (buffer[i] && buffer[i]->length)
				{
					newLibraryDirs[numLibraryDirs] = ILStringToPathname(thread, (ILString *)buffer[i]);
					numLibraryDirs++;
				}
			}

			/* now set the new library dirs */
			ILContextSetLibraryDirs(((ILExecProcess *)appDomain)->context, newLibraryDirs, numLibraryDirs);

			IL_METADATA_UNLOCK((ILExecProcess *)appDomain);
		}
	}
}
Beispiel #9
0
/*
 * private static void SetShadowCopyPathInternal(Object appDomain, String[] splitPaths);
 */
void _IL_AppDomain_SetShadowCopyPathInternal(ILExecThread *thread,
											 ILObject *appDomain,
											 System_Array *splitPaths)
{
	if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain))
	{
		if (splitPaths && (ArrayLength(splitPaths) > 0))
		{
			char **shadowCopyDirs;
			int numShadowCopyDirs = 0;
			System_String **buffer = (System_String **)ArrayToBuffer(splitPaths);
			int i;  /* loop counter */

			/* allocate the array for the directories */
			if (!(shadowCopyDirs = (char **)ILMalloc(sizeof(char *) * (ArrayLength(splitPaths)))))
			{
				ILExecThreadThrowOutOfMemory(thread);
				return;
			}
		
			/* now copy the dirs */
			for (i = 0; i < ArrayLength(splitPaths); i++)
			{
				if (buffer[i] && buffer[i]->length)
				{
					shadowCopyDirs[numShadowCopyDirs] = _ToAnsiString(thread, (ILString *)buffer[i]);
					numShadowCopyDirs++;
				}
			}

			IL_METADATA_WRLOCK((ILExecProcess *)appDomain);

			/* now set the new shadow copy dirs */
			ILContextSetShadowCopyDirs(((ILExecProcess *)appDomain)->context, shadowCopyDirs, numShadowCopyDirs);

			IL_METADATA_UNLOCK((ILExecProcess *)appDomain);
		}
		else
		{
			_IL_AppDomain_ClearShadowCopyPathInternal(thread, appDomain);
		}
	}
}