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