Example #1
0
 protected override object?Visit(Expression.Block block)
 {
     symbolTable.PushScope(ScopeKind.None);
     base.Visit(block);
     symbolTable.PopScope();
     return(null);
 }
Example #2
0
 protected override Value?Visit(Expression.Block block)
 {
     // We just compile statements and the optional value
     foreach (var stmt in block.Statements)
     {
         Visit(stmt);
     }
     return(block.Value == null ? null : Visit(block.Value));
 }
Example #3
0
        protected override Expression Visit(Expression.Block block)
        {
            var statements = block.Statements.Select(Desugar).ToArray();
            var value      = TransformNullable(block.Value);

            if (value == null &&
                statements.Length > 0 &&
                statements.Last() is Statement.Expression_ expr &&
                !expr.HasSemicolon &&
                HasExplicitValue(expr.Expression))
            {
                // There was no return value, but the last statement was an expression without a semicolon
                // Promote it to value
                value      = expr.Expression;
                statements = statements.SkipLast(1).ToArray();
            }
            return(new Expression.Block(block.ParseTreeNode, statements, value));
        }