Changeset 8cbe732 for src


Ignore:
Timestamp:
Oct 13, 2023, 7:13:21 PM (2 years ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
a97b9ed, bab2917
Parents:
85034ed (diff), 0bf0b978 (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:
5 added
24 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r85034ed r8cbe732  
    269269                        node->location,
    270270                        Type::StorageClasses( node->storage.val ),
    271             get<Type>().accept1( node->base ),
     271                        get<Type>().accept1( node->base ),
    272272                        LinkageSpec::Spec( node->linkage.val )
    273273                );
     
    567567        }
    568568
    569     const ast::WhenClause * visit( const ast::WhenClause * node ) override final {
     569        const ast::WhenClause * visit( const ast::WhenClause * node ) override final {
    570570                // There is no old-AST WhenClause, so this should never be called.
    571571                assert( !node );
     
    604604        }
    605605
    606     const ast::Stmt * visit( const ast::WaitUntilStmt * node ) override final {
    607         // There is no old-AST WaitUntilStmt, so this should never be called.
     606        const ast::Stmt * visit( const ast::WaitUntilStmt * node ) override final {
     607                // There is no old-AST WaitUntilStmt, so this should never be called.
    608608                assert( !node );
    609609                return nullptr;
     
    648648                );
    649649                return stmtPostamble( stmt, node );
     650        }
     651
     652        const ast::Stmt * visit( const ast::CorunStmt * node ) override final {
     653                // There is no old-AST CorunStmt, so this should never be called.
     654                assert( !node );
     655                return nullptr;
    650656        }
    651657
     
    853859                // New workd:   one public type: node->result, plus node->underlyer only to support roundtrip conversion
    854860                //              preserving underlyer because the correct type for string literals is complicated to construct,
    855             //              and distinguishing a string from other literals using the type is hard to do accurately
     861                //              and distinguishing a string from other literals using the type is hard to do accurately
    856862                // Both worlds: the outer, expression-level type can change during resolution
    857863                //              for a string, that's char[k] before-resolve and char * after
     
    859865                //              for a string, that's char[k] always
    860866                // Both worlds: the "rep" field of a constant is the C source file fragment that compiles to the desired value
    861         //              for a string, that includes outer quotes, backslashes, et al cases from the Literals test
     867                //              for a string, that includes outer quotes, backslashes, et al cases from the Literals test
    862868                ConstantExpr *rslt = new ConstantExpr(Constant(
    863869                        get<Type>().accept1(node->underlyer),
     
    15181524                return strict_dynamic_cast< ast::Decl * >( node );
    15191525        }
    1520        
     1526
    15211527        ConverterOldToNew() = default;
    15221528        ConverterOldToNew(const ConverterOldToNew &) = delete;
     
    15811587        ast::Label make_label(const Label* old) {
    15821588                CodeLocation const & location =
    1583                     ( old->labelled ) ? old->labelled->location : CodeLocation();
     1589                        ( old->labelled ) ? old->labelled->location : CodeLocation();
    15841590                return ast::Label(
    15851591                        location,
     
    22402246        // TypeSubstitution shouldn't exist yet in old.
    22412247        ast::TypeSubstitution * convertTypeSubstitution(const TypeSubstitution * old) {
    2242                
    22432248                if (!old) return nullptr;
    22442249                if (old->empty()) return nullptr;
     
    22852290        ast::Expr * visitBaseExpr_SkipResultType( const Expression * old, ast::Expr * nw) {
    22862291
    2287                 nw->env    = convertTypeSubstitution(old->env);
     2292                nw->env = convertTypeSubstitution(old->env);
    22882293
    22892294                nw->extension = old->extension;
     
    28562861
    28572862        virtual void visit( const EnumInstType * old ) override final {
    2858                 ast::EnumInstType * ty; 
     2863                ast::EnumInstType * ty;
    28592864                if ( old->baseEnum ) {
    28602865                        ty = new ast::EnumInstType{
  • src/AST/Fwd.hpp

    r85034ed r8cbe732  
    6767class ImplicitCtorDtorStmt;
    6868class MutexStmt;
     69class CorunStmt;
    6970
    7071class Expr;
  • src/AST/Node.cpp

    r85034ed r8cbe732  
    192192template class ast::ptr_base< ast::MutexStmt, ast::Node::ref_type::weak >;
    193193template class ast::ptr_base< ast::MutexStmt, ast::Node::ref_type::strong >;
     194template class ast::ptr_base< ast::CorunStmt, ast::Node::ref_type::weak >;
     195template class ast::ptr_base< ast::CorunStmt, ast::Node::ref_type::strong >;
    194196template class ast::ptr_base< ast::Expr, ast::Node::ref_type::weak >;
    195197template class ast::ptr_base< ast::Expr, ast::Node::ref_type::strong >;
  • src/AST/Pass.hpp

    r85034ed r8cbe732  
    162162        const ast::FinallyClause *    visit( const ast::FinallyClause        * ) override final;
    163163        const ast::Stmt *             visit( const ast::SuspendStmt          * ) override final;
    164     const ast::WhenClause *       visit( const ast::WhenClause           * ) override final;
     164        const ast::WhenClause *       visit( const ast::WhenClause           * ) override final;
    165165        const ast::Stmt *             visit( const ast::WaitForStmt          * ) override final;
    166166        const ast::WaitForClause *    visit( const ast::WaitForClause        * ) override final;
    167     const ast::Stmt *             visit( const ast::WaitUntilStmt        * ) override final;
     167        const ast::Stmt *             visit( const ast::WaitUntilStmt        * ) override final;
    168168        const ast::Decl *             visit( const ast::WithStmt             * ) override final;
    169169        const ast::NullStmt *         visit( const ast::NullStmt             * ) override final;
     
    171171        const ast::Stmt *             visit( const ast::ImplicitCtorDtorStmt * ) override final;
    172172        const ast::Stmt *             visit( const ast::MutexStmt            * ) override final;
     173        const ast::Stmt *             visit( const ast::CorunStmt            * ) override final;
    173174        const ast::Expr *             visit( const ast::ApplicationExpr      * ) override final;
    174175        const ast::Expr *             visit( const ast::UntypedExpr          * ) override final;
  • src/AST/Pass.impl.hpp

    r85034ed r8cbe732  
    11211121
    11221122//--------------------------------------------------------------------------
     1123// CorunStmt
     1124template< typename core_t >
     1125const ast::Stmt * ast::Pass< core_t >::visit( const ast::CorunStmt * node ) {
     1126        VISIT_START( node );
     1127
     1128        if ( __visit_children() ) {
     1129                maybe_accept( node, &CorunStmt::stmt );
     1130        }
     1131
     1132        VISIT_END( Stmt, node );
     1133}
     1134
     1135//--------------------------------------------------------------------------
    11231136// ApplicationExpr
    11241137template< typename core_t >
  • src/AST/Print.cpp

    r85034ed r8cbe732  
    209209        }
    210210
    211     void print( const ast::WaitStmt * node ) {
     211        void print( const ast::WaitStmt * node ) {
    212212                if ( node->timeout_time ) {
    213213                        os << indent-1 << "timeout of:" << endl;
     
    860860        }
    861861
    862     virtual const ast::Stmt * visit( const ast::WaitUntilStmt * node ) override final {
     862        virtual const ast::Stmt * visit( const ast::WaitUntilStmt * node ) override final {
    863863                os << "Waituntil Statement" << endl;
    864864                indent += 2;
     
    866866                        clause->accept( *this );
    867867                }
    868         print(node);    // calls print( const ast::WaitStmt * node )
     868                // calls print( const ast::WaitStmt * node )
     869                print(node);
    869870                return node;
    870871        }
     
    913914                printAll( node->mutexObjs );
    914915                --indent;
     916                os << indent << "... with Statement: ";
     917                ++indent;
     918                safe_print( node->stmt );
     919                --indent;
     920                os << endl;
     921
     922                return node;
     923        }
     924
     925        virtual const ast::Stmt * visit( const ast::CorunStmt * node ) override final {
     926                os << "Corun Statement" << endl;
    915927                os << indent << "... with Statement: ";
    916928                ++indent;
  • src/AST/Stmt.hpp

    r85034ed r8cbe732  
    532532};
    533533
     534// Corun Statement
     535class CorunStmt final : public Stmt {
     536  public:
     537        ptr<Stmt> stmt;
     538
     539        CorunStmt( const CodeLocation & loc, const Stmt * stmt, const std::vector<Label> && labels = {} )
     540                : Stmt(loc, std::move(labels)), stmt(stmt) {}
     541
     542        const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
     543  private:
     544        CorunStmt * clone() const override { return new CorunStmt{ *this }; }
     545        MUTATE_FRIEND
     546};
     547
    534548} // namespace ast
    535549
  • src/AST/Visitor.hpp

    r85034ed r8cbe732  
    5959    virtual const ast::Stmt *             visit( const ast::ImplicitCtorDtorStmt * ) = 0;
    6060    virtual const ast::Stmt *             visit( const ast::MutexStmt            * ) = 0;
     61    virtual const ast::Stmt *             visit( const ast::CorunStmt            * ) = 0;
    6162    virtual const ast::Expr *             visit( const ast::ApplicationExpr      * ) = 0;
    6263    virtual const ast::Expr *             visit( const ast::UntypedExpr          * ) = 0;
  • src/CodeGen/CodeGenerator.cc

    r85034ed r8cbe732  
    11571157
    11581158        void CodeGenerator::postvisit( WithStmt * with ) {
    1159                 if ( ! options.genC ) {
    1160                         output << "with ( ";
    1161                         genCommaList( with->exprs.begin(), with->exprs.end() );
    1162                         output << " ) ";
    1163                 }
     1159                assertf( ! options.genC, "WithStmts should not reach code generation." );
     1160
     1161                output << "with ( ";
     1162                genCommaList( with->exprs.begin(), with->exprs.end() );
     1163                output << " ) ";
    11641164                with->stmt->accept( *visitor );
    11651165        }
  • src/CodeGen/LinkOnce.cc

    r85034ed r8cbe732  
    1010// Created On       : Thur May 13 10:10:00 2021
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thur May 13 14:39:00 2021
    13 // Update Count     : 0
     12// Last Modified On : Wed Oct  4 10:52:00 2023
     13// Update Count     : 1
    1414//
    1515
     
    1818#include <algorithm>
    1919
     20#include "AST/Attribute.hpp"
     21#include "AST/Decl.hpp"
     22#include "AST/Expr.hpp"
     23#include "AST/Pass.hpp"
    2024#include "Common/PassVisitor.h"       // for PassVisitor, WithShortCircuiting
    2125
    2226namespace CodeGen {
    2327
    24 static bool is_cfa_linkonce( Attribute const * attr ) {
     28namespace {
     29
     30bool is_cfa_linkonce_old( Attribute const * attr ) {
    2531        return std::string("cfa_linkonce") == attr->name;
    2632}
    2733
    28 static bool is_section_attribute( Attribute const * attr ) {
     34bool is_section_attribute_old( Attribute const * attr ) {
    2935        return std::string("section") == attr->name;
    3036}
     
    3945                std::list< Attribute * > & attributes = decl->attributes;
    4046                // See if we can find the element:
    41                 auto found = std::find_if(attributes.begin(), attributes.end(), is_cfa_linkonce );
     47                auto found = std::find_if(attributes.begin(), attributes.end(), is_cfa_linkonce_old );
    4248                if ( attributes.end() != found ) {
    4349                        // Remove any other sections:
    44                         attributes.remove_if( is_section_attribute );
     50                        attributes.remove_if( is_section_attribute_old );
    4551                        // Iterator to the cfa_linkonce attribute should still be valid.
    4652                        Attribute * attribute = *found;
     
    6369};
    6470
     71bool is_cfa_linkonce( ast::Attribute const * attr ) {
     72        return "cfa_linkonce" == attr->name;
     73}
     74
     75bool is_section_attribute( ast::Attribute const * attr ) {
     76        return "section" == attr->name;
     77}
     78
     79struct LinkOnceCore : public ast::WithShortCircuiting {
     80        void previsit( ast::Decl const * ) {
     81                visit_children = false;
     82        }
     83
     84        ast::DeclWithType const * postvisit( ast::DeclWithType const * decl ) {
     85                // Check to see if we have to mutate, because should be uncommon.
     86                {
     87                        auto & attributes = decl->attributes;
     88                        auto found = std::find_if( attributes.begin(), attributes.end(),
     89                                        is_cfa_linkonce );
     90                        if ( attributes.end() == found ) return decl;
     91                }
     92                auto mutDecl = mutate( decl );
     93                auto & attributes = mutDecl->attributes;
     94
     95                // Remove all conflicting section attributes.
     96                erase_if( attributes, is_section_attribute );
     97
     98                // Get the attribute, and overwrite it as a section attribute.
     99                auto found = std::find_if( attributes.begin(), attributes.end(),
     100                                is_cfa_linkonce );
     101                assert( attributes.end() != found );
     102                ast::Attribute * attribute = found->get_and_mutate();
     103                assert( attribute->params.empty() );
     104                assert( !decl->mangleName.empty() );
     105
     106                attribute->name = "section";
     107                attribute->params.push_back(
     108                        ast::ConstantExpr::from_string( mutDecl->location,
     109                                ".gnu.linkonce." + decl->mangleName
     110                        )
     111                );
     112
     113                // Unconditionnaly add "visibility(default)" to anything with
     114                // .gnu.linkonce visibility is a mess otherwise.
     115                attributes.push_back( new ast::Attribute( "visibility", {
     116                        ast::ConstantExpr::from_string( mutDecl->location, "default" )
     117                } ) );
     118                return mutDecl;
     119        }
     120};
     121
     122} // namespace
     123
    65124void translateLinkOnce( std::list< Declaration *> & translationUnit ) {
    66125        PassVisitor<LinkOnceVisitorCore> translator;
     
    68127}
    69128
     129void translateLinkOnce( ast::TranslationUnit & translationUnit ) {
     130        ast::Pass<LinkOnceCore>::run( translationUnit );
    70131}
     132
     133} // namespace CodeGen
  • src/CodeGen/LinkOnce.h

    r85034ed r8cbe732  
    1010// Created On       : Thur May 13 10:06:00 2021
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thur May 13 14:38:00 2021
    13 // Update Count     : 0
     12// Last Modified On : Wed Oct  4 10:52:00 2023
     13// Update Count     : 1
    1414//
    1515
     
    2323
    2424class Declaration;
     25namespace ast {
     26        class TranslationUnit;
     27}
    2528
    2629namespace CodeGen {
    2730
    2831void translateLinkOnce( std::list< Declaration *> & translationUnit );
     32void translateLinkOnce( ast::TranslationUnit & translationUnit );
    2933/* Convert the cfa_linkonce attribute on top level declaration into
    3034 * a special section declaration (.gnu.linkonce) so that it may be defined
  • src/Common/CodeLocationTools.cpp

    r85034ed r8cbe732  
    137137    macro(ImplicitCtorDtorStmt, Stmt) \
    138138    macro(MutexStmt, Stmt) \
     139    macro(CorunStmt, Stmt) \
    139140    macro(ApplicationExpr, Expr) \
    140141    macro(UntypedExpr, Expr) \
  • src/Concurrency/module.mk

    r85034ed r8cbe732  
    1818        Concurrency/Actors.cpp \
    1919        Concurrency/Actors.hpp \
     20        Concurrency/Corun.cpp \
     21        Concurrency/Corun.hpp \
    2022        Concurrency/KeywordsNew.cpp \
    2123        Concurrency/Keywords.cc \
  • src/GenPoly/Box.h

    r85034ed r8cbe732  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Box.h --
     7// Box.h -- Implement polymorphic function calls and types.
    88//
    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 : Sat Jul 22 09:23:52 2017
    13 // Update Count     : 6
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr Oct  6 13:37:00 2022
     13// Update Count     : 7
    1414//
    1515
     
    1919
    2020class Declaration;
     21namespace ast {
     22        class TranslationUnit;
     23}
    2124
    2225namespace GenPoly {
    2326        /// boxes polymorphic function calls
    2427        void box( std::list< Declaration* >& translationUnit );
     28void box( ast::TranslationUnit & translationUnit );
    2529} // namespace GenPoly
    2630
  • src/GenPoly/InstantiateGeneric.h

    r85034ed r8cbe732  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // InstantiateGeneric.h --
     7// InstantiateGeneric.h -- Create concrete instances of generic types.
    88//
    99// Author           : Aaron B. Moss
     
    2424
    2525namespace GenPoly {
    26 /// Replaces all generic types that have static layout with concrete
    27 /// instantiations. Types with concrete values for otype parameters will be
    28 /// template-expanded, while dtype and ftype parameters will be replaced by
    29 /// the appropriate void type.
     26
    3027void instantiateGeneric( std::list< Declaration* > &translationUnit );
    3128void instantiateGeneric( ast::TranslationUnit & translationUnit );
     29/// Replaces all generic types that have static layout with concrete
     30/// instantiations. Sized types are replaced with the concrete argument types
     31/// while unsized types are erased to a void type.
     32/// This pass can cause designators to ignore the pretty print option.
     33
    3234} // namespace GenPoly
    3335
  • src/GenPoly/InstantiateGenericNew.cpp

    r85034ed r8cbe732  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // InstantiateGenericNew.cpp --
     7// InstantiateGenericNew.cpp -- Create concrete instances of generic types.
    88//
    99// Author           : Andrew Beach
     
    335335ast::Expr const * FixDtypeStatic::postvisit( ast::MemberExpr const * expr ) {
    336336        ast::ptr<ast::Type> const & type = expr->aggregate->result;
    337         if ( !isGenericType( type ) ) {
    338                 return expr;
    339         } else if ( auto inst = type.as<ast::StructInstType>() ) {
    340                 return fixMemberExpr( inst, expr );
     337        if ( auto inst = type.as<ast::StructInstType>() ) {
     338                if ( !inst->params.empty() ) return fixMemberExpr( inst, expr );
    341339        } else if ( auto inst = type.as<ast::UnionInstType>() ) {
    342                 return fixMemberExpr( inst, expr );
     340                if ( !inst->params.empty() ) return fixMemberExpr( inst, expr );
    343341        }
    344342        return expr;
     
    451449        ast::Expr const * postvisit( ast::MemberExpr const * expr );
    452450        ast::Expr const * postvisit( ast::Expr const * expr );
    453         void previsit( ast::ParseNode const * node );
    454 
     451        ast::Designation const * postvisit( ast::Designation const * );
     452
     453        void previsit( ast::ParseNode const * node ) {
     454                GuardValue( location ) = &node->location;
     455        }
    455456        void previsit( ast::FunctionType const * ) {
    456457                GuardValue( inFunctionType ) = true;
     
    628629}
    629630
    630 void GenericInstantiator::previsit( ast::ParseNode const * node ) {
    631         GuardValue( location ) = &node->location;
     631// This attempts to figure out what the final name of the field will be.
     632// Pretty printing can cause this to become incorrect.
     633std::string getPrintName( ast::DeclWithType const * decl ) {
     634        return ( decl->linkage.is_mangled )
     635                ? decl->scopedMangleName() : decl->name;
     636}
     637
     638ast::Designation const * GenericInstantiator::postvisit(
     639                ast::Designation const * designation ) {
     640        // Disconnect designator names from their fields.
     641        // It is now incorrect to point at the generic definition where the used
     642        // type now is replaced with a concrete instance. Ideally, new variable
     643        // expressions would point at fields in the concrete instances, but that
     644        // is work and that information should not be needed this late in
     645        // compilation.
     646
     647        // Modify all designations, even if not needed.
     648        auto mutNode = mutate( designation );
     649        for ( ast::ptr<ast::Expr> & designator : mutNode->designators ) {
     650                if ( auto var = designator.as<ast::VariableExpr>() ) {
     651                        designator = new ast::NameExpr(
     652                                var->location, getPrintName( var->var ) );
     653                }
     654        }
     655        return mutNode;
    632656}
    633657
  • src/GenPoly/module.mk

    r85034ed r8cbe732  
    2222
    2323SRC += $(SRC_GENPOLY) \
     24        GenPoly/BoxNew.cpp \
    2425        GenPoly/Box.cc \
    2526        GenPoly/Box.h \
  • src/Parser/StatementNode.cc

    r85034ed r8cbe732  
    498498} // build_mutex
    499499
     500ast::Stmt * build_corun( const CodeLocation & location, StatementNode * stmt ) {
     501        ast::Stmt * body = maybeMoveBuild( stmt );
     502        return new ast::CorunStmt( location, body );
     503} // build_corun
     504
    500505// Local Variables: //
    501506// tab-width: 4 //
  • src/Parser/StatementNode.h

    r85034ed r8cbe732  
    105105ast::Stmt * build_with( const CodeLocation &, ExpressionNode * exprs, StatementNode * stmt );
    106106ast::Stmt * build_mutex( const CodeLocation &, ExpressionNode * exprs, StatementNode * stmt );
     107ast::Stmt * build_corun( const CodeLocation &, StatementNode * stmt );
  • src/Parser/lex.ll

    r85034ed r8cbe732  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Fri Jun  9 10:04:00 2023
    13  * Update Count     : 770
     12 * Last Modified On : Tue Oct  3 17:10:57 2023
     13 * Update Count     : 773
    1414 */
    1515
     
    217217
    218218                                /* keywords */
     219alignas                 { KEYWORD_RETURN(ALIGNAS); }                    // CFA
    219220_Alignas                { KEYWORD_RETURN(ALIGNAS); }                    // C11
     221alignof                 { KEYWORD_RETURN(ALIGNOF); }                    // CFA
    220222_Alignof                { KEYWORD_RETURN(ALIGNOF); }                    // C11
    221223__alignof               { KEYWORD_RETURN(ALIGNOF); }                    // GCC
     
    239241choose                  { KEYWORD_RETURN(CHOOSE); }                             // CFA
    240242coerce                  { KEYWORD_RETURN(COERCE); }                             // CFA
     243corun                   { KEYWORD_RETURN(CORUN); }                              // CFA
     244cofor                   { KEYWORD_RETURN(COFOR); }                              // CFA
    241245_Complex                { KEYWORD_RETURN(COMPLEX); }                    // C99
    242246__complex               { KEYWORD_RETURN(COMPLEX); }                    // GCC
     
    319323static                  { KEYWORD_RETURN(STATIC); }
    320324_Static_assert  { KEYWORD_RETURN(STATICASSERT); }               // C11
    321 _static_assert  { KEYWORD_RETURN(STATICASSERT); }               // C23
     325static_assert   { KEYWORD_RETURN(STATICASSERT); }               // C23
    322326struct                  { KEYWORD_RETURN(STRUCT); }
    323327suspend                 { KEYWORD_RETURN(SUSPEND); }                    // CFA
     
    326330__thread                { KEYWORD_RETURN(THREADLOCALGCC); }             // GCC
    327331_Thread_local   { KEYWORD_RETURN(THREADLOCALC11); }             // C11
     332thread_local    { KEYWORD_RETURN(THREADLOCALC11); }             // C23
    328333throw                   { KEYWORD_RETURN(THROW); }                              // CFA
    329334throwResume             { KEYWORD_RETURN(THROWRESUME); }                // CFA
  • src/Parser/parser.yy

    r85034ed r8cbe732  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep  4 18:28:12 2023
    13 // Update Count     : 6393
     12// Last Modified On : Tue Oct  3 17:14:12 2023
     13// Update Count     : 6396
    1414//
    1515
     
    350350%token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN
    351351%token CHOOSE FALLTHRU FALLTHROUGH WITH WHEN WAITFOR WAITUNTIL // CFA
     352%token CORUN COFOR
    352353%token DISABLE ENABLE TRY THROW THROWRESUME AT                  // CFA
    353354%token ASM                                                                                              // C99, extension ISO/IEC 9899:1999 Section J.5.10(1)
     
    422423%type<stmt> with_statement
    423424%type<expr> with_clause_opt
     425%type<stmt> corun_statement                             cofor_statement
    424426%type<stmt> exception_statement
    425427%type<clause> handler_clause                    finally_clause
     
    11401142        | waitfor_statement
    11411143        | waituntil_statement
     1144        | corun_statement
     1145        | cofor_statement
    11421146        | exception_statement
    11431147        | enable_disable_statement
     
    17131717        wor_waituntil_clause                                                            %prec THEN
    17141718                { $$ = new StatementNode( build_waituntil_stmt( yylloc, $1 ) ); }
     1719        ;
     1720
     1721corun_statement:
     1722        CORUN statement
     1723                { $$ = new StatementNode( build_corun( yylloc, $2 ) ); }
     1724        ;
     1725
     1726cofor_statement:
     1727        COFOR '(' for_control_expression_list ')' statement
     1728                { SemanticError( yylloc, "cofor statement is currently unimplemented." ); $$ = nullptr; }
    17151729        ;
    17161730
  • src/ResolvExpr/module.mk

    r85034ed r8cbe732  
    7272        ResolvExpr/AlternativePrinter.h \
    7373        ResolvExpr/CandidatePrinter.cpp \
    74         ResolvExpr/CandidatePrinter.hpp
     74        ResolvExpr/CandidatePrinter.hpp \
     75        ResolvExpr/EraseWith.cpp \
     76        ResolvExpr/EraseWith.hpp
    7577
    7678SRCDEMANGLE += $(SRC_RESOLVEXPR)
  • src/Validate/NoIdSymbolTable.hpp

    r85034ed r8cbe732  
    2020namespace Validate {
    2121
    22 // A SymbolTable that only has the operations used in the Translate Dimension
    23 // pass. More importantly, it doesn't have some methods that should no be
     22// A SymbolTable that only tracks names relevant to Validate passes.
     23// It tracks type names but not identifier names.
     24// Some of the canonicalization that occurs before the resolver
     25// affects how identifier name errors get reported to the user.
     26// The Validate phase needs to chase type names,
     27// but it is too early to try tracking identifier names.
     28// Identifier skipping is acheived by omitting methods that should not be
    2429// called by the Pass template (lookupId and addId).
    2530class NoIdSymbolTable {
    2631        ast::SymbolTable base;
    2732public:
     33        // All names that are tracked (now) are eligible for collision validation (now).
     34        // (Names that are only tracked later get their collision validation then.)
     35        NoIdSymbolTable() : base(ast::SymbolTable::ValidateOnAdd) {}
     36
    2837#       define FORWARD_X( func, types_and_names, just_names ) \
    2938        inline auto func types_and_names -> decltype( base.func just_names ) { \
  • src/main.cc

    r85034ed r8cbe732  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Apr 10 21:12:17 2023
    13 // Update Count     : 682
     12// Last Modified On : Thu Sep 28 22:28:45 2023
     13// Update Count     : 687
    1414//
    1515
     
    4646#include "Common/utility.h"                 // for deleteAll, filter, printAll
    4747#include "Concurrency/Actors.hpp"           // for implementActors
     48#include "Concurrency/Corun.hpp"            // for implementCorun
    4849#include "Concurrency/Keywords.h"           // for implementMutex, implement...
    4950#include "Concurrency/Waitfor.h"            // for generateWaitfor
     
    6263#include "Parser/RunParser.hpp"             // for buildList, dumpParseTree,...
    6364#include "ResolvExpr/CandidatePrinter.hpp"  // for printCandidates
     65#include "ResolvExpr/EraseWith.hpp"         // for eraseWith
    6466#include "ResolvExpr/Resolver.h"            // for resolve
    6567#include "SynTree/LinkageSpec.h"            // for Spec, Cforall, Intrinsic
     
    344346                PASS( "Implement Concurrent Keywords", Concurrency::implementKeywords, transUnit );
    345347                PASS( "Fix Unique Ids", Validate::fixUniqueIds, transUnit );
     348                PASS( "Implement Corun", Concurrency::implementCorun, transUnit );
    346349                PASS( "Hoist Control Declarations", ControlStruct::hoistControlDecls, transUnit );
    347350
     
    396399
    397400                PASS( "Fix Init", InitTweak::fix, transUnit, buildingLibrary() );
     401                PASS( "Erase With", ResolvExpr::eraseWith, transUnit );
    398402
    399403                // fix ObjectDecl - replaces ConstructorInit nodes
     
    419423
    420424                PASS( "Convert L-Value", GenPoly::convertLvalue, transUnit );
     425                DUMP( bboxp, std::move( transUnit ) );
     426                PASS( "Box", GenPoly::box, transUnit );
     427                PASS( "Link-Once", CodeGen::translateLinkOnce, transUnit );
    421428
    422429                translationUnit = convert( std::move( transUnit ) );
    423 
    424                 DUMP( bboxp, translationUnit );
    425                 PASS( "Box", GenPoly::box, translationUnit );
    426 
    427                 PASS( "Link-Once", CodeGen::translateLinkOnce, translationUnit );
    428430
    429431                // Code has been lowered to C, now we can start generation.
     
    540542        { "ascodegen", codegenp, true, "print AST as codegen rather than AST" },
    541543        { "asterr", errorp, true, "print AST on error" },
    542         { "declstats", declstatsp, true, "code property statistics" },
    543         { "parse", yydebug, true, "yacc (parsing) debug information" },
     544        { "declstats", declstatsp, true, "print code property statistics" },
     545        { "parse", yydebug, true, "print yacc (parsing) debug information" },
    544546        { "pretty", prettycodegenp, true, "prettyprint for ascodegen flag" },
    545547        { "rproto", resolvprotop, true, "resolver-proto instance" },
    546548        { "rsteps", resolvep, true, "print resolver steps" },
    547         // code dumps
     549        // AST dumps
    548550        { "ast", astp, true, "print AST after parsing" },
    549         { "exdecl", exdeclp, true, "print AST after translating exception decls" },
     551        { "excpdecl", exdeclp, true, "print AST after translating exception decls" },
    550552        { "symevt", symtabp, true, "print AST after symbol table events" },
    551         { "altexpr", expraltp, true, "print alternatives for expressions" },
    552         { "astdecl", validp, true, "print AST after declaration validation pass" },
    553         { "resolver", bresolvep, true, "print AST before resolver step" },
    554         { "astexpr", exprp, true, "print AST after expression analysis" },
     553        { "expralt", expraltp, true, "print AST after expressions alternatives" },
     554        { "valdecl", validp, true, "print AST after declaration validation pass" },
     555        { "bresolver", bresolvep, true, "print AST before resolver step" },
     556        { "expranly", exprp, true, "print AST after expression analysis" },
    555557        { "ctordtor", ctorinitp, true, "print AST after ctor/dtor are replaced" },
    556558        { "tuple", tuplep, true, "print AST after tuple expansion" },
    557         { "astgen", genericsp, true, "print AST after instantiate generics" },
    558         { "box", bboxp, true, "print AST before box step" },
    559         { "codegen", bcodegenp, true, "print AST before code generation" },
     559        { "instgen", genericsp, true, "print AST after instantiate generics" },
     560        { "bbox", bboxp, true, "print AST before box pass" },
     561        { "bcodegen", bcodegenp, true, "print AST before code generation" },
    560562};
    561563enum { printoptsSize = sizeof( printopts ) / sizeof( printopts[0] ) };
Note: See TracChangeset for help on using the changeset viewer.