private void NormalizeArrowFunctionParameterType(ArrowFunction arrowFunNode) { foreach (Parameter parameter in arrowFunNode.Parameters) { parameter.IgnoreType = true; } }
private ArrowFunction ParseArrowFunction(ExpressionNode left) { ArrowFunction ret = NewNode <ArrowFunction>(); int precedence = TokenPrecedence; if (left != null) { GetArrowFunctionArgs(left, ret.Arguments); } NextToken(); if (Token == TokenType.LBRACE) { ret.Body = new FunctionBlock(); NextToken(); while (Token != TokenType.RBRACE) { ret.Body.Statements.Add(ParseStatement()); } NextToken(); } else { ret.Expression = ParseExpression(1); } return(ret); }
private ArrowFunction ParseObjectLiteralFunction() { NextToken(); ArrowFunction ret = NewNode <ArrowFunction>(); ret.Token = TokenType.ARROW; ret.Body = new FunctionBlock(); bool first = true; while (Token != TokenType.RPAREN) { if (first) { first = false; } else { ExpectToken(TokenType.COMMA); NextToken(); } ExpectToken(TokenType.IDENTIFIER); ret.Arguments.Add(StrVal); NextToken(); } NextToken(); ExpectToken(TokenType.LBRACE); NextToken(); while (Token != TokenType.RBRACE) { ret.Body.Statements.Add(ParseStatement()); } NextToken(); return(ret); }
public Function(ArrowFunction fn, Function parent) { FnType = FunctionType.ARROW; FunctionScope = new Scope(parent.FunctionScope, fn.Arguments); Body = fn.Body; if (Body == null) { Body = new Block(); Body.Statements.Add(new ControllStatement { Token = TokenType.RETURN, Value = fn.Expression }); } Visitor = new NodeVisitor(Body); }
public CSharpSyntaxNode Convert(ArrowFunction node) { return(SyntaxFactory .ParenthesizedLambdaExpression(node.Body.ToCsNode <CSharpSyntaxNode>()) .AddParameterListParameters(node.Parameters.ToCsNodes <ParameterSyntax>())); }
public AstNode RefactorArrowFunction(ArrowFunction fn) { return(new Function(fn, this)); }