/// <summary> /// Tries to resolve the given managed method to function reference. /// </summary> /// <param name="method">The method to resolve.</param> /// <param name="handle">The resolved function reference (if any).</param> /// <returns>True, if the requested function could be resolved.</returns> public bool TryGetMethodHandle(MethodBase method, out MethodHandle handle) { if (method == null) { throw new ArgumentNullException(nameof(method)); } // Synchronize all accesses below using a read scope using var readScope = irLock.EnterUpgradeableReadScope(); return(methods.TryGetHandle(method, out handle)); }
/// <summary> /// Returns the associated OpenCL type name. /// </summary> /// <param name="typeNode">The internal IR type node.</param> /// <returns>The resolved OpenCL type name.</returns> public string this[TypeNode typeNode] { get { // Synchronize all accesses below using a read/write scope using var readWriteScope = readerWriterLock.EnterUpgradeableReadScope(); if (mapping.TryGetValue(typeNode, out string typeName)) { return(typeName); } // Synchronize all accesses below using a write scope using var writeScope = readWriteScope.EnterWriteScope(); return(GetOrCreateType(typeNode)); } }
/// <summary> /// Resolves type information for the given type. /// </summary> /// <param name="type">The type to resolve.</param> /// <returns>The resolved type information.</returns> public TypeInformation GetTypeInfo(Type type) { if (type == null) { throw new ArgumentNullException(nameof(type)); } // Synchronize all accesses below using a read/write scope using var readWriteScope = cachingLock.EnterUpgradeableReadScope(); if (!typeInfoMapping.TryGetValue(type, out TypeInformation typeInfo)) { // Synchronize all accesses below using a write scope using var writeScope = readWriteScope.EnterWriteScope(); typeInfo = CreateTypeInfo(type); } return(typeInfo); }