Changeset 862658a


Ignore:
Timestamp:
Jan 11, 2023, 1:43:30 PM (15 months ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, master
Children:
42b739d7
Parents:
b49310f (diff), 8fcf921 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rb49310f r862658a  
    283283                                assert( obj );
    284284                                output << "static ";
    285                                 output << genType(enumDecl->base, "", options) << " const ";
    286                                 output << mangleName( obj ) << " ";
     285                                output << genType(enumDecl->base, mangleName( obj ), options);
    287286                                output << " = ";
    288287                                output << "(" << genType(enumDecl->base, "", options) << ")";
  • src/CodeGen/GenType.cc

    rb49310f r862658a  
    255255        void GenType::postvisit( EnumInstType * enumInst ) {
    256256                if ( enumInst->baseEnum && enumInst->baseEnum->base ) {
    257                         typeString = genType(enumInst->baseEnum->base, "", options) + typeString;
     257                        typeString = genType(enumInst->baseEnum->base, typeString, options);
    258258                } else {
    259259                        typeString = enumInst->name + " " + typeString;
  • src/SymTab/Mangler.cc

    rb49310f r862658a  
    439439                  private:
    440440                        void mangleDecl( const ast::DeclWithType *declaration );
    441                         void mangleRef( const ast::BaseInstType *refType, std::string prefix );
     441                        void mangleRef( const ast::BaseInstType *refType, const std::string & prefix );
    442442
    443443                        void printQualifiers( const ast::Type *type );
     
    535535                }
    536536
    537                 __attribute__((unused))
    538                 inline std::vector< ast::ptr< ast::Type > > getTypes( const std::vector< ast::ptr< ast::DeclWithType > > & decls ) {
    539                         std::vector< ast::ptr< ast::Type > > ret;
    540                         std::transform( decls.begin(), decls.end(), std::back_inserter( ret ),
    541                                                         std::mem_fun( &ast::DeclWithType::get_type ) );
    542                         return ret;
    543                 }
    544 
    545537                void Mangler_new::postvisit( const ast::FunctionType * functionType ) {
    546538                        printQualifiers( functionType );
     
    558550                }
    559551
    560                 void Mangler_new::mangleRef( const ast::BaseInstType * refType, std::string prefix ) {
     552                void Mangler_new::mangleRef(
     553                                const ast::BaseInstType * refType, const std::string & prefix ) {
    561554                        printQualifiers( refType );
    562555
    563556                        mangleName += prefix + std::to_string( refType->name.length() ) + refType->name;
    564557
    565                         if ( mangleGenericParams ) {
    566                                 if ( ! refType->params.empty() ) {
    567                                         mangleName += "_";
    568                                         for ( const ast::Expr * param : refType->params ) {
    569                                                 auto paramType = dynamic_cast< const ast::TypeExpr * >( param );
    570                                                 assertf(paramType, "Aggregate parameters should be type expressions: %s", toCString(param));
    571                                                 maybeAccept( paramType->type.get(), *visitor );
    572                                         }
    573                                         mangleName += "_";
     558                        if ( mangleGenericParams && ! refType->params.empty() ) {
     559                                mangleName += "_";
     560                                for ( const ast::Expr * param : refType->params ) {
     561                                        auto paramType = dynamic_cast< const ast::TypeExpr * >( param );
     562                                        assertf(paramType, "Aggregate parameters should be type expressions: %s", toCString(param));
     563                                        maybeAccept( paramType->type.get(), *visitor );
    574564                                }
     565                                mangleName += "_";
    575566                        }
    576567                }
     
    656647                }
    657648
     649                // For debugging:
    658650                __attribute__((unused)) void printVarMap( const std::map< std::string, std::pair< int, int > > &varMap, std::ostream &os ) {
    659651                        for ( std::map< std::string, std::pair< int, int > >::const_iterator i = varMap.begin(); i != varMap.end(); ++i ) {
     
    665657                        // skip if not including qualifiers
    666658                        if ( typeMode ) return;
    667                         if ( auto ptype = dynamic_cast< const ast::FunctionType * >(type) ) {
    668                                 if ( ! ptype->forall.empty() ) {
    669                                         std::list< std::string > assertionNames;
    670                                         int dcount = 0, fcount = 0, vcount = 0, acount = 0;
    671                                         mangleName += Encoding::forall;
    672                                         for ( auto & decl : ptype->forall ) {
    673                                                 switch ( decl->kind ) {
    674                                                   case ast::TypeDecl::Kind::Dtype:
    675                                                         dcount++;
    676                                                         break;
    677                                                   case ast::TypeDecl::Kind::Ftype:
    678                                                         fcount++;
    679                                                         break;
    680                                                   case ast::TypeDecl::Kind::Ttype:
    681                                                         vcount++;
    682                                                         break;
    683                                                   default:
    684                                                         assertf( false, "unimplemented kind for type variable %s", SymTab::Mangler::Encoding::typeVariables[decl->kind].c_str() );
    685                                                 } // switch
    686                                                 varNums[ decl->name ] = std::make_pair( nextVarNum, (int)decl->kind );
    687                                         } // for
    688                                         for ( auto & assert : ptype->assertions ) {
    689                                                 assertionNames.push_back( ast::Pass<Mangler_new>::read(
    690                                                         assert->var.get(),
    691                                                         mangleOverridable, typeMode, mangleGenericParams, nextVarNum, varNums ) );
    692                                                 acount++;
    693                                         } // for
    694                                         mangleName += std::to_string( dcount ) + "_" + std::to_string( fcount ) + "_" + std::to_string( vcount ) + "_" + std::to_string( acount ) + "_";
    695                                         for(const auto & a : assertionNames) mangleName += a;
    696 //                                      std::copy( assertionNames.begin(), assertionNames.end(), std::ostream_iterator< std::string >( mangleName, "" ) );
    697                                         mangleName += "_";
    698                                 } // if
     659                        auto funcType = dynamic_cast<const ast::FunctionType *>( type );
     660                        if ( funcType && !funcType->forall.empty() ) {
     661                                std::list< std::string > assertionNames;
     662                                int dcount = 0, fcount = 0, vcount = 0, acount = 0;
     663                                mangleName += Encoding::forall;
     664                                for ( auto & decl : funcType->forall ) {
     665                                        switch ( decl->kind ) {
     666                                        case ast::TypeDecl::Dtype:
     667                                                dcount++;
     668                                                break;
     669                                        case ast::TypeDecl::Ftype:
     670                                                fcount++;
     671                                                break;
     672                                        case ast::TypeDecl::Ttype:
     673                                                vcount++;
     674                                                break;
     675                                        default:
     676                                                assertf( false, "unimplemented kind for type variable %s", SymTab::Mangler::Encoding::typeVariables[decl->kind].c_str() );
     677                                        } // switch
     678                                        varNums[ decl->name ] = std::make_pair( nextVarNum, (int)decl->kind );
     679                                } // for
     680                                for ( auto & assert : funcType->assertions ) {
     681                                        assertionNames.push_back( ast::Pass<Mangler_new>::read(
     682                                                assert->var.get(),
     683                                                mangleOverridable, typeMode, mangleGenericParams, nextVarNum, varNums ) );
     684                                        acount++;
     685                                } // for
     686                                mangleName += std::to_string( dcount ) + "_" + std::to_string( fcount ) + "_" + std::to_string( vcount ) + "_" + std::to_string( acount ) + "_";
     687                                for ( const auto & a : assertionNames ) mangleName += a;
     688                                mangleName += "_";
    699689                        } // if
    700690                        if ( ! inFunctionType ) {
Note: See TracChangeset for help on using the changeset viewer.