Canon/Canon.Core/SyntaxNodes/Subprogram.cs
jackfiled 3a584751dc feat: 针对C的代码生成 (#50)
Co-authored-by: Lan_G <2911328695@qq.com>
Reviewed-on: PostGuard/Canon#50
2024-04-21 22:24:35 +08:00

35 lines
886 B
C#

using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
namespace Canon.Core.SyntaxNodes;
public class Subprogram : NonTerminatedSyntaxNode
{
public override NonTerminatorType Type => NonTerminatorType.Subprogram;
/// <summary>
/// 子程序头部
/// </summary>
public SubprogramHead Head => Children[0].Convert<SubprogramHead>();
/// <summary>
/// 子程序体
/// </summary>
public SubprogramBody Body => Children[2].Convert<SubprogramBody>();
public static Subprogram Create(List<SyntaxNodeBase> children)
{
return new Subprogram { Children = children };
}
public override void GenerateCCode(CCodeBuilder builder)
{
//子函数头
Head.GenerateCCode(builder);
//子函数体
builder.AddString("{");
Body.GenerateCCode(builder);
builder.AddString("}");
}
}