Changes in src/main.cc [d3b7937:fea7ca7]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
rd3b7937 rfea7ca7 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 : Fri Apr 29 12:02:21 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" … … 41 40 #include "MakeLibCfa.h" 42 41 #include "InitTweak/Mutate.h" 43 #include "InitTweak/RemoveInit.h" 42 #include "InitTweak/GenInit.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 bboxp = false, 64 ctorinitp = false, 63 65 exprp = false, 64 66 expraltp = false, … … 75 77 codegenp = false; 76 78 77 enum { Ast, B resolver, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, };79 enum { Ast, Bbox, Bresolver, CtorInitFix, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, }; 78 80 79 81 static struct option long_opts[] = { 80 82 { "ast", no_argument, 0, Ast }, 83 { "before-box", no_argument, 0, Bbox }, 81 84 { "before-resolver", no_argument, 0, Bresolver }, 85 { "ctorinitfix", no_argument, 0, CtorInitFix }, 82 86 { "expr", no_argument, 0, Expr }, 83 87 { "expralt", no_argument, 0, ExprAlt }, … … 101 105 102 106 opterr = 0; // prevent getopt from printing error messages 103 107 104 108 int c; 105 while ( (c = getopt_long( argc, argv, "ab efglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {109 while ( (c = getopt_long( argc, argv, "abBcefFglnpqrstvyzD:", long_opts, &long_index )) != -1 ) { 106 110 switch ( c ) { 107 111 case Ast: … … 112 116 case 'b': // print before resolver steps 113 117 bresolvep = true; 118 break; 119 case 'B': // print before resolver steps 120 bboxp = true; 121 break; 122 case CtorInitFix: 123 case 'c': 124 ctorinitp = true; 114 125 break; 115 126 case Expr: … … 188 199 output = new ofstream( argv[ optind ] ); 189 200 } // if 190 201 191 202 Parser::get_parser().set_debug( grammarp ); 192 203 … … 209 220 exit( 1 ); 210 221 } // if 211 222 212 223 parse( prelude, LinkageSpec::Intrinsic ); 213 224 } // if 214 225 } // if 215 226 216 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp ); 217 227 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp ); 228 218 229 if ( parsep ) { 219 230 Parser::get_parser().get_parseTree()->printList( std::cout ); … … 250 261 OPTPRINT( "mutate" ) 251 262 ControlStruct::mutate( translationUnit ); 252 OPTPRINT( "fixNames" ) 263 OPTPRINT( "fixNames" ) 253 264 CodeGen::fixNames( translationUnit ); 254 OPTPRINT( "tweak " )255 InitTweak:: tweak( translationUnit );265 OPTPRINT( "tweakInit" ) 266 InitTweak::genInit( translationUnit ); 256 267 257 268 if ( libcfap ) { … … 269 280 if ( exprp ) { 270 281 dump( translationUnit ); 282 return 0; 271 283 } 272 284 273 OPTPRINT( "instantiateGeneric" ) 274 GenPoly::instantiateGeneric( translationUnit ); 285 OPTPRINT( "fixInit" ) 286 // fix ObjectDecl - replaces ConstructorInit nodes 287 InitTweak::fix( translationUnit ); 288 if ( ctorinitp ) { 289 dump ( translationUnit ); 290 return 0; 291 } 292 275 293 OPTPRINT( "copyParams" ); 276 294 GenPoly::copyParams( translationUnit ); … … 279 297 OPTPRINT( "convertLvalue" ) 280 298 GenPoly::convertLvalue( translationUnit ); 299 300 if ( bboxp ) { 301 dump( translationUnit ); 302 return 0; 303 } 281 304 OPTPRINT( "box" ) 282 305 GenPoly::box( translationUnit ); … … 295 318 } catch ( SemanticError &e ) { 296 319 if ( errorp ) { 297 dump( translationUnit ); 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; 298 323 } 299 324 e.print( std::cerr ); … … 317 342 } // try 318 343 344 deleteAll( translationUnit ); 319 345 return 0; 320 346 } // main … … 334 360 } 335 361 336 static void dump( std::list< Declaration * > & translationUnit ) {362 static void dump( std::list< Declaration * > & translationUnit, std::ostream & out ) { 337 363 std::list< Declaration * > decls; 338 364 if ( noprotop ) { 339 filter( translationUnit.begin(), translationUnit.end(), 365 filter( translationUnit.begin(), translationUnit.end(), 340 366 std::back_inserter( decls ), notPrelude ); 341 367 } else { … … 343 369 } 344 370 345 printAll( decls, std::cout );371 printAll( decls, out ); 346 372 deleteAll( translationUnit ); 347 373 }
Note: See TracChangeset
for help on using the changeset viewer.