Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    r01d433e r1622af5  
    99// Author           : Peter Buhr and Rob Schluntz
    1010// Created On       : Fri May 15 23:12:02 2015
    11 // Last Modified By : Henry Xue
    12 // Last Modified On : Tue Jul 20 04:27:35 2021
    13 // Update Count     : 658
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tue Nov  9 11:10:00 2021
     13// Update Count     : 657
    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
    4547#include "Common/Stats.h"
    4648#include "Common/PassVisitor.h"
     
    5153#include "ControlStruct/ExceptDecl.h"       // for translateExcept
    5254#include "ControlStruct/ExceptTranslate.h"  // for translateEHM
     55#include "ControlStruct/FixLabels.hpp"      // for fixLabels
    5356#include "ControlStruct/Mutate.h"           // for mutate
    5457#include "GenPoly/Box.h"                    // for box
     
    6265#include "Parser/TypedefTable.h"            // for TypedefTable
    6366#include "ResolvExpr/AlternativePrinter.h"  // for AlternativePrinter
     67#include "ResolvExpr/CandidatePrinter.hpp"  // for printCandidates
    6468#include "ResolvExpr/Resolver.h"            // for resolve
    6569#include "SymTab/Validate.h"                // for validate
     
    315319                // add the assignment statement after the initialization of a type parameter
    316320                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
    353321
    354322                CodeTools::fillLocations( translationUnit );
    355 
    356                 if ( resolvprotop ) {
    357                         CodeTools::dumpAsResolvProto( translationUnit );
    358                         return EXIT_SUCCESS;
    359                 } // if
    360323
    361324                if( useNewAST ) {
     
    365328                        }
    366329                        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
    367373                        PASS( "Resolve", ResolvExpr::resolve( transUnit ) );
    368374                        if ( exprp ) {
     
    375381                        PASS( "Fix Init", InitTweak::fix(transUnit, buildingLibrary()));
    376382
    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
    385383                        translationUnit = convert( move( transUnit ) );
    386384                } 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
    387430                        PASS( "Resolve", ResolvExpr::resolve( translationUnit ) );
    388431                        if ( exprp ) {
     
    392435
    393436                        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
    402437                }
     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
    403446
    404447                PASS( "Translate Tries" , ControlStruct::translateTries( translationUnit ) );
     
    447490                PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ) );
    448491
    449                 CodeGen::FixMain::fix( *output, (PreludeDirector + "/bootloader.c").c_str() );
     492                CodeGen::FixMain::fix( translationUnit, *output,
     493                                (PreludeDirector + "/bootloader.c").c_str() );
    450494                if ( output != &cout ) {
    451495                        delete output;
Note: See TracChangeset for help on using the changeset viewer.