Changeset d60ccbf for src/main.cc


Ignore:
Timestamp:
Aug 12, 2015, 2:27:31 PM (10 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
f32c7f4
Parents:
e45215c (diff), e869d663 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into designate

Conflicts:

src/CodeGen/CodeGenerator.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    re45215c rd60ccbf  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Mon Jul 06 15:01:26 2015
    13 // Update Count     : 79
     12// Last Modified On : Thu Jul 30 16:08:18 2015
     13// Update Count     : 167
    1414//
    1515
     
    5454        if ( errorp ) std::cerr << x << std::endl;
    5555
    56 void parse( FILE * input, LinkageSpec::Type t, bool shouldExit = false );
     56static void parse( FILE * input, LinkageSpec::Type t, bool shouldExit = false );
     57static void dump( std::list< Declaration * > & translationUnit );
    5758
    5859bool
     
    6465        libcfap = false,
    6566        nopreludep = false,
    66         protop = false,
     67        noprotop = false,
    6768        parsep = false,
    6869        resolvep = false,                                                                       // used in AlternativeFinder
     
    8182        { "grammar", no_argument, 0, Grammar },
    8283        { "libcfa", no_argument, 0, LibCFA },
    83         { "nopreamble", no_argument, 0, Nopreamble },
     84        { "no-preamble", no_argument, 0, Nopreamble },
    8485        { "parse", no_argument, 0, Parse },
    85         { "prototypes", no_argument, 0, Prototypes },
     86        { "no-prototypes", no_argument, 0, Prototypes },
    8687        { "resolver", no_argument, 0, Resolver },
    8788        { "symbol", no_argument, 0, Symbol },
     
    131132                  case Prototypes:
    132133                  case 'p':                                                                             // generate prototypes for preamble functions
    133                         protop = true;
     134                        noprotop = true;
    134135                        break;
    135136                  case Parse:
     
    221222                Parser::get_parser().freeTree();
    222223                if ( astp ) {
    223                         printAll( translationUnit, std::cout );
     224                        dump( translationUnit );
    224225                        return 0;
    225226                } // if
     
    227228                // add the assignment statement after the
    228229                // initialization of a type parameter
    229                 OPTPRINT( "tweak" )
    230                 InitTweak::tweak( translationUnit );
    231230                OPTPRINT( "validate" )
    232231                SymTab::validate( translationUnit, symtabp );
     
    242241
    243242                if ( validp ) {
    244                         printAll( translationUnit, std::cout );
     243                        dump( translationUnit );
    245244                        return 0;
    246245                } // if
     
    250249                OPTPRINT( "fixNames" )
    251250                CodeGen::fixNames( translationUnit );
     251                OPTPRINT( "tweak" )
     252                InitTweak::tweak( translationUnit );
    252253
    253254                if ( libcfap ) {
    254                         protop = true;
    255255                        // generate the bodies of cfa library functions
    256256                        LibCfa::makeLibCfa( translationUnit );
     
    258258
    259259                if ( bresolvep ) {
    260                         printAll( translationUnit, std::cout );
     260                        dump( translationUnit );
    261261                        return 0;
    262262                } // if
     
    265265                ResolvExpr::resolve( translationUnit );
    266266                if ( exprp ) {
    267                         printAll( translationUnit, std::cout );
     267                        dump( translationUnit );
    268268                }
    269269
     
    279279                // print tree right before code generation
    280280                if ( codegenp ) {
    281                         printAll( translationUnit, std::cout );
    282                         return 0;
    283                 } // if
    284 
    285                 CodeGen::generate( translationUnit, *output, true ); //protop );
     281                        dump( translationUnit );
     282                        return 0;
     283                } // if
     284
     285                CodeGen::generate( translationUnit, *output, ! noprotop );
    286286
    287287                if ( output != &std::cout ) {
     
    290290        } catch ( SemanticError &e ) {
    291291                if ( errorp ) {
    292                         printAll( translationUnit, std::cerr );
     292                        dump( translationUnit );
    293293                }
    294294                e.print( std::cerr );
     
    315315} // main
    316316
    317 void parse( FILE * input, LinkageSpec::Type linkage, bool shouldExit ) {
     317static void parse( FILE * input, LinkageSpec::Type linkage, bool shouldExit ) {
    318318        Parser::get_parser().set_linkage( linkage );
    319319        Parser::get_parser().parse( input );
     
    325325}
    326326
     327static bool notPrelude( Declaration * decl ) {
     328        return ! LinkageSpec::isBuiltin( decl->get_linkage() );
     329}
     330
     331static void dump( std::list< Declaration * > & translationUnit ) {
     332        std::list< Declaration * > decls;
     333        if ( noprotop ) {
     334                filter( translationUnit.begin(), translationUnit.end(),
     335                                std::back_inserter( decls ), notPrelude );
     336        } else {
     337                decls = translationUnit;
     338        }
     339
     340        printAll( decls, std::cout );
     341        deleteAll( translationUnit );
     342}
     343
     344
    327345// Local Variables: //
    328346// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.