Changes in src/main.cc [4990812:bd06384]
- File:
-
- 1 edited
-
src/main.cc (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
r4990812 rbd06384 1 1 2 // 2 3 // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo … … 10 11 // Created On : Fri May 15 23:12:02 2015 11 12 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 7 14:35:57 201813 // Update Count : 4 9213 // Last Modified On : Tue Oct 31 12:22:40 2017 14 // Update Count : 445 14 15 // 15 16 … … 34 35 #include "CodeTools/DeclStats.h" // for printDeclStats 35 36 #include "CodeTools/TrackLoc.h" // for fillLocations 37 #include "Common/PassVisitor.h" 36 38 #include "Common/CompilerError.h" // for CompilerError 37 #include "Common/Heap.h" 38 #include "Common/PassVisitor.h" 39 #include "Common/GC.h" // for GC 39 40 #include "Common/SemanticError.h" // for SemanticError 40 41 #include "Common/UnimplementedError.h" // for UnimplementedError … … 57 58 #include "SymTab/Validate.h" // for validate 58 59 #include "SynTree/Declaration.h" // for Declaration 60 #include "SynTree/GcTracer.h" // for GC << TranslationUnit 59 61 #include "SynTree/Visitor.h" // for acceptAll 60 62 #include "Tuples/Tuples.h" // for expandMemberTuples, expan... … … 63 65 using namespace std; 64 66 65 #define PASS(name, pass) \ 66 if ( errorp ) { cerr << name << endl; } \ 67 HeapStats::newPass(name); \ 68 pass; 67 #define OPTPRINT(x) if ( errorp ) cerr << x << endl; 69 68 70 69 LinkageSpec::Spec linkage = LinkageSpec::Cforall; … … 177 176 signal( SIGABRT, sigAbortHandler ); 178 177 179 // std::cout << "main" << std::endl;180 // for ( int i = 0; i < argc; i += 1 ) {181 // std::cout << '\t' << argv[i] << std::endl;182 // } // for183 184 178 parse_cmdline( argc, argv, filename ); // process command-line arguments 185 179 CodeGen::FixMain::setReplaceMain( !nomainp ); … … 240 234 delete parseTree; 241 235 parseTree = nullptr; 236 collect( translationUnit ); 242 237 243 238 if ( astp ) { … … 247 242 248 243 // add the assignment statement after the initialization of a type parameter 249 PASS( "validate", SymTab::validate( translationUnit, symtabp ) ); 250 if ( symtabp ) { 251 deleteAll( translationUnit ); 252 return 0; 253 } // if 244 OPTPRINT( "validate" ) 245 SymTab::validate( translationUnit, symtabp ); 246 if ( symtabp ) return 0; 247 collect( translationUnit ); 254 248 255 249 if ( expraltp ) { … … 264 258 } // if 265 259 266 PASS( "mutate", ControlStruct::mutate( translationUnit ) ); 267 PASS( "fixNames", CodeGen::fixNames( translationUnit ) ); 268 PASS( "genInit", InitTweak::genInit( translationUnit ) ); 269 PASS( "expandMemberTuples" , Tuples::expandMemberTuples( translationUnit ) ); 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 ); 270 269 if ( libcfap ) { 271 270 // generate the bodies of cfa library functions … … 275 274 if ( declstatsp ) { 276 275 CodeTools::printDeclStats( translationUnit ); 277 deleteAll( translationUnit );278 276 return 0; 279 277 } … … 286 284 CodeTools::fillLocations( translationUnit ); 287 285 288 PASS( "resolve", ResolvExpr::resolve( translationUnit ) ); 286 OPTPRINT( "resolve" ) 287 ResolvExpr::resolve( translationUnit ); 288 collect( translationUnit ); 289 289 if ( exprp ) { 290 290 dump( translationUnit ); … … 293 293 294 294 // fix ObjectDecl - replaces ConstructorInit nodes 295 PASS( "fixInit", InitTweak::fix( translationUnit, filename, libcfap || treep ) ); 295 OPTPRINT( "fixInit" ) 296 InitTweak::fix( translationUnit, filename, libcfap || treep ); 297 collect( translationUnit ); 296 298 if ( ctorinitp ) { 297 299 dump ( translationUnit ); … … 299 301 } // if 300 302 301 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 reused303 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 reused 302 304 Tuples::expandUniqueExpr( translationUnit ); 303 305 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 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 ); 312 318 if ( tuplep ) { 313 319 dump( translationUnit ); … … 315 321 } 316 322 317 PASS( "virtual expandCasts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM 318 319 PASS( "instantiateGenerics", GenPoly::instantiateGeneric( translationUnit ) ); 323 OPTPRINT( "virtual expandCasts" ) // Must come after translateEHM 324 Virtual::expandCasts( translationUnit ); 325 326 OPTPRINT("instantiateGenerics") 327 GenPoly::instantiateGeneric( translationUnit ); 328 collect( translationUnit ); 320 329 if ( genericsp ) { 321 330 dump( translationUnit ); 322 331 return 0; 323 332 } 324 PASS( "convertLvalue", GenPoly::convertLvalue( translationUnit ) ); 325 326 333 334 OPTPRINT( "convertLvalue" ) 335 GenPoly::convertLvalue( translationUnit ); 336 collect( translationUnit ); 327 337 if ( bboxp ) { 328 338 dump( translationUnit ); 329 339 return 0; 330 340 } // if 331 PASS( "box", GenPoly::box( translationUnit ) ); 332 341 342 OPTPRINT( "box" ) 343 GenPoly::box( translationUnit ); 344 collect( translationUnit ); 333 345 if ( bcodegenp ) { 334 346 dump( translationUnit ); … … 341 353 342 354 CodeTools::fillLocations( translationUnit ); 343 PASS( "codegen", CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ) ); 355 OPTPRINT( "codegen" ) 356 CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ); 344 357 345 358 CodeGen::FixMain::fix( *output, treep ? "../prelude/bootloader.c" : CFA_LIBDIR "/bootloader.c" ); 359 OPTPRINT( "end" ) 360 346 361 if ( output != &cout ) { 347 362 delete output; … … 371 386 } // if 372 387 return 1; 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(); 388 } // try 389 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;423 422 int c; 424 while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrstTv wW:yzZD:F:", long_opts, &long_index )) != -1 ) {423 while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) { 425 424 switch ( c ) { 426 425 case Ast: … … 458 457 yydebug = true; 459 458 break; 460 case 'G': // dump AST after instantiate generics459 case 'G': // dump AST after instantiate generics 461 460 genericsp = true; 462 461 break; … … 506 505 case 'v': // dump AST after decl validation pass 507 506 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 } // if526 SemanticWarning_Set( warning, s );527 } // if528 507 break; 529 508 case 'y': // dump AST on error … … 547 526 assertf( false, "Unknown option: %s\n", argv[optind - 1] ); 548 527 } // if 549 #if defined(__GNUC__) && __GNUC__ >= 7 528 #if __GNUC__ < 7 529 #else 550 530 __attribute__((fallthrough)); 551 531 #endif … … 554 534 } // switch 555 535 } // while 556 557 if ( Werror ) {558 SemanticWarning_WarningAsError();559 } // if560 if ( Wsuppress ) {561 SemanticWarning_SuppressAll();562 } // if563 // for ( const auto w : WarningFormats ) {564 // cout << w.name << ' ' << (int)w.severity << endl;565 // } // for566 536 } // parse_cmdline 567 537 … … 602 572 printAll( decls, out ); 603 573 } 604 deleteAll( translationUnit );605 574 } // dump 606 575
Note:
See TracChangeset
for help on using the changeset viewer.