Fixed multithread issue, minor performance improvement
このコミットが含まれているのは:
1 親
b5c13451b0
コミット
381f99dd3e
2ファイル変更
+40
-44
検索条件に一致するファイルはありません
@@ -29,11 +29,6 @@ namespace ComputeSharp.Shaders.Translation
|
||||
/// </summary>
|
||||
public static MethodDecompiler Instance { get; } = new MethodDecompiler();
|
||||
|
||||
/// <summary>
|
||||
/// The dummy object used to handle concurrent decompilation requests
|
||||
/// </summary>
|
||||
private readonly object Lock = new object();
|
||||
|
||||
/// <summary>
|
||||
/// The mapping of available <see cref="CSharpDecompiler"/> instances targeting different assemblies
|
||||
/// </summary>
|
||||
@@ -141,25 +136,22 @@ namespace ComputeSharp.Shaders.Translation
|
||||
/// <param name="semanticModel">The semantic model for the input method</param>
|
||||
public void GetSyntaxTree(MethodInfo methodInfo, MethodType methodType, out MethodDeclarationSyntax rootNode, out SemanticModel semanticModel)
|
||||
{
|
||||
lock (Lock)
|
||||
string sourceCode = methodType switch
|
||||
{
|
||||
string sourceCode = methodType switch
|
||||
{
|
||||
MethodType.Closure => GetSyntaxTreeForClosureMethod(methodInfo),
|
||||
MethodType.Static => GetSyntaxTreeForStaticMethod(methodInfo),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(methodType), $"Invalid method type: {methodType}")
|
||||
};
|
||||
MethodType.Closure => GetSyntaxTreeForClosureMethod(methodInfo),
|
||||
MethodType.Static => GetSyntaxTreeForStaticMethod(methodInfo),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(methodType), $"Invalid method type: {methodType}")
|
||||
};
|
||||
|
||||
// Load the type syntax tree
|
||||
SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(sourceCode);
|
||||
// Load the type syntax tree
|
||||
SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(sourceCode);
|
||||
|
||||
// Get the root node to return
|
||||
rootNode = syntaxTree.GetRoot().DescendantNodes().OfType<MethodDeclarationSyntax>().First(node => node.GetLeadingTrivia().ToFullString().Contains(methodInfo.Name));
|
||||
// Get the root node to return
|
||||
rootNode = syntaxTree.GetRoot().DescendantNodes().OfType<MethodDeclarationSyntax>().First(node => node.GetLeadingTrivia().ToFullString().Contains(methodInfo.Name));
|
||||
|
||||
// Update the incremental compilation and retrieve the syntax tree for the method
|
||||
_Compilation = _Compilation.AddSyntaxTrees(syntaxTree);
|
||||
semanticModel = _Compilation.GetSemanticModel(syntaxTree);
|
||||
}
|
||||
// Update the incremental compilation and retrieve the syntax tree for the method
|
||||
_Compilation = _Compilation.AddSyntaxTrees(syntaxTree);
|
||||
semanticModel = _Compilation.GetSemanticModel(syntaxTree);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする