Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    rf57faf6f r7006ba5  
    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 : Mon Dec  7 15:29:00 2020
    13 // Update Count     : 639
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Dec 16 17:55:53 2019
     13// Update Count     : 627
    1414//
    1515
     
    3131using namespace std;
    3232
    33 #include "AST/Convert.hpp"
     33
    3434#include "CompilationState.h"
    3535#include "../config.h"                      // for CFA_LIBDIR
     
    4040#include "CodeTools/ResolvProtoDump.h"      // for dumpAsResolvProto
    4141#include "CodeTools/TrackLoc.h"             // for fillLocations
    42 #include "Common/CodeLocationTools.hpp"     // for forceFillCodeLocations
    4342#include "Common/CompilerError.h"           // for CompilerError
    4443#include "Common/Stats.h"
     
    106105
    107106static void backtrace( int start ) {                                    // skip first N stack frames
    108         enum { Frames = 50, };                                                          // maximum number of stack frames
     107        enum { Frames = 50 };
    109108        void * array[Frames];
    110         size_t size = ::backtrace( array, Frames );
     109        int size = ::backtrace( array, Frames );
    111110        char ** messages = ::backtrace_symbols( array, size ); // does not demangle names
    112111
     
    115114
    116115        // skip last 2 stack frames after main
    117         for ( unsigned int i = start; i < size - 2 && messages != nullptr; i += 1 ) {
     116        for ( int i = start; i < size - 2 && messages != nullptr; i += 1 ) {
    118117                char * mangled_name = nullptr, * offset_begin = nullptr, * offset_end = nullptr;
    119118
     
    181180} // sigSegvBusHandler
    182181
    183 static void sigFpeHandler( SIGPARMS ) {
    184         const char * msg;
    185 
    186         switch ( sfp->si_code ) {
    187           case FPE_INTDIV: case FPE_FLTDIV: msg = "divide by zero"; break;
    188           case FPE_FLTOVF: msg = "overflow"; break;
    189           case FPE_FLTUND: msg = "underflow"; break;
    190           case FPE_FLTRES: msg = "inexact result"; break;
    191           case FPE_FLTINV: msg = "invalid operation"; break;
    192           default: msg = "unknown";
    193         } // choose
    194         cerr << "Computation error " << msg << " at location " << sfp->si_addr << endl
    195                  << "Possible cause is constant-expression evaluation invalid." << endl;
    196         backtrace( 2 );                                                                         // skip first 2 stack frames
    197         abort();                                                                                        // cause core dump for debugging
    198 } // sigFpeHandler
    199 
    200182static void sigAbortHandler( SIGPARMS ) {
    201183        backtrace( 6 );                                                                         // skip first 6 stack frames
     
    211193        Signal( SIGSEGV, sigSegvBusHandler, SA_SIGINFO );
    212194        Signal( SIGBUS, sigSegvBusHandler, SA_SIGINFO );
    213         Signal( SIGFPE, sigFpeHandler, SA_SIGINFO );
    214195        Signal( SIGABRT, sigAbortHandler, SA_SIGINFO );
    215196
     
    313294                } // if
    314295
    315                 PASS( "Translate Throws", ControlStruct::translateThrows( translationUnit ) );
    316296                PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) );
    317297                PASS( "Fix Names", CodeGen::fixNames( translationUnit ) );
     
    341321                } // if
    342322
    343                 if( useNewAST ) {
    344                         if (Stats::Counters::enabled) {
    345                                 ast::pass_visitor_stats.avg = Stats::Counters::build<Stats::Counters::AverageCounter<double>>("Average Depth - New");
    346                                 ast::pass_visitor_stats.max = Stats::Counters::build<Stats::Counters::MaxCounter<double>>("Max depth - New");
    347                         }
    348                         auto transUnit = convert( move( translationUnit ) );
    349                         PASS( "Resolve", ResolvExpr::resolve( transUnit ) );
    350                         if ( exprp ) {
    351                                 translationUnit = convert( move( transUnit ) );
    352                                 dump( translationUnit );
    353                                 return EXIT_SUCCESS;
    354                         } // if
    355 
    356                         forceFillCodeLocations( transUnit );
    357 
    358                         PASS( "Fix Init", InitTweak::fix(transUnit, buildingLibrary()));
    359                         translationUnit = convert( move( transUnit ) );
    360                 } else {
    361                         PASS( "Resolve", ResolvExpr::resolve( translationUnit ) );
    362                         if ( exprp ) {
    363                                 dump( translationUnit );
    364                                 return EXIT_SUCCESS;
    365                         }
    366 
    367                         PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) );
    368                 }
     323                PASS( "Resolve", ResolvExpr::resolve( translationUnit ) );
     324                if ( exprp ) {
     325                        dump( translationUnit );
     326                        return EXIT_SUCCESS;
     327                } // if
    369328
    370329                // fix ObjectDecl - replaces ConstructorInit nodes
     330                PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) );
    371331                if ( ctorinitp ) {
    372332                        dump ( translationUnit );
     
    376336                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
    377337
    378                 PASS( "Translate Tries" , ControlStruct::translateTries( translationUnit ) );
     338                PASS( "Translate EHM" , ControlStruct::translateEHM( translationUnit ) );
    379339
    380340                PASS( "Gen Waitfor" , Concurrency::generateWaitFor( translationUnit ) );
     
    465425
    466426
    467 static const char optstring[] = ":c:ghlLmNnpdOAP:S:twW:D:";
     427static const char optstring[] = ":c:ghlLmNnpP:S:twW:D:";
    468428
    469429enum { PreludeDir = 128 };
     
    478438        { "no-prelude", no_argument, nullptr, 'n' },
    479439        { "prototypes", no_argument, nullptr, 'p' },
    480         { "deterministic-out", no_argument, nullptr, 'd' },
    481         { "old-ast", no_argument, nullptr, 'O'},
    482         { "new-ast", no_argument, nullptr, 'A'},
    483440        { "print", required_argument, nullptr, 'P' },
    484441        { "prelude-dir", required_argument, nullptr, PreludeDir },
     
    492449
    493450static const char * description[] = {
    494         "diagnostic color: never, always, or auto.",            // -c
    495         "wait for gdb to attach",                                                       // -g
    496         "print help message",                                                           // -h
    497         "generate libcfa.c",                                                            // -l
    498         "generate line marks",                                                          // -L
    499         "do not replace main",                                                          // -m
    500         "do not generate line marks",                                           // -N
    501         "do not read prelude",                                                          // -n
     451        "diagnostic color: never, always, or auto.",          // -c
     452        "wait for gdb to attach",                             // -g
     453        "print help message",                                 // -h
     454        "generate libcfa.c",                                  // -l
     455        "generate line marks",                                // -L
     456        "do not replace main",                                // -m
     457        "do not generate line marks",                         // -N
     458        "do not read prelude",                                // -n
    502459        "generate prototypes for prelude functions",            // -p
    503         "only print deterministic output",                  // -d
    504         "Use the old-ast",                                                                      // -O
    505         "Use the new-ast",                                                                      // -A
    506         "print",                                                                                        // -P
     460        "print",                                              // -P
    507461        "<directory> prelude directory for debug/nodebug",      // no flag
    508462        "<option-list> enable profiling information:\n          counters,heap,time,all,none", // -S
    509         "building cfa standard lib",                                            // -t
    510         "",                                                                                                     // -w
    511         "",                                                                                                     // -W
    512         "",                                                                                                     // -D
     463        "building cfa standard lib",                          // -t
     464        "",                                                   // -w
     465        "",                                                   // -W
     466        "",                                                   // -D
    513467}; // description
    514468
     
    608562                        genproto = true;
    609563                        break;
    610                   case 'd':                                     // don't print non-deterministic output
    611                         deterministic_output = true;
    612                         break;
    613                   case 'O':                                     // don't print non-deterministic output
    614                         useNewAST = false;
    615                         break;
    616                   case 'A':                                     // don't print non-deterministic output
    617                         useNewAST = true;
    618                         break;
    619564                  case 'P':                                                                             // print options
    620565                        for ( int i = 0;; i += 1 ) {
Note: See TracChangeset for help on using the changeset viewer.