2024-04-26 10:18:49 +08:00
|
|
|
|
using Canon.Core.Abstractions;
|
2024-04-21 22:24:35 +08:00
|
|
|
|
using Canon.Core.Enums;
|
2024-04-07 16:47:28 +08:00
|
|
|
|
using Canon.Core.LexicalParser;
|
|
|
|
|
|
|
|
|
|
namespace Canon.Core.SyntaxNodes;
|
|
|
|
|
|
2024-04-28 22:02:29 +08:00
|
|
|
|
public class OnParameterGeneratorEventArgs : EventArgs
|
|
|
|
|
{
|
|
|
|
|
public required ExpressionList Parameters { get; init; }
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-07 16:47:28 +08:00
|
|
|
|
public class ProcedureCall : NonTerminatedSyntaxNode
|
|
|
|
|
{
|
|
|
|
|
public override NonTerminatorType Type => NonTerminatorType.ProcedureCall;
|
|
|
|
|
|
|
|
|
|
public IdentifierSemanticToken ProcedureId
|
2024-04-28 22:02:29 +08:00
|
|
|
|
=> Children[0].Convert<TerminatedSyntaxNode>().Token.Convert<IdentifierSemanticToken>();
|
2024-04-07 16:47:28 +08:00
|
|
|
|
|
2024-04-28 22:02:29 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 调用函数时含有参数的事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
public event EventHandler<OnParameterGeneratorEventArgs>? OnParameterGenerator;
|
2024-04-07 16:47:28 +08:00
|
|
|
|
|
2024-04-26 10:18:49 +08:00
|
|
|
|
public override void PreVisit(SyntaxNodeVisitor visitor)
|
|
|
|
|
{
|
|
|
|
|
visitor.PreVisit(this);
|
2024-04-28 22:02:29 +08:00
|
|
|
|
RaiseEvent();
|
2024-04-26 10:18:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void PostVisit(SyntaxNodeVisitor visitor)
|
|
|
|
|
{
|
|
|
|
|
visitor.PostVisit(this);
|
2024-04-28 22:02:29 +08:00
|
|
|
|
RaiseEvent();
|
2024-04-26 10:18:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-04-07 16:47:28 +08:00
|
|
|
|
public static ProcedureCall Create(List<SyntaxNodeBase> children)
|
|
|
|
|
{
|
|
|
|
|
return new ProcedureCall { Children = children };
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-28 22:02:29 +08:00
|
|
|
|
private void RaiseEvent()
|
2024-04-21 22:24:35 +08:00
|
|
|
|
{
|
2024-04-28 22:02:29 +08:00
|
|
|
|
if (Children.Count == 4)
|
2024-04-21 22:24:35 +08:00
|
|
|
|
{
|
2024-04-28 22:02:29 +08:00
|
|
|
|
OnParameterGenerator?.Invoke(this, new OnParameterGeneratorEventArgs
|
2024-04-21 22:24:35 +08:00
|
|
|
|
{
|
2024-04-28 22:02:29 +08:00
|
|
|
|
Parameters = Children[2].Convert<ExpressionList>()
|
|
|
|
|
});
|
2024-04-21 22:24:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-04-28 22:02:29 +08:00
|
|
|
|
OnParameterGenerator = null;
|
2024-04-21 22:24:35 +08:00
|
|
|
|
}
|
2024-04-07 16:47:28 +08:00
|
|
|
|
}
|