Changeset 24ceace for src


Ignore:
Timestamp:
May 2, 2022, 3:19:03 AM (3 years ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
12bb5ab1, 49a1684
Parents:
9e7236f4 (diff), 4b4f95f (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:
7 added
18 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r9e7236f4 r24ceace  
    1010// Created On       : Thu May 09 15::37::05 2019
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Mar 16 15:01:00 2022
    13 // Update Count     : 42
     12// Last Modified On : Wed Apr 20 13:58:00 2022
     13// Update Count     : 43
    1414//
    1515
     
    562562                for ( auto clause : node->clauses ) {
    563563                        stmt->clauses.push_back({{
    564                                         get<Expression>().accept1( clause.target.func ),
    565                                         get<Expression>().acceptL( clause.target.args ),
     564                                        get<Expression>().accept1( clause->target_func ),
     565                                        get<Expression>().acceptL( clause->target_args ),
    566566                                },
    567                                 get<Statement>().accept1( clause.stmt ),
    568                                 get<Expression>().accept1( clause.cond ),
     567                                get<Statement>().accept1( clause->stmt ),
     568                                get<Expression>().accept1( clause->cond ),
    569569                        });
    570570                }
    571571                stmt->timeout = {
    572                         get<Expression>().accept1( node->timeout.time ),
    573                         get<Statement>().accept1( node->timeout.stmt ),
    574                         get<Expression>().accept1( node->timeout.cond ),
     572                        get<Expression>().accept1( node->timeout_time ),
     573                        get<Statement>().accept1( node->timeout_stmt ),
     574                        get<Expression>().accept1( node->timeout_cond ),
    575575                };
    576576                stmt->orelse = {
    577                         get<Statement>().accept1( node->orElse.stmt ),
    578                         get<Expression>().accept1( node->orElse.cond ),
     577                        get<Statement>().accept1( node->else_stmt ),
     578                        get<Expression>().accept1( node->else_cond ),
    579579                };
    580580                return stmtPostamble( stmt, node );
     581        }
     582
     583        const ast::WaitForClause * visit( const ast::WaitForClause * node ) override final {
     584                // There is no old-AST WaitForClause, so this should never be called.
     585                assert( !node );
     586                return nullptr;
    581587        }
    582588
     
    20962102                stmt->clauses.reserve( old->clauses.size() );
    20972103                for (size_t i = 0 ; i < old->clauses.size() ; ++i) {
    2098                         stmt->clauses.push_back({
    2099                                 ast::WaitForStmt::Target{
    2100                                         GET_ACCEPT_1(clauses[i].target.function, Expr),
    2101                                         GET_ACCEPT_V(clauses[i].target.arguments, Expr)
    2102                                 },
    2103                                 GET_ACCEPT_1(clauses[i].statement, Stmt),
    2104                                 GET_ACCEPT_1(clauses[i].condition, Expr)
    2105                         });
    2106                 }
    2107                 stmt->timeout = {
    2108                         GET_ACCEPT_1(timeout.time, Expr),
    2109                         GET_ACCEPT_1(timeout.statement, Stmt),
    2110                         GET_ACCEPT_1(timeout.condition, Expr),
    2111                 };
    2112                 stmt->orElse = {
    2113                         GET_ACCEPT_1(orelse.statement, Stmt),
    2114                         GET_ACCEPT_1(orelse.condition, Expr),
    2115                 };
     2104                        auto clause = new ast::WaitForClause( old->location );
     2105
     2106                        clause->target_func = GET_ACCEPT_1(clauses[i].target.function, Expr);
     2107                        clause->target_args = GET_ACCEPT_V(clauses[i].target.arguments, Expr);
     2108                        clause->stmt = GET_ACCEPT_1(clauses[i].statement, Stmt);
     2109                        clause->cond = GET_ACCEPT_1(clauses[i].condition, Expr);
     2110
     2111                        stmt->clauses.push_back( clause );
     2112                }
     2113                stmt->timeout_time = GET_ACCEPT_1(timeout.time, Expr);
     2114                stmt->timeout_stmt = GET_ACCEPT_1(timeout.statement, Stmt);
     2115                stmt->timeout_cond = GET_ACCEPT_1(timeout.condition, Expr);
     2116                stmt->else_stmt = GET_ACCEPT_1(orelse.statement, Stmt);
     2117                stmt->else_cond = GET_ACCEPT_1(orelse.condition, Expr);
    21162118
    21172119                this->node = stmt;
     
    27272729                        ty->forall.emplace_back(new ast::TypeInstType(param));
    27282730                        for (auto asst : param->assertions) {
    2729                                 ty->assertions.emplace_back(new ast::VariableExpr({}, asst));
     2731                                ty->assertions.emplace_back(
     2732                                        new ast::VariableExpr(param->location, asst));
    27302733                        }
    27312734                }
  • src/AST/Fwd.hpp

    r9e7236f4 r24ceace  
    5656class SuspendStmt;
    5757class WaitForStmt;
     58class WaitForClause;
    5859class WithStmt;
    5960class DeclStmt;
  • src/AST/Node.cpp

    r9e7236f4 r24ceace  
    176176template class ast::ptr_base< ast::WaitForStmt, ast::Node::ref_type::weak >;
    177177template class ast::ptr_base< ast::WaitForStmt, ast::Node::ref_type::strong >;
     178template class ast::ptr_base< ast::WaitForClause, ast::Node::ref_type::weak >;
     179template class ast::ptr_base< ast::WaitForClause, ast::Node::ref_type::strong >;
    178180template class ast::ptr_base< ast::WithStmt, ast::Node::ref_type::weak >;
    179181template class ast::ptr_base< ast::WithStmt, ast::Node::ref_type::strong >;
  • src/AST/Pass.hpp

    r9e7236f4 r24ceace  
    158158        const ast::Stmt *             visit( const ast::SuspendStmt          * ) override final;
    159159        const ast::Stmt *             visit( const ast::WaitForStmt          * ) override final;
     160        const ast::WaitForClause *    visit( const ast::WaitForClause        * ) override final;
    160161        const ast::Decl *             visit( const ast::WithStmt             * ) override final;
    161162        const ast::NullStmt *         visit( const ast::NullStmt             * ) override final;
  • src/AST/Pass.impl.hpp

    r9e7236f4 r24ceace  
    10101010const ast::Stmt * ast::Pass< core_t >::visit( const ast::WaitForStmt * node ) {
    10111011        VISIT_START( node );
    1012                 // for( auto & clause : node->clauses ) {
    1013                 //      maybeAccept_impl( clause.target.function, *this );
    1014                 //      maybeAccept_impl( clause.target.arguments, *this );
    1015 
    1016                 //      maybeAccept_impl( clause.statement, *this );
    1017                 //      maybeAccept_impl( clause.condition, *this );
    1018                 // }
    1019 
    1020         if ( __visit_children() ) {
    1021                 std::vector<WaitForStmt::Clause> new_clauses;
    1022                 new_clauses.reserve( node->clauses.size() );
    1023                 bool mutated = false;
    1024                 for( const auto & clause : node->clauses ) {
    1025 
    1026                         const Expr * func = clause.target.func ? clause.target.func->accept(*this) : nullptr;
    1027                         if(func != clause.target.func) mutated = true;
    1028                         else func = nullptr;
    1029 
    1030                         std::vector<ptr<Expr>> new_args;
    1031                         new_args.reserve(clause.target.args.size());
    1032                         for( const auto & arg : clause.target.args ) {
    1033                                 auto a = arg->accept(*this);
    1034                                 if( a != arg ) {
    1035                                         mutated = true;
    1036                                         new_args.push_back( a );
    1037                                 } else
    1038                                         new_args.push_back( nullptr );
    1039                         }
    1040 
    1041                         const Stmt * stmt = clause.stmt ? clause.stmt->accept(*this) : nullptr;
    1042                         if(stmt != clause.stmt) mutated = true;
    1043                         else stmt = nullptr;
    1044 
    1045                         const Expr * cond = clause.cond ? clause.cond->accept(*this) : nullptr;
    1046                         if(cond != clause.cond) mutated = true;
    1047                         else cond = nullptr;
    1048 
    1049                         new_clauses.push_back( WaitForStmt::Clause{ {func, std::move(new_args) }, stmt, cond } );
    1050                 }
    1051 
    1052                 if(mutated) {
    1053                         auto n = __pass::mutate<core_t>(node);
    1054                         for(size_t i = 0; i < new_clauses.size(); i++) {
    1055                                 if(new_clauses.at(i).target.func != nullptr) swap(n->clauses.at(i).target.func, new_clauses.at(i).target.func);
    1056 
    1057                                 for(size_t j = 0; j < new_clauses.at(i).target.args.size(); j++) {
    1058                                         if(new_clauses.at(i).target.args.at(j) != nullptr) swap(n->clauses.at(i).target.args.at(j), new_clauses.at(i).target.args.at(j));
    1059                                 }
    1060 
    1061                                 if(new_clauses.at(i).stmt != nullptr) swap(n->clauses.at(i).stmt, new_clauses.at(i).stmt);
    1062                                 if(new_clauses.at(i).cond != nullptr) swap(n->clauses.at(i).cond, new_clauses.at(i).cond);
    1063                         }
    1064                         node = n;
    1065                 }
    1066         }
    1067 
    1068         #define maybe_accept(field) \
    1069                 if(node->field) { \
    1070                         auto nval = call_accept( node->field ); \
    1071                         if(nval.differs ) { \
    1072                                 auto nparent = __pass::mutate<core_t>(node); \
    1073                                 nparent->field = nval.value; \
    1074                                 node = nparent; \
    1075                         } \
    1076                 }
    1077 
    1078         if ( __visit_children() ) {
    1079                 maybe_accept( timeout.time );
    1080                 maybe_accept( timeout.stmt );
    1081                 maybe_accept( timeout.cond );
    1082                 maybe_accept( orElse.stmt  );
    1083                 maybe_accept( orElse.cond  );
    1084         }
    1085 
    1086         #undef maybe_accept
     1012
     1013        if ( __visit_children() ) {
     1014                maybe_accept( node, &WaitForStmt::clauses );
     1015                maybe_accept( node, &WaitForStmt::timeout_time );
     1016                maybe_accept( node, &WaitForStmt::timeout_stmt );
     1017                maybe_accept( node, &WaitForStmt::timeout_cond );
     1018                maybe_accept( node, &WaitForStmt::else_stmt );
     1019                maybe_accept( node, &WaitForStmt::else_cond );
     1020        }
    10871021
    10881022        VISIT_END( Stmt, node );
     1023}
     1024
     1025//--------------------------------------------------------------------------
     1026// WaitForClause
     1027template< typename core_t >
     1028const ast::WaitForClause * ast::Pass< core_t >::visit( const ast::WaitForClause * node ) {
     1029        VISIT_START( node );
     1030
     1031        if ( __visit_children() ) {
     1032                maybe_accept( node, &WaitForClause::target_func );
     1033                maybe_accept( node, &WaitForClause::target_args );
     1034                maybe_accept( node, &WaitForClause::stmt );
     1035                maybe_accept( node, &WaitForClause::cond );
     1036        }
     1037
     1038        VISIT_END( WaitForClause, node );
    10891039}
    10901040
  • src/AST/Print.cpp

    r9e7236f4 r24ceace  
    760760                indent += 2;
    761761                for( const auto & clause : node->clauses ) {
    762                         os << indent-1 << "target function: ";
    763                         safe_print( clause.target.func );
    764 
    765                         if ( ! clause.target.args.empty() ) {
    766                                 os << endl << indent-1 << "... with arguments:" << endl;
    767                                 for( const ast::Expr * arg : clause.target.args ) {
    768                                         arg->accept( *this );
    769                                 }
     762                        clause->accept( *this );
     763                }
     764
     765                if ( node->timeout_time ) {
     766                        os << indent-1 << "timeout of:" << endl;
     767                        node->timeout_time->accept( *this );
     768
     769                        if ( node->timeout_stmt ) {
     770                                os << indent-1 << "... with statment:" << endl;
     771                                node->timeout_stmt->accept( *this );
    770772                        }
    771773
    772                         if ( clause.stmt ) {
    773                                 os << indent-1 << "... with statment:" << endl;
    774                                 clause.stmt->accept( *this );
     774                        if ( node->timeout_cond ) {
     775                                os << indent-1 << "... with condition:" << endl;
     776                                node->timeout_cond->accept( *this );
    775777                        }
    776 
    777                         if ( clause.cond ) {
     778                }
     779
     780                if ( node->else_stmt ) {
     781                        os << indent-1 << "else:" << endl;
     782                        node->else_stmt->accept( *this );
     783
     784                        if ( node->else_cond ) {
    778785                                os << indent-1 << "... with condition:" << endl;
    779                                 clause.cond->accept( *this );
     786                                node->else_cond->accept( *this );
    780787                        }
    781788                }
    782789
    783                 if ( node->timeout.time ) {
    784                         os << indent-1 << "timeout of:" << endl;
    785                         node->timeout.time->accept( *this );
    786 
    787                         if ( node->timeout.stmt ) {
    788                                 os << indent-1 << "... with statment:" << endl;
    789                                 node->timeout.stmt->accept( *this );
     790                return node;
     791        }
     792
     793        virtual const ast::WaitForClause * visit( const ast::WaitForClause * node ) override final {
     794                os << indent-1 << "target function: ";
     795                safe_print( node->target_func );
     796
     797                if ( !node->target_args.empty() ) {
     798                        os << endl << indent-1 << "... with arguments:" << endl;
     799                        for( const ast::Expr * arg : node->target_args ) {
     800                                arg->accept( *this );
    790801                        }
    791 
    792                         if ( node->timeout.cond ) {
    793                                 os << indent-1 << "... with condition:" << endl;
    794                                 node->timeout.cond->accept( *this );
    795                         }
    796                 }
    797 
    798                 if ( node->orElse.stmt ) {
    799                         os << indent-1 << "else:" << endl;
    800                         node->orElse.stmt->accept( *this );
    801 
    802                         if ( node->orElse.cond ) {
    803                                 os << indent-1 << "... with condition:" << endl;
    804                                 node->orElse.cond->accept( *this );
    805                         }
    806                 }
    807                 indent -= 2;
     802                }
     803
     804                if ( node->stmt ) {
     805                        os << indent-1 << "... with statment:" << endl;
     806                        node->stmt->accept( *this );
     807                }
     808
     809                if ( node->cond ) {
     810                        os << indent-1 << "... with condition:" << endl;
     811                        node->cond->accept( *this );
     812                }
    808813
    809814                return node;
  • src/AST/Stmt.hpp

    r9e7236f4 r24ceace  
    1010// Created On       : Wed May  8 13:00:00 2019
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Mar 28  9:50:00 2022
    13 // Update Count     : 35
     12// Last Modified On : Wed Apr 20 14:34:00 2022
     13// Update Count     : 36
    1414//
    1515
     
    378378class WaitForStmt final : public Stmt {
    379379  public:
    380         struct Target {
    381                 ptr<Expr> func;
    382                 std::vector<ptr<Expr>> args;
    383         };
    384 
    385         struct Clause {
    386                 Target target;
    387                 ptr<Stmt> stmt;
    388                 ptr<Expr> cond;
    389         };
    390 
    391         struct Timeout {
    392                 ptr<Expr> time;
    393                 ptr<Stmt> stmt;
    394                 ptr<Expr> cond;
    395         };
    396 
    397         struct OrElse {
    398                 ptr<Stmt> stmt;
    399                 ptr<Expr> cond;
    400         };
    401 
    402         std::vector<Clause> clauses;
    403         Timeout timeout;
    404         OrElse orElse;
     380        std::vector<ptr<WaitForClause>> clauses;
     381        ptr<Expr> timeout_time;
     382        ptr<Stmt> timeout_stmt;
     383        ptr<Expr> timeout_cond;
     384        ptr<Stmt> else_stmt;
     385        ptr<Expr> else_cond;
    405386
    406387        WaitForStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} )
     
    411392        WaitForStmt * clone() const override { return new WaitForStmt{ *this }; }
    412393        MUTATE_FRIEND
     394};
     395
     396class WaitForClause final : public StmtClause {
     397  public:
     398    ptr<Expr> target_func;
     399    std::vector<ptr<Expr>> target_args;
     400    ptr<Stmt> stmt;
     401    ptr<Expr> cond;
     402
     403    WaitForClause( const CodeLocation & loc )
     404                : StmtClause( loc ) {}
     405
     406        const WaitForClause * accept( Visitor & v ) const override { return v.visit( this ); }
     407  private:
     408    WaitForClause * clone() const override { return new WaitForClause{ *this }; }
     409    MUTATE_FRIEND
    413410};
    414411
  • src/AST/Visitor.hpp

    r9e7236f4 r24ceace  
    5050    virtual const ast::Stmt *             visit( const ast::SuspendStmt          * ) = 0;
    5151    virtual const ast::Stmt *             visit( const ast::WaitForStmt          * ) = 0;
     52    virtual const ast::WaitForClause *    visit( const ast::WaitForClause        * ) = 0;
    5253    virtual const ast::Decl *             visit( const ast::WithStmt             * ) = 0;
    5354    virtual const ast::NullStmt *         visit( const ast::NullStmt             * ) = 0;
  • src/Common/CodeLocationTools.cpp

    r9e7236f4 r24ceace  
    121121    macro(SuspendStmt, Stmt) \
    122122    macro(WaitForStmt, Stmt) \
     123    macro(WaitForClause, WaitForClause) \
    123124    macro(WithStmt, Decl) \
    124125    macro(NullStmt, NullStmt) \
  • src/Common/utility.h

    r9e7236f4 r24ceace  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb 11 13:00:36 2020
    13 // Update Count     : 50
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon Apr 25 14:26:00 2022
     13// Update Count     : 51
    1414//
    1515
     
    230230}
    231231
     232template<typename Container, typename Pred>
     233void erase_if( Container & cont, Pred && pred ) {
     234        auto keep_end = std::remove_if( cont.begin(), cont.end(), pred );
     235        cont.erase( keep_end, cont.end() );
     236}
     237
    232238template< typename... Args >
    233239auto zip(Args&&... args) -> decltype(zipWith(std::forward<Args>(args)..., std::make_pair)) {
  • src/ResolvExpr/Resolver.cc

    r9e7236f4 r24ceace  
    1010// Created On       : Sun May 17 12:17:01 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Mar 18 10:41:00 2022
    13 // Update Count     : 247
     12// Last Modified On : Wed Apr 20 10:41:00 2022
     13// Update Count     : 248
    1414//
    1515
     
    17221722                // Resolve all clauses first
    17231723                for ( unsigned i = 0; i < stmt->clauses.size(); ++i ) {
    1724                         const ast::WaitForStmt::Clause & clause = stmt->clauses[i];
     1724                        const ast::WaitForClause & clause = *stmt->clauses[i];
    17251725
    17261726                        ast::TypeEnvironment env;
     
    17281728
    17291729                        // Find all candidates for a function in canonical form
    1730                         funcFinder.find( clause.target.func, ResolvMode::withAdjustment() );
     1730                        funcFinder.find( clause.target_func, ResolvMode::withAdjustment() );
    17311731
    17321732                        if ( funcFinder.candidates.empty() ) {
    17331733                                stringstream ss;
    17341734                                ss << "Use of undeclared indentifier '";
    1735                                 ss << clause.target.func.strict_as< ast::NameExpr >()->name;
     1735                                ss << clause.target_func.strict_as< ast::NameExpr >()->name;
    17361736                                ss << "' in call to waitfor";
    17371737                                SemanticError( stmt->location, ss.str() );
    17381738                        }
    17391739
    1740                         if ( clause.target.args.empty() ) {
     1740                        if ( clause.target_args.empty() ) {
    17411741                                SemanticError( stmt->location,
    17421742                                        "Waitfor clause must have at least one mutex parameter");
     
    17451745                        // Find all alternatives for all arguments in canonical form
    17461746                        std::vector< CandidateFinder > argFinders =
    1747                                 funcFinder.findSubExprs( clause.target.args );
     1747                                funcFinder.findSubExprs( clause.target_args );
    17481748
    17491749                        // List all combinations of arguments
     
    19181918
    19191919                        // build new clause
    1920                         ast::WaitForStmt::Clause clause2;
    1921 
    1922                         clause2.target.func = funcCandidates.front()->expr;
    1923 
    1924                         clause2.target.args.reserve( clause.target.args.size() );
     1920                        auto clause2 = new ast::WaitForClause( clause.location );
     1921
     1922                        clause2->target_func = funcCandidates.front()->expr;
     1923
     1924                        clause2->target_args.reserve( clause.target_args.size() );
    19251925                        const ast::StructDecl * decl_monitor = symtab.lookupStruct( "monitor$" );
    19261926                        for ( auto arg : argsCandidates.front() ) {
     
    19391939                                );
    19401940
    1941                                 clause2.target.args.emplace_back( findSingleExpression( init, context ) );
     1941                                clause2->target_args.emplace_back( findSingleExpression( init, context ) );
    19421942                        }
    19431943
    19441944                        // Resolve the conditions as if it were an IfStmt, statements normally
    1945                         clause2.cond = findSingleExpression( clause.cond, context );
    1946                         clause2.stmt = clause.stmt->accept( *visitor );
     1945                        clause2->cond = findSingleExpression( clause.cond, context );
     1946                        clause2->stmt = clause.stmt->accept( *visitor );
    19471947
    19481948                        // set results into stmt
    19491949                        auto n = mutate( stmt );
    1950                         n->clauses[i] = std::move( clause2 );
     1950                        n->clauses[i] = clause2;
    19511951                        stmt = n;
    19521952                }
    19531953
    1954                 if ( stmt->timeout.stmt ) {
     1954                if ( stmt->timeout_stmt ) {
    19551955                        // resolve the timeout as a size_t, the conditions like IfStmt, and stmts normally
    1956                         ast::WaitForStmt::Timeout timeout2;
    1957 
    19581956                        ast::ptr< ast::Type > target =
    19591957                                new ast::BasicType{ ast::BasicType::LongLongUnsignedInt };
    1960                         timeout2.time = findSingleExpression( stmt->timeout.time, target, context );
    1961                         timeout2.cond = findSingleExpression( stmt->timeout.cond, context );
    1962                         timeout2.stmt = stmt->timeout.stmt->accept( *visitor );
     1958                        auto timeout_time = findSingleExpression( stmt->timeout_time, target, context );
     1959                        auto timeout_cond = findSingleExpression( stmt->timeout_cond, context );
     1960                        auto timeout_stmt = stmt->timeout_stmt->accept( *visitor );
    19631961
    19641962                        // set results into stmt
    19651963                        auto n = mutate( stmt );
    1966                         n->timeout = std::move( timeout2 );
     1964                        n->timeout_time = std::move( timeout_time );
     1965                        n->timeout_cond = std::move( timeout_cond );
     1966                        n->timeout_stmt = std::move( timeout_stmt );
    19671967                        stmt = n;
    19681968                }
    19691969
    1970                 if ( stmt->orElse.stmt ) {
     1970                if ( stmt->else_stmt ) {
    19711971                        // resolve the condition like IfStmt, stmts normally
    1972                         ast::WaitForStmt::OrElse orElse2;
    1973 
    1974                         orElse2.cond = findSingleExpression( stmt->orElse.cond, context );
    1975                         orElse2.stmt = stmt->orElse.stmt->accept( *visitor );
     1972                        auto else_cond = findSingleExpression( stmt->else_cond, context );
     1973                        auto else_stmt = stmt->else_stmt->accept( *visitor );
    19761974
    19771975                        // set results into stmt
    19781976                        auto n = mutate( stmt );
    1979                         n->orElse = std::move( orElse2 );
     1977                        n->else_cond = std::move( else_cond );
     1978                        n->else_stmt = std::move( else_stmt );
    19801979                        stmt = n;
    19811980                }
  • src/SymTab/Validate.cc

    r9e7236f4 r24ceace  
    1010// Created On       : Sun May 17 21:50:04 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Nov 12 11:00:00 2021
    13 // Update Count     : 364
     12// Last Modified On : Fri Apr 29  9:45:00 2022
     13// Update Count     : 365
    1414//
    1515
     
    143143        struct LinkReferenceToTypes_old final : public WithIndexer, public WithGuards, public WithVisitorRef<LinkReferenceToTypes_old>, public WithShortCircuiting {
    144144                LinkReferenceToTypes_old( const Indexer * indexer );
     145
    145146                void postvisit( TypeInstType * typeInst );
    146147
     
    370371        }
    371372
     373        void linkReferenceToTypes( std::list< Declaration * > & translationUnit ) {
     374                PassVisitor<LinkReferenceToTypes_old> lrt( nullptr );
     375                acceptAll( translationUnit, lrt ); // must happen before autogen, because sized flag needs to propagate to generated functions
     376        }
     377
    372378        void validate_B( std::list< Declaration * > & translationUnit ) {
    373                 PassVisitor<LinkReferenceToTypes_old> lrt( nullptr );
    374379                PassVisitor<FixQualifiedTypes> fixQual;
    375380                {
    376381                        Stats::Heap::newPass("validate-B");
    377382                        Stats::Time::BlockGuard guard("validate-B");
    378                         acceptAll( translationUnit, lrt ); // must happen before autogen, because sized flag needs to propagate to generated functions
     383                        //linkReferenceToTypes( translationUnit );
    379384                        mutateAll( translationUnit, fixQual ); // must happen after LinkReferenceToTypes_old, because aggregate members are accessed
    380385                        HoistStruct::hoistStruct( translationUnit );
  • src/SymTab/Validate.h

    r9e7236f4 r24ceace  
    4242        void validate_E( std::list< Declaration * > &translationUnit );
    4343        void validate_F( std::list< Declaration * > &translationUnit );
     44        void linkReferenceToTypes( std::list< Declaration * > &translationUnit );
    4445
    4546        const ast::Type * validateType(
  • src/Validate/ForallPointerDecay.cpp

    r9e7236f4 r24ceace  
    1010// Created On       : Tue Dec  7 16:15:00 2021
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Feb 11 10:59:00 2022
    13 // Update Count     : 0
     12// Last Modified On : Sat Apr 23 13:10:00 2022
     13// Update Count     : 1
    1414//
    1515
     
    237237}
    238238
     239std::vector<ast::ptr<ast::DeclWithType>> expandAssertions(
     240                std::vector<ast::ptr<ast::DeclWithType>> const & old ) {
     241        return TraitExpander::expandAssertions( old );
     242}
     243
    239244} // namespace Validate
    240245
  • src/Validate/ForallPointerDecay.hpp

    r9e7236f4 r24ceace  
    1010// Created On       : Tue Dec  7 16:15:00 2021
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Dec  8 11:50:00 2021
    13 // Update Count     : 0
     12// Last Modified On : Sat Apr 23 13:13:00 2022
     13// Update Count     : 1
    1414//
    1515
    1616#pragma once
    1717
     18#include <vector>
     19#include "AST/Node.hpp"
     20
    1821namespace ast {
     22        class DeclWithType;
    1923        class TranslationUnit;
    2024}
     
    2731void decayForallPointers( ast::TranslationUnit & transUnit );
    2832
     33/// Expand all traits in an assertion list.
     34std::vector<ast::ptr<ast::DeclWithType>> expandAssertions(
     35        std::vector<ast::ptr<ast::DeclWithType>> const & );
     36
    2937}
    3038
  • src/Validate/GenericParameter.cpp

    r9e7236f4 r24ceace  
    1010// Created On       : Fri Mar 21 10:02:00 2022
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Apr 13 10:09:00 2022
    13 // Update Count     : 0
     12// Last Modified On : Fri Apr 22 16:43:00 2022
     13// Update Count     : 1
    1414//
    1515
     
    2222#include "AST/TranslationUnit.hpp"
    2323#include "AST/Type.hpp"
     24#include "Validate/NoIdSymbolTable.hpp"
    2425
    2526namespace Validate {
     
    138139// --------------------------------------------------------------------------
    139140
    140 // A SymbolTable that only has the operations used in the Translate Dimension
    141 // pass. More importantly, it doesn't have some methods that should no be
    142 // called by the Pass template (lookupId and addId).
    143 class NoIdSymbolTable {
    144         ast::SymbolTable base;
    145 public:
    146 #       define FORWARD_X( func, types_and_names, just_names ) \
    147         inline auto func types_and_names -> decltype( base.func just_names ) { \
    148                 return base.func just_names ; \
    149         }
    150 #       define FORWARD_0( func )         FORWARD_X( func, (),             () )
    151 #       define FORWARD_1( func, type )   FORWARD_X( func, (type arg),     (arg) )
    152 #       define FORWARD_2( func, t0, t1 ) FORWARD_X( func, (t0 a0, t1 a1), (a0, a1) )
    153 
    154         FORWARD_0( enterScope )
    155         FORWARD_0( leaveScope )
    156         FORWARD_1( lookupType, const std::string &        )
    157         FORWARD_1( addType   , const ast::NamedTypeDecl * )
    158         FORWARD_1( addStruct , const ast::StructDecl *    )
    159         FORWARD_1( addEnum   , const ast::EnumDecl *      )
    160         FORWARD_1( addUnion  , const ast::UnionDecl *     )
    161         FORWARD_1( addTrait  , const ast::TraitDecl *     )
    162         FORWARD_2( addWith   , const std::vector< ast::ptr<ast::Expr> > &, const ast::Decl * )
    163 };
    164 
    165 struct TranslateDimensionCore : public ast::WithGuards {
    166         NoIdSymbolTable symtab;
     141struct TranslateDimensionCore :
     142                public WithNoIdSymbolTable, public ast::WithGuards {
    167143
    168144        // SUIT: Struct- or Union- InstType
  • src/Validate/module.mk

    r9e7236f4 r24ceace  
    2020        Validate/CompoundLiteral.cpp \
    2121        Validate/CompoundLiteral.hpp \
     22        Validate/EliminateTypedef.cpp \
     23        Validate/EliminateTypedef.hpp \
     24        Validate/FixQualifiedTypes.cpp \
     25        Validate/FixQualifiedTypes.hpp \
    2226        Validate/ForallPointerDecay.cpp \
    2327        Validate/ForallPointerDecay.hpp \
     
    2630        Validate/HandleAttributes.cc \
    2731        Validate/HandleAttributes.h \
     32        Validate/HoistStruct.cpp \
     33        Validate/HoistStruct.hpp \
    2834        Validate/InitializerLength.cpp \
    2935        Validate/InitializerLength.hpp \
    3036        Validate/LabelAddressFixer.cpp \
    3137        Validate/LabelAddressFixer.hpp \
     38        Validate/NoIdSymbolTable.hpp \
    3239        Validate/ReturnCheck.cpp \
    3340        Validate/ReturnCheck.hpp \
  • src/main.cc

    r9e7236f4 r24ceace  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Apr 13 11:11:00 2022
    13 // Update Count     : 672
     12// Last Modified On : Fri Apr 29  9:52:00 2022
     13// Update Count     : 673
    1414//
    1515
     
    7575#include "Tuples/Tuples.h"                  // for expandMemberTuples, expan...
    7676#include "Validate/Autogen.hpp"             // for autogenerateRoutines
     77#include "Validate/CompoundLiteral.hpp"     // for handleCompoundLiterals
     78#include "Validate/EliminateTypedef.hpp"    // for eliminateTypedef
     79#include "Validate/FindSpecialDecls.h"      // for findGlobalDecls
     80#include "Validate/FixQualifiedTypes.hpp"   // for fixQualifiedTypes
     81#include "Validate/ForallPointerDecay.hpp"  // for decayForallPointers
    7782#include "Validate/GenericParameter.hpp"    // for fillGenericParameters, tr...
    78 #include "Validate/FindSpecialDecls.h"      // for findGlobalDecls
    79 #include "Validate/ForallPointerDecay.hpp"  // for decayForallPointers
    80 #include "Validate/CompoundLiteral.hpp"     // for handleCompoundLiterals
     83#include "Validate/HoistStruct.hpp"         // for hoistStruct
    8184#include "Validate/InitializerLength.hpp"   // for setLengthFromInitializer
    8285#include "Validate/LabelAddressFixer.hpp"   // for fixLabelAddresses
     
    328331                // add the assignment statement after the initialization of a type parameter
    329332                PASS( "Validate-A", SymTab::validate_A( translationUnit ) );
    330                 PASS( "Validate-B", SymTab::validate_B( translationUnit ) );
     333
     334                // Must happen before auto-gen, because it uses the sized flag.
     335                PASS( "Link Reference To Types", SymTab::linkReferenceToTypes( translationUnit ) );
    331336
    332337                CodeTools::fillLocations( translationUnit );
     
    342347
    343348                        forceFillCodeLocations( transUnit );
     349
     350                        // Must happen after Link References To Types,
     351                        // because aggregate members are accessed.
     352                        PASS( "Fix Qualified Types", Validate::fixQualifiedTypes( transUnit ) );
     353
     354                        PASS( "Hoist Struct", Validate::hoistStruct( transUnit ) );
     355                        PASS( "Eliminate Typedef", Validate::eliminateTypedef( transUnit ) );
    344356
    345357                        // Check as early as possible. Can't happen before
     
    438450                        translationUnit = convert( move( transUnit ) );
    439451                } else {
     452                        PASS( "Validate-B", SymTab::validate_B( translationUnit ) );
    440453                        PASS( "Validate-C", SymTab::validate_C( translationUnit ) );
    441454                        PASS( "Validate-D", SymTab::validate_D( translationUnit ) );
Note: See TracChangeset for help on using the changeset viewer.