Changeset 1ab4ce2


Ignore:
Timestamp:
Jul 15, 2015, 4:47:34 PM (9 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:
724c2b6
Parents:
145f1fc
Message:

modified -p option to remove the prelude from output whenever this option is on

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    r145f1fc r1ab4ce2  
    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 : Wed Jul 15 16:45:24 2015
     13// Update Count     : 145
    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
     
    242243
    243244                if ( validp ) {
    244                         printAll( translationUnit, std::cout );
     245                        dump( translationUnit );
    245246                        return 0;
    246247                } // if
     
    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}
     342
     343
    327344// Local Variables: //
    328345// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.