MLLIF
a MLIR-based Language to Language Interoperability Flyover
Loading...
Searching...
No Matches
MethodDeclWriter.cs
Go to the documentation of this file.
1using Microsoft.CodeAnalysis;
3
5
6public readonly struct MethodDeclWriter(IMethodSymbol symbol) : ICodeWriter
7{
8 public IEnumerable<WorkspaceDiagnostic> WriteTo(CodeWriter w, CodeContext ctx)
9 {
10 if (!symbol.IsTarget())
11 yield break;
12
13 if (symbol.IsStatic)
14 w.Write("static ");
15
16 if (symbol.ReturnsVoid)
17 w.Write("void ");
18 else
19 {
20 w.Write(symbol.ReturnType.ToNativeInterfaceType(true));
21 w.Write(' ');
22 }
23
24 var intParms = symbol.Parameters.Select(parm => $"{parm.Type.ToNativeInterfaceType()} {parm.Name}");
25 var intParmsStr = string.Join(", ", intParms);
26
27 w.WriteLine($"{symbol.Name}({intParmsStr});");
28 }
29}