-
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from Sergio0694/feature_static-methods
Added support for static methods
- Loading branch information
Showing
11 changed files
with
510 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/ComputeSharp.Shaders/Renderer/Models/Functions/FunctionInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using ComputeSharp.Shaders.Extensions; | ||
|
||
namespace ComputeSharp.Shaders.Renderer.Models.Functions | ||
{ | ||
/// <summary> | ||
/// A <see langword="class"/> that contains info on a shader function | ||
/// </summary> | ||
internal class FunctionInfo | ||
{ | ||
/// <summary> | ||
/// Gets the return type of the current function in the C# source | ||
/// </summary> | ||
public string FunctionCsharpReturnType { get; } | ||
|
||
/// <summary> | ||
/// Gets the fullname of the current function in the C# source | ||
/// </summary> | ||
public string FunctionFullName { get; } | ||
|
||
/// <summary> | ||
/// Gets the parameters of the function in the C# source | ||
/// </summary> | ||
public string FunctionCsharpParameters { get; } | ||
|
||
/// <summary> | ||
/// Gets the return type of the current function | ||
/// </summary> | ||
public string ReturnType { get; } | ||
|
||
/// <summary> | ||
/// Gets the name of the current function | ||
/// </summary> | ||
public string FunctionName { get; } | ||
|
||
/// <summary> | ||
/// Gets the list of parameters for the current function | ||
/// </summary> | ||
public IReadOnlyList<ParameterInfo> ParametersList { get; } | ||
|
||
/// <summary> | ||
/// Gets the body of the current function | ||
/// </summary> | ||
public string FunctionBody { get; } | ||
|
||
/// <summary> | ||
/// Creates a new <see cref="FunctionInfo"/> instance with the specified parameters | ||
/// </summary> | ||
/// <param name="functionCsharpType">The concrete return type for the function</param> | ||
/// <param name="functionFullname">The fullname of the function in the C# source</param> | ||
/// <param name="functionCsharpParameters">The parameters of the function in the C# source</param> | ||
/// <param name="returnType">The return type of the current function</param> | ||
/// <param name="functionName">The name of the current function</param> | ||
/// <param name="parameters">The function parameters, if any</param> | ||
/// <param name="functionBody">The current function</param> | ||
public FunctionInfo( | ||
Type functionCsharpType, | ||
string functionFullname, | ||
string functionCsharpParameters, | ||
string returnType, | ||
string functionName, | ||
IReadOnlyList<ParameterInfo> parameters, | ||
string functionBody) | ||
{ | ||
FunctionCsharpReturnType = functionCsharpType.ToFriendlyString(); | ||
FunctionFullName = functionFullname; | ||
FunctionCsharpParameters = functionCsharpParameters; | ||
ReturnType = returnType; | ||
FunctionName = functionName; | ||
ParametersList = parameters; | ||
FunctionBody = functionBody; | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/ComputeSharp.Shaders/Renderer/Models/Functions/ParameterInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp; | ||
|
||
namespace ComputeSharp.Shaders.Renderer.Models.Functions | ||
{ | ||
/// <summary> | ||
/// A <see langword="class"/> that contains info on a function parameter | ||
/// </summary> | ||
internal class ParameterInfo | ||
{ | ||
/// <summary> | ||
/// Gets the modifier to use for the current parameter | ||
/// </summary> | ||
public string ParameterModifier { get; } | ||
|
||
/// <summary> | ||
/// Gets the type of the current parameter | ||
/// </summary> | ||
public string ParameterType { get; } | ||
|
||
/// <summary> | ||
/// Gets the name to use for the current parameter | ||
/// </summary> | ||
public string ParameterName { get; } | ||
|
||
/// <summary> | ||
/// Gets whether or not the current parameter is the last one for the parent function | ||
/// </summary> | ||
public bool IsLastParameter { get; } | ||
|
||
/// <summary> | ||
/// Creates a new <see cref="ParameterInfo"/> instance with the specified parameters | ||
/// </summary> | ||
/// <param name="parameterModifiers">The modifiers used in the current parameter</param> | ||
/// <param name="parameterType">The type of the current parameter</param> | ||
/// <param name="parameterName">The name of the current parameter</param> | ||
/// <param name="last">Indicates whether or not the current parameter is the last one</param> | ||
public ParameterInfo(IReadOnlyList<SyntaxToken> parameterModifiers, string parameterType, string parameterName, bool last) | ||
{ | ||
if (parameterModifiers.Count == 0) ParameterModifier = "in"; | ||
else if (parameterModifiers.First().IsKind(SyntaxKind.OutKeyword)) ParameterModifier = "out"; | ||
else if (parameterModifiers.Any(m => m.IsKind(SyntaxKind.RefKeyword)) && !parameterModifiers.Any(m => m.IsKind(SyntaxKind.ReadOnlyKeyword))) ParameterModifier = "inout"; | ||
else ParameterModifier = "in"; | ||
|
||
ParameterType = parameterType; | ||
ParameterName = parameterName; | ||
IsLastParameter = last; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace ComputeSharp.Shaders.Translation.Enums | ||
{ | ||
/// <summary> | ||
/// An <see langword="enum"/> that indicates a type of method to decompile | ||
/// </summary> | ||
internal enum MethodType | ||
{ | ||
/// <summary> | ||
/// An instance method that belongs to a closure class | ||
/// </summary> | ||
Closure, | ||
|
||
/// <summary> | ||
/// A standalone, static method | ||
/// </summary> | ||
Static | ||
} | ||
} |
Oops, something went wrong.