forked from SharpGenTools/SharpGenTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethodCodeGenerator.cs
More file actions
42 lines (37 loc) · 1.36 KB
/
Copy pathMethodCodeGenerator.cs
File metadata and controls
42 lines (37 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.Collections.Generic;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using SharpGen.Model;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
namespace SharpGen.Generator;
internal sealed class MethodCodeGenerator : MemberMultiCodeGeneratorBase<CsMethod>
{
public MethodCodeGenerator(Ioc ioc) : base(ioc)
{
}
public override IEnumerable<MemberDeclarationSyntax> GenerateCode(CsMethod csElement)
{
var list = NewMemberList;
if (csElement.CustomVtbl)
list.Add(
FieldDeclaration(
default,
TokenList(Token(SyntaxKind.PrivateKeyword)),
VariableDeclaration(
PredefinedType(Token(SyntaxKind.UIntKeyword)),
SingletonSeparatedList(
VariableDeclarator(
Identifier($"{csElement.Name}__vtbl_index"),
null,
EqualsValueClause(csElement.VTableOffsetExpression(Generators.Config.Platforms))
)
)
)
)
);
// If not hidden, generate body
if (!csElement.Hidden)
list.Add(csElement, Generators.Callable);
return list;
}
}