protected BoundStatement(SourceLocation location) { if (location == null) throw new ArgumentNullException("location"); Location = location; }
public SwitchCase(ExpressionSyntax expression, BlockSyntax body, SourceLocation location) { if (body == null) throw new ArgumentNullException("body"); if (location == null) throw new ArgumentNullException("location"); Expression = expression; Body = body; Location = location; }
public BoundFunction Update(string name, ReadOnlyArray<string> parameters, BoundBody body, SourceLocation location) { if ( name == Name && parameters == Parameters && body == Body && location == Location ) return this; return new BoundFunction(name, parameters, body, location); }
public BoundFunction(string name, ReadOnlyArray<string> parameters, BoundBody body, SourceLocation location) { if (parameters == null) throw new ArgumentNullException("parameters"); if (body == null) throw new ArgumentNullException("body"); if (location == null) throw new ArgumentNullException("location"); Name = name; Parameters = parameters; Body = body; Location = location; }
public FunctionSyntax BuildFunction(string name, ReadOnlyArray<string> parameters, BodySyntax body, SourceLocation location) { IIdentifier identifier = null; if (name != null) { identifier = _scope.CreateIdentifier(name); _scope.DeclareIdentifier(name); } return new FunctionSyntax( identifier, parameters, body, location ); }
public SyntaxNode BuildFor(EcmaScriptParser parser, SourceLocation location) { if (Expression != null) { IIdentifier identifier; if (Initialization is IdentifierSyntax) { identifier = ((IdentifierSyntax)Initialization).Identifier; } else { var variableDeclaration = (VariableDeclarationSyntax)Initialization; Debug.Assert(variableDeclaration.Declarations.Count == 1); var declaration = variableDeclaration.Declarations[0]; identifier = declaration.Identifier; Debug.Assert(declaration.Expression == null); } return _builder.BuildForEachIn( identifier, Expression, Body, location ); } return _builder.BuildFor( Initialization, Test, Increment, Body, location ); }
private BoundBlock BuildBlock(SyntaxNode syntax, SourceLocation location) { IEnumerable<SyntaxNode> items; var block = syntax as BlockSyntax; if (block != null) items = block.Statements; else items = new[] { syntax }; var builder = new BlockBuilder(this); foreach (var item in items) { var node = item.Accept(this); var statement = node as BoundStatement ?? new BoundExpressionStatement((BoundExpression)node, GetLocation(item)); builder.Add(statement); } return builder.BuildBlock(location ?? SourceLocation.Missing); }
public DoWhileSyntax BuildDoWhile(ExpressionSyntax condition, SyntaxNode statement, SourceLocation location) { return new DoWhileSyntax(condition, statement, location); }
public ContinueSyntax BuildContinue(string target, SourceLocation location) { return new ContinueSyntax(target, location); }
public BreakSyntax BuildBreak(string target, SourceLocation location) { return new BreakSyntax(target, location); }
public WhileSyntax BuildWhile(ExpressionSyntax test, SyntaxNode body, SourceLocation location) { return new WhileSyntax(test, body, location); }
public VariableDeclarationSyntax BuildVariableDeclaration(ReadOnlyArray<VariableDeclaration> declarations, SourceLocation location) { return new VariableDeclarationSyntax(declarations, location); }
public WithSyntax ExitWith(ExpressionSyntax expression, SyntaxNode body, SourceLocation location) { return _scope.ExitWith(expression, body, location); }
public SyntaxNode BuildForEachIn(IIdentifier identifier, ExpressionSyntax expression, SyntaxNode body, SourceLocation location) { return new ForEachInSyntax(identifier, expression, body, location); }
public ReturnSyntax BuildReturn(ExpressionSyntax expression, SourceLocation location) { return new ReturnSyntax(expression, location); }
public IfSyntax BuildIf(ExpressionSyntax test, SyntaxNode then, SyntaxNode @else, SourceLocation location) { return new IfSyntax(test, then, @else, location); }
public WithSyntax ExitWith(ExpressionSyntax expression, SyntaxNode body, SourceLocation location) { var result = new WithSyntax(expression, _withScope.WithScope.Identifier, body, location); _withScope = _withScope.Parent; return result; }
public BoundBlock BuildBlock(SourceLocation location) { if (_nodes == null) { Debug.Assert(_temporaries == null); return new BoundBlock( ReadOnlyArray<BoundTemporary>.Empty, ReadOnlyArray<BoundStatement>.Empty, location ); } var nodes = new ReadOnlyArray<BoundStatement>.Builder(); foreach (var node in _nodes.ToReadOnly()) { // Flatten blocks. Nested blocks have no use, so we flatten // them into this block. First we try to see whether the node // is a block. If not, we try to see whether the node is an // expression statement that has an expression block // as its expression. In that case, we're taking the value of // an expression block without doing anything with it. var block = node as BoundBlock; if (block != null) { if (_temporaries == null) _temporaries = new ReadOnlyArray<BoundTemporary>.Builder(); _temporaries.AddRange(block.Temporaries); if (block.Location != SourceLocation.Missing) nodes.Add(new BoundEmpty(block.Location)); nodes.AddRange(block.Nodes); continue; } // Otherwise, we keep the node unchanged. nodes.Add(node); } return new BoundBlock( _temporaries == null ? ReadOnlyArray<BoundTemporary>.Empty : _temporaries.ToReadOnly(), nodes.ToReadOnly(), location ); }
public BoundExpression BuildExpression(BoundTemporary result, SourceLocation location) { return new BoundExpressionBlock( result, new BoundBlock( _temporaries == null ? ReadOnlyArray<BoundTemporary>.Empty : _temporaries.ToReadOnly(), _nodes == null ? ReadOnlyArray<BoundStatement>.Empty : _nodes.ToReadOnly(), location ) ); }
public ExpressionStatementSyntax BuildExpressionStatement(ExpressionSyntax expression, SourceLocation location) { return new ExpressionStatementSyntax(expression, location); }
public SyntaxNode BuildFor(SyntaxNode initialization, SyntaxNode test, SyntaxNode increment, SyntaxNode body, SourceLocation location) { return new ForSyntax(initialization, test, increment, body, location); }
public SwitchCase BuildSwitchCase(ExpressionSyntax expression, BlockSyntax body, SourceLocation location) { return new SwitchCase(expression, body, location); }
public SwitchSyntax BuildSwitch(SyntaxNode expression, ReadOnlyArray<SwitchCase> cases, SourceLocation location) { return new SwitchSyntax(expression, cases, location); }
public ThrowSyntax BuildThrow(ExpressionSyntax expression, SourceLocation location) { return new ThrowSyntax(expression, location); }