Added support for static methods in parent class
このコミットが含まれているのは:
1 親
1d708f4e69
コミット
1c7428f1ea
4ファイル変更
+70
-4
検索条件に一致するファイルはありません
@@ -299,7 +299,7 @@ namespace ComputeSharp.Shaders.Translation
|
||||
MethodDecompiler.Instance.GetSyntaxTree(Action.Method, MethodType.Closure, out MethodDeclarationSyntax root, out SemanticModel semanticModel);
|
||||
|
||||
// Rewrite the shader method (eg. to fix the type declarations)
|
||||
ShaderSyntaxRewriter syntaxRewriter = new ShaderSyntaxRewriter(semanticModel);
|
||||
ShaderSyntaxRewriter syntaxRewriter = new ShaderSyntaxRewriter(semanticModel, ShaderType);
|
||||
root = (MethodDeclarationSyntax)syntaxRewriter.Visit(root);
|
||||
|
||||
// Extract the implicit local functions
|
||||
@@ -340,7 +340,7 @@ namespace ComputeSharp.Shaders.Translation
|
||||
MethodDecompiler.Instance.GetSyntaxTree(methodInfo, MethodType.Static, out MethodDeclarationSyntax root, out SemanticModel semanticModel);
|
||||
|
||||
// Rewrite the method
|
||||
ShaderSyntaxRewriter syntaxRewriter = new ShaderSyntaxRewriter(semanticModel);
|
||||
ShaderSyntaxRewriter syntaxRewriter = new ShaderSyntaxRewriter(semanticModel, methodInfo.DeclaringType);
|
||||
root = (MethodDeclarationSyntax)syntaxRewriter.Visit(root);
|
||||
|
||||
// Register the captured static members
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using ComputeSharp.Shaders.Extensions;
|
||||
using ComputeSharp.Shaders.Translation.Models;
|
||||
@@ -18,11 +19,20 @@ namespace ComputeSharp.Shaders.Translation
|
||||
/// </summary>
|
||||
private readonly SemanticModel SemanticModel;
|
||||
|
||||
/// <summary>
|
||||
/// The declaring type that hosts the root from which the current syntax tree is inspected
|
||||
/// </summary>
|
||||
private readonly Type DeclaringType;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ShaderSyntaxRewriter"/> instance with the specified parameters
|
||||
/// </summary>
|
||||
/// <param name="semanticModel"></param>
|
||||
public ShaderSyntaxRewriter(SemanticModel semanticModel) => SemanticModel = semanticModel;
|
||||
public ShaderSyntaxRewriter(SemanticModel semanticModel, Type declaringType)
|
||||
{
|
||||
SemanticModel = semanticModel;
|
||||
DeclaringType = declaringType;
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, ReadableMember> _StaticMembers = new Dictionary<string, ReadableMember>();
|
||||
|
||||
@@ -119,6 +129,21 @@ namespace ComputeSharp.Shaders.Translation
|
||||
return syntaxNode;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode VisitInvocationExpression(InvocationExpressionSyntax node)
|
||||
{
|
||||
node = (InvocationExpressionSyntax)base.VisitInvocationExpression(node);
|
||||
node = node.ReplaceInvocation(DeclaringType, out var method);
|
||||
|
||||
// Register the captured member, if present
|
||||
if (method.HasValue && !_StaticMethods.ContainsKey(method.Value.Name))
|
||||
{
|
||||
_StaticMethods.Add(method.Value.Name, method.Value.MethodInfo);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode VisitMethodDeclaration(MethodDeclarationSyntax node)
|
||||
{
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする