e055217292
* 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 * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * Run dotnet format pass * Remove left-over files and adjust namespaces * Fix alignment
53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
using Microsoft.CodeAnalysis;
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Ryujinx.Horizon.Kernel.Generators
|
|
{
|
|
class SyscallSyntaxReceiver : ISyntaxReceiver
|
|
{
|
|
public List<MethodDeclarationSyntax> SvcImplementations { get; }
|
|
|
|
public SyscallSyntaxReceiver()
|
|
{
|
|
SvcImplementations = new List<MethodDeclarationSyntax>();
|
|
}
|
|
|
|
public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
|
|
{
|
|
if (!(syntaxNode is ClassDeclarationSyntax classDeclaration) || classDeclaration.AttributeLists.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!classDeclaration.AttributeLists.Any(attributeList =>
|
|
attributeList.Attributes.Any(x => x.Name.GetText().ToString() == "SvcImpl")))
|
|
{
|
|
return;
|
|
}
|
|
|
|
foreach (var memberDeclaration in classDeclaration.Members)
|
|
{
|
|
if (memberDeclaration is MethodDeclarationSyntax methodDeclaration)
|
|
{
|
|
VisitMethod(methodDeclaration);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void VisitMethod(MethodDeclarationSyntax methodDeclaration)
|
|
{
|
|
if (methodDeclaration.AttributeLists.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (methodDeclaration.AttributeLists.Any(attributeList =>
|
|
attributeList.Attributes.Any(x => x.Name.GetText().ToString() == "Svc")))
|
|
{
|
|
SvcImplementations.Add(methodDeclaration);
|
|
}
|
|
}
|
|
}
|
|
}
|