Changeset 2f42718 for src/CodeTools


Ignore:
Timestamp:
Feb 22, 2019, 10:43:29 AM (7 years ago)
Author:
tdelisle <tdelisle@…>
Branches:
no_list
Parents:
43e0949
Message:

Parameters and return value of functions are now vectors (and some related clean-up)

Location:
src/CodeTools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/CodeTools/DeclStats.cc

    r43e0949 r2f42718  
    183183                }
    184184
    185                 void analyzeSubtypes( std::list<DeclarationWithType*>& tys, Stats& stats,
     185                void analyzeSubtypes( std::vector<DeclarationWithType*>& tys, Stats& stats,
    186186                                std::unordered_set<std::string>& elSeen, unsigned& n_poly, bool& seen_poly,
    187                                 unsigned& max_depth, unsigned depth, unsigned& n_subs ) {
     187                                unsigned& max_depth, unsigned depth, unsigned& n_subs )
     188                {
    188189                        for ( DeclarationWithType* dwt : tys ) {
    189190                                Type* ty = dwt->get_type();
     
    204205                }
    205206
    206                 void analyzeSubtypes( std::list<Type*>& tys, Stats& stats,
     207                void analyzeSubtypes( std::vector<Type*>& tys, Stats& stats,
    207208                                std::unordered_set<std::string>& elSeen, unsigned& n_poly, bool& seen_poly,
    208209                                unsigned& max_depth, unsigned depth ) {
     
    246247                                unsigned n_subs = 0;
    247248                                analyzeSubtypes(
    248                                         ft->get_returnVals(), stats, elSeen, n_poly, seen_poly, max_depth, depth,
     249                                        ft->returnVals, stats, elSeen, n_poly, seen_poly, max_depth, depth,
    249250                                        n_subs );
    250251                                analyzeSubtypes(
    251                                         ft->get_parameters(), stats, elSeen, n_poly, seen_poly, max_depth, depth,
     252                                        ft->parameters, stats, elSeen, n_poly, seen_poly, max_depth, depth,
    252253                                        n_subs );
    253254                                ++stats.n_generic_params.at( n_subs );
     
    280281                                        name, n_generic, stats.generic_type_names, stats.generic_type_decls, elSeen);
    281282                                analyzeSubtypes(
    282                                         tt->get_types(), stats, elSeen, n_poly, seen_poly, max_depth, depth );
     283                                        tt->types, stats, elSeen, n_poly, seen_poly, max_depth, depth );
    283284                                ++stats.n_generic_params.at( tt->size() );
    284285                        } else if ( dynamic_cast<VarArgsType*>(ty) ) {
     
    299300
    300301                /// Update arg pack stats based on a declaration list
    301                 void analyze( Stats& stats, std::unordered_set<std::string>& seen,
    302                                 std::unordered_set<std::string>& elSeen, ArgPackStats& pstats,
    303                                 std::list<DeclarationWithType*>& decls ) {
     302                void analyze( Stats& stats, std::unordered_set<std::string> & seen,
     303                                std::unordered_set<std::string> & elSeen, ArgPackStats & pstats,
     304                                std::vector<DeclarationWithType*> & decls ) {
    304305                        std::unordered_set<std::string> types;
    305306                        unsigned n = 0;                 ///< number of args/returns
     
    345346                        std::unordered_set<std::string> seen;
    346347                        std::unordered_set<std::string> elSeen;
    347                         analyze( stats, seen, elSeen, params, fnTy->get_parameters() );
    348                         analyze( stats, seen, elSeen, returns, fnTy->get_returnVals() );
     348                        analyze( stats, seen, elSeen, params , fnTy->parameters );
     349                        analyze( stats, seen, elSeen, returns, fnTy->returnVals );
    349350                }
    350351
  • src/CodeTools/ResolvProtoDump.cc

    r43e0949 r2f42718  
    102102                /// builds space-separated list of types
    103103                template<typename V>
    104                 static void build( V& visitor, const std::list< Type* >& tys, std::stringstream& ss,
     104                static void build( V& visitor, const std::vector< Type* >& tys, std::stringstream& ss,
    105105                                septype mode = separated ) {
    106106                        if ( tys.empty() ) return;
     
    121121                /// builds list of types wrapped as tuple type
    122122                template<typename V>
    123                 static void buildAsTuple( V& visitor, const std::list< Type* >& tys,
     123                static void buildAsTuple( V& visitor, const std::vector< Type * > & tys,
    124124                                std::stringstream& ss ) {
    125125                        switch ( tys.size() ) {
     
    135135
    136136                /// gets types from DWT list
    137                 static std::list< Type* > from_decls( const std::list< DeclarationWithType* >& decls ) {
    138                         std::list< Type* > tys;
     137                static std::vector< Type * > from_decls( const std::vector< DeclarationWithType * > & decls ) {
     138                        std::vector< Type * > tys;
    139139                        for ( auto decl : decls ) { tys.emplace_back( decl->get_type() ); }
    140140                        return tys;
     
    142142
    143143                /// gets types from TypeExpr list
    144                 static std::list< Type* > from_exprs( const std::list< Expression* >& exprs ) {
    145                         std::list< Type* > tys;
     144                static std::vector< Type* > from_exprs( const std::list< Expression* >& exprs ) {
     145                        std::vector< Type* > tys;
    146146                        for ( auto expr : exprs ) {
    147147                                if ( TypeExpr* tyExpr = dynamic_cast<TypeExpr*>(expr) ) {
     
    587587
    588588                /// Adds all named declarations in a list to the local scope
    589                 void addAll( const std::list<DeclarationWithType*>& decls ) {
     589                void addAll( const std::vector<DeclarationWithType*>& decls ) {
    590590                        for ( auto decl : decls ) {
    591591                                // skip anonymous decls
     
    644644                        // add body if available
    645645                        if ( decl->statements ) {
    646                                 std::list<Type*> rtns = from_decls( decl->type->returnVals );
     646                                auto rtns = from_decls( decl->type->returnVals );
    647647                                Type* rtn = nullptr;
    648648                                if ( rtns.size() == 1 ) {
Note: See TracChangeset for help on using the changeset viewer.