Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    rce36b55 r9f5a19fa  
    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 : Fri Nov 12 11:06:00 2021
    13 // Update Count     : 658
     11// Last Modified By : Henry Xue
     12// Last Modified On : Mon Aug 23 15:42:08 2021
     13// Update Count     : 650
    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
     
    7268#include "SynTree/Visitor.h"                // for acceptAll
    7369#include "Tuples/Tuples.h"                  // for expandMemberTuples, expan...
    74 #include "Validate/FindSpecialDecls.h"      // for findGlobalDecls
    75 #include "Validate/InitializerLength.hpp"   // for setLengthFromInitializer
    76 #include "Validate/LabelAddressFixer.hpp"   // for fixLabelAddresses
    7770#include "Virtual/ExpandCasts.h"            // for expandCasts
    7871
     
    321314
    322315                // add the assignment statement after the initialization of a type parameter
    323                 PASS( "Validate-A", SymTab::validate_A( translationUnit ) );
    324                 PASS( "Validate-B", SymTab::validate_B( translationUnit ) );
    325                 PASS( "Validate-C", SymTab::validate_C( translationUnit ) );
    326                 PASS( "Validate-D", SymTab::validate_D( translationUnit ) );
    327                 PASS( "Validate-E", SymTab::validate_E( translationUnit ) );
     316                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
     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
    328353
    329354                CodeTools::fillLocations( translationUnit );
     355
     356                if ( resolvprotop ) {
     357                        CodeTools::dumpAsResolvProto( translationUnit );
     358                        return EXIT_SUCCESS;
     359                } // if
    330360
    331361                if( useNewAST ) {
     
    336366                        auto transUnit = convert( move( translationUnit ) );
    337367
    338                         forceFillCodeLocations( transUnit );
    339 
    340                         PASS( "Set Length From Initializer", Validate::setLengthFromInitializer( transUnit ) );
    341                         PASS( "Find Global Decls", Validate::findGlobalDecls( transUnit ) );
    342                         PASS( "Fix Label Address", Validate::fixLabelAddresses( transUnit ) );
    343 
    344                         if ( symtabp ) {
    345                                 return EXIT_SUCCESS;
    346                         } // if
    347 
    348                         if ( expraltp ) {
    349                                 ResolvExpr::printCandidates( transUnit );
    350                                 return EXIT_SUCCESS;
    351                         } // if
    352 
    353                         if ( validp ) {
    354                                 dump( move( transUnit ) );
    355                                 return EXIT_SUCCESS;
    356                         } // if
    357 
    358                         PASS( "Translate Throws", ControlStruct::translateThrows( transUnit ) );
    359                         PASS( "Fix Labels", ControlStruct::fixLabels( transUnit ) );
    360                         PASS( "Fix Names", CodeGen::fixNames( transUnit ) );
    361                         PASS( "Gen Init", InitTweak::genInit( transUnit ) );
    362368                        PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( transUnit ) );
    363 
    364                         if ( libcfap ) {
    365                                 // Generate the bodies of cfa library functions.
    366                                 LibCfa::makeLibCfa( transUnit );
    367                         } // if
    368 
    369                         if ( declstatsp ) {
    370                                 printDeclStats( transUnit );
    371                                 return EXIT_SUCCESS;
    372                         } // if
    373 
    374                         if ( bresolvep ) {
    375                                 dump( move( transUnit ) );
    376                                 return EXIT_SUCCESS;
    377                         } // if
    378 
    379                         if ( resolvprotop ) {
    380                                 dumpAsResolverProto( transUnit );
    381                                 return EXIT_SUCCESS;
    382                         } // if
    383 
     369                       
    384370                        PASS( "Resolve", ResolvExpr::resolve( transUnit ) );
    385371                        if ( exprp ) {
     
    391377
    392378                        PASS( "Fix Init", InitTweak::fix(transUnit, buildingLibrary()));
    393 
    394                         // fix ObjectDecl - replaces ConstructorInit nodes
    395                         if ( ctorinitp ) {
    396                                 dump( move( transUnit ) );
    397                                 return EXIT_SUCCESS;
    398                         } // if
    399 
    400                         // Currently not working due to unresolved issues with UniqueExpr
    401                         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
    402379                        translationUnit = convert( move( transUnit ) );
    403380                } else {
    404                         PASS( "Validate-F", SymTab::validate_F( translationUnit ) );
    405 
    406                         if ( symtabp ) {
    407                                 deleteAll( translationUnit );
    408                                 return EXIT_SUCCESS;
    409                         } // if
    410 
    411                         if ( expraltp ) {
    412                                 PassVisitor<ResolvExpr::AlternativePrinter> printer( cout );
    413                                 acceptAll( translationUnit, printer );
    414                                 return EXIT_SUCCESS;
    415                         } // if
    416 
    417                         if ( validp ) {
    418                                 dump( translationUnit );
    419                                 return EXIT_SUCCESS;
    420                         } // if
    421 
    422                         PASS( "Translate Throws", ControlStruct::translateThrows( translationUnit ) );
    423                         PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) );
    424                         PASS( "Fix Names", CodeGen::fixNames( translationUnit ) );
    425                         PASS( "Gen Init", InitTweak::genInit( translationUnit ) );
    426381                        PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) );
    427 
    428                         if ( libcfap ) {
    429                                 // Generate the bodies of cfa library functions.
    430                                 LibCfa::makeLibCfa( translationUnit );
    431                         } // if
    432 
    433                         if ( declstatsp ) {
    434                                 CodeTools::printDeclStats( translationUnit );
    435                                 deleteAll( translationUnit );
    436                                 return EXIT_SUCCESS;
    437                         } // if
    438 
    439                         if ( bresolvep ) {
    440                                 dump( translationUnit );
    441                                 return EXIT_SUCCESS;
    442                         } // if
    443 
    444                         CodeTools::fillLocations( translationUnit );
    445 
    446                         if ( resolvprotop ) {
    447                                 CodeTools::dumpAsResolvProto( translationUnit );
    448                                 return EXIT_SUCCESS;
    449                         } // if
    450382
    451383                        PASS( "Resolve", ResolvExpr::resolve( translationUnit ) );
     
    456388
    457389                        PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) );
    458 
    459                         // fix ObjectDecl - replaces ConstructorInit nodes
    460                         if ( ctorinitp ) {
    461                                 dump ( translationUnit );
    462                                 return EXIT_SUCCESS;
    463                         } // if
    464 
    465                         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
    466390                }
     391
     392                // fix ObjectDecl - replaces ConstructorInit nodes
     393                if ( ctorinitp ) {
     394                        dump ( translationUnit );
     395                        return EXIT_SUCCESS;
     396                } // if
     397
     398                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
    467399
    468400                PASS( "Translate Tries" , ControlStruct::translateTries( translationUnit ) );
     
    511443                PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ) );
    512444
    513                 CodeGen::FixMain::fix( translationUnit, *output,
    514                                 (PreludeDirector + "/bootloader.c").c_str() );
     445                CodeGen::FixMain::fix( *output, (PreludeDirector + "/bootloader.c").c_str() );
    515446                if ( output != &cout ) {
    516447                        delete output;
Note: See TracChangeset for help on using the changeset viewer.