Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    rd3b7937 rfea7ca7  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // main.cc -- 
     7// main.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Fri May 15 23:12:02 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jan 27 22:20:20 2016
    13 // Update Count     : 199
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri Apr 29 12:02:21 2016
     13// Update Count     : 200
    1414//
    1515
     
    2424#include "SynTree/Declaration.h"
    2525#include "SynTree/Visitor.h"
    26 #include "GenPoly/InstantiateGeneric.h"
    2726#include "GenPoly/Lvalue.h"
    2827#include "GenPoly/Specialize.h"
     
    4140#include "MakeLibCfa.h"
    4241#include "InitTweak/Mutate.h"
    43 #include "InitTweak/RemoveInit.h"
     42#include "InitTweak/GenInit.h"
     43#include "InitTweak/FixInit.h"
    4444//#include "Explain/GenProlog.h"
    4545//#include "Try/Visit.h"
     
    5656
    5757static void parse( FILE * input, LinkageSpec::Type t, bool shouldExit = false );
    58 static void dump( std::list< Declaration * > & translationUnit );
     58static void dump( std::list< Declaration * > & translationUnit, std::ostream & out = std::cout );
    5959
    6060bool
    6161        astp = false,
    6262        bresolvep = false,
     63        bboxp = false,
     64        ctorinitp = false,
    6365        exprp = false,
    6466        expraltp = false,
     
    7577        codegenp = false;
    7678
    77 enum { Ast, Bresolver, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, };
     79enum { Ast, Bbox, Bresolver, CtorInitFix, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, };
    7880
    7981static struct option long_opts[] = {
    8082        { "ast", no_argument, 0, Ast },
     83        { "before-box", no_argument, 0, Bbox },
    8184        { "before-resolver", no_argument, 0, Bresolver },
     85        { "ctorinitfix", no_argument, 0, CtorInitFix },
    8286        { "expr", no_argument, 0, Expr },
    8387        { "expralt", no_argument, 0, ExprAlt },
     
    101105
    102106        opterr = 0;                                                                                     // prevent getopt from printing error messages
    103        
     107
    104108        int c;
    105         while ( (c = getopt_long( argc, argv, "abefglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {
     109        while ( (c = getopt_long( argc, argv, "abBcefFglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {
    106110                switch ( c ) {
    107111                  case Ast:
     
    112116                  case 'b':                                                                             // print before resolver steps
    113117                        bresolvep = true;
     118                        break;
     119                  case 'B':                                                                             // print before resolver steps
     120                        bboxp = true;
     121                        break;
     122                  case CtorInitFix:
     123                  case 'c':
     124                        ctorinitp = true;
    114125                        break;
    115126                  case Expr:
     
    188199                        output = new ofstream( argv[ optind ] );
    189200                } // if
    190        
     201
    191202                Parser::get_parser().set_debug( grammarp );
    192203
     
    209220                                        exit( 1 );
    210221                                } // if
    211                    
     222
    212223                                parse( prelude, LinkageSpec::Intrinsic );
    213224                        } // if
    214225                } // if
    215226
    216                 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp );     
    217  
     227                parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp );
     228
    218229                if ( parsep ) {
    219230                        Parser::get_parser().get_parseTree()->printList( std::cout );
     
    250261                OPTPRINT( "mutate" )
    251262                ControlStruct::mutate( translationUnit );
    252                 OPTPRINT( "fixNames" ) 
     263                OPTPRINT( "fixNames" )
    253264                CodeGen::fixNames( translationUnit );
    254                 OPTPRINT( "tweak" )
    255                 InitTweak::tweak( translationUnit );
     265                OPTPRINT( "tweakInit" )
     266                InitTweak::genInit( translationUnit );
    256267
    257268                if ( libcfap ) {
     
    269280                if ( exprp ) {
    270281                        dump( translationUnit );
     282                        return 0;
    271283                }
    272284
    273                 OPTPRINT( "instantiateGeneric" )
    274                 GenPoly::instantiateGeneric( translationUnit );
     285                OPTPRINT( "fixInit" )
     286                // fix ObjectDecl - replaces ConstructorInit nodes
     287                InitTweak::fix( translationUnit );
     288                if ( ctorinitp ) {
     289                        dump ( translationUnit );
     290                        return 0;
     291                }
     292
    275293                OPTPRINT( "copyParams" );
    276294                GenPoly::copyParams( translationUnit );
     
    279297                OPTPRINT( "convertLvalue" )
    280298                GenPoly::convertLvalue( translationUnit );
     299
     300                if ( bboxp ) {
     301                        dump( translationUnit );
     302                        return 0;
     303                }
    281304                OPTPRINT( "box" )
    282305                GenPoly::box( translationUnit );
     
    295318        } catch ( SemanticError &e ) {
    296319                if ( errorp ) {
    297                         dump( translationUnit );
     320                        std::cerr << "---AST at error:---" << std::endl;
     321                        dump( translationUnit, std::cerr );
     322                        std::cerr << std::endl << "---End of AST, begin error message:---\n" << std::endl;
    298323                }
    299324                e.print( std::cerr );
     
    317342        } // try
    318343
     344        deleteAll( translationUnit );
    319345        return 0;
    320346} // main
     
    334360}
    335361
    336 static void dump( std::list< Declaration * > & translationUnit ) {
     362static void dump( std::list< Declaration * > & translationUnit, std::ostream & out ) {
    337363        std::list< Declaration * > decls;
    338364        if ( noprotop ) {
    339                 filter( translationUnit.begin(), translationUnit.end(), 
     365                filter( translationUnit.begin(), translationUnit.end(),
    340366                                std::back_inserter( decls ), notPrelude );
    341367        } else {
     
    343369        }
    344370
    345         printAll( decls, std::cout );
     371        printAll( decls, out );
    346372        deleteAll( translationUnit );
    347373}
Note: See TracChangeset for help on using the changeset viewer.