Changeset 66d12f7


Ignore:
Timestamp:
Jul 30, 2016, 2:31:17 AM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, 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:
ac911f4
Parents:
2750cde
Message:

change case ranges to use gcc syntax, first attempt

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r2750cde r66d12f7  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 15 15:53:15 2016
    13 // Update Count     : 306
     12// Last Modified On : Sat Jul 30 01:48:20 2016
     13// Update Count     : 329
    1414//
    1515
     
    472472                                }
    473473                        } else {
    474                                 nameExpr->accept( *this );
    475                                 output << "(";
    476                                 genCommaList( untypedExpr->get_args().begin(), untypedExpr->get_args().end() );
    477                                 output << ")";
     474                                if ( nameExpr->get_name() != "Range" ) {
     475                                        nameExpr->accept( *this );
     476                                        output << "(";
     477                                        genCommaList( untypedExpr->get_args().begin(), untypedExpr->get_args().end() );
     478                                        output << ")";
     479                                } else {
     480                                        genFredList( untypedExpr->get_args().begin(), untypedExpr->get_args().end() );
     481//                                      output << (*(untypedExpr->get_args().begin()))->accept( *this );// << " ... " << (*untypedExpr->get_args().end())->accept( *this ).getname();
     482                                } // if
    478483                        } // if
    479484                } else {
  • src/CodeGen/CodeGenerator.h

    r2750cde r66d12f7  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jul  4 17:12:40 2016
    13 // Update Count     : 34
     12// Last Modified On : Sat Jul 30 01:23:43 2016
     13// Update Count     : 36
    1414//
    1515
     
    9090
    9191                template< class Iterator > void genCommaList( Iterator begin, Iterator end );
     92                template< class Iterator > void genFredList( Iterator begin, Iterator end );
    9293
    9394                struct Indenter {
     
    118119                void handleAggregate( AggregateDecl *aggDecl );
    119120                void handleTypedef( NamedTypeDecl *namedType );
    120         };
     121        }; // CodeGenerator
    121122
    122123        template< class Iterator >
     
    128129                        if ( begin == end ) return;
    129130                        output << ", ";
     131                } // for
     132        }
     133
     134        template< class Iterator >
     135        void CodeGenerator::genFredList( Iterator begin, Iterator end ) {
     136                if ( begin == end ) return;
     137
     138                for ( ;; ) {
     139                        (*begin++)->accept( *this );
     140                        if ( begin == end ) return;
     141                        output << " ... ";
    130142                } // for
    131143        }
  • src/ControlStruct/CaseRangeMutator.cc

    r2750cde r66d12f7  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 12 17:35:13 2016
    13 // Update Count     : 9
     12// Last Modified On : Thu Jul 28 01:56:47 2016
     13// Update Count     : 14
    1414//
    1515
     
    7171                        NameExpr *nmfunc;
    7272                        if ( ( nmfunc = dynamic_cast< NameExpr *>( cond->get_function() )) != 0 ) {
    73                                 if ( nmfunc->get_name() == std::string("Range") ) {
     73                                if ( nmfunc->get_name() == "Range" ) {
    7474                                        assert( cond->get_args().size() == 2 );
    7575                                        std::list<Expression *>::iterator i = cond->get_args().begin();
    7676                                        Expression *lo = *i, *hi = *(++i ); // "unnecessary" temporaries
    77                                         fillRange( lo, hi );
     77                                        //fillRange( lo, hi );
    7878                                } // if
    7979                        } // if
     
    8282                        assert( ! tcond->get_exprs().empty() );
    8383                        for ( std::list< Expression * >::iterator i = tcond->get_exprs().begin(); i != tcond->get_exprs().end(); i++ )
    84                                 newCaseLabels.push_back( *i ); // do I need to clone them?
     84                                newCaseLabels.push_back( *i );                  // do I need to clone them?
    8585                } // if
    8686
     
    9999
    100100                if ( ce_lo && ce_hi ) {
     101                        std::cout << ce_lo->get_constant()->get_value() << " " << ce_hi->get_constant()->get_value() << std::endl;
    101102                        c_lo = ce_lo->get_constant(); c_hi = ce_hi->get_constant();
    102103                } /* else {
     
    109110                if ( ! ty_lo || ! ty_hi )
    110111                        return; // one of them is not a constant
    111 
     112#if 0
    112113                switch ( ty_lo->get_kind() ) {
    113114                  case BasicType::Char:
     
    176177                        break;
    177178                } // switch
    178 
     179#endif
    179180                /* End: */{
    180181                        // invalid range, signal a warning (it still generates the two case labels)
    181                         newCaseLabels.push_back( lo );
    182                         newCaseLabels.push_back( hi );
     182//                      newCaseLabels.push_back( lo );
     183//                      newCaseLabels.push_back( hi );
    183184                        return;
    184185                }
Note: See TracChangeset for help on using the changeset viewer.