Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    rf77f12e2 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 : Mon Apr 11 17:49:38 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"
     
    4142#include "InitTweak/Mutate.h"
    4243#include "InitTweak/RemoveInit.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, std::ostream & out = std::cout );
     58static void dump( std::list< Declaration * > & translationUnit );
    5959
    6060bool
    6161        astp = false,
    6262        bresolvep = false,
    63         ctorinitp = false,
    6463        exprp = false,
    6564        expraltp = false,
     
    7675        codegenp = false;
    7776
    78 enum { Ast, 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, };
    7978
    8079static struct option long_opts[] = {
    8180        { "ast", no_argument, 0, Ast },
    8281        { "before-resolver", no_argument, 0, Bresolver },
    83         { "ctorinitfix", no_argument, 0, CtorInitFix },
    8482        { "expr", no_argument, 0, Expr },
    8583        { "expralt", no_argument, 0, ExprAlt },
     
    103101
    104102        opterr = 0;                                                                                     // prevent getopt from printing error messages
    105 
     103       
    106104        int c;
    107         while ( (c = getopt_long( argc, argv, "abcefFglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {
     105        while ( (c = getopt_long( argc, argv, "abefglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {
    108106                switch ( c ) {
    109107                  case Ast:
     
    114112                  case 'b':                                                                             // print before resolver steps
    115113                        bresolvep = true;
    116                         break;
    117                         case CtorInitFix:
    118                         case 'c':
    119                         ctorinitp = true;
    120114                        break;
    121115                  case Expr:
     
    194188                        output = new ofstream( argv[ optind ] );
    195189                } // if
    196 
     190       
    197191                Parser::get_parser().set_debug( grammarp );
    198192
     
    215209                                        exit( 1 );
    216210                                } // if
    217 
     211                   
    218212                                parse( prelude, LinkageSpec::Intrinsic );
    219213                        } // if
    220214                } // if
    221215
    222                 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp );
    223 
     216                parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp );     
     217 
    224218                if ( parsep ) {
    225219                        Parser::get_parser().get_parseTree()->printList( std::cout );
     
    256250                OPTPRINT( "mutate" )
    257251                ControlStruct::mutate( translationUnit );
    258                 OPTPRINT( "fixNames" )
     252                OPTPRINT( "fixNames" ) 
    259253                CodeGen::fixNames( translationUnit );
    260                 OPTPRINT( "tweakInit" )
     254                OPTPRINT( "tweak" )
    261255                InitTweak::tweak( translationUnit );
    262256
     
    275269                if ( exprp ) {
    276270                        dump( translationUnit );
    277                         return 0;
    278271                }
    279272
    280                 OPTPRINT( "fixInit" )
    281                 // fix ObjectDecl - replaces ConstructorInit nodes
    282                 InitTweak::fix( translationUnit );
    283                 if ( ctorinitp ) {
    284                         dump ( translationUnit );
    285                         return 0;
    286                 }
    287 
     273                OPTPRINT( "instantiateGeneric" )
     274                GenPoly::instantiateGeneric( translationUnit );
    288275                OPTPRINT( "copyParams" );
    289276                GenPoly::copyParams( translationUnit );
     
    308295        } catch ( SemanticError &e ) {
    309296                if ( errorp ) {
    310                         std::cerr << "---AST at error:---" << std::endl;
    311                         dump( translationUnit, std::cerr );
    312                         std::cerr << std::endl << "---End of AST, begin error message:---\n" << std::endl;
     297                        dump( translationUnit );
    313298                }
    314299                e.print( std::cerr );
     
    332317        } // try
    333318
    334         deleteAll( translationUnit );
    335319        return 0;
    336320} // main
     
    350334}
    351335
    352 static void dump( std::list< Declaration * > & translationUnit, std::ostream & out ) {
     336static void dump( std::list< Declaration * > & translationUnit ) {
    353337        std::list< Declaration * > decls;
    354338        if ( noprotop ) {
    355                 filter( translationUnit.begin(), translationUnit.end(),
     339                filter( translationUnit.begin(), translationUnit.end(), 
    356340                                std::back_inserter( decls ), notPrelude );
    357341        } else {
     
    359343        }
    360344
    361         printAll( decls, out );
     345        printAll( decls, std::cout );
    362346        deleteAll( translationUnit );
    363347}
Note: See TracChangeset for help on using the changeset viewer.