Changes in src/main.cc [fea7ca7:d3b7937]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
rfea7ca7 rd3b7937 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // main.cc -- 7 // main.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Fri May 15 23:12:02 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Fri Apr 29 12:02:21201613 // Update Count : 20011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jan 27 22:20:20 2016 13 // Update Count : 199 14 14 // 15 15 … … 24 24 #include "SynTree/Declaration.h" 25 25 #include "SynTree/Visitor.h" 26 #include "GenPoly/InstantiateGeneric.h" 26 27 #include "GenPoly/Lvalue.h" 27 28 #include "GenPoly/Specialize.h" … … 40 41 #include "MakeLibCfa.h" 41 42 #include "InitTweak/Mutate.h" 42 #include "InitTweak/GenInit.h" 43 #include "InitTweak/FixInit.h" 43 #include "InitTweak/RemoveInit.h" 44 44 //#include "Explain/GenProlog.h" 45 45 //#include "Try/Visit.h" … … 56 56 57 57 static void parse( FILE * input, LinkageSpec::Type t, bool shouldExit = false ); 58 static void dump( std::list< Declaration * > & translationUnit , std::ostream & out = std::cout);58 static void dump( std::list< Declaration * > & translationUnit ); 59 59 60 60 bool 61 61 astp = false, 62 62 bresolvep = false, 63 bboxp = false,64 ctorinitp = false,65 63 exprp = false, 66 64 expraltp = false, … … 77 75 codegenp = false; 78 76 79 enum { Ast, B box, Bresolver, CtorInitFix, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, };77 enum { Ast, Bresolver, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, }; 80 78 81 79 static struct option long_opts[] = { 82 80 { "ast", no_argument, 0, Ast }, 83 { "before-box", no_argument, 0, Bbox },84 81 { "before-resolver", no_argument, 0, Bresolver }, 85 { "ctorinitfix", no_argument, 0, CtorInitFix },86 82 { "expr", no_argument, 0, Expr }, 87 83 { "expralt", no_argument, 0, ExprAlt }, … … 105 101 106 102 opterr = 0; // prevent getopt from printing error messages 107 103 108 104 int c; 109 while ( (c = getopt_long( argc, argv, "ab BcefFglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {105 while ( (c = getopt_long( argc, argv, "abefglnpqrstvyzD:", long_opts, &long_index )) != -1 ) { 110 106 switch ( c ) { 111 107 case Ast: … … 116 112 case 'b': // print before resolver steps 117 113 bresolvep = true; 118 break;119 case 'B': // print before resolver steps120 bboxp = true;121 break;122 case CtorInitFix:123 case 'c':124 ctorinitp = true;125 114 break; 126 115 case Expr: … … 199 188 output = new ofstream( argv[ optind ] ); 200 189 } // if 201 190 202 191 Parser::get_parser().set_debug( grammarp ); 203 192 … … 220 209 exit( 1 ); 221 210 } // if 222 211 223 212 parse( prelude, LinkageSpec::Intrinsic ); 224 213 } // if 225 214 } // if 226 215 227 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp ); 228 216 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp ); 217 229 218 if ( parsep ) { 230 219 Parser::get_parser().get_parseTree()->printList( std::cout ); … … 261 250 OPTPRINT( "mutate" ) 262 251 ControlStruct::mutate( translationUnit ); 263 OPTPRINT( "fixNames" ) 252 OPTPRINT( "fixNames" ) 264 253 CodeGen::fixNames( translationUnit ); 265 OPTPRINT( "tweak Init" )266 InitTweak:: genInit( translationUnit );254 OPTPRINT( "tweak" ) 255 InitTweak::tweak( translationUnit ); 267 256 268 257 if ( libcfap ) { … … 280 269 if ( exprp ) { 281 270 dump( translationUnit ); 282 return 0;283 271 } 284 272 285 OPTPRINT( "fixInit" ) 286 // fix ObjectDecl - replaces ConstructorInit nodes 287 InitTweak::fix( translationUnit ); 288 if ( ctorinitp ) { 289 dump ( translationUnit ); 290 return 0; 291 } 292 273 OPTPRINT( "instantiateGeneric" ) 274 GenPoly::instantiateGeneric( translationUnit ); 293 275 OPTPRINT( "copyParams" ); 294 276 GenPoly::copyParams( translationUnit ); … … 297 279 OPTPRINT( "convertLvalue" ) 298 280 GenPoly::convertLvalue( translationUnit ); 299 300 if ( bboxp ) {301 dump( translationUnit );302 return 0;303 }304 281 OPTPRINT( "box" ) 305 282 GenPoly::box( translationUnit ); … … 318 295 } catch ( SemanticError &e ) { 319 296 if ( errorp ) { 320 std::cerr << "---AST at error:---" << std::endl; 321 dump( translationUnit, std::cerr ); 322 std::cerr << std::endl << "---End of AST, begin error message:---\n" << std::endl; 297 dump( translationUnit ); 323 298 } 324 299 e.print( std::cerr ); … … 342 317 } // try 343 318 344 deleteAll( translationUnit );345 319 return 0; 346 320 } // main … … 360 334 } 361 335 362 static void dump( std::list< Declaration * > & translationUnit , std::ostream & out) {336 static void dump( std::list< Declaration * > & translationUnit ) { 363 337 std::list< Declaration * > decls; 364 338 if ( noprotop ) { 365 filter( translationUnit.begin(), translationUnit.end(), 339 filter( translationUnit.begin(), translationUnit.end(), 366 340 std::back_inserter( decls ), notPrelude ); 367 341 } else { … … 369 343 } 370 344 371 printAll( decls, out );345 printAll( decls, std::cout ); 372 346 deleteAll( translationUnit ); 373 347 }
Note: See TracChangeset
for help on using the changeset viewer.