Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/FixMain.cc

    r61efa42 rc6b4432  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FixMain.cc -- Tools to change a Cforall main into a C main.
     7// FixMain.cc --
    88//
    99// Author           : Thierry Delisle
     
    3333namespace {
    3434
    35 struct FindMainCore final {
     35struct FindMainCore_new {
    3636        ast::FunctionDecl const * main_declaration = nullptr;
    3737
    3838        void previsit( ast::FunctionDecl const * decl ) {
    39                 if ( isMain( decl ) ) {
     39                if ( FixMain::isMain( decl ) ) {
    4040                        if ( main_declaration ) {
    4141                                SemanticError( decl, "Multiple definition of main routine\n" );
     
    106106}
    107107
    108 struct FixLinkageCore final {
    109         ast::Linkage::Spec const spec;
    110         FixLinkageCore( ast::Linkage::Spec spec ) : spec( spec ) {}
    111 
    112         ast::FunctionDecl const * previsit( ast::FunctionDecl const * decl ) {
    113                 if ( decl->name != "main" ) return decl;
    114                 return ast::mutate_field( decl, &ast::FunctionDecl::linkage, spec );
    115         }
    116 };
    117 
    118108} // namespace
    119109
    120 bool isMain( const ast::FunctionDecl * decl ) {
     110bool FixMain::isMain( const ast::FunctionDecl * decl ) {
    121111        if ( std::string("main") != decl->name ) {
    122112                return false;
     
    125115}
    126116
    127 void fixMainLinkage( ast::TranslationUnit & translationUnit,
    128                 bool replace_main ) {
    129         ast::Linkage::Spec const spec =
    130                 ( replace_main ) ? ast::Linkage::Cforall : ast::Linkage::C;
    131         ast::Pass<FixLinkageCore>::run( translationUnit, spec );
    132 }
    133 
    134 void fixMainInvoke( ast::TranslationUnit & translationUnit,
     117void FixMain::fix( ast::TranslationUnit & translationUnit,
    135118                std::ostream &os, const char * bootloader_filename ) {
    136119
    137         ast::Pass<FindMainCore> main_finder;
     120        ast::Pass<FindMainCore_new> main_finder;
    138121        ast::accept_all( translationUnit, main_finder );
    139122        if ( nullptr == main_finder.core.main_declaration ) return;
Note: See TracChangeset for help on using the changeset viewer.