Enabled support for var declarations in shaders
このコミットが含まれているのは:
1 親
4c50309bdd
コミット
da786aaf0d
4ファイル変更
+45
-20
検索条件に一致するファイルはありません
@@ -171,21 +171,6 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
|
||||
return base.VisitUsingStatement(node);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode? VisitVariableDeclarator(VariableDeclaratorSyntax node)
|
||||
{
|
||||
var updatedNode = (VariableDeclaratorSyntax)base.VisitVariableDeclarator(node)!;
|
||||
|
||||
if (node.Initializer is null &&
|
||||
node.Parent is VariableDeclarationSyntax declaration &&
|
||||
SemanticModel.For(node).GetTypeInfo(declaration.Type).Type is ITypeSymbol { IsUnmanagedType: false } type)
|
||||
{
|
||||
Context.ReportDiagnostic(InvalidObjectDeclaration, node, type);
|
||||
}
|
||||
|
||||
return updatedNode;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode? VisitYieldStatement(YieldStatementSyntax node)
|
||||
{
|
||||
|
||||
@@ -73,6 +73,25 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
|
||||
return updatedNode.ReplaceAndTrackType(updatedNode.Type, node.Type, SemanticModel.For(node), DiscoveredTypes);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode? VisitVariableDeclaration(VariableDeclarationSyntax node)
|
||||
{
|
||||
var updatedNode = (VariableDeclarationSyntax)base.VisitVariableDeclaration(node)!;
|
||||
|
||||
if (SemanticModel.For(node).GetTypeInfo(node.Type).Type is ITypeSymbol { IsUnmanagedType: false } type)
|
||||
{
|
||||
Context.ReportDiagnostic(InvalidObjectDeclaration, node, type);
|
||||
}
|
||||
|
||||
// If var is used, replace it with the explicit type
|
||||
if (updatedNode.Type is IdentifierNameSyntax { IsVar: true })
|
||||
{
|
||||
updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.Type, node.Type, SemanticModel.For(node), DiscoveredTypes);
|
||||
}
|
||||
|
||||
return updatedNode;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode VisitObjectCreationExpression(ObjectCreationExpressionSyntax node)
|
||||
{
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする