Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeTools/ResolvProtoDump.cc

    r04bdc26 r4c42a5f  
    204204                /// ensures type inst names are uppercase
    205205                static void ti_name( const std::string& name, std::stringstream& ss ) {
    206                         // replace built-in wide character types with named types
    207                         if ( name == "char16_t" || name == "char32_t" || name == "wchar_t" ) {
    208                                 ss << "#" << name;
    209                                 return;
    210                         }
    211 
    212                         // strip leading underscore
    213206                        unsigned i = 0;
    214207                        while ( i < name.size() && name[i] == '_' ) { ++i; }
     
    217210                                return;
    218211                        }
    219 
    220                         std::string stripped = name.substr(i);
    221                         // strip trailing "_generic_" from autogen names (avoids some user-generation issues)
    222                         char generic[] = "_generic_"; size_t n_generic = sizeof(generic) - 1;
    223                         if ( stripped.size() >= n_generic
    224                                         && stripped.substr( stripped.size() - n_generic ) == generic ) {
    225                                 stripped.resize( stripped.size() - n_generic );
    226                         }
    227 
    228                         // uppercase first character
    229                         ss << (char)std::toupper( static_cast<unsigned char>(stripped[0]) )
    230                            << (stripped.c_str() + 1);
     212                        ss << (char)std::toupper( static_cast<unsigned char>(name[i]) )
     213                           << (name.c_str() + i + 1);
    231214                }
    232215
     
    321304                        }
    322305
    323                         // TODO support variable args for functions
    324                         void previsit( VarArgsType* ) {
    325                                 // only include varargs for top level (argument type)
    326                                 if ( depth == 0 ) { ss << "#$varargs"; }
    327                         }
     306                        // TODO support VarArgsType
    328307
    329308                        // replace 0 and 1 with int
     
    418397                        }
    419398
    420                         /// Handle already-resolved variables as type constants
    421                         void previsit( VariableExpr* expr ) {
    422                                 PassVisitor<TypePrinter> tyPrinter{ closed, ss };
    423                                 expr->var->get_type()->accept( tyPrinter );
    424                                 visit_children = false;
    425                         }
    426 
    427399                        /// Calls handled as calls
    428400                        void previsit( UntypedExpr* expr ) {
     
    454426                        }
    455427
    456                         /// Already-resolved calls reduced to their type constant
    457                         void previsit( ApplicationExpr* expr ) {
    458                                 PassVisitor<TypePrinter> tyPrinter{ closed, ss };
    459                                 expr->result->accept( tyPrinter );
     428                        /// Already-resolved calls skipped
     429                        void previsit( ApplicationExpr* ) {
    460430                                visit_children = false;
    461431                        }
     
    562532                                for ( Initializer* it : li->initializers ) {
    563533                                        build( it, ss );
     534                                        ss << ' ';
    564535                                }
    565536                        }
     
    568539                /// Adds an object initializer to the list of expressions
    569540                void build( const std::string& name, Initializer* init, std::stringstream& ss ) {
    570                         ss << "$constructor( &";
     541                        ss << "$constructor( ";
    571542                        rp_name( name, ss );
    572                         ss << ' ';
     543                        ss << "() ";
    573544                        build( init, ss );
    574545                        ss << ')';
     
    705676                }
    706677
    707                 void previsit( AsmStmt* ) {
    708                         // skip asm statements
    709                         visit_children = false;
    710                 }
    711 
    712678                void previsit( Expression* expr ) {
    713679                        std::stringstream ss;
     
    720686                /// Print non-prelude global declarations for resolv proto
    721687                void printGlobals() const {
    722                         std::cout << "#$ptr<T> $addr T" << std::endl;  // &?
     688                        std::cout << "#ptr<T> $addr T" << std::endl;  // &?
    723689                        int i = (int)BasicType::SignedInt;
    724690                        std::cout << i << " $and " << i << ' ' << i << std::endl;  // ?&&?
Note: See TracChangeset for help on using the changeset viewer.