Changes in src/CodeGen/FixMain.cc [61efa42:c6b4432]
- File:
-
- 1 edited
-
src/CodeGen/FixMain.cc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/FixMain.cc
r61efa42 rc6b4432 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // FixMain.cc -- Tools to change a Cforall main into a C main.7 // FixMain.cc -- 8 8 // 9 9 // Author : Thierry Delisle … … 33 33 namespace { 34 34 35 struct FindMainCore final{35 struct FindMainCore_new { 36 36 ast::FunctionDecl const * main_declaration = nullptr; 37 37 38 38 void previsit( ast::FunctionDecl const * decl ) { 39 if ( isMain( decl ) ) {39 if ( FixMain::isMain( decl ) ) { 40 40 if ( main_declaration ) { 41 41 SemanticError( decl, "Multiple definition of main routine\n" ); … … 106 106 } 107 107 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 118 108 } // namespace 119 109 120 bool isMain( const ast::FunctionDecl * decl ) {110 bool FixMain::isMain( const ast::FunctionDecl * decl ) { 121 111 if ( std::string("main") != decl->name ) { 122 112 return false; … … 125 115 } 126 116 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, 117 void FixMain::fix( ast::TranslationUnit & translationUnit, 135 118 std::ostream &os, const char * bootloader_filename ) { 136 119 137 ast::Pass<FindMainCore > main_finder;120 ast::Pass<FindMainCore_new> main_finder; 138 121 ast::accept_all( translationUnit, main_finder ); 139 122 if ( nullptr == main_finder.core.main_declaration ) return;
Note:
See TracChangeset
for help on using the changeset viewer.