Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    r51b986f r73737e5  
    1010// Created On       : Sun May 17 21:50:04 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Jul 22 13:16:00 2015
    13 // Update Count     : 194
     12// Last Modified On : Mon Jul 13 14:38:19 2015
     13// Update Count     : 184
    1414//
    1515
     
    162162        class EliminateTypedef : public Mutator {
    163163          public:
    164                 EliminateTypedef() : scopeLevel( 0 ) {}
     164          EliminateTypedef() : scopeLevel( 0 ) {}
     165            /// Replaces typedefs by forward declarations
    165166                static void eliminateTypedef( std::list< Declaration * > &translationUnit );
    166167          private:
     
    168169                virtual TypeDecl *mutate( TypeDecl *typeDecl );
    169170                virtual DeclarationWithType *mutate( FunctionDecl *funcDecl );
    170                 virtual DeclarationWithType *mutate( ObjectDecl *objDecl );
     171                virtual ObjectDecl *mutate( ObjectDecl *objDecl );
    171172                virtual CompoundStmt *mutate( CompoundStmt *compoundStmt );
    172173                virtual Type *mutate( TypeInstType *aggregateUseType );
     
    202203        void validateType( Type *type, const Indexer *indexer ) {
    203204                Pass1 pass1;
    204                 Pass2 pass2( false, indexer );
    205205                Pass3 pass3( indexer );
    206206                type->accept( pass1 );
    207                 type->accept( pass2 );
    208207                type->accept( pass3 );
    209208        }
     
    404403                        } // for
    405404                } // for
    406 
    407                 if ( ctx->get_parameters().size() != contextInst->get_parameters().size() ) {
    408                         throw SemanticError( "incorrect number of context parameters: ", contextInst );
    409                 } // if
    410 
    411405                applySubstitution( ctx->get_parameters().begin(), ctx->get_parameters().end(), contextInst->get_parameters().begin(), ctx->get_members().begin(), ctx->get_members().end(), back_inserter( contextInst->get_members() ) );
    412406        }
     
    540534                init->get_args().push_back( new NameExpr( "0" ) );
    541535                Statement *initStmt = new ExprStmt( noLabels, init );
    542                 std::list<Statement *> initList;
    543                 initList.push_back( initStmt );
    544 
     536 
    545537                UntypedExpr *cond = new UntypedExpr( new NameExpr( "?<?" ) );
    546538                cond->get_args().push_back( new VariableExpr( index ) );
     
    567559                assignExpr->get_args().push_back( srcIndex );
    568560 
    569                 *out++ = new ForStmt( noLabels, initList, cond, inc, new ExprStmt( noLabels, assignExpr ) );
     561                *out++ = new ForStmt( noLabels, initStmt, cond, inc, new ExprStmt( noLabels, assignExpr ) );
    570562        }
    571563
     
    617609
    618610                // need to remove the prototypes, since this may be nested in a routine
    619                 for ( int start = 0, end = assigns.size() / 2; start < end; start++ ) {
     611                for (int start = 0, end = assigns.size()/2; start < end; start++) {
    620612                        delete assigns.front();
    621613                        assigns.pop_front();
    622                 } // for
     614                }
    623615
    624616                declsToAdd.insert( declsToAdd.begin(), assigns.begin(), assigns.end() );
     
    835827                                rtt->get_parameters().clear();
    836828                                cloneAll(typeInst->get_parameters(), rtt->get_parameters());
    837                         } // if
     829                        }
    838830                        delete typeInst;
    839831                        return ret;
     
    889881        }
    890882
    891         DeclarationWithType *EliminateTypedef::mutate( ObjectDecl * objDecl ) {
     883        ObjectDecl *EliminateTypedef::mutate( ObjectDecl * objDecl ) {
    892884                TypedefMap oldNames = typedefNames;
    893                 DeclarationWithType *ret = Mutator::mutate( objDecl );
    894                 if ( FunctionType *funtype = dynamic_cast<FunctionType *>( ret->get_type() ) ) {
    895                         return new FunctionDecl( ret->get_name(), ret->get_storageClass(), ret->get_linkage(), funtype, 0, ret->get_isInline(), ret->get_isNoreturn() );
    896                 } else if ( objDecl->get_isInline() || objDecl->get_isNoreturn() ) {
    897                         throw SemanticError( "invalid inline or _Noreturn specification in declaration of ", objDecl );
    898                 } // if
     885                ObjectDecl *ret = Mutator::mutate( objDecl );
    899886                typedefNames = oldNames;
    900887                return ret;
     
    960947        }
    961948
    962         Declaration *EliminateTypedef::mutate( ContextDecl * contextDecl ) {
     949                Declaration *EliminateTypedef::mutate( ContextDecl * contextDecl ) {
    963950                Mutator::mutate( contextDecl );
    964951                return handleAggregate( contextDecl );
Note: See TracChangeset for help on using the changeset viewer.