Changeset def751f for src


Ignore:
Timestamp:
Jul 25, 2022, 3:17:25 PM (3 years ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
b0d9ff7
Parents:
4e2befe3 (diff), ffec1bf (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' into qualifiedEnum

Location:
src
Files:
2 added
47 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.cpp

    r4e2befe3 rdef751f  
    272272        // Adjust the length of the string for the terminator.
    273273        const Expr * strSize = from_ulong( loc, str.size() + 1 );
    274         const Type * strType = new ArrayType( charType, strSize, FixedLen, StaticDim );
     274        const Type * strType = new ArrayType( charType, strSize, FixedLen, DynamicDim );
    275275        const std::string strValue = "\"" + str + "\"";
    276276        return new ConstantExpr( loc, strType, strValue, std::nullopt );
  • src/AST/Pass.hpp

    r4e2befe3 rdef751f  
    264264        __pass::result1<ast::Stmt> call_accept_as_compound(const ast::Stmt *);
    265265
     266        // requests type environment to be updated (why is it implemented like this?)
     267        __pass::result1<ast::Expr> call_accept_top(const ast::Expr *);
     268
    266269        template< template <class...> class container_t >
    267270        __pass::resultNstmt<container_t> call_accept( const container_t< ptr<Stmt> > & );
     
    277280        template<typename node_t, typename parent_t, typename field_t>
    278281        void maybe_accept_as_compound(const node_t * &, field_t parent_t::* field);
     282
     283        template<typename node_t, typename parent_t, typename field_t>
     284        void maybe_accept_top(const node_t * &, field_t parent_t::* field);
    279285
    280286private:
  • src/AST/Pass.impl.hpp

    r4e2befe3 rdef751f  
    155155                __pedantic_pass_assert( expr );
    156156
    157                 const ast::TypeSubstitution ** typeSubs_ptr = __pass::typeSubs( core, 0 );
    158                 if ( typeSubs_ptr && expr->env ) {
    159                         *typeSubs_ptr = expr->env;
    160                 }
    161 
    162157                auto nval = expr->accept( *this );
    163158                return { nval != expr, nval };
     
    171166                const ast::Stmt * nval = stmt->accept( *this );
    172167                return { nval != stmt, nval };
     168        }
     169
     170        template< typename core_t >
     171        __pass::template result1<ast::Expr> ast::Pass< core_t >::call_accept_top( const ast::Expr * expr ) {
     172                __pedantic_pass_assert( __visit_children() );
     173                __pedantic_pass_assert( expr );
     174
     175                const ast::TypeSubstitution ** typeSubs_ptr = __pass::typeSubs( core, 0 );
     176                if ( typeSubs_ptr && expr->env ) {
     177                        *typeSubs_ptr = expr->env;
     178                }
     179
     180                auto nval = expr->accept( *this );
     181                return { nval != expr, nval };
    173182        }
    174183
     
    410419
    411420                auto new_val = call_accept( old_val );
     421
     422                static_assert( !std::is_same<const ast::Node *, decltype(new_val)>::value /* || std::is_same<int, decltype(old_val)>::value */, "ERROR");
     423
     424                if( new_val.differs ) {
     425                        auto new_parent = __pass::mutate<core_t>(parent);
     426                        new_val.apply(new_parent, field);
     427                        parent = new_parent;
     428                }
     429        }
     430
     431        template< typename core_t >
     432        template<typename node_t, typename super_t, typename field_t>
     433        void ast::Pass< core_t >::maybe_accept_top(
     434                const node_t * & parent,
     435                field_t super_t::*field
     436        ) {
     437                static_assert( std::is_base_of<super_t, node_t>::value, "Error deducing member object" );
     438
     439                if(__pass::skip(parent->*field)) return;
     440                const auto & old_val = __pass::get(parent->*field, 0);
     441
     442                static_assert( !std::is_same<const ast::Node * &, decltype(old_val)>::value, "ERROR");
     443
     444                auto new_val = call_accept_top( old_val );
    412445
    413446                static_assert( !std::is_same<const ast::Node *, decltype(new_val)>::value /* || std::is_same<int, decltype(old_val)>::value */, "ERROR");
     
    756789
    757790        if ( __visit_children() ) {
    758                 maybe_accept( node, &StaticAssertDecl::cond );
     791                maybe_accept_top( node, &StaticAssertDecl::cond );
    759792                maybe_accept( node, &StaticAssertDecl::msg  );
    760793        }
     
    798831
    799832        if ( __visit_children() ) {
    800                 maybe_accept( node, &ExprStmt::expr );
     833                maybe_accept_top( node, &ExprStmt::expr );
    801834        }
    802835
     
    839872                guard_symtab guard { *this };
    840873                maybe_accept( node, &IfStmt::inits    );
    841                 maybe_accept( node, &IfStmt::cond     );
     874                maybe_accept_top( node, &IfStmt::cond     );
    842875                maybe_accept_as_compound( node, &IfStmt::then );
    843876                maybe_accept_as_compound( node, &IfStmt::else_ );
     
    857890                guard_symtab guard { *this };
    858891                maybe_accept( node, &WhileDoStmt::inits );
    859                 maybe_accept( node, &WhileDoStmt::cond  );
     892                maybe_accept_top( node, &WhileDoStmt::cond  );
    860893                maybe_accept_as_compound( node, &WhileDoStmt::body  );
    861894        }
     
    875908                // xxx - old ast does not create WithStmtsToAdd scope for loop inits. should revisit this later.
    876909                maybe_accept( node, &ForStmt::inits );
    877                 maybe_accept( node, &ForStmt::cond  );
    878                 maybe_accept( node, &ForStmt::inc   );
     910                maybe_accept_top( node, &ForStmt::cond  );
     911                maybe_accept_top( node, &ForStmt::inc   );
    879912                maybe_accept_as_compound( node, &ForStmt::body  );
    880913        }
     
    890923
    891924        if ( __visit_children() ) {
    892                 maybe_accept( node, &SwitchStmt::cond  );
     925                maybe_accept_top( node, &SwitchStmt::cond  );
    893926                maybe_accept( node, &SwitchStmt::cases );
    894927        }
     
    904937
    905938        if ( __visit_children() ) {
    906                 maybe_accept( node, &CaseClause::cond  );
     939                maybe_accept_top( node, &CaseClause::cond  );
    907940                maybe_accept( node, &CaseClause::stmts );
    908941        }
     
    926959
    927960        if ( __visit_children() ) {
    928                 maybe_accept( node, &ReturnStmt::expr );
     961                maybe_accept_top( node, &ReturnStmt::expr );
    929962        }
    930963
     
    9711004                guard_symtab guard { *this };
    9721005                maybe_accept( node, &CatchClause::decl );
    973                 maybe_accept( node, &CatchClause::cond );
     1006                maybe_accept_top( node, &CatchClause::cond );
    9741007                maybe_accept_as_compound( node, &CatchClause::body );
    9751008        }
     
    20582091
    20592092        if ( __visit_children() ) {
    2060                 maybe_accept( node, &SingleInit::value );
     2093                maybe_accept_top( node, &SingleInit::value );
    20612094        }
    20622095
  • src/AST/SymbolTable.cpp

    r4e2befe3 rdef751f  
    6565
    6666Expr * SymbolTable::IdData::combine( const CodeLocation & loc, ResolvExpr::Cost & cost ) const {
    67         Expr * ret = ( baseExpr ) ?
    68                 (Expr *)new MemberExpr{ loc, id, referenceToRvalueConversion( baseExpr, cost ) } :
    69                 (Expr *)new VariableExpr{ loc, id };
     67        Expr * ret;
     68        if ( baseExpr ) {
     69                if (baseExpr->env) {
     70                        Expr * base = shallowCopy(baseExpr);
     71                        const TypeSubstitution * subs = baseExpr->env;
     72                        base->env = nullptr;
     73                        ret = new MemberExpr{loc, id, referenceToRvalueConversion( base, cost )};
     74                        ret->env = subs;
     75                }
     76                else {
     77                        ret = new MemberExpr{ loc, id, referenceToRvalueConversion( baseExpr, cost ) };
     78                }
     79        }
     80        else {
     81                ret = new VariableExpr{ loc, id };
     82        }
    7083        if ( deleter ) { ret = new DeletedExpr{ loc, ret, deleter }; }
    7184        return ret;
     
    772785                                                && ! dynamic_cast<const UnionInstType *>(rty) ) continue;
    773786                                        ResolvExpr::Cost cost = ResolvExpr::Cost::zero;
     787                                        ast::ptr<ast::TypeSubstitution> tmp = expr->env;
     788                                        expr = mutate_field(expr, &Expr::env, nullptr);
    774789                                        const Expr * base = ResolvExpr::referenceToRvalueConversion( expr, cost );
     790                                        base = mutate_field(base, &Expr::env, tmp);
     791
    775792                                        addMembers(
    776793                                                rty->aggr(), new MemberExpr{ base->location, dwt, base }, handleConflicts );
  • src/AST/TypeSubstitution.cpp

    r4e2befe3 rdef751f  
    9797                TypeSubstitution * newEnv;
    9898                EnvTrimmer( const TypeSubstitution * env, TypeSubstitution * newEnv ) : env( env ), newEnv( newEnv ){}
    99                 void previsit( FunctionType * ftype ) {
     99                void previsit( const FunctionType * ftype ) {
    100100                        // transfer known bindings for seen type variables
    101101                        for (auto & formal : ftype->forall) {
  • src/CodeGen/FixNames.cc

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FixNames.cc --
     7// FixNames.cc -- Adjustments to typed declarations.
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Oct 29 15:49:00 2021
    13 // Update Count     : 23
     12// Last Modified On : Wed Jul 20 11:49:00 2022
     13// Update Count     : 24
    1414//
    1515
     
    8787
    8888/// Does work with the main function and scopeLevels.
    89 class FixNames_new : public ast::WithGuards {
     89class FixNames_new final {
    9090        int scopeLevel = 1;
    9191
     
    103103
    104104        const ast::FunctionDecl *postvisit( const ast::FunctionDecl *functionDecl ) {
    105                 // This store is used to ensure a maximum of one call to mutate.
    106                 ast::FunctionDecl * mutDecl = nullptr;
     105                if ( FixMain::isMain( functionDecl ) ) {
     106                        auto mutDecl = ast::mutate( functionDecl );
    107107
    108                 if ( shouldSetScopeLevel( functionDecl ) ) {
    109                         mutDecl = ast::mutate( functionDecl );
    110                         mutDecl->scopeLevel = scopeLevel;
    111                 }
    112 
    113                 if ( FixMain::isMain( functionDecl ) ) {
    114                         if ( !mutDecl ) { mutDecl = ast::mutate( functionDecl ); }
     108                        if ( shouldSetScopeLevel( mutDecl ) ) {
     109                                mutDecl->scopeLevel = scopeLevel;
     110                        }
    115111
    116112                        int nargs = mutDecl->params.size();
     
    124120                                )
    125121                        );
     122
     123                        return mutDecl;
     124                } else if ( shouldSetScopeLevel( functionDecl ) ) {
     125                        return ast::mutate_field( functionDecl, &ast::FunctionDecl::scopeLevel, scopeLevel );
     126                } else {
     127                        return functionDecl;
    126128                }
    127                 return mutDecl ? mutDecl : functionDecl;
    128129        }
    129130
    130131        void previsit( const ast::CompoundStmt * ) {
    131                 GuardValue( scopeLevel ) += 1;
     132                scopeLevel += 1;
     133        }
     134
     135        void postvisit( const ast::CompoundStmt * ) {
     136                scopeLevel -= 1;
    132137        }
    133138};
  • src/CodeGen/FixNames.h

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FixNames.h --
     7// FixNames.h -- Adjustments to typed declarations.
    88//
    99// Author           : Richard C. Bilson
     
    2626        /// mangles object and function names
    2727        void fixNames( std::list< Declaration* > & translationUnit );
    28         void fixNames( ast::TranslationUnit & translationUnit );
     28/// Sets scope levels and fills in main's default return.
     29void fixNames( ast::TranslationUnit & translationUnit );
    2930} // namespace CodeGen
    3031
  • src/Concurrency/Keywords.h

    r4e2befe3 rdef751f  
    2828        void implementThreadStarter( std::list< Declaration * > & translationUnit );
    2929
    30 /// Implement the sue-like keywords and the suspend keyword.
     30/// Implement the sue-like keywords and the suspend keyword. Pre-Autogen
    3131void implementKeywords( ast::TranslationUnit & translationUnit );
    32 /// Implement the mutex parameters and mutex statement.
     32/// Implement the mutex parameters and mutex statement. Post-Autogen
    3333void implementMutex( ast::TranslationUnit & translationUnit );
    34 /// Add the thread starter code to constructors.
     34/// Add the thread starter code to constructors. Post-Autogen
    3535void implementThreadStarter( ast::TranslationUnit & translationUnit );
    3636};
  • src/ControlStruct/ExceptDecl.cc

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ExceptDecl.cc --
     7// ExceptDecl.cc -- Handles declarations of exception types.
    88//
    99// Author           : Henry Xue
  • src/ControlStruct/ExceptDecl.h

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ExceptDecl.h --
     7// ExceptDecl.h -- Handles declarations of exception types.
    88//
    99// Author           : Henry Xue
    1010// Created On       : Tue Jul 20 04:10:50 2021
    11 // Last Modified By : Henry Xue
    12 // Last Modified On : Tue Jul 20 04:10:50 2021
    13 // Update Count     : 1
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tue Jul 12 15:49:00 2022
     13// Update Count     : 2
    1414//
    1515
     
    2020class Declaration;
    2121
     22namespace ast {
     23        class TranslationUnit;
     24}
     25
    2226namespace ControlStruct {
    23         void translateExcept( std::list< Declaration *> & translationUnit );
     27/// Unfold exception declarations into raw structure declarations.
     28/// Also builds vtable declarations and converts vtable types.
     29void translateExcept( std::list< Declaration *> & translationUnit );
     30void translateExcept( ast::TranslationUnit & translationUnit );
    2431}
  • src/ControlStruct/HoistControlDecls.hpp

    r4e2befe3 rdef751f  
    2121
    2222namespace ControlStruct {
    23 // Hoist declarations out of control flow statements into compound statement.
     23/// Hoist declarations out of control flow statements into compound statement.
     24/// Must happen before auto-gen routines are added.
    2425void hoistControlDecls( ast::TranslationUnit & translationUnit );
    2526} // namespace ControlStruct
  • src/ControlStruct/MultiLevelExit.cpp

    r4e2befe3 rdef751f  
    149149};
    150150
    151 NullStmt * labelledNullStmt(
    152         const CodeLocation & cl, const Label & label ) {
     151NullStmt * labelledNullStmt( const CodeLocation & cl, const Label & label ) {
    153152        return new NullStmt( cl, vector<Label>{ label } );
    154153}
     
    164163
    165164const CompoundStmt * MultiLevelExitCore::previsit(
    166         const CompoundStmt * stmt ) {
     165                const CompoundStmt * stmt ) {
    167166        visit_children = false;
    168167
     
    189188}
    190189
    191 size_t getUnusedIndex(
    192         const Stmt * stmt, const Label & originalTarget ) {
     190size_t getUnusedIndex( const Stmt * stmt, const Label & originalTarget ) {
    193191        const size_t size = stmt->labels.size();
    194192
     
    210208}
    211209
    212 const Stmt * addUnused(
    213         const Stmt * stmt, const Label & originalTarget ) {
     210const Stmt * addUnused( const Stmt * stmt, const Label & originalTarget ) {
    214211        size_t i = getUnusedIndex( stmt, originalTarget );
    215212        if ( i == stmt->labels.size() ) {
     
    356353
    357354// Mimic what the built-in push_front would do anyways. It is O(n).
    358 void push_front(
    359         vector<ptr<Stmt>> & vec, const Stmt * element ) {
     355void push_front( vector<ptr<Stmt>> & vec, const Stmt * element ) {
    360356        vec.emplace_back( nullptr );
    361357        for ( size_t i = vec.size() - 1 ; 0 < i ; --i ) {
     
    590586
    591587                ptr<Stmt> else_stmt = nullptr;
    592                 Stmt * loop_kid = nullptr;
     588                const Stmt * loop_kid = nullptr;
    593589                // check if loop node and if so add else clause if it exists
    594                 const WhileDoStmt * whilePtr = dynamic_cast<const WhileDoStmt *>(kid.get());
    595                 if ( whilePtr && whilePtr->else_) {
     590                const WhileDoStmt * whilePtr = kid.as<WhileDoStmt>();
     591                if ( whilePtr && whilePtr->else_ ) {
    596592                        else_stmt = whilePtr->else_;
    597                         WhileDoStmt * mutate_ptr = mutate(whilePtr);
    598                         mutate_ptr->else_ = nullptr;
    599                         loop_kid = mutate_ptr;
    600                 }
    601                 const ForStmt * forPtr = dynamic_cast<const ForStmt *>(kid.get());
    602                 if ( forPtr && forPtr->else_) {
     593                        loop_kid = mutate_field( whilePtr, &WhileDoStmt::else_, nullptr );
     594                }
     595                const ForStmt * forPtr = kid.as<ForStmt>();
     596                if ( forPtr && forPtr->else_ ) {
    603597                        else_stmt = forPtr->else_;
    604                         ForStmt * mutate_ptr = mutate(forPtr);
    605                         mutate_ptr->else_ = nullptr;
    606                         loop_kid = mutate_ptr;
     598                        loop_kid = mutate_field( forPtr, &ForStmt::else_, nullptr );
    607599                }
    608600
  • src/ControlStruct/module.mk

    r4e2befe3 rdef751f  
    1717SRC += \
    1818        ControlStruct/ExceptDecl.cc \
     19        ControlStruct/ExceptDeclNew.cpp \
    1920        ControlStruct/ExceptDecl.h \
    2021        ControlStruct/ExceptTranslateNew.cpp \
  • src/GenPoly/Box.cc

    r4e2befe3 rdef751f  
    189189                        /// Enters a new scope for type-variables, adding the type variables from ty
    190190                        void beginTypeScope( Type *ty );
    191                         /// Exits the type-variable scope
    192                         void endTypeScope();
    193191                        /// Enters a new scope for knowLayouts and knownOffsets and queues exit calls
    194192                        void beginGenericScope();
     
    198196                        UniqueName bufNamer;                           ///< Namer for VLA buffers
    199197                        Expression * addrMember = nullptr;             ///< AddressExpr argument is MemberExpr?
     198                        bool expect_func_type = false;                 ///< used to avoid recursing too deep in type decls
    200199                };
    201200
     
    14191418                void PolyGenericCalculator::beginGenericScope() {
    14201419                        GuardScope( *this );
     1420                        // We expect the first function type see to be the type relating to this scope
     1421                        // but any further type is probably some unrelated function pointer
     1422                        // keep track of which is the first
     1423                        GuardValue( expect_func_type );
     1424                        expect_func_type = true;
    14211425                }
    14221426
     
    14681472                void PolyGenericCalculator::premutate( FunctionType *funcType ) {
    14691473                        beginTypeScope( funcType );
     1474
     1475                        GuardValue( expect_func_type );
     1476
     1477                        if(!expect_func_type) {
     1478                                GuardAction( [this]() {
     1479                                        knownLayouts.endScope();
     1480                                        knownOffsets.endScope();
     1481                                });
     1482                                // If this is the first function type we see
     1483                                // Then it's the type of the declaration and we care about it
     1484                                knownLayouts.beginScope();
     1485                                knownOffsets.beginScope();
     1486                        }
     1487
     1488                        // The other functions type we will see in this scope are probably functions parameters
     1489                        // they don't help us with the layout and offsets so don't mark them as known in this scope
     1490                        expect_func_type = false;
    14701491
    14711492                        // make sure that any type information passed into the function is accounted for
     
    17461767                                }
    17471768
     1769                                // std::cout << "TRUE 2" << std::endl;
     1770
    17481771                                return true;
    17491772                        } else if ( UnionInstType *unionTy = dynamic_cast< UnionInstType* >( ty ) ) {
  • src/GenPoly/Specialize.h

    r4e2befe3 rdef751f  
    1717
    1818#include <list>  // for list
     19#include "AST/TranslationUnit.hpp"
    1920
    2021class Declaration;
     
    2324        /// generates thunks where needed
    2425        void convertSpecializations( std::list< Declaration* >& translationUnit );
     26
     27        void convertSpecializations( ast::TranslationUnit & translationUnit );
    2528} // namespace GenPoly
    2629
  • src/GenPoly/module.mk

    r4e2befe3 rdef751f  
    3434        GenPoly/ScrubTyVars.h \
    3535        GenPoly/Specialize.cc \
     36        GenPoly/SpecializeNew.cpp \
    3637        GenPoly/Specialize.h
    3738
  • src/InitTweak/FixInitNew.cpp

    r4e2befe3 rdef751f  
    7373        /// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which
    7474        /// function calls need their parameters to be copy constructed
    75         struct InsertImplicitCalls : public ast::WithConstTypeSubstitution, public ast::WithShortCircuiting {
     75        struct InsertImplicitCalls : public ast::WithShortCircuiting {
    7676                const ast::Expr * postvisit( const ast::ApplicationExpr * appExpr );
    7777
     
    457457                // is needed to obtain the type of temporary variables so that copy
    458458                // constructor calls can be resolved.
    459                 assert( typeSubs );
    460459                expr->env = tmp;
    461460                return expr;
  • src/InitTweak/GenInit.cc

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // GenInit.cc --
     7// GenInit.cc -- Generate initializers, and other stuff.
    88//
    99// Author           : Rob Schluntz
  • src/InitTweak/GenInit.h

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // GenInit.h --
     7// GenInit.h -- Generate initializers, and other stuff.
    88//
    99// Author           : Rodolfo G. Esteves
     
    2929        void genInit( ast::TranslationUnit & translationUnit );
    3030
    31         /// Converts return statements into copy constructor calls on the hidden return variable
     31        /// Converts return statements into copy constructor calls on the hidden return variable.
     32        /// This pass must happen before auto-gen.
    3233        void fixReturnStatements( std::list< Declaration * > & translationUnit );
    3334        void fixReturnStatements( ast::TranslationUnit & translationUnit );
  • src/ResolvExpr/CandidateFinder.cpp

    r4e2befe3 rdef751f  
    12631263                                        newExpr, copy( tenv ), ast::OpenVarSet{}, ast::AssertionSet{}, Cost::zero,
    12641264                                        cost );
     1265
     1266                                if (newCand->expr->env) {
     1267                                        newCand->env.add(*newCand->expr->env);
     1268                                        auto mutExpr = newCand->expr.get_and_mutate();
     1269                                        mutExpr->env  = nullptr;
     1270                                        newCand->expr = mutExpr;
     1271                                }
     1272
    12651273                                PRINT(
    12661274                                        std::cerr << "decl is ";
  • src/ResolvExpr/Resolver.cc

    r4e2befe3 rdef751f  
    15551555                if ( type->dimension ) {
    15561556                        ast::ptr< ast::Type > sizeType = context.global.sizeType;
     1557                        ast::ptr< ast::Expr > dimension = findSingleExpression( type->dimension, sizeType, context );
     1558                        assertf(dimension->env->empty(), "array dimension expr has nonempty env");
     1559                        dimension.get_and_mutate()->env = nullptr;
    15571560                        ast::mutate_field(
    15581561                                type, &PtrType::dimension,
    1559                                 findSingleExpression( type->dimension, sizeType, context ) );
     1562                                dimension);
    15601563                }
    15611564                return type;
     
    20082011                                tmp->accept( *visitor );
    20092012                        }
     2013                        else if (expr->env && expr->env->empty()) {
     2014                                expr = ast::mutate_field(expr.get(), &ast::Expr::env, nullptr);
     2015                        }
    20102016                }
    20112017        }
  • src/Tuples/Tuples.cc

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Tuples.h --
     7// Tuples.cc -- A collection of tuple operations.
    88//
    99// Author           : Andrew Beach
  • src/Tuples/Tuples.h

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Tuples.h --
     7// Tuples.h -- A collection of tuple operations.
    88//
    99// Author           : Rodolfo G. Esteves
  • src/Validate/Autogen.hpp

    r4e2befe3 rdef751f  
    2222namespace Validate {
    2323
     24/// Generate routines for all data types in the translation unit.
     25/// A lot of passes have to happen either before or after this pass.
    2426void autogenerateRoutines( ast::TranslationUnit & translationUnit );
    2527
  • src/Validate/CompoundLiteral.hpp

    r4e2befe3 rdef751f  
    2323
    2424/// Use variables to implement compound literals.
     25/// Must happen after auto-gen routines are added.
    2526void handleCompoundLiterals( ast::TranslationUnit & translationUnit );
    2627
  • src/Validate/EnumAndPointerDecay.cpp

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // EnumAndPointerDecay.cpp --
     7// EnumAndPointerDecay.cpp -- Normalizes enumerations and types in functions.
    88//
    99// Author           : Andrew Beach
  • src/Validate/EnumAndPointerDecay.hpp

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // EnumAndPointerDecay.hpp --
     7// EnumAndPointerDecay.hpp -- Normalizes enumerations and types in functions.
    88//
    99// Author           : Andrew Beach
     
    2222namespace Validate {
    2323
     24/// Fix the parameter and return types of functions. Also assigns types to
     25/// enumeration values. This must happen before Link Reference to Types,
     26/// it needs correct types for mangling, and before auto-gen.
    2427void decayEnumsAndPointers( ast::TranslationUnit & translationUnit );
    2528
  • src/Validate/FindSpecialDecls.h

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FindSpecialDeclarations.h --
     7// FindSpecialDeclarations.h -- Find special declarations used in the compiler.
    88//
    99// Author           : Rob Schluntz
     
    4343        void findSpecialDecls( std::list< Declaration * > & translationUnit );
    4444
    45 /// find and remember some of the special declarations that are useful for
     45/// Find and remember some of the special declarations that are useful for
    4646/// generating code, so that they do not have to be discovered multiple times.
    4747void findGlobalDecls( ast::TranslationUnit & translationUnit );
  • src/Validate/FixQualifiedTypes.cpp

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FixQualifiedTypes.cpp --
     7// FixQualifiedTypes.cpp -- Replace the qualified type with a direct type.
    88//
    99// Author           : Andrew Beach
     
    7676                                                        ret->qualifiers = type->qualifiers;
    7777                                                        ast::TypeSubstitution sub( aggr->params, instp->params );
    78                                                         // = parent->genericSubstitution();
    7978                                                        auto result = sub.apply(ret);
    8079                                                        return result.node.release();
  • src/Validate/FixQualifiedTypes.hpp

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FixQualifiedTypes.hpp --
     7// FixQualifiedTypes.hpp -- Replace the qualified type with a direct type.
    88//
    99// Author           : Andrew Beach
     
    2222namespace Validate {
    2323
     24/// Replaces qualified types with an unqualified NamedTypeDecl.
     25/// Must happen after Link References To Types,
     26/// because aggregate members are accessed.
    2427void fixQualifiedTypes( ast::TranslationUnit & translationUnit );
    2528
  • src/Validate/FixReturnTypes.cpp

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FixReturnTypes.cpp --
     7// FixReturnTypes.cpp -- Unifies the representation of return types.
    88//
    99// Author           : Andrew Beach
  • src/Validate/FixReturnTypes.hpp

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FixReturnTypes.hpp --
     7// FixReturnTypes.hpp -- Unifies the representation of return types.
    88//
    99// Author           : Andrew Beach
     
    2222namespace Validate {
    2323
    24 // This pass needs to happen early so that other passes can find tuple types
    25 // in the right places, especially for function return types.
     24/// This pass needs to happen early so that other passes can find tuple types
     25/// in the right places, especially for function return types.
     26/// Must happen before auto-gen.
    2627void fixReturnTypes( ast::TranslationUnit & translationUnit );
    2728
  • src/Validate/ForallPointerDecay.hpp

    r4e2befe3 rdef751f  
    2929/// Also checks that operator names are used properly on functions and
    3030/// assigns unique IDs. This is a "legacy" pass.
     31/// Must be after implement concurrent keywords; because uniqueIds must be
     32/// set on declaration before resolution.
     33/// Must happen before auto-gen routines are added.
    3134void decayForallPointers( ast::TranslationUnit & transUnit );
    3235
  • src/Validate/GenericParameter.cpp

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // GenericParameter.hpp --
     7// GenericParameter.hpp -- Generic parameter related passes.
    88//
    99// Author           : Andrew Beach
  • src/Validate/GenericParameter.hpp

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // GenericParameter.hpp --
     7// GenericParameter.hpp -- Generic parameter related passes.
    88//
    99// Author           : Andrew Beach
     
    2323
    2424/// Perform substutions for generic parameters and fill in defaults.
     25/// Check as early as possible, but it can't happen before Link References to
     26/// Types and observed failing when attempted before eliminate typedef.
    2527void fillGenericParameters( ast::TranslationUnit & translationUnit );
    2628
  • src/Validate/HoistStruct.hpp

    r4e2befe3 rdef751f  
    2222namespace Validate {
    2323
    24 /// Flattens nested type declarations.
     24/// Flattens nested type declarations. (Run right after Fix Qualified Types.)
    2525void hoistStruct( ast::TranslationUnit & translationUnit );
    2626
  • src/Validate/HoistTypeDecls.cpp

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // HoistTypeDecls.cpp --
     7// HoistTypeDecls.cpp -- Hoists declarations of implicitly declared types.
    88//
    99// Author           : Andrew Beach
  • src/Validate/HoistTypeDecls.hpp

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // HoistTypeDecls.hpp --
     7// HoistTypeDecls.hpp -- Hoists declarations of implicitly declared types.
    88//
    99// Author           : Andrew Beach
     
    2222namespace Validate {
    2323
     24/// There are some places where a type can be declared but are usually only
     25/// referenced (with an *InstType). This inserts the declarations before
     26/// they are referenced.
    2427void hoistTypeDecls( ast::TranslationUnit & translationUnit );
    2528
  • src/Validate/LabelAddressFixer.cpp

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // LabelAddressFixer.cpp --
     7// LabelAddressFixer.cpp -- Create label address expressions.
    88//
    99// Author           : Andrew Beach
  • src/Validate/LabelAddressFixer.hpp

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // LabelAddressFixer.hpp --
     7// LabelAddressFixer.hpp -- Create label address expressions.
    88//
    99// Author           : Andrew Beach
     
    2020namespace Validate {
    2121
     22/// Label addresses are not actually created in the parser, this pass finds
     23/// the patterns that represent the label address expression.
    2224void fixLabelAddresses( ast::TranslationUnit & translationUnit );
    2325
  • src/Validate/LinkReferenceToTypes.hpp

    r4e2befe3 rdef751f  
    2222namespace Validate {
    2323
     24/// Fills in the base value of various instance types, and some related
     25/// adjustments, such as setting the sized flag.
     26/// Because of the sized flag, it must happen before auto-gen.
    2427void linkReferenceToTypes( ast::TranslationUnit & translationUnit );
    2528
  • src/Validate/ReplaceTypedef.cpp

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ReplaceTypedef.cpp --
     7// ReplaceTypedef.cpp -- Fill in all typedefs with the underlying type.
    88//
    99// Author           : Andrew Beach
    1010// Created On       : Tue Jun 29 14:59:00 2022
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jul 12 14:17:00 2022
    13 // Update Count     : 0
     12// Last Modified On : Wed Jul 13 14:45:00 2022
     13// Update Count     : 1
    1414//
    1515
     
    6363        void previsit( ast::TraitDecl const * );
    6464
    65         void previsit( ast::FunctionType const * );
    66 
    6765        template<typename AggrDecl>
    6866        void addImplicitTypedef( AggrDecl * aggDecl );
     
    7876        CodeLocation const * nearestLocation = nullptr;
    7977        int scopeLevel;
    80         bool inFunctionType = false;
     78        bool isAtFunctionTop = false;
    8179};
    8280
     
    105103                ast::Type * ret = ast::deepCopy( def->second.first->base );
    106104                ret->qualifiers |= type->qualifiers;
    107                 // GCC ignores certain attributes if they arrive by typedef,
    108                 // this mimics that.
    109                 // TODO: This might cover too much, it should just cover arguments
    110                 //   and return values of a function.
    111                 if ( visitor->isInFunction() ) {
     105                // We ignore certain attributes on function parameters if they arrive
     106                // by typedef. GCC appears to do the same thing.
     107                if ( isAtFunctionTop ) {
    112108                        erase_if( ret->attributes, isNonParameterAttribute );
    113109                }
     
    207203        GuardScope( typedefNames );
    208204        GuardScope( typedeclNames );
     205        GuardValue( isAtFunctionTop ) = true;
    209206}
    210207
     
    262259        GuardScope( typedefNames );
    263260        GuardScope( typedeclNames );
     261        GuardValue( isAtFunctionTop ) = false;
    264262        scopeLevel += 1;
    265263}
     
    292290        GuardScope( typedefNames );
    293291        GuardScope( typedeclNames );
    294 }
    295 
    296 void ReplaceTypedefCore::previsit( ast::FunctionType const * ) {
    297         GuardValue( inFunctionType ) = true;
    298292}
    299293
  • src/Validate/ReplaceTypedef.hpp

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ReplaceTypedef.hpp --
     7// ReplaceTypedef.hpp -- Fill in all typedefs with the underlying type.
    88//
    99// Author           : Andrew Beach
     
    2222namespace Validate {
    2323
     24/// Uses of typedef are replaced with the type in the typedef.
    2425void replaceTypedef( ast::TranslationUnit & translationUnit );
    2526
  • src/Validate/VerifyCtorDtorAssign.cpp

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // VerifyCtorDtorAssign.cpp --
     7// VerifyCtorDtorAssign.cpp -- Check the form of operators.
    88//
    99// Author           : Andrew Beach
  • src/Validate/VerifyCtorDtorAssign.hpp

    r4e2befe3 rdef751f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // VerifyCtorDtorAssign.hpp --
     7// VerifyCtorDtorAssign.hpp -- Check the form of operators.
    88//
    99// Author           : Andrew Beach
     
    2222namespace Validate {
    2323
     24/// Check that constructors, destructors and assignments all have the correct
     25/// form. Must happen before auto-gen or anything that examines operators.
    2426void verifyCtorDtorAssign( ast::TranslationUnit & translationUnit );
    2527
  • src/Virtual/Tables.h

    r4e2befe3 rdef751f  
    1919#include "AST/Fwd.hpp"
    2020class Declaration;
     21class Expression;
     22class FunctionDecl;
     23class Initializer;
     24class ObjectDecl;
    2125class StructDecl;
    22 class Expression;
     26class StructInstType;
     27class Type;
    2328
    2429namespace Virtual {
  • src/main.cc

    r4e2befe3 rdef751f  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Jul 12 12:02:00 2022
    13 // Update Count     : 675
     12// Last Modified On : Mon Jul 18 11:08:00 2022
     13// Update Count     : 676
    1414//
    1515
     
    330330                Stats::Time::StopBlock();
    331331
    332                 PASS( "Translate Exception Declarations", ControlStruct::translateExcept( translationUnit ) );
    333                 if ( exdeclp ) {
    334                         dump( translationUnit );
    335                         return EXIT_SUCCESS;
    336                 } // if
    337 
    338                 CodeTools::fillLocations( translationUnit );
    339 
    340332                if( useNewAST ) {
    341                         CodeTools::fillLocations( translationUnit );
    342 
    343333                        if (Stats::Counters::enabled) {
    344334                                ast::pass_visitor_stats.avg = Stats::Counters::build<Stats::Counters::AverageCounter<double>>("Average Depth - New");
     
    349339                        forceFillCodeLocations( transUnit );
    350340
    351                         // Must happen before auto-gen, or anything that examines ops.
     341                        PASS( "Translate Exception Declarations", ControlStruct::translateExcept( transUnit ) );
     342                        if ( exdeclp ) {
     343                                dump( move( transUnit ) );
     344                                return EXIT_SUCCESS;
     345                        }
     346
    352347                        PASS( "Verify Ctor, Dtor & Assign", Validate::verifyCtorDtorAssign( transUnit ) );
    353 
    354348                        PASS( "Hoist Type Decls", Validate::hoistTypeDecls( transUnit ) );
    355349                        // Hoist Type Decls pulls some declarations out of contexts where
     
    359353
    360354                        PASS( "Replace Typedefs", Validate::replaceTypedef( transUnit ) );
    361 
    362                         // Must happen before auto-gen.
    363355                        PASS( "Fix Return Types", Validate::fixReturnTypes( transUnit ) );
    364 
    365                         // Must happen before Link Reference to Types, it needs correct
    366                         // types for mangling.
    367356                        PASS( "Enum and Pointer Decay", Validate::decayEnumsAndPointers( transUnit ) );
    368357
    369                         // Must happen before auto-gen, because it uses the sized flag.
    370358                        PASS( "Link Reference To Types", Validate::linkReferenceToTypes( transUnit ) );
    371359
    372                         // Must happen after Link References To Types,
    373                         // because aggregate members are accessed.
    374360                        PASS( "Fix Qualified Types", Validate::fixQualifiedTypes( transUnit ) );
    375 
    376361                        PASS( "Hoist Struct", Validate::hoistStruct( transUnit ) );
    377362                        PASS( "Eliminate Typedef", Validate::eliminateTypedef( transUnit ) );
    378 
    379                         // Check as early as possible. Can't happen before
    380                         // LinkReferenceToType, observed failing when attempted
    381                         // before eliminateTypedef
    382363                        PASS( "Validate Generic Parameters", Validate::fillGenericParameters( transUnit ) );
    383 
    384364                        PASS( "Translate Dimensions", Validate::translateDimensionParameters( transUnit ) );
    385365                        PASS( "Check Function Returns", Validate::checkReturnStatements( transUnit ) );
    386 
    387                         // Must happen before Autogen.
    388366                        PASS( "Fix Return Statements", InitTweak::fixReturnStatements( transUnit ) );
    389 
    390367                        PASS( "Implement Concurrent Keywords", Concurrency::implementKeywords( transUnit ) );
    391 
    392                         // Must be after implement concurrent keywords; because uniqueIds
    393                         //   must be set on declaration before resolution.
    394                         // Must happen before autogen routines are added.
    395368                        PASS( "Forall Pointer Decay", Validate::decayForallPointers( transUnit ) );
    396 
    397                         // Must happen before autogen routines are added.
    398369                        PASS( "Hoist Control Declarations", ControlStruct::hoistControlDecls( transUnit ) );
    399370
    400                         // Must be after enum and pointer decay.
    401                         // Must be before compound literals.
    402371                        PASS( "Generate Autogen Routines", Validate::autogenerateRoutines( transUnit ) );
    403372
     
    470439                        PASS( "Translate Tries", ControlStruct::translateTries( transUnit ) );
    471440                        PASS( "Gen Waitfor", Concurrency::generateWaitFor( transUnit ) );
     441                        PASS( "Convert Specializations",  GenPoly::convertSpecializations( transUnit ) ); // needs to happen before tuple types are expanded
     442
    472443
    473444                        translationUnit = convert( move( transUnit ) );
    474445                } else {
     446                        PASS( "Translate Exception Declarations", ControlStruct::translateExcept( translationUnit ) );
     447                        if ( exdeclp ) {
     448                                dump( translationUnit );
     449                                return EXIT_SUCCESS;
     450                        } // if
     451
    475452                        // add the assignment statement after the initialization of a type parameter
    476453                        PASS( "Validate", SymTab::validate( translationUnit ) );
     
    538515                        PASS( "Translate Tries", ControlStruct::translateTries( translationUnit ) );
    539516                        PASS( "Gen Waitfor", Concurrency::generateWaitFor( translationUnit ) );
     517                        PASS( "Convert Specializations",  GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded
     518
    540519                }
    541520
    542                 PASS( "Convert Specializations",  GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded
     521
     522                // PASS( "Convert Specializations",  GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded
    543523
    544524                PASS( "Expand Tuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this?
Note: See TracChangeset for help on using the changeset viewer.