Changeset 3c13c03 for src/CodeGen


Ignore:
Timestamp:
Sep 17, 2016, 8:27:51 AM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
8c49c0e
Parents:
12bc63a
Message:

expand TupleExpr? and TupleIndexExpr?, add UniqueExpr?

Location:
src/CodeGen
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r12bc63a r3c13c03  
    639639        }
    640640
    641         void CodeGenerator::visit( TupleExpr * tupleExpr ) {}
     641        void CodeGenerator::visit( TupleExpr * tupleExpr ) { assert( false ); }
    642642
    643643        void CodeGenerator::visit( TypeExpr * typeExpr ) {}
     
    655655        }
    656656
     657        void CodeGenerator::visit( CompoundLiteralExpr *compLitExpr ) {
     658                assert( compLitExpr->get_type() && dynamic_cast< ListInit * > ( compLitExpr->get_initializer() ) );
     659                output << "(" << genType( compLitExpr->get_type(), "" ) << ")";
     660                compLitExpr->get_initializer()->accept( *this );
     661        }
     662
    657663        void CodeGenerator::visit( StmtExpr * stmtExpr ) {
    658                 output << "(";
    659                 stmtExpr->get_statements()->accept( *this );
    660                 output << ")";
     664                std::list< Statement * > & stmts = stmtExpr->get_statements()->get_kids();
     665                output << "({" << std::endl;
     666                cur_indent += CodeGenerator::tabsize;
     667                unsigned int numStmts = stmts.size();
     668                unsigned int i = 0;
     669                for ( Statement * stmt : stmts ) {
     670                        output << indent << printLabels( stmt->get_labels() );
     671                        if ( i+1 == numStmts ) {
     672                                // last statement in a statement expression needs to be handled specially -
     673                                // cannot cast to void, otherwise the expression statement has no value
     674                                if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( stmt ) ) {
     675                                        exprStmt->get_expr()->accept( *this );
     676                                        output << ";" << endl;
     677                                        ++i;
     678                                        break;
     679                                }
     680                        }
     681                        stmt->accept( *this );
     682                        output << endl;
     683                        if ( wantSpacing( stmt ) ) {
     684                                output << endl;
     685                        } // if
     686                        ++i;
     687                }
     688                cur_indent -= CodeGenerator::tabsize;
     689                output << indent << "})";
    661690        }
    662691
  • src/CodeGen/CodeGenerator.h

    r12bc63a r3c13c03  
    7070                virtual void visit( ConditionalExpr *conditionalExpr );
    7171                virtual void visit( CommaExpr *commaExpr );
     72                virtual void visit( CompoundLiteralExpr *compLitExpr );
    7273                virtual void visit( TupleExpr *tupleExpr );
    7374                virtual void visit( TypeExpr *typeExpr );
  • src/CodeGen/GenType.cc

    r12bc63a r3c13c03  
    213213                        typeString = "_Atomic " + typeString;
    214214                } // if
    215                 if ( type->get_isAttribute() ) {
    216                         typeString = "__attribute(( )) " + typeString;
    217                 } // if
    218215        }
    219216} // namespace CodeGen
Note: See TracChangeset for help on using the changeset viewer.