Changeset ba97ebf


Ignore:
Timestamp:
Apr 19, 2024, 5:29:53 PM (3 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
d7c0ad5
Parents:
fc1a3e2
Message:

The polyCost function was just a bit more complicated than it needed to be.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/PolyCost.cc

    rfc1a3e2 rba97ebf  
    2929        const ast::TypeEnvironment &env_;
    3030
    31         PolyCost( const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ) 
     31        PolyCost( const ast::SymbolTable & symtab, const ast::TypeEnvironment & env )
    3232        : symtab( symtab ), result( 0 ), env_( env ) {}
    3333
    3434        void previsit( const ast::TypeInstType * type ) {
    35                 if ( const ast::EqvClass * eqv = env_.lookup( *type ) ) /* && */ if ( eqv->bound ) {
     35                if ( const ast::EqvClass * eqv = env_.lookup( *type ) ; eqv && eqv->bound ) {
    3636                        if ( const ast::TypeInstType * otherType = eqv->bound.as< ast::TypeInstType >() ) {
    3737                                if ( symtab.lookupType( otherType->name ) ) {
    3838                                        // Bound to opaque type.
    39                                         result += 1;
     39                                        result = 1;
    4040                                }
    4141                        } else {
    4242                                // Bound to concrete type.
    43                                 result += 1;
     43                                result = 1;
    4444                        }
    4545                }
     
    5252        const ast::Type * type, const ast::SymbolTable & symtab, const ast::TypeEnvironment & env
    5353) {
    54         ast::Pass<PolyCost> costing( symtab, env );
    55         type->accept( costing );
    56         return (costing.core.result > 0) ? 1 : 0;
     54        return ast::Pass<PolyCost>::read( type, symtab, env );
    5755}
    5856
Note: See TracChangeset for help on using the changeset viewer.