Changeset e0016a5


Ignore:
Timestamp:
May 21, 2019, 3:32:08 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
112fe04, 733074e
Parents:
51ff278
Message:

All ast visit functions are implemented

Location:
src/AST
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r51ff278 re0016a5  
    358358                for ( auto clause : node->clauses ) {
    359359                        stmt->clauses.push_back({{
    360                                         get<Expression>().accept1( clause.target.function ),
    361                                         get<Expression>().acceptL( clause.target.arguments ),
     360                                        get<Expression>().accept1( clause.target.func ),
     361                                        get<Expression>().acceptL( clause.target.args ),
    362362                                },
    363363                                get<Statement>().accept1( clause.stmt ),
     
    12601260        }
    12611261
    1262         void convertInferUnion(ast::Expr::InferUnion               &newInferred, 
     1262        void convertInferUnion(ast::Expr::InferUnion               &newInferred,
    12631263                                                   const std::map<UniqueId,ParamEntry> &oldInferParams,
    12641264                                                   const std::vector<UniqueId>         &oldResnSlots) {
  • src/AST/Pass.impl.hpp

    r51ff278 re0016a5  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Pass.impl.hpp --
     7// ast::Pass.impl.hpp --
    88//
    99// Author           : Thierry Delisle
     
    121121        template< typename pass_t >
    122122        template< typename node_t >
    123         auto Pass< pass_t >::call_accept( const node_t * node )
     123        auto ast::Pass< pass_t >::call_accept( const node_t * node )
    124124                -> typename std::enable_if<
    125125                                !std::is_base_of<ast::Expr, node_t>::value &&
     
    139139
    140140        template< typename pass_t >
    141         const ast::Expr * Pass< pass_t >::call_accept( const ast::Expr * expr ) {
     141        const ast::Expr * ast::Pass< pass_t >::call_accept( const ast::Expr * expr ) {
    142142                __pedantic_pass_assert( __visit_children() );
    143143                __pedantic_pass_assert( expr );
     
    152152
    153153        template< typename pass_t >
    154         const ast::Stmt * Pass< pass_t >::call_accept( const ast::Stmt * stmt ) {
     154        const ast::Stmt * ast::Pass< pass_t >::call_accept( const ast::Stmt * stmt ) {
    155155                __pedantic_pass_assert( __visit_children() );
    156156                __pedantic_pass_assert( stmt );
     
    204204        template< typename pass_t >
    205205        template< template <class...> class container_t >
    206         container_t< ptr<Stmt> > Pass< pass_t >::call_accept( const container_t< ptr<Stmt> > & statements ) {
     206        container_t< ptr<Stmt> > ast::Pass< pass_t >::call_accept( const container_t< ptr<Stmt> > & statements ) {
    207207                __pedantic_pass_assert( __visit_children() );
    208208                if( statements.empty() ) return {};
     
    270270        template< typename pass_t >
    271271        template< template <class...> class container_t, typename node_t >
    272         container_t< ast::ptr<node_t> > Pass< pass_t >::call_accept( const container_t< ast::ptr<node_t> > & container ) {
     272        container_t< ast::ptr<node_t> > ast::Pass< pass_t >::call_accept( const container_t< ast::ptr<node_t> > & container ) {
    273273                __pedantic_pass_assert( __visit_children() );
    274274                if( container.empty() ) return {};
     
    301301        template< typename pass_t >
    302302        template<typename node_t, typename parent_t, typename child_t>
    303         void Pass< pass_t >::maybe_accept(
     303        void ast::Pass< pass_t >::maybe_accept(
    304304                const node_t * & parent,
    305305                child_t parent_t::*child
     
    835835                // }
    836836
     837        VISIT({
     838                std::vector<WaitForStmt::Clause> new_clauses;
     839                new_clauses.reserve( node->clauses.size() );
     840                bool mutated = false;
     841                for( const auto & clause : node->clauses ) {
     842
     843                        Expr * func = clause.target.func ? clause.target.func->accept(*this) : nullptr;
     844                        if(func != clause.target.func) mutated = true;
     845
     846                        std::vector<ptr<Expr>> new_args;
     847                        new_args.reserve(clause.target.args.size());
     848                        for( const auto & arg : clause.target.args ) {
     849                                auto a = arg->accept(*this);
     850                                new_args.push_back( a );
     851                                if( a != arg ) mutated = true;
     852                        }
     853
     854                        Stmt * stmt = clause.stmt ? clause.stmt->accept(*this) : nullptr;
     855                        if(stmt != clause.stmt) mutated = true;
     856
     857                        Expr * cond = clause.cond ? clause.cond->accept(*this) : nullptr;
     858                        if(cond != clause.cond) mutated = true;
     859
     860                        new_clauses.push_back( WaitForStmt::Clause{ {func, std::move(new_args) }, stmt, cond } );
     861                }
     862
     863                if(mutated) {
     864                        auto n = mutate(node);
     865                        n->clauses = std::move( new_clauses );
     866                        node = n;
     867                }
     868        })
     869
    837870        #define maybe_accept(field) \
    838871                if(node->field) { \
     
    15581591}
    15591592
    1560 
    1561 
     1593//--------------------------------------------------------------------------
     1594// VoidType
     1595template< typename pass_t >
     1596const ast::Type * ast::Pass< pass_t >::visit( const ast::VoidType * node ) {
     1597        VISIT_START( node );
     1598
     1599        VISIT_END( Type, node );
     1600}
     1601
     1602//--------------------------------------------------------------------------
     1603// BasicType
     1604template< typename pass_t >
     1605const ast::Type * ast::Pass< pass_t >::visit( const ast::BasicType * node ) {
     1606        VISIT_START( node );
     1607
     1608        VISIT_END( Type, node );
     1609}
     1610
     1611//--------------------------------------------------------------------------
     1612// PointerType
     1613template< typename pass_t >
     1614const ast::Type * ast::Pass< pass_t >::visit( const ast::PointerType * node ) {
     1615        VISIT_START( node );
     1616
     1617        VISIT(
     1618                // xxx - should PointerType visit/mutate dimension?
     1619                maybe_accept( node, &PointerType::base );
     1620        )
     1621
     1622        VISIT_END( Type, node );
     1623}
     1624
     1625//--------------------------------------------------------------------------
     1626// ArrayType
     1627template< typename pass_t >
     1628const ast::Type * ast::Pass< pass_t >::visit( const ast::ArrayType * node ) {
     1629        VISIT_START( node );
     1630
     1631        VISIT(
     1632                maybe_accept( node, &ArrayType::dimension );
     1633                maybe_accept( node, &ArrayType::base );
     1634        )
     1635
     1636        VISIT_END( Type, node );
     1637}
     1638
     1639//--------------------------------------------------------------------------
     1640// ReferenceType
     1641template< typename pass_t >
     1642const ast::Type * ast::Pass< pass_t >::visit( const ast::ReferenceType * node ) {
     1643        VISIT_START( node );
     1644
     1645        VISIT(
     1646                maybe_accept( node, &ReferenceType::base );
     1647        )
     1648
     1649        VISIT_END( Type, node );
     1650}
     1651
     1652//--------------------------------------------------------------------------
     1653// QualifiedType
     1654template< typename pass_t >
     1655const ast::Type * ast::Pass< pass_t >::visit( const ast::QualifiedType * node ) {
     1656        VISIT_START( node );
     1657
     1658        VISIT(
     1659                maybe_accept( node, &QualifiedType::parent );
     1660                maybe_accept( node, &QualifiedType::child );
     1661        )
     1662
     1663        VISIT_END( Type, node );
     1664}
     1665
     1666//--------------------------------------------------------------------------
     1667// FunctionType
     1668template< typename pass_t >
     1669const ast::Type * ast::Pass< pass_t >::visit( const ast::FunctionType * node ) {
     1670        VISIT_START( node );
     1671
     1672        VISIT(
     1673                maybe_accept( node, &FunctionType::forall  );
     1674                maybe_accept( node, &FunctionType::returns );
     1675                maybe_accept( node, &FunctionType::params  );
     1676        )
     1677
     1678        VISIT_END( Type, node );
     1679}
     1680
     1681//--------------------------------------------------------------------------
     1682// StructInstType
     1683template< typename pass_t >
     1684const ast::Type * ast::Pass< pass_t >::visit( const ast::StructInstType * node ) {
     1685        VISIT_START( node );
     1686
     1687        __pass::indexer::addStruct( node->name, 0, pass );
     1688
     1689        VISIT({
     1690                guard_indexer guard { *this };
     1691                maybe_accept( node, &StructInstType::forall );
     1692                maybe_accept( node, &StructInstType::params );
     1693        })
     1694
     1695        VISIT_END( Type, node );
     1696}
     1697
     1698//--------------------------------------------------------------------------
     1699// UnionInstType
     1700template< typename pass_t >
     1701const ast::Type * ast::Pass< pass_t >::visit( const ast::UnionInstType * node ) {
     1702        VISIT_START( node );
     1703
     1704        __pass::indexer::addStruct( node->name, 0, pass );
     1705
     1706        {
     1707                guard_indexer guard { *this };
     1708                maybe_accept( node, &UnionInstType::forall );
     1709                maybe_accept( node, &UnionInstType::params );
     1710        }
     1711
     1712        VISIT_END( Type, node );
     1713}
     1714
     1715//--------------------------------------------------------------------------
     1716// EnumInstType
     1717template< typename pass_t >
     1718const ast::Type * ast::Pass< pass_t >::visit( const ast::EnumInstType * node ) {
     1719        VISIT_START( node );
     1720
     1721        VISIT(
     1722                maybe_accept( node, &EnumInstType::forall );
     1723                maybe_accept( node, &EnumInstType::params );
     1724        )
     1725
     1726        VISIT_END( Type, node );
     1727}
     1728
     1729//--------------------------------------------------------------------------
     1730// TraitInstType
     1731template< typename pass_t >
     1732const ast::Type * ast::Pass< pass_t >::visit( const ast::TraitInstType * node ) {
     1733        VISIT_START( node );
     1734
     1735        VISIT(
     1736                maybe_accept( node, &TraitInstType::forall );
     1737                maybe_accept( node, &TraitInstType::params );
     1738        )
     1739
     1740        VISIT_END( Type, node );
     1741}
     1742
     1743//--------------------------------------------------------------------------
     1744// TypeInstType
     1745template< typename pass_t >
     1746const ast::Type * ast::Pass< pass_t >::visit( const ast::TypeInstType * node ) {
     1747        VISIT_START( node );
     1748
     1749        VISIT(
     1750                maybe_accept( node, &TypeInstType::forall );
     1751                maybe_accept( node, &TypeInstType::params );
     1752        )
     1753
     1754        VISIT_END( Type, node );
     1755}
     1756
     1757//--------------------------------------------------------------------------
     1758// TupleType
     1759template< typename pass_t >
     1760const ast::Type * ast::Pass< pass_t >::visit( const ast::TupleType * node ) {
     1761        VISIT_START( node );
     1762
     1763        VISIT(
     1764                maybe_accept( node, &TupleType::types );
     1765                maybe_accept( node, &TupleType::members );
     1766        )
     1767
     1768        VISIT_END( Type, node );
     1769}
     1770
     1771//--------------------------------------------------------------------------
     1772// TypeofType
     1773template< typename pass_t >
     1774const ast::Type * ast::Pass< pass_t >::visit( const ast::TypeofType * node ) {
     1775        VISIT_START( node );
     1776
     1777        VISIT(
     1778                maybe_accept( node, &TypeofType::expr );
     1779        )
     1780
     1781        VISIT_END( Type, node );
     1782}
     1783
     1784//--------------------------------------------------------------------------
     1785// VarArgsType
     1786template< typename pass_t >
     1787const ast::Type * ast::Pass< pass_t >::visit( const ast::VarArgsType * node ) {
     1788        VISIT_START( node );
     1789
     1790        VISIT_END( Type, node );
     1791}
     1792
     1793//--------------------------------------------------------------------------
     1794// ZeroType
     1795template< typename pass_t >
     1796const ast::Type * ast::Pass< pass_t >::visit( const ast::ZeroType * node ) {
     1797        VISIT_START( node );
     1798
     1799        VISIT_END( Type, node );
     1800}
     1801
     1802//--------------------------------------------------------------------------
     1803// OneType
     1804template< typename pass_t >
     1805const ast::Type * ast::Pass< pass_t >::visit( const ast::OneType * node ) {
     1806        VISIT_START( node );
     1807
     1808        VISIT_END( Type, node );
     1809}
     1810
     1811//--------------------------------------------------------------------------
     1812// GlobalScopeType
     1813template< typename pass_t >
     1814const ast::Type * ast::Pass< pass_t >::visit( const ast::GlobalScopeType * node ) {
     1815        VISIT_START( node );
     1816
     1817        VISIT_END( Type, node );
     1818}
     1819
     1820
     1821//--------------------------------------------------------------------------
     1822// Designation
     1823template< typename pass_t >
     1824const ast::Designation * ast::Pass< pass_t >::visit( const ast::Designation * node ) {
     1825        VISIT_START( node );
     1826
     1827        VISIT( maybe_accept( node, &Designation::designators ); )
     1828
     1829        VISIT_END( Designation, node );
     1830}
    15621831
    15631832//--------------------------------------------------------------------------
  • src/AST/Stmt.hpp

    r51ff278 re0016a5  
    330330public:
    331331        struct Target {
    332                 ptr<Expr> function;
    333                 std::vector<ptr<Expr>> arguments;
     332                ptr<Expr> func;
     333                std::vector<ptr<Expr>> args;
    334334        };
    335335
Note: See TracChangeset for help on using the changeset viewer.