Example #1
0
        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);
            }
        }
Example #2
0
        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);
            }
        }