Changeset fc1a3e2 for src/ResolvExpr


Ignore:
Timestamp:
Apr 19, 2024, 2:36:52 PM (3 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
ba97ebf
Parents:
b9b6efb
Message:

Style update. Focused on indentation and trailing whitespace.

Location:
src/ResolvExpr
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CandidateFinder.cpp

    rb9b6efb rfc1a3e2  
    14121412        }
    14131413
    1414     void Finder::postvisit(const ast::VariableExpr *variableExpr) {
    1415         // not sufficient to just pass `variableExpr` here, type might have changed
    1416 
    1417         auto cand = new Candidate(variableExpr, tenv);
    1418         candidates.emplace_back(cand);
    1419     }
     1414        void Finder::postvisit(const ast::VariableExpr *variableExpr) {
     1415                // not sufficient to just pass `variableExpr` here, type might have changed
     1416
     1417                auto cand = new Candidate(variableExpr, tenv);
     1418                candidates.emplace_back(cand);
     1419        }
    14201420
    14211421        void Finder::postvisit( const ast::ConstantExpr * constantExpr ) {
     
    21332133
    21342134// get the valueE(...) ApplicationExpr that returns the enum value
    2135 const ast::Expr * getValueEnumCall( 
    2136         const ast::Expr * expr, 
     2135const ast::Expr * getValueEnumCall(
     2136        const ast::Expr * expr,
    21372137        const ResolvExpr::ResolveContext & context, const ast::TypeEnvironment & env ) {
    21382138                auto callExpr = new ast::UntypedExpr(
  • src/ResolvExpr/CommonType.cc

    rb9b6efb rfc1a3e2  
    397397                        }
    398398                } else if ( auto type2AsAttr = dynamic_cast< const ast::EnumAttrType * >( type2 ) ) {
    399             if ( type2AsAttr->attr == ast::EnumAttribute::Posn ) {
    400                             ast::BasicKind kind = commonTypes[ basic->kind ][ ast::BasicKind::SignedInt ];
    401                             if (
    402                                     ( ( kind == basic->kind && basic->qualifiers >= type2->qualifiers )
    403                                             || widen.first )
    404                                     && ( ( kind != basic->kind && basic->qualifiers <= type2->qualifiers )
    405                                             || widen.second )
    406                             ) {
    407                                     result = new ast::BasicType{ kind, basic->qualifiers | type2->qualifiers };
    408                             }
    409             }
     399                        if ( type2AsAttr->attr == ast::EnumAttribute::Posn ) {
     400                                ast::BasicKind kind = commonTypes[ basic->kind ][ ast::BasicKind::SignedInt ];
     401                                if (
     402                                        ( ( kind == basic->kind && basic->qualifiers >= type2->qualifiers )
     403                                                || widen.first )
     404                                        && ( ( kind != basic->kind && basic->qualifiers <= type2->qualifiers )
     405                                                || widen.second )
     406                                ) {
     407                                        result = new ast::BasicType{ kind, basic->qualifiers | type2->qualifiers };
     408                                }
     409                        }
    410410                }
    411411        }
     
    519519                                                                // xxx - assume LHS is always the target type
    520520
    521                                                                 if ( ! ((widen.second && ref2->qualifiers.is_mutex) 
     521                                                                if ( ! ((widen.second && ref2->qualifiers.is_mutex)
    522522                                                                || (ref1->qualifiers.is_mutex == ref2->qualifiers.is_mutex ))) return;
    523523
  • src/ResolvExpr/ConversionCost.cc

    rb9b6efb rfc1a3e2  
    379379
    380380void ConversionCost::postvisit( const ast::EnumAttrType * src ) {
    381     auto dstAsEnumAttrType = dynamic_cast<const ast::EnumAttrType *>(dst);
     381        auto dstAsEnumAttrType = dynamic_cast<const ast::EnumAttrType *>(dst);
    382382        assert( src->attr != ast::EnumAttribute::Label );
    383     if ( src->attr == ast::EnumAttribute::Value ) {
    384         if ( dstAsEnumAttrType && dstAsEnumAttrType->attr == ast::EnumAttribute::Value) {
    385             cost = costCalc( src->instance, dstAsEnumAttrType->instance, srcIsLvalue, symtab, env );
    386         } else {
    387             auto baseType = src->instance->base->base;
    388             cost = costCalc( baseType, dst, srcIsLvalue, symtab, env );
     383        if ( src->attr == ast::EnumAttribute::Value ) {
     384                if ( dstAsEnumAttrType && dstAsEnumAttrType->attr == ast::EnumAttribute::Value) {
     385                        cost = costCalc( src->instance, dstAsEnumAttrType->instance, srcIsLvalue, symtab, env );
     386                } else {
     387                        auto baseType = src->instance->base->base;
     388                        cost = costCalc( baseType, dst, srcIsLvalue, symtab, env );
    389389                        if ( cost < Cost::infinity ) {
    390390                                cost.incUnsafe();
    391391                        }
    392         }
    393     } else { // ast::EnumAttribute::Posn
    394         if ( auto dstBase = dynamic_cast<const ast::EnumInstType *>( dst ) ) {
    395                     cost = costCalc( src->instance, dstBase, srcIsLvalue, symtab, env );
    396                     if ( cost < Cost::unsafe ) cost.incSafe();
    397             } else {
    398                     static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) };
    399                     cost = costCalc( integer, dst, srcIsLvalue, symtab, env );
    400                     if ( cost < Cost::unsafe ) {
    401                             cost.incSafe();
    402                     }
    403             }
    404     }
     392                }
     393        } else { // ast::EnumAttribute::Posn
     394                if ( auto dstBase = dynamic_cast<const ast::EnumInstType *>( dst ) ) {
     395                        cost = costCalc( src->instance, dstBase, srcIsLvalue, symtab, env );
     396                        if ( cost < Cost::unsafe ) cost.incSafe();
     397                } else {
     398                        static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) };
     399                        cost = costCalc( integer, dst, srcIsLvalue, symtab, env );
     400                        if ( cost < Cost::unsafe ) {
     401                                cost.incSafe();
     402                        }
     403                }
     404        }
    405405}
    406406
  • src/ResolvExpr/Unify.cc

    rb9b6efb rfc1a3e2  
    307307                                // type unification calls expression unification (mutual recursion)
    308308                                if ( ! unify(array->dimension, array2->dimension,
    309                                     tenv, need, have, open, widen) ) return;
     309                                        tenv, need, have, open, widen) ) return;
    310310                        }
    311311
     
    455455                        // check that the other type is compatible and named the same
    456456                        auto otherInst = dynamic_cast< const XInstType * >( other );
    457                         if (otherInst && inst->name == otherInst->name) 
     457                        if (otherInst && inst->name == otherInst->name)
    458458                                this->result = otherInst;
    459459                        return otherInst;
     
    542542                        // Lazy approach for now
    543543                        if ( auto otherPos = dynamic_cast< const ast::EnumAttrType *>(type2) ) {
    544                             if ( enumAttr->match(otherPos) ) {
    545                                     result = otherPos;
    546                             }
    547             } 
     544                                if ( enumAttr->match(otherPos) ) {
     545                                        result = otherPos;
     546                                }
     547                        }
    548548                }
    549549
Note: See TracChangeset for help on using the changeset viewer.