Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    r1622af5 r01d433e  
    99// Author           : Peter Buhr and Rob Schluntz
    1010// Created On       : Fri May 15 23:12:02 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Nov  9 11:10:00 2021
    13 // Update Count     : 657
     11// Last Modified By : Henry Xue
     12// Last Modified On : Tue Jul 20 04:27:35 2021
     13// Update Count     : 658
    1414//
    1515
     
    4343#include "Common/CodeLocationTools.hpp"     // for forceFillCodeLocations
    4444#include "Common/CompilerError.h"           // for CompilerError
    45 #include "Common/DeclStats.hpp"             // for printDeclStats
    46 #include "Common/ResolvProtoDump.hpp"       // for dumpAsResolverProto
    4745#include "Common/Stats.h"
    4846#include "Common/PassVisitor.h"
     
    5351#include "ControlStruct/ExceptDecl.h"       // for translateExcept
    5452#include "ControlStruct/ExceptTranslate.h"  // for translateEHM
    55 #include "ControlStruct/FixLabels.hpp"      // for fixLabels
    5653#include "ControlStruct/Mutate.h"           // for mutate
    5754#include "GenPoly/Box.h"                    // for box
     
    6562#include "Parser/TypedefTable.h"            // for TypedefTable
    6663#include "ResolvExpr/AlternativePrinter.h"  // for AlternativePrinter
    67 #include "ResolvExpr/CandidatePrinter.hpp"  // for printCandidates
    6864#include "ResolvExpr/Resolver.h"            // for resolve
    6965#include "SymTab/Validate.h"                // for validate
     
    319315                // add the assignment statement after the initialization of a type parameter
    320316                PASS( "Validate", SymTab::validate( translationUnit, symtabp ) );
     317                if ( symtabp ) {
     318                        deleteAll( translationUnit );
     319                        return EXIT_SUCCESS;
     320                } // if
     321
     322                if ( expraltp ) {
     323                        PassVisitor<ResolvExpr::AlternativePrinter> printer( cout );
     324                        acceptAll( translationUnit, printer );
     325                        return EXIT_SUCCESS;
     326                } // if
     327
     328                if ( validp ) {
     329                        dump( translationUnit );
     330                        return EXIT_SUCCESS;
     331                } // if
     332
     333                PASS( "Translate Throws", ControlStruct::translateThrows( translationUnit ) );
     334                PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) );
     335                PASS( "Fix Names", CodeGen::fixNames( translationUnit ) );
     336                PASS( "Gen Init", InitTweak::genInit( translationUnit ) );
     337                PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) );
     338                if ( libcfap ) {
     339                        // generate the bodies of cfa library functions
     340                        LibCfa::makeLibCfa( translationUnit );
     341                } // if
     342
     343                if ( declstatsp ) {
     344                        CodeTools::printDeclStats( translationUnit );
     345                        deleteAll( translationUnit );
     346                        return EXIT_SUCCESS;
     347                } // if
     348
     349                if ( bresolvep ) {
     350                        dump( translationUnit );
     351                        return EXIT_SUCCESS;
     352                } // if
    321353
    322354                CodeTools::fillLocations( translationUnit );
     355
     356                if ( resolvprotop ) {
     357                        CodeTools::dumpAsResolvProto( translationUnit );
     358                        return EXIT_SUCCESS;
     359                } // if
    323360
    324361                if( useNewAST ) {
     
    328365                        }
    329366                        auto transUnit = convert( move( translationUnit ) );
    330 
    331                         forceFillCodeLocations( transUnit );
    332 
    333                         if ( symtabp ) {
    334                                 return EXIT_SUCCESS;
    335                         } // if
    336 
    337                         if ( expraltp ) {
    338                                 ResolvExpr::printCandidates( transUnit );
    339                                 return EXIT_SUCCESS;
    340                         } // if
    341 
    342                         if ( validp ) {
    343                                 dump( move( transUnit ) );
    344                                 return EXIT_SUCCESS;
    345                         } // if
    346 
    347                         PASS( "Translate Throws", ControlStruct::translateThrows( transUnit ) );
    348                         PASS( "Fix Labels", ControlStruct::fixLabels( transUnit ) );
    349                         PASS( "Fix Names", CodeGen::fixNames( transUnit ) );
    350                         PASS( "Gen Init", InitTweak::genInit( transUnit ) );
    351                         PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( transUnit ) );
    352 
    353                         if ( libcfap ) {
    354                                 // Generate the bodies of cfa library functions.
    355                                 LibCfa::makeLibCfa( transUnit );
    356                         } // if
    357 
    358                         if ( declstatsp ) {
    359                                 printDeclStats( transUnit );
    360                                 return EXIT_SUCCESS;
    361                         } // if
    362 
    363                         if ( bresolvep ) {
    364                                 dump( move( transUnit ) );
    365                                 return EXIT_SUCCESS;
    366                         } // if
    367 
    368                         if ( resolvprotop ) {
    369                                 dumpAsResolverProto( transUnit );
    370                                 return EXIT_SUCCESS;
    371                         } // if
    372 
    373367                        PASS( "Resolve", ResolvExpr::resolve( transUnit ) );
    374368                        if ( exprp ) {
     
    381375                        PASS( "Fix Init", InitTweak::fix(transUnit, buildingLibrary()));
    382376
     377                        // fix ObjectDecl - replaces ConstructorInit nodes
     378                        if ( ctorinitp ) {
     379                                dump( move( transUnit ) );
     380                                return EXIT_SUCCESS;
     381                        } // if
     382
     383                        // Currently not working due to unresolved issues with UniqueExpr
     384                        PASS( "Expand Unique Expr", Tuples::expandUniqueExpr( transUnit ) ); // 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
    383385                        translationUnit = convert( move( transUnit ) );
    384386                } else {
    385                         if ( symtabp ) {
    386                                 deleteAll( translationUnit );
    387                                 return EXIT_SUCCESS;
    388                         } // if
    389 
    390                         if ( expraltp ) {
    391                                 PassVisitor<ResolvExpr::AlternativePrinter> printer( cout );
    392                                 acceptAll( translationUnit, printer );
    393                                 return EXIT_SUCCESS;
    394                         } // if
    395 
    396                         if ( validp ) {
    397                                 dump( translationUnit );
    398                                 return EXIT_SUCCESS;
    399                         } // if
    400 
    401                         PASS( "Translate Throws", ControlStruct::translateThrows( translationUnit ) );
    402                         PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) );
    403                         PASS( "Fix Names", CodeGen::fixNames( translationUnit ) );
    404                         PASS( "Gen Init", InitTweak::genInit( translationUnit ) );
    405                         PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) );
    406 
    407                         if ( libcfap ) {
    408                                 // Generate the bodies of cfa library functions.
    409                                 LibCfa::makeLibCfa( translationUnit );
    410                         } // if
    411 
    412                         if ( declstatsp ) {
    413                                 CodeTools::printDeclStats( translationUnit );
    414                                 deleteAll( translationUnit );
    415                                 return EXIT_SUCCESS;
    416                         } // if
    417 
    418                         if ( bresolvep ) {
    419                                 dump( translationUnit );
    420                                 return EXIT_SUCCESS;
    421                         } // if
    422 
    423                         CodeTools::fillLocations( translationUnit );
    424 
    425                         if ( resolvprotop ) {
    426                                 CodeTools::dumpAsResolvProto( translationUnit );
    427                                 return EXIT_SUCCESS;
    428                         } // if
    429 
    430387                        PASS( "Resolve", ResolvExpr::resolve( translationUnit ) );
    431388                        if ( exprp ) {
     
    435392
    436393                        PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) );
     394
     395                        // fix ObjectDecl - replaces ConstructorInit nodes
     396                        if ( ctorinitp ) {
     397                                dump ( translationUnit );
     398                                return EXIT_SUCCESS;
     399                        } // if
     400
     401                        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
    437402                }
    438 
    439                 // fix ObjectDecl - replaces ConstructorInit nodes
    440                 if ( ctorinitp ) {
    441                         dump ( translationUnit );
    442                         return EXIT_SUCCESS;
    443                 } // if
    444 
    445                 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
    446403
    447404                PASS( "Translate Tries" , ControlStruct::translateTries( translationUnit ) );
     
    490447                PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ) );
    491448
    492                 CodeGen::FixMain::fix( translationUnit, *output,
    493                                 (PreludeDirector + "/bootloader.c").c_str() );
     449                CodeGen::FixMain::fix( *output, (PreludeDirector + "/bootloader.c").c_str() );
    494450                if ( output != &cout ) {
    495451                        delete output;
Note: See TracChangeset for help on using the changeset viewer.