Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    rfea7ca7 rd3b7937  
    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 : Rob Schluntz
    12 // Last Modified On : Fri Apr 29 12:02:21 2016
    13 // Update Count     : 200
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Jan 27 22:20:20 2016
     13// Update Count     : 199
    1414//
    1515
     
    2424#include "SynTree/Declaration.h"
    2525#include "SynTree/Visitor.h"
     26#include "GenPoly/InstantiateGeneric.h"
    2627#include "GenPoly/Lvalue.h"
    2728#include "GenPoly/Specialize.h"
     
    4041#include "MakeLibCfa.h"
    4142#include "InitTweak/Mutate.h"
    42 #include "InitTweak/GenInit.h"
    43 #include "InitTweak/FixInit.h"
     43#include "InitTweak/RemoveInit.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, std::ostream & out = std::cout );
     58static void dump( std::list< Declaration * > & translationUnit );
    5959
    6060bool
    6161        astp = false,
    6262        bresolvep = false,
    63         bboxp = false,
    64         ctorinitp = false,
    6563        exprp = false,
    6664        expraltp = false,
     
    7775        codegenp = false;
    7876
    79 enum { Ast, Bbox, Bresolver, CtorInitFix, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, };
     77enum { Ast, Bresolver, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, };
    8078
    8179static struct option long_opts[] = {
    8280        { "ast", no_argument, 0, Ast },
    83         { "before-box", no_argument, 0, Bbox },
    8481        { "before-resolver", no_argument, 0, Bresolver },
    85         { "ctorinitfix", no_argument, 0, CtorInitFix },
    8682        { "expr", no_argument, 0, Expr },
    8783        { "expralt", no_argument, 0, ExprAlt },
     
    105101
    106102        opterr = 0;                                                                                     // prevent getopt from printing error messages
    107 
     103       
    108104        int c;
    109         while ( (c = getopt_long( argc, argv, "abBcefFglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {
     105        while ( (c = getopt_long( argc, argv, "abefglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {
    110106                switch ( c ) {
    111107                  case Ast:
     
    116112                  case 'b':                                                                             // print before resolver steps
    117113                        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;
    125114                        break;
    126115                  case Expr:
     
    199188                        output = new ofstream( argv[ optind ] );
    200189                } // if
    201 
     190       
    202191                Parser::get_parser().set_debug( grammarp );
    203192
     
    220209                                        exit( 1 );
    221210                                } // if
    222 
     211                   
    223212                                parse( prelude, LinkageSpec::Intrinsic );
    224213                        } // if
    225214                } // if
    226215
    227                 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp );
    228 
     216                parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp );     
     217 
    229218                if ( parsep ) {
    230219                        Parser::get_parser().get_parseTree()->printList( std::cout );
     
    261250                OPTPRINT( "mutate" )
    262251                ControlStruct::mutate( translationUnit );
    263                 OPTPRINT( "fixNames" )
     252                OPTPRINT( "fixNames" ) 
    264253                CodeGen::fixNames( translationUnit );
    265                 OPTPRINT( "tweakInit" )
    266                 InitTweak::genInit( translationUnit );
     254                OPTPRINT( "tweak" )
     255                InitTweak::tweak( translationUnit );
    267256
    268257                if ( libcfap ) {
     
    280269                if ( exprp ) {
    281270                        dump( translationUnit );
    282                         return 0;
    283271                }
    284272
    285                 OPTPRINT( "fixInit" )
    286                 // fix ObjectDecl - replaces ConstructorInit nodes
    287                 InitTweak::fix( translationUnit );
    288                 if ( ctorinitp ) {
    289                         dump ( translationUnit );
    290                         return 0;
    291                 }
    292 
     273                OPTPRINT( "instantiateGeneric" )
     274                GenPoly::instantiateGeneric( translationUnit );
    293275                OPTPRINT( "copyParams" );
    294276                GenPoly::copyParams( translationUnit );
     
    297279                OPTPRINT( "convertLvalue" )
    298280                GenPoly::convertLvalue( translationUnit );
    299 
    300                 if ( bboxp ) {
    301                         dump( translationUnit );
    302                         return 0;
    303                 }
    304281                OPTPRINT( "box" )
    305282                GenPoly::box( translationUnit );
     
    318295        } catch ( SemanticError &e ) {
    319296                if ( errorp ) {
    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;
     297                        dump( translationUnit );
    323298                }
    324299                e.print( std::cerr );
     
    342317        } // try
    343318
    344         deleteAll( translationUnit );
    345319        return 0;
    346320} // main
     
    360334}
    361335
    362 static void dump( std::list< Declaration * > & translationUnit, std::ostream & out ) {
     336static void dump( std::list< Declaration * > & translationUnit ) {
    363337        std::list< Declaration * > decls;
    364338        if ( noprotop ) {
    365                 filter( translationUnit.begin(), translationUnit.end(),
     339                filter( translationUnit.begin(), translationUnit.end(), 
    366340                                std::back_inserter( decls ), notPrelude );
    367341        } else {
     
    369343        }
    370344
    371         printAll( decls, out );
     345        printAll( decls, std::cout );
    372346        deleteAll( translationUnit );
    373347}
Note: See TracChangeset for help on using the changeset viewer.