Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    r1db21619 r145f1fc  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:50:04 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 16 16:10:02 2015
    13 // Update Count     : 189
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Tue Jul 14 12:27:54 2015
     13// Update Count     : 186
    1414//
    1515
     
    6060        class HoistStruct : public Visitor {
    6161          public:
    62                 /// Flattens nested struct types
    6362                static void hoistStruct( std::list< Declaration * > &translationUnit );
    6463 
     
    8584        };
    8685
    87         /// Replaces enum types by int, and function or array types in function parameter and return lists by appropriate pointers
    8886        class Pass1 : public Visitor {
    8987                typedef Visitor Parent;
     
    9189                virtual void visit( FunctionType *func );
    9290        };
    93 
    94         /// Associates forward declarations of aggregates with their definitions
     91 
    9592        class Pass2 : public Indexer {
    9693                typedef Indexer Parent;
     
    113110        };
    114111
    115         /// Replaces array and function types in forall lists by appropriate pointer type
    116112        class Pass3 : public Indexer {
    117113                typedef Indexer Parent;
     
    127123        class AddStructAssignment : public Visitor {
    128124          public:
    129                 /// Generates assignment operators for aggregate types as required
    130125                static void addStructAssignment( std::list< Declaration * > &translationUnit );
    131126
     
    162157        class EliminateTypedef : public Mutator {
    163158          public:
    164                 EliminateTypedef() : scopeLevel( 0 ) {}
     159          EliminateTypedef() : scopeLevel( 0 ) {}
    165160                static void eliminateTypedef( std::list< Declaration * > &translationUnit );
    166161          private:
     
    168163                virtual TypeDecl *mutate( TypeDecl *typeDecl );
    169164                virtual DeclarationWithType *mutate( FunctionDecl *funcDecl );
    170                 virtual DeclarationWithType *mutate( ObjectDecl *objDecl );
     165                virtual ObjectDecl *mutate( ObjectDecl *objDecl );
    171166                virtual CompoundStmt *mutate( CompoundStmt *compoundStmt );
    172167                virtual Type *mutate( TypeInstType *aggregateUseType );
     
    449444        }
    450445
    451         /// Fix up assertions
    452446        void forallFixer( Type *func ) {
     447                // Fix up assertions
    453448                for ( std::list< TypeDecl * >::iterator type = func->get_forall().begin(); type != func->get_forall().end(); ++type ) {
    454449                        std::list< DeclarationWithType * > toBeDone, nextRound;
     
    612607
    613608                // need to remove the prototypes, since this may be nested in a routine
    614                 for ( int start = 0, end = assigns.size() / 2; start < end; start++ ) {
     609                for (int start = 0, end = assigns.size()/2; start < end; start++) {
    615610                        delete assigns.front();
    616611                        assigns.pop_front();
    617                 } // for
     612                }
    618613
    619614                declsToAdd.insert( declsToAdd.begin(), assigns.begin(), assigns.end() );
     
    822817                        Type *ret = def->second.first->get_base()->clone();
    823818                        ret->get_qualifiers() += typeInst->get_qualifiers();
    824                         // place instance parameters on the typedef'd type
    825                         if ( ! typeInst->get_parameters().empty() ) {
    826                                 ReferenceToType *rtt = dynamic_cast<ReferenceToType*>(ret);
    827                                 if ( ! rtt ) {
    828                                         throw SemanticError("cannot apply type parameters to base type of " + typeInst->get_name());
    829                                 }
    830                                 rtt->get_parameters().clear();
    831                                 cloneAll(typeInst->get_parameters(), rtt->get_parameters());
    832                         } // if
    833819                        delete typeInst;
    834820                        return ret;
     
    884870        }
    885871
    886         DeclarationWithType *EliminateTypedef::mutate( ObjectDecl * objDecl ) {
     872        ObjectDecl *EliminateTypedef::mutate( ObjectDecl * objDecl ) {
    887873                TypedefMap oldNames = typedefNames;
    888                 DeclarationWithType *ret = Mutator::mutate( objDecl );
    889                 if ( FunctionType *funtype = dynamic_cast<FunctionType *>( ret->get_type() ) ) {
    890                         return new FunctionDecl( ret->get_name(), ret->get_storageClass(), ret->get_linkage(), funtype, 0, ret->get_isInline(), ret->get_isNoreturn() );
    891                 } else if ( objDecl->get_isInline() || objDecl->get_isNoreturn() ) {
    892                         throw SemanticError( "invalid inline or _Noreturn specification in declaration of ", objDecl );
    893                 } // if
     874                ObjectDecl *ret = Mutator::mutate( objDecl );
    894875                typedefNames = oldNames;
    895876                return ret;
     
    955936        }
    956937
    957         Declaration *EliminateTypedef::mutate( ContextDecl * contextDecl ) {
     938                Declaration *EliminateTypedef::mutate( ContextDecl * contextDecl ) {
    958939                Mutator::mutate( contextDecl );
    959940                return handleAggregate( contextDecl );
Note: See TracChangeset for help on using the changeset viewer.