ILObject *_IL_Object_MemberwiseClone(ILExecThread *thread, ILObject *_this) { ILObject *obj; /* Test for arrays, which must be cloned differently */ if(_ILIsSArray((System_Array *)_this)) { return _ILCloneSArray(thread, (System_Array *)_this); } #ifdef IL_CONFIG_NON_VECTOR_ARRAYS else if(_ILIsMArray((System_Array *)_this)) { return _ILCloneMArray(thread, (System_MArray *)_this); } #endif /* Allocate a new object of the same class */ obj = _ILEngineAllocObject(thread, GetObjectClass(_this)); if(!obj) { return 0; } /* Copy the contents of "this" into the new object */ if(GetObjectClassPrivate(_this)->size != 0) { ILMemCpy(obj, _this, GetObjectClassPrivate(_this)->size); } /* Return the cloned object to the caller */ return obj; }
ILObject *_IL_Object_GetType(ILExecThread *thread, ILObject *_this) { ILObject *obj; /* Check if _this is Null. */ if(_this == 0) { ILExecThreadThrowSystem(thread, "System.NullReferenceException", (const char *)0); return 0; } /* Does the class already have a "ClrType" instance? */ if(GetObjectClassPrivate(_this)->clrType) { return GetObjectClassPrivate(_this)->clrType; } /* Create a new "ClrType" instance for the "ILClass" structure */ obj = _ILGetClrType(thread, GetObjectClass(_this)); if(!obj) { return 0; } /* Return the object to the caller */ return obj; }
/* * Invoke a delegate from a closure. */ static void DelegateInvoke(ffi_cif *cif, void *result, void **args, void *delegate) { ILThread *thread = ILThreadSelf(); ILClassPrivate *classPrivate = GetObjectClassPrivate(delegate); ILExecProcess *process = classPrivate->process; ILDelegateInvokeParams params; params.thread = 0; params.cif = cif; params.result = result; params.args = args; params.delegate = (System_Delegate *)delegate; if(!thread) { /* callback was invoked by a non pnet thread. */ ILThreadRunSelf(_DelegateInvokeFromNewThread, (void *)¶ms); } else { params.thread = _ILExecThreadFromThread(thread); if(params.thread) { IL_BEGIN_EXECPROCESS_SWITCH(params.thread, process) _DelegateInvoke(¶ms); IL_END_EXECPROCESS_SWITCH(params.thread) } else { /* thread is not registerd for managed execution */ if((params.thread = ILThreadRegisterForManagedExecution(process, thread)))
/* * Invoke the delegate from a new thread. */ static void *_DelegateInvokeFromNewThread(void *params) { ILThread *thread = ILThreadSelf(); ILClassPrivate *classPrivate = GetObjectClassPrivate(((ILDelegateInvokeParams *)params)->delegate); ILExecProcess *process = classPrivate->process; if((((ILDelegateInvokeParams *)params)->thread = ILThreadRegisterForManagedExecution(process, thread))) { _DelegateInvoke((ILDelegateInvokeParams *)params); ILThreadUnregisterForManagedExecution(thread); } return 0; }