Added support for implicit local functions

このコミットが含まれているのは:
Sergio Pedri committed 2019-09-05 18:09:58 +02:00
1 親 e512c5839e
コミット 4f58fe4f1f
5ファイル変更
+54 -1

検索条件に一致するファイルはありません

+12
ファイルの表示
@@ -148,6 +148,13 @@ namespace ComputeSharp.Shaders.Translation
/// </summary>
public IReadOnlyList<FunctionInfo> FunctionsList => _FunctionsList;
private readonly List<LocalFunctionInfo> _LocalFunctionsList = new List<LocalFunctionInfo>();
/// <summary>
/// Gets the collection of <see cref="LocalFunctionInfo"/> items for the shader
/// </summary>
public IReadOnlyList<LocalFunctionInfo> LocalFunctionsList => _LocalFunctionsList;
/// <summary>
/// Gets a unique hash code for a given <see cref="Action{T}"/>
/// </summary>
@@ -295,6 +302,11 @@ namespace ComputeSharp.Shaders.Translation
ShaderSyntaxRewriter syntaxRewriter = new ShaderSyntaxRewriter(semanticModel);
root = (MethodDeclarationSyntax)syntaxRewriter.Visit(root);
// Extract the implicit local functions
var locals = root.DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToArray();
root = root.RemoveNodes(locals, SyntaxRemoveOptions.KeepNoTrivia);
_LocalFunctionsList.AddRange(locals.Select(local => new LocalFunctionInfo(local.ToString())));
// Register the captured static members
foreach (var member in syntaxRewriter.StaticMembers)
{