Пример #1
0
        Stmt new_stmt_block(SrcPos pos, StmtList block)
        {
            var s = new_stmt(STMT_BLOCK, pos);

            s.block = block;
            return(s);
        }
Пример #2
0
        Stmt new_stmt_do_while(SrcPos pos, Expr cond, StmtList block)
        {
            var s = new_stmt(STMT_DO_WHILE, pos);

            s.while_stmt.cond  = cond;
            s.while_stmt.block = block;
            return(s);
        }
Пример #3
0
        Stmt new_stmt_for(SrcPos pos, Stmt init, Expr cond, Stmt next, StmtList block)
        {
            var s = new_stmt(STMT_FOR, pos);

            s.for_stmt.init  = init;
            s.for_stmt.cond  = cond;
            s.for_stmt.next  = next;
            s.for_stmt.block = block;
            return(s);
        }
Пример #4
0
        void print_stmt_block(StmtList block)
        {
            printf("(block");
            _indent++;
            foreach (var it in block.stmts)
            {
                print_newline();
                print_stmt(it);
            }

            _indent--;
            printf(")");
        }
Пример #5
0
        Stmt new_stmt_if(SrcPos pos, Stmt init, Expr cond, StmtList then_block, ElseIf[] elseifs, int num_elseifs,
                         StmtList else_block)
        {
            var s = new_stmt(STMT_IF, pos);

            s.if_stmt.cond        = cond;
            s.if_stmt.init        = init;
            s.if_stmt.then_block  = then_block;
            s.if_stmt.elseifs     = elseifs;
            s.if_stmt.num_elseifs = num_elseifs;
            s.if_stmt.else_block  = else_block;
            return(s);
        }
Пример #6
0
        Decl new_decl_func(SrcPos pos, string name, FuncParam[] @params, int num_params, Typespec ret_type, bool has_varargs, Typespec varargs_type, StmtList block)
        {
            var d = new_decl(DECL_FUNC, pos, name);

            d.func.@params      = @params;
            d.func.num_params   = num_params;
            d.func.ret_type     = ret_type;
            d.func.has_varargs  = has_varargs;
            d.func.varargs_type = varargs_type;
            d.func.block        = block;
            return(d);
        }