Changeset ff29f08 for src/main.cc


Ignore:
Timestamp:
May 18, 2018, 2:09:21 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
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.
Message:

Merge remote-tracking branch 'origin/master' into with_gc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    rf6f0cca3 rff29f08  
    1111// Created On       : Fri May 15 23:12:02 2015
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Tue Oct 31 12:22:40 2017
    14 // Update Count     : 445
     13// Last Modified On : Mon May  7 14:35:57 2018
     14// Update Count     : 492
    1515//
    1616
     
    3535#include "CodeTools/DeclStats.h"            // for printDeclStats
    3636#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"
    3740#include "Common/PassVisitor.h"
    38 #include "Common/CompilerError.h"           // for CompilerError
    39 #include "Common/GC.h"                                          // for GC
    4041#include "Common/SemanticError.h"           // for SemanticError
    4142#include "Common/UnimplementedError.h"      // for UnimplementedError
     
    6566using namespace std;
    6667
    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;
    6872
    6973LinkageSpec::Spec linkage = LinkageSpec::Cforall;
     
    242246
    243247                // 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 ) );
    246249                if ( symtabp ) return 0;
    247250                collect( translationUnit );
     
    258261                } // if
    259262
    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 ) );
    268267                collect( translationUnit );
    269268                if ( libcfap ) {
     
    284283                CodeTools::fillLocations( translationUnit );
    285284
    286                 OPTPRINT( "resolve" )
    287                 ResolvExpr::resolve( translationUnit );
     285                PASS( "resolve", ResolvExpr::resolve( translationUnit ) );
    288286                collect( translationUnit );
    289287                if ( exprp ) {
     
    293291
    294292                // fix ObjectDecl - replaces ConstructorInit nodes
    295                 OPTPRINT( "fixInit" )
    296                 InitTweak::fix( translationUnit, filename, libcfap || treep );
     293                PASS( "fixInit", InitTweak::fix( translationUnit, filename, libcfap || treep ) );
    297294                collect( translationUnit );
    298295                if ( ctorinitp ) {
     
    301298                } // if
    302299
    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 reused
     300                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
    304301                Tuples::expandUniqueExpr( translationUnit );
    305302
    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?
    317310                collect( translationUnit );
    318311                if ( tuplep ) {
     
    321314                }
    322315
    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 ) );
    328319                collect( translationUnit );
    329320                if ( genericsp ) {
     
    331322                        return 0;
    332323                }
    333 
    334                 OPTPRINT( "convertLvalue" )
    335                 GenPoly::convertLvalue( translationUnit );
     324                PASS( "convertLvalue", GenPoly::convertLvalue( translationUnit ) );
    336325                collect( translationUnit );
    337326                if ( bboxp ) {
     
    339328                        return 0;
    340329                } // if
    341 
    342                 OPTPRINT( "box" )
    343                 GenPoly::box( translationUnit );
     330                PASS( "box", GenPoly::box( translationUnit ) );
    344331                collect( translationUnit );
    345332                if ( bcodegenp ) {
     
    353340
    354341                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 ) );
    357343
    358344                CodeGen::FixMain::fix( *output, treep ? "../prelude/bootloader.c" : CFA_LIBDIR "/bootloader.c" );
    359                 OPTPRINT( "end" )
    360 
    361345                if ( output != &cout ) {
    362346                        delete output;
     
    386370                } // if
    387371                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();
    390388        return 0;
    391389} // main
     
    420418        opterr = 0;                                                                                     // (global) prevent getopt from printing error messages
    421419
     420        bool Wsuppress = false, Werror = false;
    422421        int c;
    423         while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) {
     422        while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrstTvwW:yzZD:F:", long_opts, &long_index )) != -1 ) {
    424423                switch ( c ) {
    425424                  case Ast:
     
    457456                        yydebug = true;
    458457                        break;
    459                   case 'G':                   // dump AST after instantiate generics
     458                  case 'G':                                                                             // dump AST after instantiate generics
    460459                        genericsp = true;
    461460                        break;
     
    505504                  case 'v':                                                                             // dump AST after decl validation pass
    506505                        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
    507526                        break;
    508527                  case 'y':                                                                             // dump AST on error
     
    526545                                assertf( false, "Unknown option: %s\n", argv[optind - 1] );
    527546                        } // if
    528                         #if __GNUC__ < 7
    529                         #else
     547                        #if defined(__GNUC__) && __GNUC__ >= 7
    530548                                __attribute__((fallthrough));
    531549                        #endif
     
    534552                } // switch
    535553        } // 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
    536564} // parse_cmdline
    537565
Note: See TracChangeset for help on using the changeset viewer.