Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    r03e5d14 r2a7e29b  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri May 06 15:29:42 2016
     12// Last Modified On : Fri May 06 15:59:09 2016
    1313// Update Count     : 203
    1414//
     
    4040#include "MakeLibCfa.h"
    4141#include "InitTweak/Mutate.h"
    42 #include "InitTweak/RemoveInit.h"
     42#include "InitTweak/GenInit.h"
     43#include "InitTweak/FixInit.h"
    4344#include "InitTweak/FixGlobalInit.h"
    4445//#include "Explain/GenProlog.h"
     
    5657
    5758static void parse( FILE * input, LinkageSpec::Type t, bool shouldExit = false );
    58 static void dump( std::list< Declaration * > & translationUnit );
     59static void dump( std::list< Declaration * > & translationUnit, std::ostream & out = std::cout );
    5960
    6061bool
    6162        astp = false,
    6263        bresolvep = false,
     64        bboxp = false,
     65        ctorinitp = false,
    6366        exprp = false,
    6467        expraltp = false,
     
    7578        codegenp = false;
    7679
    77 enum { Ast, Bresolver, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, };
     80enum { Ast, Bbox, Bresolver, CtorInitFix, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, };
    7881
    7982static struct option long_opts[] = {
    8083        { "ast", no_argument, 0, Ast },
     84        { "before-box", no_argument, 0, Bbox },
    8185        { "before-resolver", no_argument, 0, Bresolver },
     86        { "ctorinitfix", no_argument, 0, CtorInitFix },
    8287        { "expr", no_argument, 0, Expr },
    8388        { "expralt", no_argument, 0, ExprAlt },
     
    104109
    105110        int c;
    106         while ( (c = getopt_long( argc, argv, "abefglnpqrstvyzD:F:", long_opts, &long_index )) != -1 ) {
     111        while ( (c = getopt_long( argc, argv, "abBcefglnpqrstvyzD:F:", long_opts, &long_index )) != -1 ) {
    107112                switch ( c ) {
    108113                  case Ast:
     
    113118                  case 'b':                                                                             // print before resolver steps
    114119                        bresolvep = true;
     120                        break;
     121                  case 'B':                                                                             // print before resolver steps
     122                        bboxp = true;
     123                        break;
     124                  case CtorInitFix:
     125                  case 'c':
     126                        ctorinitp = true;
    115127                        break;
    116128                  case Expr:
     
    191203                } else {
    192204                        input = stdin;
     205                        // if running cfa-cpp directly, might forget to pass -F option. Since this takes from stdin, pass
     206                        // a fake name along
     207                        if ( filename == NULL ) filename = "stdin";
    193208                } // if
    194209
     
    262277                OPTPRINT( "fixGlobalInit" );
    263278                InitTweak::fixGlobalInit( translationUnit, filename, libcfap || treep );
    264                 OPTPRINT( "tweak" )
    265                 InitTweak::tweak( translationUnit );
     279                OPTPRINT( "tweakInit" )
     280                InitTweak::genInit( translationUnit );
    266281
    267282                if ( libcfap ) {
     
    279294                if ( exprp ) {
    280295                        dump( translationUnit );
     296                        return 0;
     297                }
     298
     299                OPTPRINT( "fixInit" )
     300                // fix ObjectDecl - replaces ConstructorInit nodes
     301                InitTweak::fix( translationUnit );
     302                if ( ctorinitp ) {
     303                        dump ( translationUnit );
     304                        return 0;
    281305                }
    282306
     
    287311                OPTPRINT( "convertLvalue" )
    288312                GenPoly::convertLvalue( translationUnit );
     313
     314                if ( bboxp ) {
     315                        dump( translationUnit );
     316                        return 0;
     317                }
    289318                OPTPRINT( "box" )
    290319                GenPoly::box( translationUnit );
     
    303332        } catch ( SemanticError &e ) {
    304333                if ( errorp ) {
    305                         dump( translationUnit );
     334                        std::cerr << "---AST at error:---" << std::endl;
     335                        dump( translationUnit, std::cerr );
     336                        std::cerr << std::endl << "---End of AST, begin error message:---\n" << std::endl;
    306337                }
    307338                e.print( std::cerr );
     
    325356        } // try
    326357
     358        deleteAll( translationUnit );
    327359        return 0;
    328360} // main
     
    342374}
    343375
    344 static void dump( std::list< Declaration * > & translationUnit ) {
     376static void dump( std::list< Declaration * > & translationUnit, std::ostream & out ) {
    345377        std::list< Declaration * > decls;
    346378        if ( noprotop ) {
     
    351383        }
    352384
    353         printAll( decls, std::cout );
     385        printAll( decls, out );
    354386        deleteAll( translationUnit );
    355387}
Note: See TracChangeset for help on using the changeset viewer.