Changeset ff29f08 for src/main.cc
- Timestamp:
- May 18, 2018, 2:09:21 PM (6 years ago)
- Branches:
- new-env, with_gc
- Children:
- 2472a19
- Parents:
- f6f0cca3 (diff), c7d8100c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
rf6f0cca3 rff29f08 11 11 // Created On : Fri May 15 23:12:02 2015 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Tue Oct 31 12:22:40 201714 // Update Count : 4 4513 // Last Modified On : Mon May 7 14:35:57 2018 14 // Update Count : 492 15 15 // 16 16 … … 35 35 #include "CodeTools/DeclStats.h" // for printDeclStats 36 36 #include "CodeTools/TrackLoc.h" // for fillLocations 37 #include "Common/CompilerError.h" // for CompilerError 38 #include "Common/GC.h" // for GC 39 #include "Common/Heap.h" 37 40 #include "Common/PassVisitor.h" 38 #include "Common/CompilerError.h" // for CompilerError39 #include "Common/GC.h" // for GC40 41 #include "Common/SemanticError.h" // for SemanticError 41 42 #include "Common/UnimplementedError.h" // for UnimplementedError … … 65 66 using namespace std; 66 67 67 #define OPTPRINT(x) if ( errorp ) cerr << x << endl; 68 #define PASS(name, pass) \ 69 if ( errorp ) { cerr << name << endl; } \ 70 HeapStats::newPass(name); \ 71 pass; 68 72 69 73 LinkageSpec::Spec linkage = LinkageSpec::Cforall; … … 242 246 243 247 // add the assignment statement after the initialization of a type parameter 244 OPTPRINT( "validate" ) 245 SymTab::validate( translationUnit, symtabp ); 248 PASS( "validate", SymTab::validate( translationUnit, symtabp ) ); 246 249 if ( symtabp ) return 0; 247 250 collect( translationUnit ); … … 258 261 } // if 259 262 260 OPTPRINT( "mutate" ) 261 ControlStruct::mutate( translationUnit ); 262 OPTPRINT( "fixNames" ) 263 CodeGen::fixNames( translationUnit ); 264 OPTPRINT( "genInit" ) 265 InitTweak::genInit( translationUnit ); 266 OPTPRINT( "expandMemberTuples" ); 267 Tuples::expandMemberTuples( translationUnit ); 263 PASS( "mutate", ControlStruct::mutate( translationUnit ) ); 264 PASS( "fixNames", CodeGen::fixNames( translationUnit ) ); 265 PASS( "genInit", InitTweak::genInit( translationUnit ) ); 266 PASS( "expandMemberTuples" , Tuples::expandMemberTuples( translationUnit ) ); 268 267 collect( translationUnit ); 269 268 if ( libcfap ) { … … 284 283 CodeTools::fillLocations( translationUnit ); 285 284 286 OPTPRINT( "resolve" ) 287 ResolvExpr::resolve( translationUnit ); 285 PASS( "resolve", ResolvExpr::resolve( translationUnit ) ); 288 286 collect( translationUnit ); 289 287 if ( exprp ) { … … 293 291 294 292 // fix ObjectDecl - replaces ConstructorInit nodes 295 OPTPRINT( "fixInit" ) 296 InitTweak::fix( translationUnit, filename, libcfap || treep ); 293 PASS( "fixInit", InitTweak::fix( translationUnit, filename, libcfap || treep ) ); 297 294 collect( translationUnit ); 298 295 if ( ctorinitp ) { … … 301 298 } // if 302 299 303 OPTPRINT( "expandUniqueExpr" ); // xxx - is this the right place for this? want to expand ASAP so that subsequent 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 reused300 PASS( "expandUniqueExpr", 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 304 301 Tuples::expandUniqueExpr( translationUnit ); 305 302 306 OPTPRINT( "translateEHM" ); 307 ControlStruct::translateEHM( translationUnit ); 308 309 OPTPRINT( "generateWaitfor" ); 310 Concurrency::generateWaitFor( translationUnit ); 311 312 OPTPRINT( "convertSpecializations" ) // needs to happen before tuple types are expanded 313 GenPoly::convertSpecializations( translationUnit ); 314 315 OPTPRINT( "expandTuples" ); // xxx - is this the right place for this? 316 Tuples::expandTuples( translationUnit ); 303 PASS( "translateEHM" , ControlStruct::translateEHM( translationUnit ) ); 304 305 PASS( "generateWaitfor" , Concurrency::generateWaitFor( translationUnit ) ); 306 307 PASS( "convertSpecializations", GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded 308 309 PASS( "expandTuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this? 317 310 collect( translationUnit ); 318 311 if ( tuplep ) { … … 321 314 } 322 315 323 OPTPRINT( "virtual expandCasts" ) // Must come after translateEHM 324 Virtual::expandCasts( translationUnit ); 325 326 OPTPRINT("instantiateGenerics") 327 GenPoly::instantiateGeneric( translationUnit ); 316 PASS( "virtual expandCasts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM 317 318 PASS( "instantiateGenerics", GenPoly::instantiateGeneric( translationUnit ) ); 328 319 collect( translationUnit ); 329 320 if ( genericsp ) { … … 331 322 return 0; 332 323 } 333 334 OPTPRINT( "convertLvalue" ) 335 GenPoly::convertLvalue( translationUnit ); 324 PASS( "convertLvalue", GenPoly::convertLvalue( translationUnit ) ); 336 325 collect( translationUnit ); 337 326 if ( bboxp ) { … … 339 328 return 0; 340 329 } // if 341 342 OPTPRINT( "box" ) 343 GenPoly::box( translationUnit ); 330 PASS( "box", GenPoly::box( translationUnit ) ); 344 331 collect( translationUnit ); 345 332 if ( bcodegenp ) { … … 353 340 354 341 CodeTools::fillLocations( translationUnit ); 355 OPTPRINT( "codegen" ) 356 CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ); 342 PASS( "codegen", CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ) ); 357 343 358 344 CodeGen::FixMain::fix( *output, treep ? "../prelude/bootloader.c" : CFA_LIBDIR "/bootloader.c" ); 359 OPTPRINT( "end" )360 361 345 if ( output != &cout ) { 362 346 delete output; … … 386 370 } // if 387 371 return 1; 388 } // try 389 372 } catch(...) { 373 std::exception_ptr eptr = std::current_exception(); 374 try { 375 if (eptr) { 376 std::rethrow_exception(eptr); 377 } 378 else { 379 std::cerr << "Exception Uncaught and Unkown" << std::endl; 380 } 381 } catch(const std::exception& e) { 382 std::cerr << "Unaught Exception \"" << e.what() << "\"\n"; 383 } 384 return 1; 385 }// try 386 387 if(!libcfap && !treep) HeapStats::printStats(); 390 388 return 0; 391 389 } // main … … 420 418 opterr = 0; // (global) prevent getopt from printing error messages 421 419 420 bool Wsuppress = false, Werror = false; 422 421 int c; 423 while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrstTv yzZD:F:", long_opts, &long_index )) != -1 ) {422 while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrstTvwW:yzZD:F:", long_opts, &long_index )) != -1 ) { 424 423 switch ( c ) { 425 424 case Ast: … … 457 456 yydebug = true; 458 457 break; 459 case 'G': 458 case 'G': // dump AST after instantiate generics 460 459 genericsp = true; 461 460 break; … … 505 504 case 'v': // dump AST after decl validation pass 506 505 validp = true; 506 break; 507 case 'w': 508 Wsuppress = true; 509 break; 510 case 'W': 511 if ( strcmp( optarg, "all" ) == 0 ) { 512 SemanticWarning_EnableAll(); 513 } else if ( strcmp( optarg, "error" ) == 0 ) { 514 Werror = true; 515 } else { 516 char * warning = optarg; 517 Severity s; 518 if ( strncmp( optarg, "no-", 3 ) == 0 ) { 519 warning += 3; 520 s = Severity::Suppress; 521 } else { 522 s = Severity::Warn; 523 } // if 524 SemanticWarning_Set( warning, s ); 525 } // if 507 526 break; 508 527 case 'y': // dump AST on error … … 526 545 assertf( false, "Unknown option: %s\n", argv[optind - 1] ); 527 546 } // if 528 #if __GNUC__ < 7 529 #else 547 #if defined(__GNUC__) && __GNUC__ >= 7 530 548 __attribute__((fallthrough)); 531 549 #endif … … 534 552 } // switch 535 553 } // while 554 555 if ( Werror ) { 556 SemanticWarning_WarningAsError(); 557 } // if 558 if ( Wsuppress ) { 559 SemanticWarning_SuppressAll(); 560 } // if 561 // for ( const auto w : WarningFormats ) { 562 // cout << w.name << ' ' << (int)w.severity << endl; 563 // } // for 536 564 } // parse_cmdline 537 565
Note: See TracChangeset
for help on using the changeset viewer.