Changeset a97b9ed for src/AST


Ignore:
Timestamp:
Oct 16, 2023, 8:09:51 AM (2 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
2bf46a5, 54e59dd, 61e5d99
Parents:
946a6e4 (diff), 8cbe732 (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/AST
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r946a6e4 ra97b9ed  
    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

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

    r946a6e4 ra97b9ed  
    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

    r946a6e4 ra97b9ed  
    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

    r946a6e4 ra97b9ed  
    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

    r946a6e4 ra97b9ed  
    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

    r946a6e4 ra97b9ed  
    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

    r946a6e4 ra97b9ed  
    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;
Note: See TracChangeset for help on using the changeset viewer.