Changes in src/main.cc [bd06384:4990812]
- File:
-
- 1 edited
-
src/main.cc (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
rbd06384 r4990812 1 2 1 // 3 2 // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo … … 11 10 // Created On : Fri May 15 23:12:02 2015 12 11 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Tue Oct 31 12:22:40 201714 // Update Count : 4 4512 // Last Modified On : Mon May 7 14:35:57 2018 13 // Update Count : 492 15 14 // 16 15 … … 35 34 #include "CodeTools/DeclStats.h" // for printDeclStats 36 35 #include "CodeTools/TrackLoc.h" // for fillLocations 36 #include "Common/CompilerError.h" // for CompilerError 37 #include "Common/Heap.h" 37 38 #include "Common/PassVisitor.h" 38 #include "Common/CompilerError.h" // for CompilerError39 #include "Common/GC.h" // for GC40 39 #include "Common/SemanticError.h" // for SemanticError 41 40 #include "Common/UnimplementedError.h" // for UnimplementedError … … 58 57 #include "SymTab/Validate.h" // for validate 59 58 #include "SynTree/Declaration.h" // for Declaration 60 #include "SynTree/GcTracer.h" // for GC << TranslationUnit61 59 #include "SynTree/Visitor.h" // for acceptAll 62 60 #include "Tuples/Tuples.h" // for expandMemberTuples, expan... … … 65 63 using namespace std; 66 64 67 #define OPTPRINT(x) if ( errorp ) cerr << x << endl; 65 #define PASS(name, pass) \ 66 if ( errorp ) { cerr << name << endl; } \ 67 HeapStats::newPass(name); \ 68 pass; 68 69 69 70 LinkageSpec::Spec linkage = LinkageSpec::Cforall; … … 176 177 signal( SIGABRT, sigAbortHandler ); 177 178 179 // std::cout << "main" << std::endl; 180 // for ( int i = 0; i < argc; i += 1 ) { 181 // std::cout << '\t' << argv[i] << std::endl; 182 // } // for 183 178 184 parse_cmdline( argc, argv, filename ); // process command-line arguments 179 185 CodeGen::FixMain::setReplaceMain( !nomainp ); … … 234 240 delete parseTree; 235 241 parseTree = nullptr; 236 collect( translationUnit );237 242 238 243 if ( astp ) { … … 242 247 243 248 // add the assignment statement after the initialization of a type parameter 244 OPTPRINT( "validate" ) 245 SymTab::validate( translationUnit, symtabp ); 246 if ( symtabp ) return 0; 247 collect( translationUnit ); 249 PASS( "validate", SymTab::validate( translationUnit, symtabp ) ); 250 if ( symtabp ) { 251 deleteAll( translationUnit ); 252 return 0; 253 } // if 248 254 249 255 if ( expraltp ) { … … 258 264 } // if 259 265 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 ); 268 collect( translationUnit ); 266 PASS( "mutate", ControlStruct::mutate( translationUnit ) ); 267 PASS( "fixNames", CodeGen::fixNames( translationUnit ) ); 268 PASS( "genInit", InitTweak::genInit( translationUnit ) ); 269 PASS( "expandMemberTuples" , Tuples::expandMemberTuples( translationUnit ) ); 269 270 if ( libcfap ) { 270 271 // generate the bodies of cfa library functions … … 274 275 if ( declstatsp ) { 275 276 CodeTools::printDeclStats( translationUnit ); 277 deleteAll( translationUnit ); 276 278 return 0; 277 279 } … … 284 286 CodeTools::fillLocations( translationUnit ); 285 287 286 OPTPRINT( "resolve" ) 287 ResolvExpr::resolve( translationUnit ); 288 collect( translationUnit ); 288 PASS( "resolve", ResolvExpr::resolve( translationUnit ) ); 289 289 if ( exprp ) { 290 290 dump( translationUnit ); … … 293 293 294 294 // fix ObjectDecl - replaces ConstructorInit nodes 295 OPTPRINT( "fixInit" ) 296 InitTweak::fix( translationUnit, filename, libcfap || treep ); 297 collect( translationUnit ); 295 PASS( "fixInit", InitTweak::fix( translationUnit, filename, libcfap || treep ) ); 298 296 if ( ctorinitp ) { 299 297 dump ( translationUnit ); … … 301 299 } // if 302 300 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 reused301 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 302 Tuples::expandUniqueExpr( translationUnit ); 305 303 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 ); 317 collect( translationUnit ); 304 PASS( "translateEHM" , ControlStruct::translateEHM( translationUnit ) ); 305 306 PASS( "generateWaitfor" , Concurrency::generateWaitFor( translationUnit ) ); 307 308 PASS( "convertSpecializations", GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded 309 310 PASS( "expandTuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this? 311 318 312 if ( tuplep ) { 319 313 dump( translationUnit ); … … 321 315 } 322 316 323 OPTPRINT( "virtual expandCasts" ) // Must come after translateEHM 324 Virtual::expandCasts( translationUnit ); 325 326 OPTPRINT("instantiateGenerics") 327 GenPoly::instantiateGeneric( translationUnit ); 328 collect( translationUnit ); 317 PASS( "virtual expandCasts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM 318 319 PASS( "instantiateGenerics", GenPoly::instantiateGeneric( translationUnit ) ); 329 320 if ( genericsp ) { 330 321 dump( translationUnit ); 331 322 return 0; 332 323 } 333 334 OPTPRINT( "convertLvalue" ) 335 GenPoly::convertLvalue( translationUnit ); 336 collect( translationUnit ); 324 PASS( "convertLvalue", GenPoly::convertLvalue( translationUnit ) ); 325 326 337 327 if ( bboxp ) { 338 328 dump( translationUnit ); 339 329 return 0; 340 330 } // if 341 342 OPTPRINT( "box" ) 343 GenPoly::box( translationUnit ); 344 collect( translationUnit ); 331 PASS( "box", GenPoly::box( translationUnit ) ); 332 345 333 if ( bcodegenp ) { 346 334 dump( translationUnit ); … … 353 341 354 342 CodeTools::fillLocations( translationUnit ); 355 OPTPRINT( "codegen" ) 356 CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ); 343 PASS( "codegen", CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ) ); 357 344 358 345 CodeGen::FixMain::fix( *output, treep ? "../prelude/bootloader.c" : CFA_LIBDIR "/bootloader.c" ); 359 OPTPRINT( "end" )360 361 346 if ( output != &cout ) { 362 347 delete output; … … 386 371 } // if 387 372 return 1; 388 } // try 389 373 } catch(...) { 374 std::exception_ptr eptr = std::current_exception(); 375 try { 376 if (eptr) { 377 std::rethrow_exception(eptr); 378 } 379 else { 380 std::cerr << "Exception Uncaught and Unkown" << std::endl; 381 } 382 } catch(const std::exception& e) { 383 std::cerr << "Unaught Exception \"" << e.what() << "\"\n"; 384 } 385 return 1; 386 }// try 387 388 deleteAll( translationUnit ); 389 if(!libcfap && !treep) HeapStats::printStats(); 390 390 return 0; 391 391 } // main … … 420 420 opterr = 0; // (global) prevent getopt from printing error messages 421 421 422 bool Wsuppress = false, Werror = false; 422 423 int c; 423 while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrstTv yzZD:F:", long_opts, &long_index )) != -1 ) {424 while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrstTvwW:yzZD:F:", long_opts, &long_index )) != -1 ) { 424 425 switch ( c ) { 425 426 case Ast: … … 457 458 yydebug = true; 458 459 break; 459 case 'G': // dump AST after instantiate generics460 case 'G': // dump AST after instantiate generics 460 461 genericsp = true; 461 462 break; … … 505 506 case 'v': // dump AST after decl validation pass 506 507 validp = true; 508 break; 509 case 'w': 510 Wsuppress = true; 511 break; 512 case 'W': 513 if ( strcmp( optarg, "all" ) == 0 ) { 514 SemanticWarning_EnableAll(); 515 } else if ( strcmp( optarg, "error" ) == 0 ) { 516 Werror = true; 517 } else { 518 char * warning = optarg; 519 Severity s; 520 if ( strncmp( optarg, "no-", 3 ) == 0 ) { 521 warning += 3; 522 s = Severity::Suppress; 523 } else { 524 s = Severity::Warn; 525 } // if 526 SemanticWarning_Set( warning, s ); 527 } // if 507 528 break; 508 529 case 'y': // dump AST on error … … 526 547 assertf( false, "Unknown option: %s\n", argv[optind - 1] ); 527 548 } // if 528 #if __GNUC__ < 7 529 #else 549 #if defined(__GNUC__) && __GNUC__ >= 7 530 550 __attribute__((fallthrough)); 531 551 #endif … … 534 554 } // switch 535 555 } // while 556 557 if ( Werror ) { 558 SemanticWarning_WarningAsError(); 559 } // if 560 if ( Wsuppress ) { 561 SemanticWarning_SuppressAll(); 562 } // if 563 // for ( const auto w : WarningFormats ) { 564 // cout << w.name << ' ' << (int)w.severity << endl; 565 // } // for 536 566 } // parse_cmdline 537 567 … … 572 602 printAll( decls, out ); 573 603 } 604 deleteAll( translationUnit ); 574 605 } // dump 575 606
Note:
See TracChangeset
for help on using the changeset viewer.