Changes in src/main.cc [d3b7937:f77f12e2]
- File:
-
- 1 edited
-
src/main.cc (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
rd3b7937 rf77f12e2 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 : Peter A. Buhr12 // Last Modified On : Wed Jan 27 22:20:20201613 // Update Count : 19911 // Last Modified By : Rob Schluntz 12 // Last Modified On : Mon Apr 11 17:49:38 2016 13 // Update Count : 200 14 14 // 15 15 … … 24 24 #include "SynTree/Declaration.h" 25 25 #include "SynTree/Visitor.h" 26 #include "GenPoly/InstantiateGeneric.h"27 26 #include "GenPoly/Lvalue.h" 28 27 #include "GenPoly/Specialize.h" … … 42 41 #include "InitTweak/Mutate.h" 43 42 #include "InitTweak/RemoveInit.h" 43 #include "InitTweak/FixInit.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 );58 static void dump( std::list< Declaration * > & translationUnit, std::ostream & out = std::cout ); 59 59 60 60 bool 61 61 astp = false, 62 62 bresolvep = false, 63 ctorinitp = false, 63 64 exprp = false, 64 65 expraltp = false, … … 75 76 codegenp = false; 76 77 77 enum { Ast, Bresolver, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, };78 enum { Ast, Bresolver, CtorInitFix, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, }; 78 79 79 80 static struct option long_opts[] = { 80 81 { "ast", no_argument, 0, Ast }, 81 82 { "before-resolver", no_argument, 0, Bresolver }, 83 { "ctorinitfix", no_argument, 0, CtorInitFix }, 82 84 { "expr", no_argument, 0, Expr }, 83 85 { "expralt", no_argument, 0, ExprAlt }, … … 101 103 102 104 opterr = 0; // prevent getopt from printing error messages 103 105 104 106 int c; 105 while ( (c = getopt_long( argc, argv, "ab efglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {107 while ( (c = getopt_long( argc, argv, "abcefFglnpqrstvyzD:", long_opts, &long_index )) != -1 ) { 106 108 switch ( c ) { 107 109 case Ast: … … 112 114 case 'b': // print before resolver steps 113 115 bresolvep = true; 116 break; 117 case CtorInitFix: 118 case 'c': 119 ctorinitp = true; 114 120 break; 115 121 case Expr: … … 188 194 output = new ofstream( argv[ optind ] ); 189 195 } // if 190 196 191 197 Parser::get_parser().set_debug( grammarp ); 192 198 … … 209 215 exit( 1 ); 210 216 } // if 211 217 212 218 parse( prelude, LinkageSpec::Intrinsic ); 213 219 } // if 214 220 } // if 215 221 216 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp ); 217 222 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp ); 223 218 224 if ( parsep ) { 219 225 Parser::get_parser().get_parseTree()->printList( std::cout ); … … 250 256 OPTPRINT( "mutate" ) 251 257 ControlStruct::mutate( translationUnit ); 252 OPTPRINT( "fixNames" ) 258 OPTPRINT( "fixNames" ) 253 259 CodeGen::fixNames( translationUnit ); 254 OPTPRINT( "tweak " )260 OPTPRINT( "tweakInit" ) 255 261 InitTweak::tweak( translationUnit ); 256 262 … … 269 275 if ( exprp ) { 270 276 dump( translationUnit ); 277 return 0; 271 278 } 272 279 273 OPTPRINT( "instantiateGeneric" ) 274 GenPoly::instantiateGeneric( translationUnit ); 280 OPTPRINT( "fixInit" ) 281 // fix ObjectDecl - replaces ConstructorInit nodes 282 InitTweak::fix( translationUnit ); 283 if ( ctorinitp ) { 284 dump ( translationUnit ); 285 return 0; 286 } 287 275 288 OPTPRINT( "copyParams" ); 276 289 GenPoly::copyParams( translationUnit ); … … 295 308 } catch ( SemanticError &e ) { 296 309 if ( errorp ) { 297 dump( translationUnit ); 310 std::cerr << "---AST at error:---" << std::endl; 311 dump( translationUnit, std::cerr ); 312 std::cerr << std::endl << "---End of AST, begin error message:---\n" << std::endl; 298 313 } 299 314 e.print( std::cerr ); … … 317 332 } // try 318 333 334 deleteAll( translationUnit ); 319 335 return 0; 320 336 } // main … … 334 350 } 335 351 336 static void dump( std::list< Declaration * > & translationUnit ) {352 static void dump( std::list< Declaration * > & translationUnit, std::ostream & out ) { 337 353 std::list< Declaration * > decls; 338 354 if ( noprotop ) { 339 filter( translationUnit.begin(), translationUnit.end(), 355 filter( translationUnit.begin(), translationUnit.end(), 340 356 std::back_inserter( decls ), notPrelude ); 341 357 } else { … … 343 359 } 344 360 345 printAll( decls, std::cout );361 printAll( decls, out ); 346 362 deleteAll( translationUnit ); 347 363 }
Note:
See TracChangeset
for help on using the changeset viewer.