Changeset 0b5e780
- Timestamp:
- Oct 27, 2023, 2:42:26 PM (14 months ago)
- Branches:
- master
- Children:
- 3c714ad
- Parents:
- f43146e4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
rf43146e4 r0b5e780 31 31 #include "AST/Convert.hpp" 32 32 #include "AST/Pass.hpp" // for pass_visitor_stats 33 #include "AST/Print.hpp" // for printAll 33 34 #include "AST/TranslationUnit.hpp" // for TranslationUnit 34 35 #include "AST/Util.hpp" // for checkInvariants … … 132 133 133 134 static void parse_cmdline( int argc, char * argv[] ); 134 static void dump( list< Declaration * > & translationUnit, ostream & out = cout );135 135 static void dump( ast::TranslationUnit && transUnit, ostream & out = cout ); 136 136 … … 246 246 FILE * input; // use FILE rather than istream because yyin is FILE 247 247 ostream * output = & cout; 248 list< Declaration * > translationUnit;249 248 ast::TranslationUnit transUnit; 250 249 … … 440 439 if ( errorp ) { 441 440 cerr << "---AST at error:---" << endl; 442 // We check which section the errors came from without looking at 443 // transUnit because std::move means it could look like anything. 444 if ( !translationUnit.empty() ) { 445 dump( translationUnit, cerr ); 446 } else { 447 dump( std::move( transUnit ), cerr ); 448 } 441 dump( std::move( transUnit ), cerr ); 449 442 cerr << endl << "---End of AST, begin error message:---\n" << endl; 450 443 } // if … … 472 465 } // try 473 466 474 deleteAll( translationUnit );475 467 Stats::print(); 476 468 return EXIT_SUCCESS; … … 702 694 } // parse_cmdline 703 695 704 static bool notPrelude( Declaration * decl ) { 705 return ! LinkageSpec::isBuiltin( decl->get_linkage() ); 706 } // notPrelude 707 708 static void dump( list< Declaration * > & translationUnit, ostream & out ) { 709 list< Declaration * > decls; 710 696 static bool notPrelude( ast::ptr<ast::Decl> & decl ) { 697 return !decl->linkage.is_builtin; 698 } 699 700 static void dump( ast::TranslationUnit && unit, std::ostream & out ) { 701 // May filter out all prelude declarations. 711 702 if ( genproto ) { 712 filter( translationUnit.begin(), translationUnit.end(), back_inserter( decls ), notPrelude ); 703 std::list<ast::ptr<ast::Decl>> decls; 704 std::copy_if( unit.decls.begin(), unit.decls.end(), 705 std::back_inserter( decls ), notPrelude ); 706 decls.swap( unit.decls ); 707 } 708 709 // May print as full dump or as code generation. 710 if ( codegenp ) { 711 CodeGen::generate( unit, out, !genproto, prettycodegenp, false, false, false ); 713 712 } else { 714 decls = translationUnit; 715 } // if 716 717 // depending on commandline options, either generate code or dump the AST 718 if ( codegenp ) { 719 CodeGen::generate( decls, out, ! genproto, prettycodegenp ); 720 } else { 721 printAll( decls, out ); 722 } // if 723 deleteAll( translationUnit ); 724 } // dump 725 726 static void dump( ast::TranslationUnit && transUnit, ostream & out ) { 727 std::list< Declaration * > translationUnit = convert( std::move( transUnit ) ); 728 dump( translationUnit, out ); 713 ast::printAll( out, unit.decls ); 714 } 729 715 } 730 716
Note: See TracChangeset
for help on using the changeset viewer.