mirror of
https://git.743378673.xyz/MeloNX/MeloNX.git
synced 2025-07-27 00:47:11 +02:00
[Ryujinx.HLE] Address dotnet-format issues (#5380)
* dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Silence dotnet format IDE0052 warnings * Address or silence dotnet format IDE1006 warnings * Address dotnet format CA1816 warnings * Address or silence dotnet format CA2208 warnings * Address or silence dotnet format CA1806 and a few CA1854 warnings * Address dotnet format CA2211 warnings * Address dotnet format CA1822 warnings * Address or silence dotnet format CA1069 warnings * Make dotnet format succeed in style mode * Address or silence dotnet format CA2211 warnings * Address review comments * Address dotnet format CA2208 warnings properly * Make ProcessResult readonly * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Add previously silenced warnings back I have no clue how these disappeared * Revert formatting changes for while and for-loops * Format if-blocks correctly * Run dotnet format style after rebase * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Run dotnet format analyzers after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Disable 'prefer switch expression' rule * Add comments to disabled warnings * Fix a few disabled warnings * Fix naming rule violation, Convert shader properties to auto-property and convert values to const * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Fix and silence a few dotnet-format warnings again * Run dotnet format after rebase * Use using declaration instead of block syntax * Address IDE0251 warnings * Address a few disabled IDE0060 warnings * Silence IDE0060 in .editorconfig * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Fix naming rule violations * Fix typo * Add trailing commas, use targeted new and use array initializer * Fix build issues * Fix remaining build issues * Remove SuppressMessage for CA1069 where possible * Address dotnet format issues * Address formatting issues Co-authored-by: Ac_K <acoustik666@gmail.com> * Add GetHashCode implementation for RenderingSurfaceInfo * Explicitly silence CA1822 for every affected method in Syscall * Address formatting issues in Demangler.cs * Address review feedback Co-authored-by: Ac_K <acoustik666@gmail.com> * Revert marking service methods as static * Next dotnet format pass * Address review feedback --------- Co-authored-by: Ac_K <acoustik666@gmail.com>
This commit is contained in:
parent
fec8291c17
commit
326749498b
1015 changed files with 8173 additions and 7615 deletions
|
@ -8,25 +8,25 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
{
|
||||
class Demangler
|
||||
{
|
||||
private static readonly string Base36 = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
private List<BaseNode> _substitutionList = new List<BaseNode>();
|
||||
private List<BaseNode> _templateParamList = new List<BaseNode>();
|
||||
private static readonly string _base36 = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
private readonly List<BaseNode> _substitutionList = new();
|
||||
private List<BaseNode> _templateParamList = new();
|
||||
|
||||
private List<ForwardTemplateReference> _forwardTemplateReferenceList = new List<ForwardTemplateReference>();
|
||||
private readonly List<ForwardTemplateReference> _forwardTemplateReferenceList = new();
|
||||
|
||||
public string Mangled { get; private set; }
|
||||
|
||||
private int _position;
|
||||
private int _length;
|
||||
private readonly int _length;
|
||||
|
||||
private bool _canForwardTemplateReference;
|
||||
private bool _canParseTemplateArgs;
|
||||
|
||||
public Demangler(string mangled)
|
||||
{
|
||||
Mangled = mangled;
|
||||
_position = 0;
|
||||
_length = mangled.Length;
|
||||
Mangled = mangled;
|
||||
_position = 0;
|
||||
_length = mangled.Length;
|
||||
_canParseTemplateArgs = true;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
|
||||
for (int i = 0; i < reversedEncoded.Length; i++)
|
||||
{
|
||||
int value = Base36.IndexOf(reversedEncoded[i]);
|
||||
int value = _base36.IndexOf(reversedEncoded[i]);
|
||||
if (value == -1)
|
||||
{
|
||||
return -1;
|
||||
|
@ -101,8 +101,8 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
|
||||
private int ParseSeqId()
|
||||
{
|
||||
ReadOnlySpan<char> part = Mangled.AsSpan(_position);
|
||||
int seqIdLen = 0;
|
||||
ReadOnlySpan<char> part = Mangled.AsSpan(_position);
|
||||
int seqIdLen = 0;
|
||||
|
||||
for (; seqIdLen < part.Length; seqIdLen++)
|
||||
{
|
||||
|
@ -274,7 +274,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
}
|
||||
else if (ConsumeIf("Dw"))
|
||||
{
|
||||
List<BaseNode> types = new List<BaseNode>();
|
||||
List<BaseNode> types = new();
|
||||
|
||||
while (!ConsumeIf("E"))
|
||||
{
|
||||
|
@ -308,7 +308,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
}
|
||||
|
||||
Reference referenceQualifier = Reference.None;
|
||||
List<BaseNode> Params = new List<BaseNode>();
|
||||
List<BaseNode> paramsList = new();
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
@ -339,10 +339,10 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
return null;
|
||||
}
|
||||
|
||||
Params.Add(type);
|
||||
paramsList.Add(type);
|
||||
}
|
||||
|
||||
return new FunctionType(returnType, new NodeArray(Params), new CvType(cvQualifiers, null), new SimpleReferenceType(referenceQualifier, null), exceptionSpec);
|
||||
return new FunctionType(returnType, new NodeArray(paramsList), new CvType(cvQualifiers, null), new SimpleReferenceType(referenceQualifier, null), exceptionSpec);
|
||||
}
|
||||
|
||||
// <array-type> ::= A <positive dimension number> _ <element type>
|
||||
|
@ -416,12 +416,9 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
private BaseNode ParseType(NameParserContext context = null)
|
||||
{
|
||||
// Temporary context
|
||||
if (context == null)
|
||||
{
|
||||
context = new NameParserContext();
|
||||
}
|
||||
context ??= new NameParserContext();
|
||||
|
||||
BaseNode result = null;
|
||||
BaseNode result;
|
||||
switch (Peek())
|
||||
{
|
||||
case 'r':
|
||||
|
@ -545,8 +542,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
case 'h':
|
||||
_position += 2;
|
||||
// FIXME: GNU c++flit returns this but that is not what is supposed to be returned.
|
||||
return new NameType("half");
|
||||
// return new NameType("decimal16");
|
||||
return new NameType("half"); // return new NameType("decimal16");
|
||||
case 'i':
|
||||
_position += 2;
|
||||
return new NameType("char32_t");
|
||||
|
@ -559,8 +555,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
case 'n':
|
||||
_position += 2;
|
||||
// FIXME: GNU c++flit returns this but that is not what is supposed to be returned.
|
||||
return new NameType("decltype(nullptr)");
|
||||
// return new NameType("std::nullptr_t");
|
||||
return new NameType("decltype(nullptr)"); // return new NameType("std::nullptr_t");
|
||||
case 't':
|
||||
case 'T':
|
||||
_position += 2;
|
||||
|
@ -882,7 +877,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
return new SimpleReferenceType(result, null);
|
||||
}
|
||||
|
||||
private BaseNode CreateNameNode(BaseNode prev, BaseNode name, NameParserContext context)
|
||||
private static BaseNode CreateNameNode(BaseNode prev, BaseNode name, NameParserContext context)
|
||||
{
|
||||
BaseNode result = name;
|
||||
if (prev != null)
|
||||
|
@ -900,8 +895,8 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
|
||||
private int ParsePositiveNumber()
|
||||
{
|
||||
ReadOnlySpan<char> part = Mangled.AsSpan(_position);
|
||||
int numberLength = 0;
|
||||
ReadOnlySpan<char> part = Mangled.AsSpan(_position);
|
||||
int numberLength = 0;
|
||||
|
||||
for (; numberLength < part.Length; numberLength++)
|
||||
{
|
||||
|
@ -933,8 +928,8 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
return null;
|
||||
}
|
||||
|
||||
ReadOnlySpan<char> part = Mangled.AsSpan(_position);
|
||||
int numberLength = 0;
|
||||
ReadOnlySpan<char> part = Mangled.AsSpan(_position);
|
||||
int numberLength = 0;
|
||||
|
||||
for (; numberLength < part.Length; numberLength++)
|
||||
{
|
||||
|
@ -1057,15 +1052,15 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
case 'v':
|
||||
_position += 2;
|
||||
|
||||
bool canParseTemplateArgsBackup = _canParseTemplateArgs;
|
||||
bool canParseTemplateArgsBackup = _canParseTemplateArgs;
|
||||
bool canForwardTemplateReferenceBackup = _canForwardTemplateReference;
|
||||
|
||||
_canParseTemplateArgs = false;
|
||||
_canParseTemplateArgs = false;
|
||||
_canForwardTemplateReference = canForwardTemplateReferenceBackup || context != null;
|
||||
|
||||
BaseNode type = ParseType();
|
||||
|
||||
_canParseTemplateArgs = canParseTemplateArgsBackup;
|
||||
_canParseTemplateArgs = canParseTemplateArgsBackup;
|
||||
_canForwardTemplateReference = canForwardTemplateReferenceBackup;
|
||||
|
||||
if (type == null)
|
||||
|
@ -1324,17 +1319,17 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
// ::= C3 # complete object allocating constructor
|
||||
// ::= D0 # deleting destructor
|
||||
// ::= D1 # complete object destructor
|
||||
// ::= D2 # base object destructor
|
||||
// ::= D2 # base object destructor
|
||||
private BaseNode ParseCtorDtorName(NameParserContext context, BaseNode prev)
|
||||
{
|
||||
if (prev.Type == NodeType.SpecialSubstitution && prev is SpecialSubstitution)
|
||||
if (prev.Type == NodeType.SpecialSubstitution && prev is SpecialSubstitution substitution)
|
||||
{
|
||||
((SpecialSubstitution)prev).SetExtended();
|
||||
substitution.SetExtended();
|
||||
}
|
||||
|
||||
if (ConsumeIf("C"))
|
||||
{
|
||||
bool isInherited = ConsumeIf("I");
|
||||
bool isInherited = ConsumeIf("I");
|
||||
|
||||
char ctorDtorType = Peek();
|
||||
if (ctorDtorType != '1' && ctorDtorType != '2' && ctorDtorType != '3')
|
||||
|
@ -1434,9 +1429,9 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
return null;
|
||||
}
|
||||
|
||||
char foldKind = Peek();
|
||||
char foldKind = Peek();
|
||||
bool hasInitializer = foldKind == 'L' || foldKind == 'R';
|
||||
bool isLeftFold = foldKind == 'l' || foldKind == 'L';
|
||||
bool isLeftFold = foldKind == 'l' || foldKind == 'L';
|
||||
|
||||
if (!isLeftFold && !(foldKind == 'r' || foldKind == 'R'))
|
||||
{
|
||||
|
@ -1445,7 +1440,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
|
||||
_position++;
|
||||
|
||||
string operatorName = null;
|
||||
string operatorName;
|
||||
|
||||
switch (PeekString(0, 2))
|
||||
{
|
||||
|
@ -1567,9 +1562,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
|
||||
if (isLeftFold && initializer != null)
|
||||
{
|
||||
BaseNode temp = expression;
|
||||
expression = initializer;
|
||||
initializer = temp;
|
||||
(initializer, expression) = (expression, initializer);
|
||||
}
|
||||
|
||||
return new FoldExpression(isLeftFold, operatorName, new PackedTemplateParameterExpansion(expression), initializer);
|
||||
|
@ -1586,16 +1579,16 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
}
|
||||
|
||||
bool canParseTemplateArgsBackup = _canParseTemplateArgs;
|
||||
_canParseTemplateArgs = false;
|
||||
BaseNode type = ParseType();
|
||||
_canParseTemplateArgs = canParseTemplateArgsBackup;
|
||||
_canParseTemplateArgs = false;
|
||||
BaseNode type = ParseType();
|
||||
_canParseTemplateArgs = canParseTemplateArgsBackup;
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<BaseNode> expressions = new List<BaseNode>();
|
||||
List<BaseNode> expressions = new();
|
||||
if (ConsumeIf("_"))
|
||||
{
|
||||
while (!ConsumeIf("E"))
|
||||
|
@ -1730,15 +1723,15 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
private BaseNode ParseNewExpression()
|
||||
{
|
||||
bool isGlobal = ConsumeIf("gs");
|
||||
bool isArray = Peek(1) == 'a';
|
||||
bool isArray = Peek(1) == 'a';
|
||||
|
||||
if (!ConsumeIf("nw") || !ConsumeIf("na"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<BaseNode> expressions = new List<BaseNode>();
|
||||
List<BaseNode> initializers = new List<BaseNode>();
|
||||
List<BaseNode> expressions = new();
|
||||
List<BaseNode> initializers = new();
|
||||
|
||||
while (!ConsumeIf("_"))
|
||||
{
|
||||
|
@ -1824,7 +1817,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
private BaseNode ParseExpression()
|
||||
{
|
||||
bool isGlobal = ConsumeIf("gs");
|
||||
BaseNode expression = null;
|
||||
BaseNode expression;
|
||||
if (Count() < 2)
|
||||
{
|
||||
return null;
|
||||
|
@ -1906,7 +1899,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
return null;
|
||||
}
|
||||
|
||||
List<BaseNode> names = new List<BaseNode>();
|
||||
List<BaseNode> names = new();
|
||||
while (!ConsumeIf("E"))
|
||||
{
|
||||
expression = ParseExpression();
|
||||
|
@ -1929,8 +1922,8 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
}
|
||||
return null;
|
||||
case 'd':
|
||||
BaseNode leftNode = null;
|
||||
BaseNode rightNode = null;
|
||||
BaseNode leftNode;
|
||||
BaseNode rightNode;
|
||||
switch (Peek(1))
|
||||
{
|
||||
case 'a':
|
||||
|
@ -2055,7 +2048,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
case 'l':
|
||||
_position += 2;
|
||||
|
||||
List<BaseNode> bracedExpressions = new List<BaseNode>();
|
||||
List<BaseNode> bracedExpressions = new();
|
||||
while (!ConsumeIf("E"))
|
||||
{
|
||||
expression = ParseBracedExpression();
|
||||
|
@ -2310,7 +2303,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
return new EnclosedExpression("sizeof (", expression, ")");
|
||||
case 'Z':
|
||||
_position += 2;
|
||||
BaseNode sizeofParamNode = null;
|
||||
BaseNode sizeofParamNode;
|
||||
switch (Peek())
|
||||
{
|
||||
case 'T':
|
||||
|
@ -2334,7 +2327,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
return null;
|
||||
case 'P':
|
||||
_position += 2;
|
||||
List<BaseNode> arguments = new List<BaseNode>();
|
||||
List<BaseNode> arguments = new();
|
||||
while (!ConsumeIf("E"))
|
||||
{
|
||||
BaseNode argument = ParseTemplateArgument();
|
||||
|
@ -2375,7 +2368,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
return null;
|
||||
}
|
||||
|
||||
List<BaseNode> bracedExpressions = new List<BaseNode>();
|
||||
List<BaseNode> bracedExpressions = new();
|
||||
while (!ConsumeIf("E"))
|
||||
{
|
||||
expression = ParseBracedExpression();
|
||||
|
@ -2582,7 +2575,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
|
||||
if (_canForwardTemplateReference)
|
||||
{
|
||||
ForwardTemplateReference forwardTemplateReference = new ForwardTemplateReference(index);
|
||||
ForwardTemplateReference forwardTemplateReference = new(index);
|
||||
_forwardTemplateReferenceList.Add(forwardTemplateReference);
|
||||
return forwardTemplateReference;
|
||||
}
|
||||
|
@ -2607,12 +2600,12 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
_templateParamList.Clear();
|
||||
}
|
||||
|
||||
List<BaseNode> args = new List<BaseNode>();
|
||||
List<BaseNode> args = new();
|
||||
while (!ConsumeIf("E"))
|
||||
{
|
||||
if (hasContext)
|
||||
{
|
||||
List<BaseNode> templateParamListTemp = new List<BaseNode>(_templateParamList);
|
||||
List<BaseNode> templateParamListTemp = new(_templateParamList);
|
||||
BaseNode templateArgument = ParseTemplateArgument();
|
||||
_templateParamList = templateParamListTemp;
|
||||
if (templateArgument == null)
|
||||
|
@ -2666,7 +2659,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
// J <template-arg>* E
|
||||
case 'J':
|
||||
_position++;
|
||||
List<BaseNode> templateArguments = new List<BaseNode>();
|
||||
List<BaseNode> templateArguments = new();
|
||||
while (!ConsumeIf("E"))
|
||||
{
|
||||
BaseNode templateArgument = ParseTemplateArgument();
|
||||
|
@ -2976,7 +2969,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
}
|
||||
|
||||
BaseNode result = null;
|
||||
CvType cv = new CvType(ParseCvQualifiers(), null);
|
||||
CvType cv = new(ParseCvQualifiers(), null);
|
||||
if (context != null)
|
||||
{
|
||||
context.Cv = cv;
|
||||
|
@ -3269,7 +3262,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
// ::= <special-name>
|
||||
private BaseNode ParseEncoding()
|
||||
{
|
||||
NameParserContext context = new NameParserContext();
|
||||
NameParserContext context = new();
|
||||
if (Peek() == 'T' || (Peek() == 'G' && Peek(1) == 'V'))
|
||||
{
|
||||
return ParseSpecialName(context);
|
||||
|
@ -3305,7 +3298,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
return new EncodedFunction(name, null, context.Cv, context.Ref, null, returnType);
|
||||
}
|
||||
|
||||
List<BaseNode> Params = new List<BaseNode>();
|
||||
List<BaseNode> paramsList = new();
|
||||
|
||||
// backup because that can be destroyed by parseType
|
||||
CvType cv = context.Cv;
|
||||
|
@ -3319,10 +3312,10 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
return null;
|
||||
}
|
||||
|
||||
Params.Add(param);
|
||||
paramsList.Add(param);
|
||||
}
|
||||
|
||||
return new EncodedFunction(name, new NodeArray(Params), cv, Ref, null, returnType);
|
||||
return new EncodedFunction(name, new NodeArray(paramsList), cv, Ref, null, returnType);
|
||||
}
|
||||
|
||||
// <mangled-name> ::= _Z <encoding>
|
||||
|
@ -3351,12 +3344,12 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
|||
|
||||
public static string Parse(string originalMangled)
|
||||
{
|
||||
Demangler instance = new Demangler(originalMangled);
|
||||
BaseNode resNode = instance.Parse();
|
||||
Demangler instance = new(originalMangled);
|
||||
BaseNode resNode = instance.Parse();
|
||||
|
||||
if (resNode != null)
|
||||
{
|
||||
StringWriter writer = new StringWriter();
|
||||
StringWriter writer = new();
|
||||
resNode.Print(writer);
|
||||
return writer.ToString();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue