internal static DataLayout FromHandle(Context context, LLVMTargetDataRef targetDataRef, bool isDisposable) { lock ( TargetDataMap ) { if (TargetDataMap.TryGetValue(targetDataRef.Pointer, out DataLayout retVal)) { return(retVal); } retVal = new DataLayout(context, targetDataRef, isDisposable); Func <bool> cleanOnException = () => { retVal.Dispose( ); return(true); }; try { TargetDataMap.Add(targetDataRef.Pointer, retVal); } catch when(cleanOnException()) { // NOP } return(retVal); } }
internal static DataLayout FromHandle(LLVMTargetDataRef targetDataRef) { lock ( TargetDataMap ) { if (TargetDataMap.TryGetValue(targetDataRef, out DataLayout retVal)) { return(retVal); } retVal = new DataLayout(targetDataRef); TargetDataMap.Add(targetDataRef, retVal); return(retVal); } }