Changes in src/main.cc [03e5d14:2a7e29b]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
r03e5d14 r2a7e29b 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri May 06 15: 29:42201612 // Last Modified On : Fri May 06 15:59:09 2016 13 13 // Update Count : 203 14 14 // … … 40 40 #include "MakeLibCfa.h" 41 41 #include "InitTweak/Mutate.h" 42 #include "InitTweak/RemoveInit.h" 42 #include "InitTweak/GenInit.h" 43 #include "InitTweak/FixInit.h" 43 44 #include "InitTweak/FixGlobalInit.h" 44 45 //#include "Explain/GenProlog.h" … … 56 57 57 58 static void parse( FILE * input, LinkageSpec::Type t, bool shouldExit = false ); 58 static void dump( std::list< Declaration * > & translationUnit );59 static void dump( std::list< Declaration * > & translationUnit, std::ostream & out = std::cout ); 59 60 60 61 bool 61 62 astp = false, 62 63 bresolvep = false, 64 bboxp = false, 65 ctorinitp = false, 63 66 exprp = false, 64 67 expraltp = false, … … 75 78 codegenp = false; 76 79 77 enum { Ast, B resolver, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, };80 enum { Ast, Bbox, Bresolver, CtorInitFix, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, }; 78 81 79 82 static struct option long_opts[] = { 80 83 { "ast", no_argument, 0, Ast }, 84 { "before-box", no_argument, 0, Bbox }, 81 85 { "before-resolver", no_argument, 0, Bresolver }, 86 { "ctorinitfix", no_argument, 0, CtorInitFix }, 82 87 { "expr", no_argument, 0, Expr }, 83 88 { "expralt", no_argument, 0, ExprAlt }, … … 104 109 105 110 int c; 106 while ( (c = getopt_long( argc, argv, "ab efglnpqrstvyzD:F:", long_opts, &long_index )) != -1 ) {111 while ( (c = getopt_long( argc, argv, "abBcefglnpqrstvyzD:F:", long_opts, &long_index )) != -1 ) { 107 112 switch ( c ) { 108 113 case Ast: … … 113 118 case 'b': // print before resolver steps 114 119 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; 115 127 break; 116 128 case Expr: … … 191 203 } else { 192 204 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"; 193 208 } // if 194 209 … … 262 277 OPTPRINT( "fixGlobalInit" ); 263 278 InitTweak::fixGlobalInit( translationUnit, filename, libcfap || treep ); 264 OPTPRINT( "tweak " )265 InitTweak:: tweak( translationUnit );279 OPTPRINT( "tweakInit" ) 280 InitTweak::genInit( translationUnit ); 266 281 267 282 if ( libcfap ) { … … 279 294 if ( exprp ) { 280 295 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; 281 305 } 282 306 … … 287 311 OPTPRINT( "convertLvalue" ) 288 312 GenPoly::convertLvalue( translationUnit ); 313 314 if ( bboxp ) { 315 dump( translationUnit ); 316 return 0; 317 } 289 318 OPTPRINT( "box" ) 290 319 GenPoly::box( translationUnit ); … … 303 332 } catch ( SemanticError &e ) { 304 333 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; 306 337 } 307 338 e.print( std::cerr ); … … 325 356 } // try 326 357 358 deleteAll( translationUnit ); 327 359 return 0; 328 360 } // main … … 342 374 } 343 375 344 static void dump( std::list< Declaration * > & translationUnit ) {376 static void dump( std::list< Declaration * > & translationUnit, std::ostream & out ) { 345 377 std::list< Declaration * > decls; 346 378 if ( noprotop ) { … … 351 383 } 352 384 353 printAll( decls, std::cout );385 printAll( decls, out ); 354 386 deleteAll( translationUnit ); 355 387 }
Note: See TracChangeset
for help on using the changeset viewer.