Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rda9d79b rbd06384  
    116116        }
    117117
    118         CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC, bool lineMarks, bool printExprTypes ) : indent( CodeGenerator::tabsize ), output( os ), printLabels( *this ), pretty( pretty ), genC( genC ), lineMarks( lineMarks ), printExprTypes( printExprTypes ), endl( *this ) {}
     118        CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC, bool lineMarks ) : indent( CodeGenerator::tabsize ), output( os ), printLabels( *this ), pretty( pretty ), genC( genC ), lineMarks( lineMarks ), endl( *this ) {}
    119119
    120120        string CodeGenerator::mangleName( DeclarationWithType * decl ) {
     
    159159        }
    160160
    161         // *** Expression
    162         void CodeGenerator::previsit( Expression * node ) {
    163                 previsit( (BaseSyntaxNode *)node );
    164                 GuardAction( [this, node](){
    165                         if ( printExprTypes ) {
    166                                 output << " /* " << genType( node->result, "", pretty, genC ) << " */ ";
    167                         }
    168                 } );
    169         }
    170 
    171161        // *** Declarations
    172162        void CodeGenerator::postvisit( FunctionDecl * functionDecl ) {
     
    213203
    214204        void CodeGenerator::handleAggregate( AggregateDecl * aggDecl, const std::string & kind ) {
     205                genAttributes( aggDecl->get_attributes() );
     206
    215207                if( ! aggDecl->get_parameters().empty() && ! genC ) {
    216208                        // assertf( ! genC, "Aggregate type parameters should not reach code generation." );
     
    221213                }
    222214
    223                 output << kind;
    224                 genAttributes( aggDecl->get_attributes() );
    225                 output << aggDecl->get_name();
     215                output << kind << aggDecl->get_name();
    226216
    227217                if ( aggDecl->has_body() ) {
     
    308298                        output << " }";
    309299                }
    310         }
    311 
    312         void CodeGenerator::postvisit( StaticAssertDecl * assertDecl ) {
    313                 output << "_Static_assert(";
    314                 assertDecl->condition->accept( *visitor );
    315                 output << ", ";
    316                 assertDecl->message->accept( *visitor );
    317                 output << ")";
    318300        }
    319301
     
    596578                        output << ")";
    597579                } // if
    598                 castExpr->arg->accept( *visitor );
    599                 output << ")";
    600         }
    601 
    602         void CodeGenerator::postvisit( KeywordCastExpr * castExpr ) {
    603                 assertf( ! genC, "KeywordCast should not reach code generation." );
    604                 extension( castExpr );
    605                 output << "((" << castExpr->targetString() << " &)";
    606                 castExpr->arg->accept( *visitor );
     580                castExpr->get_arg()->accept( *visitor );
    607581                output << ")";
    608582        }
     
    954928                        output << "continue";
    955929                        break;
    956                   case BranchStmt::FallThrough:
    957                   case BranchStmt::FallThroughDefault:
    958                         assertf( ! genC, "fallthru should not reach code generation." );
    959                   output << "fallthru";
    960                         break;
    961930                } // switch
    962                 // print branch target for labelled break/continue/fallthru in debug mode
    963                 if ( ! genC && branchStmt->get_type() != BranchStmt::Goto ) {
    964                         if ( ! branchStmt->get_target().empty() ) {
    965                                 output << " " << branchStmt->get_target();
    966                         } else if ( branchStmt->get_type() == BranchStmt::FallThrough ) {
    967                                 output << " default";
    968                         }
    969                 }
    970931                output << ";";
    971932        }
     
    11451106unsigned Indenter::tabsize = 2;
    11461107
    1147 std::ostream & operator<<( std::ostream & out, const BaseSyntaxNode * node ) {
    1148         if ( node ) {
    1149                 node->print( out );
    1150         } else {
    1151                 out << "nullptr";
    1152         }
    1153         return out;
    1154 }
    1155 
    11561108// Local Variables: //
    11571109// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.