Exemplo n.º 1
0
        public Comdat Add(string key, ComdatKind kind)
        {
            LLVMComdatRef comdatRef = NativeMethods.ModuleInsertOrUpdateComdat(Module.ModuleHandle, key, ( LLVMComdatSelectionKind )kind);

            if (!InternalComdatMap.TryGetValue(key, out Comdat retVal))
            {
                retVal = new Comdat(Module, comdatRef);
                InternalComdatMap.Add(retVal.Name, retVal);
            }

            return(retVal);
        }
Exemplo n.º 2
0
        /// <summary>Inserts or updates a <see cref="Comdat"/> entry</summary>
        /// <param name="key">Name of the <see cref="Comdat"/></param>
        /// <param name="kind"><see cref="ComdatKind"/> for the entry</param>
        /// <returns>New or updated <see cref="Comdat"/></returns>
        public Comdat InsertOrUpdate(string key, ComdatKind kind)
        {
            key.ValidateNotNullOrWhiteSpace(nameof(key));
            kind.ValidateDefined(nameof(kind));

            LLVMComdatRef comdatRef = LibLLVMModuleInsertOrUpdateComdat(Module.ModuleHandle, key, ( LLVMComdatSelectionKind )kind);

            if (!InternalComdatMap.TryGetValue(key, out Comdat retVal))
            {
                retVal = new Comdat(Module, comdatRef);
                InternalComdatMap.Add(retVal.Name, retVal);
            }

            return(retVal);
        }
Exemplo n.º 3
0
        public bool Remove(string key)
        {
            if (!InternalComdatMap.TryGetValue(key, out Comdat value))
            {
                return(false);
            }

            bool retVal = InternalComdatMap.Remove(key);

            if (retVal)
            {
                ClearComdatFromGlobals(key);
                NativeMethods.ModuleComdatRemove(Module.ModuleHandle, value.ComdatHandle);
            }

            return(retVal);
        }
Exemplo n.º 4
0
        /// <summary>Removes a <see cref="Comdat"/> entry from the module</summary>
        /// <param name="key">Name of the <see cref="Comdat"/></param>
        /// <returns>
        /// <see langword="true"/> if the value was in the list or
        /// <see langword="false"/> otherwise
        /// </returns>
        public bool Remove(string key)
        {
            key.ValidateNotNullOrWhiteSpace(nameof(key));

            if (!InternalComdatMap.TryGetValue(key, out Comdat value))
            {
                return(false);
            }

            bool retVal = InternalComdatMap.Remove(key);

            if (retVal)
            {
                ClearComdatFromGlobals(key);
                LibLLVMModuleComdatRemove(Module.ModuleHandle, value.ComdatHandle);
            }

            return(retVal);
        }
Exemplo n.º 5
0
 /// <summary>Gets a value form the collection if it exists</summary>
 /// <param name="key">Name of the item to retrieve</param>
 /// <param name="value">Value of the item if found or <see langword="null"/> if not found</param>
 /// <returns>
 /// <see langword="true"/> if the value was found
 /// the list or <see langword="false"/> otherwise.
 /// </returns>
 public bool TryGetValue(string key, out Comdat value)
 {
     key.ValidateNotNullOrWhiteSpace(nameof(key));
     return(InternalComdatMap.TryGetValue(key, out value));
 }
Exemplo n.º 6
0
 public bool TryGetValue(string key, out Comdat value) => InternalComdatMap.TryGetValue(key, out value);