public DoWhileStatementSyntax(SyntaxToken doKeyword, BlockStatementSyntax doStatement, SyntaxToken whileKeyword, ExpressionSyntax condition) { DoKeyword = doKeyword; Statament = doStatement; WhileKeyword = whileKeyword; Condition = condition; }
public void EmitBlock(BlockStatementSyntax node) { foreach (var statement in node.Statements) { EmitStatement(statement); } }
public FunctionDeclarationSyntax(SyntaxToken functionKeyword, SyntaxToken identifier, SyntaxToken openParenthesisToken, SeparatedSyntaxList <ParameterSyntax> parameters, SyntaxToken closeParenthesisToken, TypeClauseSyntax type, BlockStatementSyntax body) { FunctionKeyword = functionKeyword; Identifier = identifier; OpenParenthesisToken = openParenthesisToken; Parameters = parameters; CloseParenthesisToken = closeParenthesisToken; Type = type; Body = body; }
/// <summary> /// Block statements need to be bound for evaluation. Everytime statement is nested, we need to update the scope /// </summary> /// <param name="syntax"></param> /// <returns></returns> private BoundBlockStatement BindBlockStatement(BlockStatementSyntax syntax) { var statements = ImmutableArray.CreateBuilder <BoundStatement>(); _scope = new BoundScope(_scope); foreach (var statementSyntax in syntax.Statements) { var statement = BindStatement(statementSyntax); statements.Add(statement); } _scope = _scope.Parent; return(new BoundBlockStatement(statements.ToImmutable())); }
private AnnotatedStatement AnnotateBlockStatement(BlockStatementSyntax statement) { var statements = ImmutableArray.CreateBuilder <AnnotatedStatement>(); _scope = new AnnotationScope(_scope); foreach (var statementSyntax in statement.Statements) { var st = AnnotateStatement(statementSyntax); statements.Add(st); } _scope = _scope.Parent; return(new AnnotatedBlockStatement(statements.ToImmutable())); }
public FunctionDeclarationSyntax(SyntaxTree syntaxTree, SyntaxToken functionKeyword, SyntaxToken identifier, SyntaxToken openParenthesisToken, SeparatedSyntaxList <ParameterSyntax> parameters, SyntaxToken closeParenthesisToken, TypeClauseSyntax type, BlockStatementSyntax body, bool isPublic, bool isVirtual, bool isOverride) : base(syntaxTree) { FunctionKeyword = functionKeyword; Identifier = identifier; OpenParenthesisToken = openParenthesisToken; Parameters = parameters; CloseParenthesisToken = closeParenthesisToken; Type = type; Body = body; IsPublic = isPublic; IsVirtual = isVirtual; IsOverride = isOverride; }
// Statements private BlockStatementSyntax ParseBlockStatement() { ParseExpected(SyntaxKind.OpenBraceToken); var node = new BlockStatementSyntax(); node.Statements = new List <StatementSyntax>(); while (true) { if (ParseOptional(SyntaxKind.CloseBraceToken)) { break; } node.Statements.Add(ParseStatement()); } ParseOptional(SyntaxKind.SemicolonToken); return(node); }
internal FunctionDeclarationSyntax( SyntaxTree syntaxTree, SyntaxToken functionKeyword, SyntaxToken?receiver, SyntaxToken?dotToken, SyntaxToken identifier, SyntaxToken openParenthesisToken, SeparatedSyntaxList <ParameterSyntax> parameters, SyntaxToken closeParenthesisToken, TypeClauseSyntax?type, BlockStatementSyntax body ) : base(syntaxTree) { FunctionKeyword = functionKeyword; Receiver = receiver; DotToken = dotToken; Identifier = identifier; OpenParenthesisToken = openParenthesisToken; Parameters = parameters; CloseParenthesisToken = closeParenthesisToken; Type = type; Body = body; }
public virtual void VisitBlock(BlockStatementSyntax node) { }