Changeset 711eee5 for src/main.cc


Ignore:
Timestamp:
May 4, 2016, 4:57:43 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
4e24610
Parents:
1b7ea43
Message:

generate global init function for each translation unit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    r1b7ea43 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 Jan 27 22:20:20 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed May 04 16:54:52 2016
    1313// Update Count     : 199
    1414//
     
    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"
     
    100101
    101102        opterr = 0;                                                                                     // prevent getopt from printing error messages
    102        
     103
    103104        int c;
    104105        while ( (c = getopt_long( argc, argv, "abefglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {
     
    172173
    173174        try {
     175                std::string fileName;
     176
    174177                // choose to read the program from a file or stdin
    175178                if ( optind < argc ) {
    176179                        input = fopen( argv[ optind ], "r" );
    177180                        if ( ! input ) {
    178                                 std::cout << "Error: can't open " << argv[optind] << std::endl;
     181                                std::cout << "Error: can't open " << argv[ optind ] << std::endl;
    179182                                exit( 1 );
    180183                        } // if
    181184                        optind += 1;
     185
     186                        // assert( optind < argc );
     187                        fileName = argv[ optind-1 ]; // placeholder
     188                        // optind += 1;
    182189                } else {
    183190                        input = stdin;
     
    187194                        output = new ofstream( argv[ optind ] );
    188195                } // if
    189        
     196
    190197                Parser::get_parser().set_debug( grammarp );
    191198
     
    208215                                        exit( 1 );
    209216                                } // if
    210                    
     217
    211218                                parse( prelude, LinkageSpec::Intrinsic );
    212219                        } // if
    213220                } // if
    214221
    215                 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp );     
    216  
     222                parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp );
     223
    217224                if ( parsep ) {
    218225                        Parser::get_parser().get_parseTree()->printList( std::cout );
     
    249256                OPTPRINT( "mutate" )
    250257                ControlStruct::mutate( translationUnit );
    251                 OPTPRINT( "fixNames" ) 
     258                OPTPRINT( "fixNames" )
    252259                CodeGen::fixNames( translationUnit );
     260                OPTPRINT( "fixGlobalInit" );
     261                InitTweak::fixGlobalInit( translationUnit, fileName );
    253262                OPTPRINT( "tweak" )
    254263                InitTweak::tweak( translationUnit );
     
    278287                OPTPRINT( "box" )
    279288                GenPoly::box( translationUnit );
    280                
     289
    281290                // print tree right before code generation
    282291                if ( codegenp ) {
     
    334343        std::list< Declaration * > decls;
    335344        if ( noprotop ) {
    336                 filter( translationUnit.begin(), translationUnit.end(), 
     345                filter( translationUnit.begin(), translationUnit.end(),
    337346                                std::back_inserter( decls ), notPrelude );
    338347        } else {
Note: See TracChangeset for help on using the changeset viewer.