Changeset 0e73845 for src


Ignore:
Timestamp:
Aug 19, 2018, 12:09:00 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
04c77791
Parents:
38587bc
Message:

Fix name mangling for type variables and forall lists

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Mangler.cc

    r38587bc r0e73845  
    149149                        void Mangler::postvisit( BasicType * basicType ) {
    150150                                printQualifiers( basicType );
    151                                 assert( basicType->get_kind() < BasicType::NUMBER_OF_BASIC_TYPES );
     151                                assertf( basicType->get_kind() < BasicType::NUMBER_OF_BASIC_TYPES, "Unhandled basic type: %d", basicType->get_kind() );
    152152                                mangleName << Encoding::basicTypes[ basicType->get_kind() ];
    153153                        }
     
    240240                                } else {
    241241                                        printQualifiers( typeInst );
    242                                         std::ostringstream numStream;
    243                                         numStream << varNum->second.first;
    244                                         switch ( (TypeDecl::Kind )varNum->second.second ) {
    245                                           case TypeDecl::Dtype:
    246                                                 mangleName << "d";
    247                                                 break;
    248                                           case TypeDecl::Ftype:
    249                                                 mangleName << "f";
    250                                                 break;
    251                                                 case TypeDecl::Ttype:
    252                                                 mangleName << "tVARGS";
    253                                                 break;
    254                                                 default:
    255                                                 assert( false );
    256                                         } // switch
    257                                         mangleName << numStream.str();
     242                                        assertf( varNum->second.second < TypeDecl::NUMBER_OF_KINDS, "Unhandled type variable kind: %d", varNum->second.second );
     243                                        mangleName << Encoding::typeVariables[varNum->second.second] << typeInst->get_name().size() << typeInst->get_name(); // varNum->second.first;
    258244                                } // if
    259245                        }
     
    301287
    302288                        void Mangler::postvisit( TypeDecl * decl ) {
    303                                 static const char *typePrefix[] = { "BT", "BD", "BF" };
    304                                 mangleName << typePrefix[ decl->get_kind() ] << ( decl->name.length() + 1 ) << decl->name;
     289                                assertf( decl->get_kind() < TypeDecl::NUMBER_OF_KINDS, "Unhandled type variable kind: %d", decl->get_kind() );
     290                                mangleName << Encoding::typeVariables[ decl->get_kind() ] << ( decl->name.length() ) << decl->name;
    305291                        }
    306292
     
    316302                                if ( ! type->get_forall().empty() ) {
    317303                                        std::list< std::string > assertionNames;
    318                                         int tcount = 0, dcount = 0, fcount = 0, vcount = 0;
    319                                         mangleName << "A";
     304                                        int dcount = 0, fcount = 0, vcount = 0, acount = 0;
     305                                        mangleName << Encoding::forall;
    320306                                        for ( Type::ForallList::iterator i = type->forall.begin(); i != type->forall.end(); ++i ) {
    321307                                                switch ( (*i)->get_kind() ) {
     
    340326                                                        (*assert)->accept( sub_mangler );
    341327                                                        assertionNames.push_back( sub_mangler.pass.mangleName.str() );
     328                                                        acount++;
    342329                                                } // for
    343330                                        } // for
    344                                         mangleName << tcount << "_" << dcount << "_" << fcount << "_" << vcount << "_";
     331                                        mangleName << dcount << "_" << fcount << "_" << vcount << "_" << acount << "_";
    345332                                        std::copy( assertionNames.begin(), assertionNames.end(), std::ostream_iterator< std::string >( mangleName, "" ) );
    346333                                        mangleName << "_";
  • src/SymTab/Mangler.h

    r38587bc r0e73845  
    5757                        extern const std::string qualifiedTypeEnd;
    5858
     59                        extern const std::string forall;
     60                        extern const std::string typeVariables[];
     61
    5962                        extern const std::string struct_t;
    6063                        extern const std::string union_t;
  • src/SymTab/ManglerCommon.cc

    r38587bc r0e73845  
    1616#include "Mangler.h"
    1717#include "SynTree/Type.h"
     18#include "SynTree/Declaration.h"
    1819
    1920namespace SymTab {
     
    8283                        const std::string qualifiedTypeEnd = "E";
    8384
     85                        const std::string forall = "Q";
     86                        const std::string typeVariables[] = {
     87                                "BD", // dtype
     88                                "BF", // ftype
     89                                "BT", // ttype
     90                        };
     91                        static_assert(
     92                                sizeof(typeVariables)/sizeof(typeVariables[0]) == TypeDecl::NUMBER_OF_KINDS,
     93                                "Each type variable kind should have a corresponding mangler prefix"
     94                        );
     95
    8496                        const std::string struct_t = "S";
    8597                        const std::string union_t = "U";
  • src/SynTree/Declaration.h

    r38587bc r0e73845  
    202202        typedef NamedTypeDecl Parent;
    203203  public:
    204         enum Kind { Dtype, Ftype, Ttype };
     204        enum Kind { Dtype, Ftype, Ttype, NUMBER_OF_KINDS };
    205205
    206206        Type * init;
Note: See TracChangeset for help on using the changeset viewer.