Changeset 490ff5c3


Ignore:
Timestamp:
Feb 14, 2018, 1:54:14 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, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
44b4114
Parents:
54c9000
git-author:
Rob Schluntz <rschlunt@…> (02/14/18 12:00:25)
git-committer:
Rob Schluntz <rschlunt@…> (02/14/18 13:54:14)
Message:

Minor code cleanup

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r54c9000 r490ff5c3  
    13801380        void AlternativeFinder::Finder::postvisit( NameExpr *nameExpr ) {
    13811381                std::list< SymTab::Indexer::IdData > declList;
    1382                 indexer.lookupId( nameExpr->get_name(), declList );
    1383                 PRINT( std::cerr << "nameExpr is " << nameExpr->get_name() << std::endl; )
     1382                indexer.lookupId( nameExpr->name, declList );
     1383                PRINT( std::cerr << "nameExpr is " << nameExpr->name << std::endl; )
    13841384                for ( auto & data : declList ) {
    13851385                        Expression * newExpr = data.combine();
     
    14021402                // not sufficient to clone here, because variable's type may have changed
    14031403                // since the VariableExpr was originally created.
    1404                 alternatives.push_back( Alternative( new VariableExpr( variableExpr->get_var() ), env, Cost::zero ) );
     1404                alternatives.push_back( Alternative( new VariableExpr( variableExpr->var ), env, Cost::zero ) );
    14051405        }
    14061406
     
    14691469                // xxx - resolveTypeof?
    14701470                if ( StructInstType *structInst = dynamic_cast< StructInstType* >( offsetofExpr->get_type() ) ) {
    1471                         addOffsetof( structInst, offsetofExpr->get_member() );
     1471                        addOffsetof( structInst, offsetofExpr->member );
    14721472                } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( offsetofExpr->get_type() ) ) {
    1473                         addOffsetof( unionInst, offsetofExpr->get_member() );
     1473                        addOffsetof( unionInst, offsetofExpr->member );
    14741474                }
    14751475        }
     
    15481548                secondFinder.findWithAdjustment( logicalExpr->get_arg2() );
    15491549                if ( secondFinder.alternatives.empty() ) return;
    1550                 for ( AltList::const_iterator first = firstFinder.alternatives.begin(); first != firstFinder.alternatives.end(); ++first ) {
    1551                         for ( AltList::const_iterator second = secondFinder.alternatives.begin(); second != secondFinder.alternatives.end(); ++second ) {
     1550                for ( const Alternative & first : firstFinder.alternatives ) {
     1551                        for ( const Alternative & second : secondFinder.alternatives ) {
    15521552                                TypeEnvironment compositeEnv;
    1553                                 compositeEnv.simpleCombine( first->env );
    1554                                 compositeEnv.simpleCombine( second->env );
    1555 
    1556                                 LogicalExpr *newExpr = new LogicalExpr( first->expr->clone(), second->expr->clone(), logicalExpr->get_isAnd() );
    1557                                 alternatives.push_back( Alternative( newExpr, compositeEnv, first->cost + second->cost ) );
     1553                                compositeEnv.simpleCombine( first.env );
     1554                                compositeEnv.simpleCombine( second.env );
     1555
     1556                                LogicalExpr *newExpr = new LogicalExpr( first.expr->clone(), second.expr->clone(), logicalExpr->get_isAnd() );
     1557                                alternatives.push_back( Alternative( newExpr, compositeEnv, first.cost + second.cost ) );
    15581558                        }
    15591559                }
     
    16051605                AlternativeFinder secondFinder( indexer, newEnv );
    16061606                secondFinder.findWithAdjustment( commaExpr->get_arg2() );
    1607                 for ( AltList::const_iterator alt = secondFinder.alternatives.begin(); alt != secondFinder.alternatives.end(); ++alt ) {
    1608                         alternatives.push_back( Alternative( new CommaExpr( newFirstArg->clone(), alt->expr->clone() ), alt->env, alt->cost ) );
     1607                for ( const Alternative & alt : secondFinder.alternatives ) {
     1608                        alternatives.push_back( Alternative( new CommaExpr( newFirstArg->clone(), alt.expr->clone() ), alt.env, alt.cost ) );
    16091609                } // for
    16101610                delete newFirstArg;
     
    16141614                // resolve low and high, accept alternatives whose low and high types unify
    16151615                AlternativeFinder firstFinder( indexer, env );
    1616                 firstFinder.findWithAdjustment( rangeExpr->get_low() );
     1616                firstFinder.findWithAdjustment( rangeExpr->low );
    16171617                if ( firstFinder.alternatives.empty() ) return;
    16181618                AlternativeFinder secondFinder( indexer, env );
    1619                 secondFinder.findWithAdjustment( rangeExpr->get_high() );
     1619                secondFinder.findWithAdjustment( rangeExpr->high );
    16201620                if ( secondFinder.alternatives.empty() ) return;
    1621                 for ( AltList::const_iterator first = firstFinder.alternatives.begin(); first != firstFinder.alternatives.end(); ++first ) {
    1622                         for ( AltList::const_iterator second = secondFinder.alternatives.begin(); second != secondFinder.alternatives.end(); ++second ) {
     1621                for ( const Alternative & first : firstFinder.alternatives ) {
     1622                        for ( const Alternative & second : secondFinder.alternatives ) {
    16231623                                TypeEnvironment compositeEnv;
    1624                                 compositeEnv.simpleCombine( first->env );
    1625                                 compositeEnv.simpleCombine( second->env );
     1624                                compositeEnv.simpleCombine( first.env );
     1625                                compositeEnv.simpleCombine( second.env );
    16261626                                OpenVarSet openVars;
    16271627                                AssertionSet needAssertions, haveAssertions;
    1628                                 Alternative newAlt( 0, compositeEnv, first->cost + second->cost );
     1628                                Alternative newAlt( 0, compositeEnv, first.cost + second.cost );
    16291629                                Type* commonType = nullptr;
    1630                                 if ( unify( first->expr->get_result(), second->expr->get_result(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {
    1631                                         RangeExpr *newExpr = new RangeExpr( first->expr->clone(), second->expr->clone() );
    1632                                         newExpr->set_result( commonType ? commonType : first->expr->get_result()->clone() );
     1630                                if ( unify( first.expr->result, second.expr->result, newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {
     1631                                        RangeExpr * newExpr = new RangeExpr( first.expr->clone(), second.expr->clone() );
     1632                                        newExpr->result = commonType ? commonType : first.expr->result->clone();
    16331633                                        newAlt.expr = newExpr;
    16341634                                        inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( alternatives ) );
  • src/SymTab/Indexer.cc

    r54c9000 r490ff5c3  
    434434                        }
    435435                } else {
    436                         // Check that a Cforall declaration doesn't overload any C declaration
     436                        // Check that a Cforall declaration doesn't override any C declaration
    437437                        if ( hasCompatibleCDecl( name, mangleName, scope ) ) {
    438438                                throw SemanticError( "Cforall declaration hides C function ", decl );
     
    654654
    655655        void Indexer::print( std::ostream &os, int indent ) const {
    656             using std::cerr;
     656                using std::cerr;
    657657
    658658                if ( tables ) {
  • src/SymTab/Indexer.h

    r54c9000 r490ff5c3  
    4040
    4141                struct IdData {
    42                         DeclarationWithType * id;
    43                         Expression * baseExpr; // WithExpr
     42                        DeclarationWithType * id = nullptr;
     43                        Expression * baseExpr = nullptr; // WithExpr
     44
     45                        /// non-null if this declaration is deleted
     46                        BaseSyntaxNode * deleteStmt = nullptr;
    4447
    4548                        Expression * combine() const;
  • src/Tuples/Explode.h

    r54c9000 r490ff5c3  
    4343        /// Append alternative to an OutputIterator of Alternatives
    4444        template<typename OutputIterator>
    45         void append( OutputIterator out, Expression* expr, const ResolvExpr::TypeEnvironment& env, 
     45        void append( OutputIterator out, Expression* expr, const ResolvExpr::TypeEnvironment& env,
    4646                        const ResolvExpr::Cost& cost, const ResolvExpr::Cost& cvtCost ) {
    4747                *out++ = ResolvExpr::Alternative{ expr, env, cost, cvtCost };
     
    4949
    5050        /// Append alternative to an ExplodedActual
    51         static inline void append( ResolvExpr::ExplodedActual& ea, Expression* expr, 
     51        static inline void append( ResolvExpr::ExplodedActual& ea, Expression* expr,
    5252                        const ResolvExpr::TypeEnvironment&, const ResolvExpr::Cost&, const ResolvExpr::Cost& ) {
    5353                ea.exprs.emplace_back( expr );
     
    5757        /// helper function used by explode
    5858        template< typename Output >
    59         void explodeUnique( Expression * expr, const ResolvExpr::Alternative & alt, 
     59        void explodeUnique( Expression * expr, const ResolvExpr::Alternative & alt,
    6060                        const SymTab::Indexer & indexer, Output&& out, bool isTupleAssign ) {
    6161                if ( isTupleAssign ) {
     
    6363                        if ( CastExpr * castExpr = isReferenceCast( expr ) ) {
    6464                                ResolvExpr::AltList alts;
    65                                 explodeUnique( 
     65                                explodeUnique(
    6666                                        castExpr->get_arg(), alt, indexer, back_inserter( alts ), isTupleAssign );
    6767                                for ( ResolvExpr::Alternative & alt : alts ) {
    6868                                        // distribute reference cast over all components
    69                                         append( std::forward<Output>(out), distributeReference( alt.release_expr() ), 
     69                                        append( std::forward<Output>(out), distributeReference( alt.release_expr() ),
    7070                                                alt.env, alt.cost, alt.cvtCost );
    7171                                }
     
    108108        /// expands a tuple-valued alternative into multiple alternatives, each with a non-tuple-type
    109109        template< typename Output >
    110         void explode( const ResolvExpr::Alternative &alt, const SymTab::Indexer & indexer, 
     110        void explode( const ResolvExpr::Alternative &alt, const SymTab::Indexer & indexer,
    111111                        Output&& out, bool isTupleAssign = false ) {
    112112                explodeUnique( alt.expr, alt, indexer, std::forward<Output>(out), isTupleAssign );
     
    115115        // explode list of alternatives
    116116        template< typename AltIterator, typename Output >
    117         void explode( AltIterator altBegin, AltIterator altEnd, const SymTab::Indexer & indexer, 
     117        void explode( AltIterator altBegin, AltIterator altEnd, const SymTab::Indexer & indexer,
    118118                        Output&& out, bool isTupleAssign = false ) {
    119119                for ( ; altBegin != altEnd; ++altBegin ) {
     
    123123
    124124        template< typename Output >
    125         void explode( const ResolvExpr::AltList & alts, const SymTab::Indexer & indexer, Output&& out, 
     125        void explode( const ResolvExpr::AltList & alts, const SymTab::Indexer & indexer, Output&& out,
    126126                        bool isTupleAssign = false ) {
    127127                explode( alts.begin(), alts.end(), indexer, std::forward<Output>(out), isTupleAssign );
Note: See TracChangeset for help on using the changeset viewer.