예제 #1
0
파일: Binder.cs 프로젝트: redcoreit/minsk
        public 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);
        }
예제 #2
0
파일: Binder.cs 프로젝트: redcoreit/minsk
        private BoundStatement BindForStatement(ForStatementSyntax syntax)
        {
            var lowerBound = BindExpression(syntax.LowerBound, TypeSymbol.Int);
            var upperBound = BindExpression(syntax.UpperBound, TypeSymbol.Int);

            _scope = new BoundScope(_scope);

            // TODO (R) isReadOnly: true by Immo
            var variable  = DeclareVariable(syntax.Identifier, TypeSymbol.Int, false);
            var statement = BindStatement(syntax.Statement);

            _scope = _scope.Parent;

            return(new BoundForStatement(variable, lowerBound, upperBound, statement));
        }
예제 #3
0
파일: Binder.cs 프로젝트: redcoreit/minsk
        private BoundStatement BindBlockStatement(BlockStatementSyntax statement)
        {
            var statements = ImmutableArray.CreateBuilder <BoundStatement>();

            _scope = new BoundScope(_scope);

            foreach (var s in statement.Statements)
            {
                statements.Add(BindStatement(s));
            }

            _scope = _scope.Parent;

            return(new BoundBlockStatement(statements.ToImmutable()));
        }
예제 #4
0
파일: Binder.cs 프로젝트: redcoreit/minsk
 private Binder(BoundScope parent)
 {
     _scope = new BoundScope(parent);
 }
예제 #5
0
 public BoundScope(BoundScope parent)
 {
     Parent     = parent;
     _variables = new Dictionary <string, VariableSymbol>();
 }