Changes in src/main.cc [0e464f6:e0bd0f9]
- File:
-
- 1 edited
-
src/main.cc (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
r0e464f6 re0bd0f9 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 5 20:35:13201913 // Update Count : 60 112 // Last Modified On : Thu Aug 22 13:06:18 2019 13 // Update Count : 605 14 14 // 15 15 … … 59 59 #include "ResolvExpr/Resolver.h" // for resolve 60 60 #include "SymTab/Validate.h" // for validate 61 #include "SynTree/TopLvalue.h" // for assertTopLvalue, clearInn... 61 62 #include "SynTree/Declaration.h" // for Declaration 62 63 #include "SynTree/Visitor.h" // for acceptAll 63 64 #include "Tuples/Tuples.h" // for expandMemberTuples, expan... 64 65 #include "Virtual/ExpandCasts.h" // for expandCasts 66 65 67 66 68 using namespace std; … … 96 98 static std::string PreludeDirector = ""; 97 99 98 static void parse_cmdline( int argc, char *argv[] , const char *& filename);100 static void parse_cmdline( int argc, char *argv[] ); 99 101 static void parse( FILE * input, LinkageSpec::Spec linkage, bool shouldExit = false ); 100 102 static void dump( list< Declaration * > & translationUnit, ostream & out = cout ); … … 169 171 FILE * input; // use FILE rather than istream because yyin is FILE 170 172 ostream * output = & cout; 171 const char * filename = nullptr;172 173 list< Declaration * > translationUnit; 173 174 … … 181 182 // } // for 182 183 183 parse_cmdline( argc, argv , filename );// process command-line arguments184 parse_cmdline( argc, argv ); // process command-line arguments 184 185 CodeGen::FixMain::setReplaceMain( !nomainp ); 185 186 … … 188 189 if ( optind < argc ) { // any commands after the flags ? => input file name 189 190 input = fopen( argv[ optind ], "r" ); 190 assertf( input, "cannot open %s\n", argv[ optind ] ); 191 // if running cfa-cpp directly, might forget to pass -F option (and really shouldn't have to) 192 if ( filename == nullptr ) filename = argv[ optind ]; 193 // prelude filename comes in differently 194 if ( libcfap ) filename = "prelude.cfa"; 191 assertf( input, "cannot open %s because %s\n", argv[ optind ], strerror( errno ) ); 195 192 optind += 1; 196 193 } else { // no input file name 197 194 input = stdin; 198 // if running cfa-cpp directly, might forget to pass -F option. Since this takes from stdin, pass199 // a fake name along200 if ( filename == nullptr ) filename = "stdin";201 195 } // if 202 196 … … 257 251 Stats::Time::StopBlock(); 258 252 253 //std::cerr << "Post-Parse Check" << std::endl; 254 clearInnerLvalue( translationUnit ); 255 assertTopLvalue( translationUnit ); 256 259 257 // add the assignment statement after the initialization of a type parameter 260 258 PASS( "Validate", SymTab::validate( translationUnit, symtabp ) ); … … 275 273 } // if 276 274 275 assertTopLvalue( translationUnit ); 277 276 PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) ); 277 assertTopLvalue( translationUnit ); 278 278 PASS( "Fix Names", CodeGen::fixNames( translationUnit ) ); 279 assertTopLvalue( translationUnit ); 279 280 PASS( "Gen Init", InitTweak::genInit( translationUnit ) ); 281 assertTopLvalue( translationUnit ); 280 282 PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) ); 283 assertTopLvalue( translationUnit ); 281 284 if ( libcfap ) { 282 285 // generate the bodies of cfa library functions … … 302 305 } // if 303 306 307 assertTopLvalue( translationUnit ); 308 304 309 PASS( "Resolve", ResolvExpr::resolve( translationUnit ) ); 305 310 if ( exprp ) { … … 308 313 } // if 309 314 315 clearInnerLvalue( translationUnit ); 316 assertTopLvalue( translationUnit ); 317 310 318 // fix ObjectDecl - replaces ConstructorInit nodes 311 319 PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) ); 320 clearInnerLvalue( translationUnit ); 321 assertTopLvalue( translationUnit ); 312 322 if ( ctorinitp ) { 313 323 dump ( translationUnit ); … … 316 326 317 327 PASS( "Expand Unique Expr", Tuples::expandUniqueExpr( translationUnit ) ); // xxx - is this the right place for this? want to expand ASAP so tha, sequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused 328 assertTopLvalue( translationUnit ); 318 329 319 330 PASS( "Translate EHM" , ControlStruct::translateEHM( translationUnit ) ); 331 assertTopLvalue( translationUnit ); 320 332 321 333 PASS( "Gen Waitfor" , Concurrency::generateWaitFor( translationUnit ) ); 334 clearInnerLvalue( translationUnit ); 335 assertTopLvalue( translationUnit ); 322 336 323 337 PASS( "Convert Specializations", GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded 338 clearInnerLvalue( translationUnit ); 339 assertTopLvalue( translationUnit ); 324 340 325 341 PASS( "Expand Tuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this? 342 assertTopLvalue( translationUnit ); 326 343 327 344 if ( tuplep ) { … … 331 348 332 349 PASS( "Virtual Expand Casts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM 350 assertTopLvalue( translationUnit ); 333 351 334 352 PASS( "Instantiate Generics", GenPoly::instantiateGeneric( translationUnit ) ); … … 337 355 return EXIT_SUCCESS; 338 356 } // if 357 clearInnerLvalue( translationUnit ); 358 assertTopLvalue( translationUnit ); 339 359 PASS( "Convert L-Value", GenPoly::convertLvalue( translationUnit ) ); 340 360 clearInnerLvalue( translationUnit ); 361 assertTopLvalue( translationUnit ); 341 362 342 363 if ( bboxp ) { … … 345 366 } // if 346 367 PASS( "Box", GenPoly::box( translationUnit ) ); 368 clearInnerLvalue( translationUnit ); 369 assertTopLvalue( translationUnit ); 347 370 348 371 if ( bcodegenp ) { … … 356 379 357 380 CodeTools::fillLocations( translationUnit ); 381 assertTopLvalue( translationUnit ); 358 382 PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ) ); 359 383 … … 406 430 407 431 408 static const char optstring[] = ":hlLmNnpP:S:twW:D: F:";432 static const char optstring[] = ":hlLmNnpP:S:twW:D:"; 409 433 410 434 enum { PreludeDir = 128 }; … … 424 448 { "", no_argument, nullptr, 0 }, // -W 425 449 { "", no_argument, nullptr, 0 }, // -D 426 { "", no_argument, nullptr, 0 }, // -F427 450 { nullptr, 0, nullptr, 0 } 428 451 }; // long_opts … … 443 466 "", // -W 444 467 "", // -D 445 "", // -F446 468 }; // description 447 469 … … 478 500 479 501 static void usage( char *argv[] ) { 480 cout << "Usage: " << argv[0] << " options are:" << endl;502 cout << "Usage: " << argv[0] << " [options] [input-file (default stdin)] [output-file (default stdout)], where options are:" << endl; 481 503 int i = 0, j = 1; // j skips starting colon 482 504 for ( ; long_opts[i].name != 0 && optstring[j] != '\0'; i += 1, j += 1 ) { … … 504 526 } // usage 505 527 506 static void parse_cmdline( int argc, char * argv[] , const char *& filename) {528 static void parse_cmdline( int argc, char * argv[] ) { 507 529 opterr = 0; // (global) prevent getopt from printing error messages 508 530 … … 575 597 case 'D': // ignore -Dxxx, forwarded by cpp, hidden 576 598 break; 577 case 'F': // source file-name without suffix, hidden578 filename = optarg;579 break;580 599 case '?': // unknown option 581 600 if ( optopt ) { // short option ?
Note:
See TracChangeset
for help on using the changeset viewer.