public LambdaNode(FunctionParametersNode parameters, AstNode body, bool isSimple, int nodeIndex) : base(SyntaxKind.LambdaFunctionDefinitionExpression, null, null, nodeIndex) { Parameters = parameters; Body = body; this.HasCurlyBrackets = body is BlockNode; this.IsSimple = isSimple; }
internal FunctionNode(string name, FunctionParametersNode parameters, int nodeIndex) : base(SyntaxKind.FunctionDefinitionExpression, "EXTERN", name, nodeIndex) { Name = name; Parameters = parameters; IsExtern = true; if (Parameters != null) { Parameters.Parent = this; } }
public static FunctionParametersNode Parameters(ParameterNode[] parameters) { // if (parameters) var result = new FunctionParametersNode(_nodeIndex++); foreach (var p in parameters) { result.AddChild(p); } return(result); }
internal FunctionNode(string name, FunctionParametersNode parameters, AstNode body, int nodeIndex) : base(SyntaxKind.FunctionDefinitionExpression, null, name, nodeIndex) { Name = name; Parameters = parameters; Body = body; if (body != null) { Body.Parent = this; } if (Parameters != null) { Parameters.Parent = this; } }
internal FunctionNode(string name, XzaarType returnType, FunctionParametersNode parameters, int nodeIndex) : base(SyntaxKind.FunctionDefinitionExpression, "EXTERN", name, nodeIndex) { this.returnType = returnType; if (this.returnType != null) { this.Type = this.returnType.Name; } Name = name; Parameters = parameters; IsExtern = true; if (Parameters != null) { Parameters.Parent = this; } }
internal FunctionNode(string name, XzaarType returnType, FunctionParametersNode parameters, AstNode body, int nodeIndex) : base(SyntaxKind.FunctionDefinitionExpression, null, name, nodeIndex) { this.returnType = returnType; if (this.returnType != null) { this.Type = this.returnType.Name; } Name = name; Parameters = parameters; Body = body; if (body != null) { Body.Parent = this; } if (Parameters != null) { Parameters.Parent = this; } }
public static FunctionParametersNode Parameters(AstNode parameters) { // if (parameters) var r = parameters as FunctionParametersNode; if (r != null) { return(r); } var result = new FunctionParametersNode(_nodeIndex++); var count = parameters.Children.Count; for (int i = 0; i < count; i += 2) { var type = parameters[i]; var isArray = parameters[i + 1].Kind == SyntaxKind.ArrayIndexExpression; if (isArray) { type.Value += "[]"; i++; } var name = parameters[i + 1]; result.AddChild(AstNode.Parameter(name, type)); if (count > 2 && i + 2 < count) { var value = parameters[i + 2].Value; if (value?.ToString() != ",") { throw new ExpressionException($"Unexpected character '{value}' found in function parameter declaration"); } i++; // skip separator } } return(result); }
public static FunctionNode ExternFunction(string name, string returnType, FunctionParametersNode parameters) { // var functionParametersNode = Parameters(argumentsExpression); return(new FunctionNode(name, XzaarType.GetType(returnType), parameters, _nodeIndex++)); }
public static FunctionNode Function(string name, string returnType, FunctionParametersNode argumentsExpression, AstNode bodyExpression) { return(new FunctionNode(name, XzaarType.GetType(returnType), argumentsExpression, bodyExpression, _nodeIndex++)); }
public static FunctionNode Function(string name, FunctionParametersNode argumentsExpression) { return(new FunctionNode(name, argumentsExpression, null, _nodeIndex++)); }
public static LambdaNode Lambda(FunctionParametersNode paremeterExpression, AstNode bodyExpression) { return(new LambdaNode(paremeterExpression, bodyExpression, false, _nodeIndex++)); }