FunctionDeclarator
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
namespace CLanguage.Syntax
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public class FunctionDeclarator : Declarator
{
public List<ParameterDeclaration> Parameters { get; set; }
public override string DeclaredIdentifier {
get {
if (base.InnerDeclarator == null)
return "";
return base.InnerDeclarator.DeclaredIdentifier;
}
}
public bool CouldBeCtorCall {
get {
if (Parameters.Count != 0)
return Parameters.All((ParameterDeclaration x) => x.CtorArgumentValue != null);
return true;
}
}
public FunctionDeclarator(Declarator innerDeclarator, List<ParameterDeclaration> parameters)
: base(innerDeclarator)
{
Parameters = parameters;
}
public FunctionDeclarator(List<ParameterDeclaration> parameters)
: base(null)
{
Parameters = parameters;
}
public override string ToString()
{
return DeclaredIdentifier + "(" + string.Join(", ", Parameters) + ")";
}
}
}