Use new ArgumentNullException and ObjectDisposedException throw-helper API (#4163)
This commit is contained in:
parent
470be03c2f
commit
0d3b82477e
15 changed files with 58 additions and 196 deletions
|
@ -80,10 +80,7 @@ namespace ARMeilleure.Common
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_disposed)
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
{
|
|
||||||
throw new ObjectDisposedException(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (_pages)
|
lock (_pages)
|
||||||
{
|
{
|
||||||
|
@ -100,10 +97,7 @@ namespace ARMeilleure.Common
|
||||||
/// <exception cref="ArgumentException">Length of <paramref name="levels"/> is less than 2</exception>
|
/// <exception cref="ArgumentException">Length of <paramref name="levels"/> is less than 2</exception>
|
||||||
public AddressTable(Level[] levels)
|
public AddressTable(Level[] levels)
|
||||||
{
|
{
|
||||||
if (levels == null)
|
ArgumentNullException.ThrowIfNull(levels);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(levels));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (levels.Length < 2)
|
if (levels.Length < 2)
|
||||||
{
|
{
|
||||||
|
@ -141,10 +135,7 @@ namespace ARMeilleure.Common
|
||||||
/// <exception cref="ArgumentException"><paramref name="address"/> is not mapped</exception>
|
/// <exception cref="ArgumentException"><paramref name="address"/> is not mapped</exception>
|
||||||
public ref TEntry GetValue(ulong address)
|
public ref TEntry GetValue(ulong address)
|
||||||
{
|
{
|
||||||
if (_disposed)
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
{
|
|
||||||
throw new ObjectDisposedException(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!IsValid(address))
|
if (!IsValid(address))
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,10 +49,7 @@ namespace ARMeilleure.Common
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_disposed)
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
{
|
|
||||||
throw new ObjectDisposedException(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ref _countTable.GetValue(_index);
|
return ref _countTable.GetValue(_index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,10 +53,7 @@ namespace ARMeilleure.Common
|
||||||
/// <exception cref="ObjectDisposedException"><see cref="EntryTable{TEntry}"/> instance was disposed</exception>
|
/// <exception cref="ObjectDisposedException"><see cref="EntryTable{TEntry}"/> instance was disposed</exception>
|
||||||
public int Allocate()
|
public int Allocate()
|
||||||
{
|
{
|
||||||
if (_disposed)
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
{
|
|
||||||
throw new ObjectDisposedException(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (_allocated)
|
lock (_allocated)
|
||||||
{
|
{
|
||||||
|
@ -83,10 +80,7 @@ namespace ARMeilleure.Common
|
||||||
/// <exception cref="ObjectDisposedException"><see cref="EntryTable{TEntry}"/> instance was disposed</exception>
|
/// <exception cref="ObjectDisposedException"><see cref="EntryTable{TEntry}"/> instance was disposed</exception>
|
||||||
public void Free(int index)
|
public void Free(int index)
|
||||||
{
|
{
|
||||||
if (_disposed)
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
{
|
|
||||||
throw new ObjectDisposedException(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (_allocated)
|
lock (_allocated)
|
||||||
{
|
{
|
||||||
|
@ -108,10 +102,7 @@ namespace ARMeilleure.Common
|
||||||
/// <exception cref="ArgumentException">Entry at <paramref name="index"/> is not allocated</exception>
|
/// <exception cref="ArgumentException">Entry at <paramref name="index"/> is not allocated</exception>
|
||||||
public ref TEntry GetValue(int index)
|
public ref TEntry GetValue(int index)
|
||||||
{
|
{
|
||||||
if (_disposed)
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
{
|
|
||||||
throw new ObjectDisposedException(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (_allocated)
|
lock (_allocated)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,10 +48,7 @@ namespace ARMeilleure.IntermediateRepresentation
|
||||||
|
|
||||||
public void AddSuccessor(BasicBlock block)
|
public void AddSuccessor(BasicBlock block)
|
||||||
{
|
{
|
||||||
if (block == null)
|
ArgumentNullException.ThrowIfNull(block);
|
||||||
{
|
|
||||||
ThrowNull(nameof(block));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((uint)_succCount + 1 > MaxSuccessors)
|
if ((uint)_succCount + 1 > MaxSuccessors)
|
||||||
{
|
{
|
||||||
|
@ -100,10 +97,7 @@ namespace ARMeilleure.IntermediateRepresentation
|
||||||
|
|
||||||
public void SetSuccessor(int index, BasicBlock block)
|
public void SetSuccessor(int index, BasicBlock block)
|
||||||
{
|
{
|
||||||
if (block == null)
|
ArgumentNullException.ThrowIfNull(block);
|
||||||
{
|
|
||||||
ThrowNull(nameof(block));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((uint)index >= (uint)_succCount)
|
if ((uint)index >= (uint)_succCount)
|
||||||
{
|
{
|
||||||
|
@ -144,7 +138,6 @@ namespace ARMeilleure.IntermediateRepresentation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ThrowNull(string name) => throw new ArgumentNullException(name);
|
|
||||||
private static void ThrowOutOfRange(string name) => throw new ArgumentOutOfRangeException(name);
|
private static void ThrowOutOfRange(string name) => throw new ArgumentOutOfRangeException(name);
|
||||||
private static void ThrowSuccessorOverflow() => throw new OverflowException($"BasicBlock can only have {MaxSuccessors} successors.");
|
private static void ThrowSuccessorOverflow() => throw new OverflowException($"BasicBlock can only have {MaxSuccessors} successors.");
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,7 @@ namespace ARMeilleure.Translation
|
||||||
|
|
||||||
public static Delegate GetDelegate(MethodInfo info)
|
public static Delegate GetDelegate(MethodInfo info)
|
||||||
{
|
{
|
||||||
if (info == null)
|
ArgumentNullException.ThrowIfNull(info);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(info));
|
|
||||||
}
|
|
||||||
|
|
||||||
Type[] parameters = info.GetParameters().Select(pI => pI.ParameterType).ToArray();
|
Type[] parameters = info.GetParameters().Select(pI => pI.ParameterType).ToArray();
|
||||||
Type returnType = info.ReturnType;
|
Type returnType = info.ReturnType;
|
||||||
|
|
|
@ -35,10 +35,7 @@ namespace ARMeilleure.Translation
|
||||||
|
|
||||||
public static IntPtr GetDelegateFuncPtr(MethodInfo info)
|
public static IntPtr GetDelegateFuncPtr(MethodInfo info)
|
||||||
{
|
{
|
||||||
if (info == null)
|
ArgumentNullException.ThrowIfNull(info);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(info));
|
|
||||||
}
|
|
||||||
|
|
||||||
string key = GetKey(info);
|
string key = GetKey(info);
|
||||||
|
|
||||||
|
@ -52,10 +49,7 @@ namespace ARMeilleure.Translation
|
||||||
|
|
||||||
public static int GetDelegateIndex(MethodInfo info)
|
public static int GetDelegateIndex(MethodInfo info)
|
||||||
{
|
{
|
||||||
if (info == null)
|
ArgumentNullException.ThrowIfNull(info);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(info));
|
|
||||||
}
|
|
||||||
|
|
||||||
string key = GetKey(info);
|
string key = GetKey(info);
|
||||||
|
|
||||||
|
|
|
@ -67,10 +67,7 @@ namespace ARMeilleure.Translation
|
||||||
/// <returns>True if the value was added, false if the start key was already in the dictionary</returns>
|
/// <returns>True if the value was added, false if the start key was already in the dictionary</returns>
|
||||||
public bool AddOrUpdate(K start, K end, V value, Func<K, V, V> updateFactoryCallback)
|
public bool AddOrUpdate(K start, K end, V value, Func<K, V, V> updateFactoryCallback)
|
||||||
{
|
{
|
||||||
if (value == null)
|
ArgumentNullException.ThrowIfNull(value);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
return BSTInsert(start, end, value, updateFactoryCallback, out IntervalTreeNode<K, V> node);
|
return BSTInsert(start, end, value, updateFactoryCallback, out IntervalTreeNode<K, V> node);
|
||||||
}
|
}
|
||||||
|
@ -85,10 +82,7 @@ namespace ARMeilleure.Translation
|
||||||
/// <returns><paramref name="value"/> if <paramref name="start"/> is not yet on the tree, or the existing value otherwise</returns>
|
/// <returns><paramref name="value"/> if <paramref name="start"/> is not yet on the tree, or the existing value otherwise</returns>
|
||||||
public V GetOrAdd(K start, K end, V value)
|
public V GetOrAdd(K start, K end, V value)
|
||||||
{
|
{
|
||||||
if (value == null)
|
ArgumentNullException.ThrowIfNull(value);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
BSTInsert(start, end, value, null, out IntervalTreeNode<K, V> node);
|
BSTInsert(start, end, value, null, out IntervalTreeNode<K, V> node);
|
||||||
return node.Value;
|
return node.Value;
|
||||||
|
@ -152,10 +146,7 @@ namespace ARMeilleure.Translation
|
||||||
/// <returns>Node reference in the tree</returns>
|
/// <returns>Node reference in the tree</returns>
|
||||||
private IntervalTreeNode<K, V> GetNode(K key)
|
private IntervalTreeNode<K, V> GetNode(K key)
|
||||||
{
|
{
|
||||||
if (key == null)
|
ArgumentNullException.ThrowIfNull(key);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
IntervalTreeNode<K, V> node = _root;
|
IntervalTreeNode<K, V> node = _root;
|
||||||
while (node != null)
|
while (node != null)
|
||||||
|
|
|
@ -30,10 +30,7 @@ namespace ARMeilleure.Translation
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_disposed)
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
{
|
|
||||||
throw new ObjectDisposedException(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _dispatchStub.Value;
|
return _dispatchStub.Value;
|
||||||
}
|
}
|
||||||
|
@ -47,10 +44,7 @@ namespace ARMeilleure.Translation
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_disposed)
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
{
|
|
||||||
throw new ObjectDisposedException(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _slowDispatchStub.Value;
|
return _slowDispatchStub.Value;
|
||||||
}
|
}
|
||||||
|
@ -64,10 +58,7 @@ namespace ARMeilleure.Translation
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_disposed)
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
{
|
|
||||||
throw new ObjectDisposedException(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _dispatchLoop.Value;
|
return _dispatchLoop.Value;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +72,9 @@ namespace ARMeilleure.Translation
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="translator"/> is null</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="translator"/> is null</exception>
|
||||||
public TranslatorStubs(Translator translator)
|
public TranslatorStubs(Translator translator)
|
||||||
{
|
{
|
||||||
_translator = translator ?? throw new ArgumentNullException(nameof(translator));
|
ArgumentNullException.ThrowIfNull(translator);
|
||||||
|
|
||||||
|
_translator = translator;
|
||||||
_dispatchStub = new(GenerateDispatchStub, isThreadSafe: true);
|
_dispatchStub = new(GenerateDispatchStub, isThreadSafe: true);
|
||||||
_dispatchLoop = new(GenerateDispatchLoop, isThreadSafe: true);
|
_dispatchLoop = new(GenerateDispatchLoop, isThreadSafe: true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,7 @@ namespace Ryujinx.Common.Collections
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception>
|
||||||
public int Get(K key, ref V[] overlaps)
|
public int Get(K key, ref V[] overlaps)
|
||||||
{
|
{
|
||||||
if (key == null)
|
ArgumentNullException.ThrowIfNull(key);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
IntervalTreeNode<K, V> node = GetNode(key);
|
IntervalTreeNode<K, V> node = GetNode(key);
|
||||||
|
|
||||||
|
@ -61,15 +58,8 @@ namespace Ryujinx.Common.Collections
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="start"/> or <paramref name="end"/> is null</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="start"/> or <paramref name="end"/> is null</exception>
|
||||||
public int Get(K start, K end, ref V[] overlaps, int overlapCount = 0)
|
public int Get(K start, K end, ref V[] overlaps, int overlapCount = 0)
|
||||||
{
|
{
|
||||||
if (start == null)
|
ArgumentNullException.ThrowIfNull(start);
|
||||||
{
|
ArgumentNullException.ThrowIfNull(end);
|
||||||
throw new ArgumentNullException(nameof(start));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (end == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(end));
|
|
||||||
}
|
|
||||||
|
|
||||||
GetValues(Root, start, end, ref overlaps, ref overlapCount);
|
GetValues(Root, start, end, ref overlaps, ref overlapCount);
|
||||||
|
|
||||||
|
@ -85,20 +75,9 @@ namespace Ryujinx.Common.Collections
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="start"/>, <paramref name="end"/> or <paramref name="value"/> are null</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="start"/>, <paramref name="end"/> or <paramref name="value"/> are null</exception>
|
||||||
public void Add(K start, K end, V value)
|
public void Add(K start, K end, V value)
|
||||||
{
|
{
|
||||||
if (start == null)
|
ArgumentNullException.ThrowIfNull(start);
|
||||||
{
|
ArgumentNullException.ThrowIfNull(end);
|
||||||
throw new ArgumentNullException(nameof(start));
|
ArgumentNullException.ThrowIfNull(value);
|
||||||
}
|
|
||||||
|
|
||||||
if (end == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(end));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
Insert(start, end, value);
|
Insert(start, end, value);
|
||||||
}
|
}
|
||||||
|
@ -112,10 +91,7 @@ namespace Ryujinx.Common.Collections
|
||||||
/// <returns>Number of deleted values</returns>
|
/// <returns>Number of deleted values</returns>
|
||||||
public int Remove(K key, V value)
|
public int Remove(K key, V value)
|
||||||
{
|
{
|
||||||
if (key == null)
|
ArgumentNullException.ThrowIfNull(key);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
int removed = Delete(key, value);
|
int removed = Delete(key, value);
|
||||||
|
|
||||||
|
@ -168,10 +144,7 @@ namespace Ryujinx.Common.Collections
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception>
|
||||||
private IntervalTreeNode<K, V> GetNode(K key)
|
private IntervalTreeNode<K, V> GetNode(K key)
|
||||||
{
|
{
|
||||||
if (key == null)
|
ArgumentNullException.ThrowIfNull(key);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
IntervalTreeNode<K, V> node = Root;
|
IntervalTreeNode<K, V> node = Root;
|
||||||
while (node != null)
|
while (node != null)
|
||||||
|
@ -462,10 +435,8 @@ namespace Ryujinx.Common.Collections
|
||||||
|
|
||||||
public bool ContainsKey(K key)
|
public bool ContainsKey(K key)
|
||||||
{
|
{
|
||||||
if (key == null)
|
ArgumentNullException.ThrowIfNull(key);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(key));
|
|
||||||
}
|
|
||||||
return GetNode(key) != null;
|
return GetNode(key) != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,7 @@ namespace Ryujinx.Common.Collections
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="node"/> is null</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="node"/> is null</exception>
|
||||||
public void Add(T node)
|
public void Add(T node)
|
||||||
{
|
{
|
||||||
if (node == null)
|
ArgumentNullException.ThrowIfNull(node);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(node));
|
|
||||||
}
|
|
||||||
|
|
||||||
Insert(node);
|
Insert(node);
|
||||||
}
|
}
|
||||||
|
@ -32,10 +29,8 @@ namespace Ryujinx.Common.Collections
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="node"/> is null</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="node"/> is null</exception>
|
||||||
public void Remove(T node)
|
public void Remove(T node)
|
||||||
{
|
{
|
||||||
if (node == null)
|
ArgumentNullException.ThrowIfNull(node);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(node));
|
|
||||||
}
|
|
||||||
if (Delete(node) != null)
|
if (Delete(node) != null)
|
||||||
{
|
{
|
||||||
Count--;
|
Count--;
|
||||||
|
@ -50,10 +45,7 @@ namespace Ryujinx.Common.Collections
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="searchNode"/> is null</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="searchNode"/> is null</exception>
|
||||||
public T GetNode(T searchNode)
|
public T GetNode(T searchNode)
|
||||||
{
|
{
|
||||||
if (searchNode == null)
|
ArgumentNullException.ThrowIfNull(searchNode);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(searchNode));
|
|
||||||
}
|
|
||||||
|
|
||||||
T node = Root;
|
T node = Root;
|
||||||
while (node != null)
|
while (node != null)
|
||||||
|
|
|
@ -92,10 +92,8 @@ namespace Ryujinx.Common.Collections
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="node"/> is null</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="node"/> is null</exception>
|
||||||
protected static T Minimum(T node)
|
protected static T Minimum(T node)
|
||||||
{
|
{
|
||||||
if (node == null)
|
ArgumentNullException.ThrowIfNull(node);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(node));
|
|
||||||
}
|
|
||||||
T tmp = node;
|
T tmp = node;
|
||||||
while (tmp.Left != null)
|
while (tmp.Left != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,10 +22,7 @@ namespace Ryujinx.Common.Collections
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception>
|
||||||
public V Get(K key)
|
public V Get(K key)
|
||||||
{
|
{
|
||||||
if (key == null)
|
ArgumentNullException.ThrowIfNull(key);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
Node<K, V> node = GetNode(key);
|
Node<K, V> node = GetNode(key);
|
||||||
|
|
||||||
|
@ -47,14 +44,8 @@ namespace Ryujinx.Common.Collections
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="key"/> or <paramref name="value"/> are null</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="key"/> or <paramref name="value"/> are null</exception>
|
||||||
public void Add(K key, V value)
|
public void Add(K key, V value)
|
||||||
{
|
{
|
||||||
if (key == null)
|
ArgumentNullException.ThrowIfNull(key);
|
||||||
{
|
ArgumentNullException.ThrowIfNull(value);
|
||||||
throw new ArgumentNullException(nameof(key));
|
|
||||||
}
|
|
||||||
if (value == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
Insert(key, value);
|
Insert(key, value);
|
||||||
}
|
}
|
||||||
|
@ -66,10 +57,8 @@ namespace Ryujinx.Common.Collections
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception>
|
||||||
public void Remove(K key)
|
public void Remove(K key)
|
||||||
{
|
{
|
||||||
if (key == null)
|
ArgumentNullException.ThrowIfNull(key);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(key));
|
|
||||||
}
|
|
||||||
if (Delete(key) != null)
|
if (Delete(key) != null)
|
||||||
{
|
{
|
||||||
Count--;
|
Count--;
|
||||||
|
@ -217,10 +206,7 @@ namespace Ryujinx.Common.Collections
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception>
|
||||||
private Node<K, V> GetNode(K key)
|
private Node<K, V> GetNode(K key)
|
||||||
{
|
{
|
||||||
if (key == null)
|
ArgumentNullException.ThrowIfNull(key);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
Node<K, V> node = Root;
|
Node<K, V> node = Root;
|
||||||
while (node != null)
|
while (node != null)
|
||||||
|
@ -370,10 +356,8 @@ namespace Ryujinx.Common.Collections
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception>
|
||||||
private Node<K, V> FloorNode(K key)
|
private Node<K, V> FloorNode(K key)
|
||||||
{
|
{
|
||||||
if (key == null)
|
ArgumentNullException.ThrowIfNull(key);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(key));
|
|
||||||
}
|
|
||||||
Node<K, V> tmp = Root;
|
Node<K, V> tmp = Root;
|
||||||
|
|
||||||
while (tmp != null)
|
while (tmp != null)
|
||||||
|
@ -424,10 +408,8 @@ namespace Ryujinx.Common.Collections
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception>
|
||||||
private Node<K, V> CeilingNode(K key)
|
private Node<K, V> CeilingNode(K key)
|
||||||
{
|
{
|
||||||
if (key == null)
|
ArgumentNullException.ThrowIfNull(key);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(key));
|
|
||||||
}
|
|
||||||
Node<K, V> tmp = Root;
|
Node<K, V> tmp = Root;
|
||||||
|
|
||||||
while (tmp != null)
|
while (tmp != null)
|
||||||
|
@ -477,10 +459,8 @@ namespace Ryujinx.Common.Collections
|
||||||
// Method descriptions are not provided as they are already included as part of the interface.
|
// Method descriptions are not provided as they are already included as part of the interface.
|
||||||
public bool ContainsKey(K key)
|
public bool ContainsKey(K key)
|
||||||
{
|
{
|
||||||
if (key == null)
|
ArgumentNullException.ThrowIfNull(key);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(key));
|
|
||||||
}
|
|
||||||
return GetNode(key) != null;
|
return GetNode(key) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,10 +473,8 @@ namespace Ryujinx.Common.Collections
|
||||||
|
|
||||||
public bool TryGetValue(K key, [MaybeNullWhen(false)] out V value)
|
public bool TryGetValue(K key, [MaybeNullWhen(false)] out V value)
|
||||||
{
|
{
|
||||||
if (null == key)
|
ArgumentNullException.ThrowIfNull(key);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(key));
|
|
||||||
}
|
|
||||||
Node<K, V> node = GetNode(key);
|
Node<K, V> node = GetNode(key);
|
||||||
value = node != null ? node.Value : default;
|
value = node != null ? node.Value : default;
|
||||||
return node != null;
|
return node != null;
|
||||||
|
@ -504,10 +482,7 @@ namespace Ryujinx.Common.Collections
|
||||||
|
|
||||||
public void Add(KeyValuePair<K, V> item)
|
public void Add(KeyValuePair<K, V> item)
|
||||||
{
|
{
|
||||||
if (item.Key == null)
|
ArgumentNullException.ThrowIfNull(item.Key);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(item.Key));
|
|
||||||
}
|
|
||||||
|
|
||||||
Add(item.Key, item.Value);
|
Add(item.Key, item.Value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,20 +32,9 @@ namespace Ryujinx.HLE
|
||||||
|
|
||||||
public Switch(HLEConfiguration configuration)
|
public Switch(HLEConfiguration configuration)
|
||||||
{
|
{
|
||||||
if (configuration.GpuRenderer == null)
|
ArgumentNullException.ThrowIfNull(configuration.GpuRenderer);
|
||||||
{
|
ArgumentNullException.ThrowIfNull(configuration.AudioDeviceDriver);
|
||||||
throw new ArgumentNullException(nameof(configuration.GpuRenderer));
|
ArgumentNullException.ThrowIfNull(configuration.UserChannelPersistence);
|
||||||
}
|
|
||||||
|
|
||||||
if (configuration.AudioDeviceDriver == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(configuration.AudioDeviceDriver));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configuration.UserChannelPersistence == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(configuration.UserChannelPersistence));
|
|
||||||
}
|
|
||||||
|
|
||||||
Configuration = configuration;
|
Configuration = configuration;
|
||||||
FileSystem = Configuration.VirtualFileSystem;
|
FileSystem = Configuration.VirtualFileSystem;
|
||||||
|
|
|
@ -279,10 +279,7 @@ namespace Ryujinx.Memory
|
||||||
{
|
{
|
||||||
IntPtr ptr = _pointer;
|
IntPtr ptr = _pointer;
|
||||||
|
|
||||||
if (ptr == IntPtr.Zero)
|
ObjectDisposedException.ThrowIf(ptr == IntPtr.Zero, this);
|
||||||
{
|
|
||||||
ThrowObjectDisposed();
|
|
||||||
}
|
|
||||||
|
|
||||||
int size = Unsafe.SizeOf<T>();
|
int size = Unsafe.SizeOf<T>();
|
||||||
|
|
||||||
|
@ -312,10 +309,7 @@ namespace Ryujinx.Memory
|
||||||
{
|
{
|
||||||
IntPtr ptr = _pointer;
|
IntPtr ptr = _pointer;
|
||||||
|
|
||||||
if (ptr == IntPtr.Zero)
|
ObjectDisposedException.ThrowIf(ptr == IntPtr.Zero, this);
|
||||||
{
|
|
||||||
ThrowObjectDisposed();
|
|
||||||
}
|
|
||||||
|
|
||||||
ulong endOffset = offset + size;
|
ulong endOffset = offset + size;
|
||||||
|
|
||||||
|
@ -454,7 +448,6 @@ namespace Ryujinx.Memory
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ThrowObjectDisposed() => throw new ObjectDisposedException(nameof(MemoryBlock));
|
|
||||||
private static void ThrowInvalidMemoryRegionException() => throw new InvalidMemoryRegionException();
|
private static void ThrowInvalidMemoryRegionException() => throw new InvalidMemoryRegionException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -411,10 +411,7 @@ namespace Ryujinx.Memory.Tracking
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (_disposed)
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
{
|
|
||||||
throw new ObjectDisposedException(GetType().FullName);
|
|
||||||
}
|
|
||||||
|
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue