Changeset 8a443f4 for src/CodeGen


Ignore:
Timestamp:
Aug 2, 2016, 6:40:27 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, 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:
73bf8cf2
Parents:
4d2434a (diff), becba789 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into ctor

Location:
src/CodeGen
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r4d2434a r8a443f4  
    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 : Fri Jul 15 15:53:15 2016
    13 // Update Count     : 306
     11// Last Modified By :
     12// Last Modified On : Sun Jul 31 08:42:18 2016
     13// Update Count     : 345
    1414//
    1515
     
    4545        bool wantSpacing( Statement * stmt) {
    4646                return dynamic_cast< IfStmt * >( stmt ) || dynamic_cast< CompoundStmt * >( stmt ) ||
    47                         dynamic_cast< WhileStmt * >( stmt ) || dynamic_cast< ForStmt * > ( stmt ) || dynamic_cast< SwitchStmt *>( stmt );
     47                        dynamic_cast< WhileStmt * >( stmt ) || dynamic_cast< ForStmt * >( stmt ) || dynamic_cast< SwitchStmt *>( stmt );
    4848        }
    4949
     
    8383        }
    8484
    85         CodeGenerator::CodeGenerator( std::ostream &os ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ) { }
     85        CodeGenerator::CodeGenerator( std::ostream &os ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ) {}
    8686
    8787        CodeGenerator::CodeGenerator( std::ostream &os, std::string init, int indentation, bool infunp )
     
    155155                        objectDecl->get_init()->accept( *this );
    156156                } // if
     157
    157158                if ( objectDecl->get_bitfieldWidth() ) {
    158159                        output << ":";
     
    172173
    173174                        cur_indent += CodeGenerator::tabsize;
    174                         for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end();  i++) {
     175                        for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++ ) {
    175176                                output << indent;
    176177                                (*i)->accept( *this );
    177178                                output << ";" << endl;
    178                         }
     179                        } // for
    179180
    180181                        cur_indent -= CodeGenerator::tabsize;
     
    257258                                (*iter)->accept( *this );
    258259                                output << "]";
    259                         }
    260                 }
     260                        } // if
     261                } // for
    261262                output << " = ";
    262263        }
     
    317318                                        // do nothing
    318319                                        ;
    319                                 }
     320                                } // switch
    320321
    321322                                switch ( opInfo.type ) {
     
    385386                                        // there are no intrinsic definitions of 0/1 or label addresses as functions
    386387                                        assert( false );
    387                                 }
     388                                } // switch
    388389                        } else {
    389390                                varExpr->accept( *this );
     
    417418                                  case OT_CALL:
    418419                                        assert( false );
    419 
    420420
    421421                                  case OT_CTOR:
     
    437437                                                // no constructors with 0 or more than 2 parameters
    438438                                                assert( false );
    439                                         }
     439                                        } // if
    440440                                        break;
    441441
     
    470470                                        // there are no intrinsic definitions of 0 or 1 as functions
    471471                                        assert( false );
    472                                 }
     472                                } // switch
    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" ) { // case V1 ... V2 or case V1~V2
     475                                        assert( untypedExpr->get_args().size() == 2 );
     476                                        (*untypedExpr->get_args().begin())->accept( *this );
     477                                        output << " ... ";
     478                                        (*--untypedExpr->get_args().end())->accept( *this );
     479                                } else {                                                                // builtin routines
     480                                        nameExpr->accept( *this );
     481                                        output << "(";
     482                                        genCommaList( untypedExpr->get_args().begin(), untypedExpr->get_args().end() );
     483                                        output << ")";
     484                                } // if
    478485                        } // if
    479486                } else {
     
    521528                        // otherwise, the cast is to an lvalue type, so the cast should be dropped, since the result of a cast is
    522529                        // never an lvalue in C
    523                 }
     530                } // if
    524531                castExpr->get_arg()->accept( *this );
    525532                output << ")";
     
    654661                        if ( wantSpacing( *i ) ) {
    655662                                output << endl;
    656                         }
     663                        } // if
    657664                }
    658665                cur_indent -= CodeGenerator::tabsize;
     
    737744                        (*i)->accept( *this );
    738745                        output << endl;
    739                 }
     746                } // for
    740747                cur_indent -= CodeGenerator::tabsize;
    741748        }
     
    759766                        output << "continue";
    760767                        break;
    761                 }
     768                } // switch
    762769                output << ";";
    763770        }
     
    798805                if ( forStmt->get_condition() != 0 ) {
    799806                        forStmt->get_condition()->accept( *this );
    800                 }
     807                } // if
    801808                output << ";";
    802809
     
    805812                        Expression * expr = new CastExpr( forStmt->get_increment() );
    806813                        expr->accept( *this );
    807                 }
     814                } // if
    808815                output << ") ";
    809816
  • src/CodeGen/CodeGenerator.h

    r4d2434a r8a443f4  
    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 11:10:42 2016
     13// Update Count     : 37
    1414//
    1515
     
    118118                void handleAggregate( AggregateDecl *aggDecl );
    119119                void handleTypedef( NamedTypeDecl *namedType );
    120         };
     120        }; // CodeGenerator
    121121
    122122        template< class Iterator >
Note: See TracChangeset for help on using the changeset viewer.