private static BoundScope CreateParentScopes(BoundGlobalScope _previous) { var _stack = new Stack <BoundGlobalScope>(); while (_previous != null) { _stack.Push(_previous); _previous = _previous.Previous; } BoundScope _parent = null; while (_stack.Count > 0) { _previous = _stack.Pop(); var _scope = new BoundScope(_parent); foreach (var _v in _previous.Variables) { _scope.TryDeclare(_v); } _parent = _scope; } return(_parent); }
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())); }
public BoundScope(BoundScope _parent) { Parent = _parent; }
public Binder(BoundScope _parent) { scope = new BoundScope(_parent); }