Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    r7b937575 r711eee5  
    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 May  4 23:32:59 2016
    13 // Update Count     : 203
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed May 04 16:54:52 2016
     13// Update Count     : 199
    1414//
    1515
     
    4141#include "InitTweak/Mutate.h"
    4242#include "InitTweak/RemoveInit.h"
     43#include "InitTweak/FixGlobalInit.h"
    4344//#include "Explain/GenProlog.h"
    4445//#include "Try/Visit.h"
     
    9798        std::ostream *output = &std::cout;
    9899        int long_index;
    99         std::list< Declaration * > translationUnit;
    100         const char *filename = NULL;;
     100        std::list< Declaration* > translationUnit;
    101101
    102102        opterr = 0;                                                                                     // prevent getopt from printing error messages
    103        
     103
    104104        int c;
    105         while ( (c = getopt_long( argc, argv, "abefglnpqrstvyzD:F:", long_opts, &long_index )) != -1 ) {
     105        while ( (c = getopt_long( argc, argv, "abefglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {
    106106                switch ( c ) {
    107107                  case Ast:
     
    163163                        break;
    164164                  case 'D':                                                                             // ignore -Dxxx
    165                         break;
    166                   case 'F':                                                                             // source file-name without suffix
    167                         filename = optarg;
    168165                        break;
    169166                  case '?':
     
    176173
    177174        try {
     175                std::string fileName;
     176
    178177                // choose to read the program from a file or stdin
    179178                if ( optind < argc ) {
    180179                        input = fopen( argv[ optind ], "r" );
    181180                        if ( ! input ) {
    182                                 std::cout << "Error: can't open " << argv[optind] << std::endl;
     181                                std::cout << "Error: can't open " << argv[ optind ] << std::endl;
    183182                                exit( 1 );
    184183                        } // if
    185184                        optind += 1;
     185
     186                        // assert( optind < argc );
     187                        fileName = argv[ optind-1 ]; // placeholder
     188                        // optind += 1;
    186189                } else {
    187190                        input = stdin;
     
    191194                        output = new ofstream( argv[ optind ] );
    192195                } // if
    193        
     196
    194197                Parser::get_parser().set_debug( grammarp );
    195198
     
    212215                                        exit( 1 );
    213216                                } // if
    214                    
     217
    215218                                parse( prelude, LinkageSpec::Intrinsic );
    216219                        } // if
    217220                } // if
    218221
    219                 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp );     
    220  
     222                parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp );
     223
    221224                if ( parsep ) {
    222225                        Parser::get_parser().get_parseTree()->printList( std::cout );
     
    253256                OPTPRINT( "mutate" )
    254257                ControlStruct::mutate( translationUnit );
    255                 OPTPRINT( "fixNames" ) 
     258                OPTPRINT( "fixNames" )
    256259                CodeGen::fixNames( translationUnit );
     260                OPTPRINT( "fixGlobalInit" );
     261                InitTweak::fixGlobalInit( translationUnit, fileName );
    257262                OPTPRINT( "tweak" )
    258263                InitTweak::tweak( translationUnit );
     
    282287                OPTPRINT( "box" )
    283288                GenPoly::box( translationUnit );
    284                
     289
    285290                // print tree right before code generation
    286291                if ( codegenp ) {
     
    338343        std::list< Declaration * > decls;
    339344        if ( noprotop ) {
    340                 filter( translationUnit.begin(), translationUnit.end(), 
     345                filter( translationUnit.begin(), translationUnit.end(),
    341346                                std::back_inserter( decls ), notPrelude );
    342347        } else {
Note: See TracChangeset for help on using the changeset viewer.