Changes in / [4acc87f:d029162e]


Ignore:
Location:
src
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r4acc87f rd029162e  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // CodeGenerator.cc -- 
     7// CodeGenerator.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:32:16 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri May 06 11:39:01 2016
    1313// Update Count     : 243
    1414//
     
    8484                output << genType( functionDecl->get_functionType(), mangleName( functionDecl ) );
    8585
     86                // generalize this
     87                switch ( functionDecl->get_attribute() ) {
     88                        case FunctionDecl::Constructor:
     89                                output << " __attribute__ ((constructor))";
     90                                break;
     91                        case FunctionDecl::Destructor:
     92                                output << " __attribute__ ((destructor))";
     93                                break;
     94                        default:
     95                                break;
     96                }
     97
    8698                // how to get this to the Functype?
    8799                std::list< Declaration * > olds = functionDecl->get_oldDecls();
     
    99111                handleStorageClass( objectDecl );
    100112                output << genType( objectDecl->get_type(), mangleName( objectDecl ) );
    101        
     113
    102114                if ( objectDecl->get_init() ) {
    103115                        output << " = ";
     
    113125                if ( aggDecl->get_name() != "" )
    114126                        output << aggDecl->get_name();
    115        
     127
    116128                std::list< Declaration * > &memb = aggDecl->get_members();
    117129
     
    119131                        output << " {" << endl;
    120132
    121                         cur_indent += CodeGenerator::tabsize; 
     133                        cur_indent += CodeGenerator::tabsize;
    122134                        for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end();  i++) {
    123                                 output << indent; 
     135                                output << indent;
    124136                                (*i)->accept( *this );
    125137                                output << ";" << endl;
    126138                        }
    127139
    128                         cur_indent -= CodeGenerator::tabsize; 
     140                        cur_indent -= CodeGenerator::tabsize;
    129141
    130142                        output << indent << "}";
     
    141153                handleAggregate( aggregateDecl );
    142154        }
    143  
     155
    144156        void CodeGenerator::visit( EnumDecl *aggDecl ) {
    145157                output << "enum ";
     
    147159                if ( aggDecl->get_name() != "" )
    148160                        output << aggDecl->get_name();
    149        
     161
    150162                std::list< Declaration* > &memb = aggDecl->get_members();
    151163
     
    153165                        output << " {" << endl;
    154166
    155                         cur_indent += CodeGenerator::tabsize; 
     167                        cur_indent += CodeGenerator::tabsize;
    156168                        for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end();  i++) {
    157169                                ObjectDecl *obj = dynamic_cast< ObjectDecl* >( *i );
    158170                                assert( obj );
    159                                 output << indent << mangleName( obj ); 
     171                                output << indent << mangleName( obj );
    160172                                if ( obj->get_init() ) {
    161173                                        output << " = ";
     
    165177                        } // for
    166178
    167                         cur_indent -= CodeGenerator::tabsize; 
     179                        cur_indent -= CodeGenerator::tabsize;
    168180
    169181                        output << indent << "}";
    170182                } // if
    171183        }
    172  
     184
    173185        void CodeGenerator::visit( TraitDecl *aggregateDecl ) {}
    174  
     186
    175187        void CodeGenerator::visit( TypedefDecl *typeDecl ) {
    176188                output << "typedef ";
    177189                output << genType( typeDecl->get_base(), typeDecl->get_name() );
    178190        }
    179  
     191
    180192        void CodeGenerator::visit( TypeDecl *typeDecl ) {
    181193                // really, we should mutate this into something that isn't a TypeDecl but that requires large-scale changes,
     
    217229        }
    218230
    219         void CodeGenerator::visit( Constant *constant ) { 
     231        void CodeGenerator::visit( Constant *constant ) {
    220232                output << constant->get_value() ;
    221233        }
     
    234246                                                assert( arg != applicationExpr->get_args().end() );
    235247                                                if ( AddressExpr *addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) {
    236                
     248
    237249                                                        *arg = addrExpr->get_arg();
    238250                                                } else {
     
    243255                                                break;
    244256                                        }
    245              
     257
    246258                                  default:
    247259                                        // do nothing
    248260                                        ;
    249261                                }
    250            
     262
    251263                                switch ( opInfo.type ) {
    252264                                  case OT_INDEX:
     
    257269                                        output << "]";
    258270                                        break;
    259              
     271
    260272                                  case OT_CALL:
    261273                                        // there are no intrinsic definitions of the function call operator
    262274                                        assert( false );
    263275                                        break;
    264              
     276
    265277                                  case OT_PREFIX:
    266278                                  case OT_PREFIXASSIGN:
     
    271283                                        output << ")";
    272284                                        break;
    273              
     285
    274286                                  case OT_POSTFIX:
    275287                                  case OT_POSTFIXASSIGN:
     
    288300                                        output << ")";
    289301                                        break;
    290              
     302
    291303                                  case OT_CONSTANT:
    292304                                  case OT_LABELADDRESS:
     
    307319                } // if
    308320        }
    309  
     321
    310322        void CodeGenerator::visit( UntypedExpr *untypedExpr ) {
    311323                if ( NameExpr *nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) {
     
    321333                                        output << "]";
    322334                                        break;
    323              
     335
    324336                                  case OT_CALL:
    325337                                        assert( false );
    326338                                        break;
    327              
     339
    328340                                  case OT_PREFIX:
    329341                                  case OT_PREFIXASSIGN:
     
    335347                                        output << ")";
    336348                                        break;
    337              
     349
    338350                                  case OT_POSTFIX:
    339351                                  case OT_POSTFIXASSIGN:
     
    342354                                        output << opInfo.symbol;
    343355                                        break;
    344  
     356
    345357                                  case OT_INFIX:
    346358                                  case OT_INFIXASSIGN:
     
    352364                                        output << ")";
    353365                                        break;
    354                                        
     366
    355367                                  case OT_CONSTANT:
    356368                                        // there are no intrinsic definitions of 0 or 1 as functions
     
    370382                } // if
    371383        }
    372  
     384
    373385        void CodeGenerator::visit( NameExpr *nameExpr ) {
    374386                OperatorInfo opInfo;
     
    380392                } // if
    381393        }
    382  
     394
    383395        void CodeGenerator::visit( AddressExpr *addressExpr ) {
    384396                output << "(&";
     
    409421                output << ")";
    410422        }
    411  
     423
    412424        void CodeGenerator::visit( UntypedMemberExpr *memberExpr ) {
    413425                assert( false );
    414426        }
    415  
     427
    416428        void CodeGenerator::visit( MemberExpr *memberExpr ) {
    417429                memberExpr->get_aggregate()->accept( *this );
    418430                output << "." << mangleName( memberExpr->get_member() );
    419431        }
    420  
     432
    421433        void CodeGenerator::visit( VariableExpr *variableExpr ) {
    422434                OperatorInfo opInfo;
     
    427439                } // if
    428440        }
    429  
     441
    430442        void CodeGenerator::visit( ConstantExpr *constantExpr ) {
    431443                assert( constantExpr->get_constant() );
    432444                constantExpr->get_constant()->accept( *this );
    433445        }
    434  
     446
    435447        void CodeGenerator::visit( SizeofExpr *sizeofExpr ) {
    436448                output << "sizeof(";
     
    469481                assert( false && "OffsetPackExpr should not reach code generation" );
    470482        }
    471  
     483
    472484        void CodeGenerator::visit( LogicalExpr *logicalExpr ) {
    473485                output << "(";
     
    481493                output << ")";
    482494        }
    483  
     495
    484496        void CodeGenerator::visit( ConditionalExpr *conditionalExpr ) {
    485497                output << "(";
     
    491503                output << ")";
    492504        }
    493  
     505
    494506        void CodeGenerator::visit( CommaExpr *commaExpr ) {
    495507                output << "(";
     
    499511                output << ")";
    500512        }
    501  
     513
    502514        void CodeGenerator::visit( TupleExpr *tupleExpr ) {}
    503  
     515
    504516        void CodeGenerator::visit( TypeExpr *typeExpr ) {}
    505517
     
    532544                        }
    533545                }
    534                 cur_indent -= CodeGenerator::tabsize; 
     546                cur_indent -= CodeGenerator::tabsize;
    535547
    536548                output << indent << "}";
     
    538550
    539551        void CodeGenerator::visit( ExprStmt *exprStmt ) {
    540                 // I don't see why this check is necessary. 
    541                 // If this starts to cause problems then put it back in, 
     552                // I don't see why this check is necessary.
     553                // If this starts to cause problems then put it back in,
    542554                // with an explanation
    543555                assert( exprStmt );
     
    589601                switchStmt->get_condition()->accept( *this );
    590602                output << " ) ";
    591                
     603
    592604                output << "{" << std::endl;
    593605                cur_indent += CodeGenerator::tabsize;
     
    609621                } // if
    610622                output << ":\n";
    611                
     623
    612624                std::list<Statement *> sts = caseStmt->get_statements();
    613625
     
    626638                        if ( ! branchStmt->get_target().empty() )
    627639                                output << "goto " << branchStmt->get_target();
    628                         else { 
     640                        else {
    629641                                if ( branchStmt->get_computedTarget() != 0 ) {
    630642                                        output << "goto *";
     
    677689
    678690        void CodeGenerator::visit( ForStmt *forStmt ) {
    679                 // initialization is always hoisted, so don't 
    680                 // bother doing anything with that 
     691                // initialization is always hoisted, so don't
     692                // bother doing anything with that
    681693                output << "for (;";
    682694
     
    702714        void CodeGenerator::visit( DeclStmt *declStmt ) {
    703715                declStmt->get_decl()->accept( *this );
    704        
     716
    705717                if ( doSemicolon( declStmt->get_decl() ) ) {
    706718                        output << ";";
  • src/InitTweak/module.mk

    r4acc87f rd029162e  
    1111## Created On       : Mon Jun  1 17:49:17 2015
    1212## Last Modified By : Rob Schluntz
    13 ## Last Modified On : Mon Jan 11 14:40:16 2016
     13## Last Modified On : Wed May 04 16:03:49 2016
    1414## Update Count     : 2
    1515###############################################################################
    1616
    17 SRC += InitTweak/RemoveInit.cc
     17SRC += InitTweak/RemoveInit.cc \
     18        InitTweak/FixGlobalInit.cc
    1819
  • src/Makefile.in

    r4acc87f rd029162e  
    124124        GenPoly/driver_cfa_cpp-DeclMutator.$(OBJEXT) \
    125125        InitTweak/driver_cfa_cpp-RemoveInit.$(OBJEXT) \
     126        InitTweak/driver_cfa_cpp-FixGlobalInit.$(OBJEXT) \
    126127        Parser/driver_cfa_cpp-parser.$(OBJEXT) \
    127128        Parser/driver_cfa_cpp-lex.$(OBJEXT) \
     
    346347        GenPoly/CopyParams.cc GenPoly/FindFunction.cc \
    347348        GenPoly/DeclMutator.cc InitTweak/RemoveInit.cc \
    348         Parser/parser.yy Parser/lex.ll Parser/TypedefTable.cc \
    349         Parser/ParseNode.cc Parser/DeclarationNode.cc \
    350         Parser/ExpressionNode.cc Parser/StatementNode.cc \
    351         Parser/InitializerNode.cc Parser/TypeData.cc \
    352         Parser/LinkageSpec.cc Parser/parseutility.cc Parser/Parser.cc \
     349        InitTweak/FixGlobalInit.cc Parser/parser.yy Parser/lex.ll \
     350        Parser/TypedefTable.cc Parser/ParseNode.cc \
     351        Parser/DeclarationNode.cc Parser/ExpressionNode.cc \
     352        Parser/StatementNode.cc Parser/InitializerNode.cc \
     353        Parser/TypeData.cc Parser/LinkageSpec.cc \
     354        Parser/parseutility.cc Parser/Parser.cc \
    353355        ResolvExpr/AlternativeFinder.cc ResolvExpr/Alternative.cc \
    354356        ResolvExpr/Unify.cc ResolvExpr/PtrsAssignable.cc \
     
    562564        @: > InitTweak/$(DEPDIR)/$(am__dirstamp)
    563565InitTweak/driver_cfa_cpp-RemoveInit.$(OBJEXT):  \
     566        InitTweak/$(am__dirstamp) InitTweak/$(DEPDIR)/$(am__dirstamp)
     567InitTweak/driver_cfa_cpp-FixGlobalInit.$(OBJEXT):  \
    564568        InitTweak/$(am__dirstamp) InitTweak/$(DEPDIR)/$(am__dirstamp)
    565569Parser/parser.h: Parser/parser.cc
     
    792796        -rm -f GenPoly/driver_cfa_cpp-ScrubTyVars.$(OBJEXT)
    793797        -rm -f GenPoly/driver_cfa_cpp-Specialize.$(OBJEXT)
     798        -rm -f InitTweak/driver_cfa_cpp-FixGlobalInit.$(OBJEXT)
    794799        -rm -f InitTweak/driver_cfa_cpp-RemoveInit.$(OBJEXT)
    795800        -rm -f Parser/driver_cfa_cpp-DeclarationNode.$(OBJEXT)
     
    897902@AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/driver_cfa_cpp-ScrubTyVars.Po@am__quote@
    898903@AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/driver_cfa_cpp-Specialize.Po@am__quote@
     904@AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Po@am__quote@
    899905@AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Po@am__quote@
    900906@AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/driver_cfa_cpp-DeclarationNode.Po@am__quote@
     
    13801386@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-RemoveInit.obj `if test -f 'InitTweak/RemoveInit.cc'; then $(CYGPATH_W) 'InitTweak/RemoveInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/RemoveInit.cc'; fi`
    13811387
     1388InitTweak/driver_cfa_cpp-FixGlobalInit.o: InitTweak/FixGlobalInit.cc
     1389@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-FixGlobalInit.o -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.o `test -f 'InitTweak/FixGlobalInit.cc' || echo '$(srcdir)/'`InitTweak/FixGlobalInit.cc
     1390@am__fastdepCXX_TRUE@   $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Po
     1391@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='InitTweak/FixGlobalInit.cc' object='InitTweak/driver_cfa_cpp-FixGlobalInit.o' libtool=no @AMDEPBACKSLASH@
     1392@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1393@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.o `test -f 'InitTweak/FixGlobalInit.cc' || echo '$(srcdir)/'`InitTweak/FixGlobalInit.cc
     1394
     1395InitTweak/driver_cfa_cpp-FixGlobalInit.obj: InitTweak/FixGlobalInit.cc
     1396@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-FixGlobalInit.obj -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.obj `if test -f 'InitTweak/FixGlobalInit.cc'; then $(CYGPATH_W) 'InitTweak/FixGlobalInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixGlobalInit.cc'; fi`
     1397@am__fastdepCXX_TRUE@   $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Po
     1398@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='InitTweak/FixGlobalInit.cc' object='InitTweak/driver_cfa_cpp-FixGlobalInit.obj' libtool=no @AMDEPBACKSLASH@
     1399@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1400@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.obj `if test -f 'InitTweak/FixGlobalInit.cc'; then $(CYGPATH_W) 'InitTweak/FixGlobalInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixGlobalInit.cc'; fi`
     1401
    13821402Parser/driver_cfa_cpp-parser.o: Parser/parser.cc
    13831403@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Parser/driver_cfa_cpp-parser.o -MD -MP -MF Parser/$(DEPDIR)/driver_cfa_cpp-parser.Tpo -c -o Parser/driver_cfa_cpp-parser.o `test -f 'Parser/parser.cc' || echo '$(srcdir)/'`Parser/parser.cc
  • src/SynTree/Declaration.h

    r4acc87f rd029162e  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Declaration.h -- 
     7// Declaration.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:28:11 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri May 06 11:16:45 2016
    1313// Update Count     : 33
    1414//
     
    106106        typedef DeclarationWithType Parent;
    107107  public:
    108         FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn );
     108        // temporary - merge this into general GCC attributes
     109        enum Attribute {
     110                NoAttribute, Constructor, Destructor,
     111        };
     112
     113        FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute = NoAttribute );
    109114        FunctionDecl( const FunctionDecl &other );
    110115        virtual ~FunctionDecl();
     
    119124        std::list< std::string >& get_oldIdents() { return oldIdents; }
    120125        std::list< Declaration* >& get_oldDecls() { return oldDecls; }
     126        Attribute get_attribute() const { return attribute; }
     127        void set_attribute( Attribute newValue ) { attribute = newValue; }
    121128
    122129        virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); }
     
    130137        std::list< std::string > oldIdents;
    131138        std::list< Declaration* > oldDecls;
     139        Attribute attribute;
    132140};
    133141
  • src/SynTree/FunctionDecl.cc

    r4acc87f rd029162e  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FunctionDecl.cc -- 
     7// FunctionDecl.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jul 13 18:11:44 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri May 06 11:35:09 2016
    1313// Update Count     : 19
    1414//
     
    2121#include "Common/utility.h"
    2222
    23 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn )
    24                 : Parent( name, sc, linkage ), type( type ), statements( statements ) {
     23FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute )
     24                : Parent( name, sc, linkage ), type( type ), statements( statements ), attribute( attribute ) {
    2525        set_isInline( isInline );
    2626        set_isNoreturn( isNoreturn );
     
    3232
    3333FunctionDecl::FunctionDecl( const FunctionDecl &other )
    34         : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) {
     34        : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), attribute( other.attribute ) {
    3535}
    3636
     
    5252        using std::endl;
    5353        using std::string;
    54        
     54
    5555        if ( get_name() != "" ) {
    5656                os << get_name() << ": ";
     
    6565                os << "_Noreturn ";
    6666        } // if
     67        switch ( attribute ) {
     68                case Constructor:
     69                        os << "Global Constructor ";
     70                        break;
     71                case Destructor:
     72                        os << "Global Destructor ";
     73                        break;
     74                default:
     75                        break;
     76        }
    6777        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    6878                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
     
    94104        using std::endl;
    95105        using std::string;
    96        
     106
    97107        if ( get_name() != "" ) {
    98108                os << get_name() << ": ";
     
    104114                os << "_Noreturn ";
    105115        } // if
     116        switch ( attribute ) {
     117                case Constructor:
     118                        os << " Global Constructor ";
     119                        break;
     120                case Destructor:
     121                        os << " Global Destructor ";
     122                        break;
     123                default:
     124                        break;
     125        }
    106126        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    107127                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
  • src/main.cc

    r4acc87f rd029162e  
    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
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri May 06 14:04:49 2016
    1313// Update Count     : 203
    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"
     
    9899        int long_index;
    99100        std::list< Declaration * > translationUnit;
    100         const char *filename = NULL;;
     101        const char *filename = NULL;
    101102
    102103        opterr = 0;                                                                                     // prevent getopt from printing error messages
    103        
     104
    104105        int c;
    105106        while ( (c = getopt_long( argc, argv, "abefglnpqrstvyzD:F:", long_opts, &long_index )) != -1 ) {
     
    180181                        input = fopen( argv[ optind ], "r" );
    181182                        if ( ! input ) {
    182                                 std::cout << "Error: can't open " << argv[optind] << std::endl;
     183                                std::cout << "Error: can't open " << argv[ optind ] << std::endl;
    183184                                exit( 1 );
    184185                        } // if
     186                        // if running cfa-cpp directly, might forget to pass -F option (and really shouldn't have to)
     187                        if ( filename == NULL ) filename = argv[ optind ];
    185188                        optind += 1;
    186189                } else {
     
    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.