- Timestamp:
- May 21, 2019, 3:32:08 PM (6 years ago)
- 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
- Location:
- src/AST
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r51ff278 re0016a5 358 358 for ( auto clause : node->clauses ) { 359 359 stmt->clauses.push_back({{ 360 get<Expression>().accept1( clause.target.func tion),361 get<Expression>().acceptL( clause.target.arg uments ),360 get<Expression>().accept1( clause.target.func ), 361 get<Expression>().acceptL( clause.target.args ), 362 362 }, 363 363 get<Statement>().accept1( clause.stmt ), … … 1260 1260 } 1261 1261 1262 void convertInferUnion(ast::Expr::InferUnion &newInferred, 1262 void convertInferUnion(ast::Expr::InferUnion &newInferred, 1263 1263 const std::map<UniqueId,ParamEntry> &oldInferParams, 1264 1264 const std::vector<UniqueId> &oldResnSlots) { -
src/AST/Pass.impl.hpp
r51ff278 re0016a5 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Pass.impl.hpp --7 // ast::Pass.impl.hpp -- 8 8 // 9 9 // Author : Thierry Delisle … … 121 121 template< typename pass_t > 122 122 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 ) 124 124 -> typename std::enable_if< 125 125 !std::is_base_of<ast::Expr, node_t>::value && … … 139 139 140 140 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 ) { 142 142 __pedantic_pass_assert( __visit_children() ); 143 143 __pedantic_pass_assert( expr ); … … 152 152 153 153 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 ) { 155 155 __pedantic_pass_assert( __visit_children() ); 156 156 __pedantic_pass_assert( stmt ); … … 204 204 template< typename pass_t > 205 205 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 ) { 207 207 __pedantic_pass_assert( __visit_children() ); 208 208 if( statements.empty() ) return {}; … … 270 270 template< typename pass_t > 271 271 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 ) { 273 273 __pedantic_pass_assert( __visit_children() ); 274 274 if( container.empty() ) return {}; … … 301 301 template< typename pass_t > 302 302 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( 304 304 const node_t * & parent, 305 305 child_t parent_t::*child … … 835 835 // } 836 836 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 837 870 #define maybe_accept(field) \ 838 871 if(node->field) { \ … … 1558 1591 } 1559 1592 1560 1561 1593 //-------------------------------------------------------------------------- 1594 // VoidType 1595 template< typename pass_t > 1596 const 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 1604 template< typename pass_t > 1605 const 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 1613 template< typename pass_t > 1614 const 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 1627 template< typename pass_t > 1628 const 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 1641 template< typename pass_t > 1642 const 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 1654 template< typename pass_t > 1655 const 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 1668 template< typename pass_t > 1669 const 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 1683 template< typename pass_t > 1684 const 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 1700 template< typename pass_t > 1701 const 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 1717 template< typename pass_t > 1718 const 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 1731 template< typename pass_t > 1732 const 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 1745 template< typename pass_t > 1746 const 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 1759 template< typename pass_t > 1760 const 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 1773 template< typename pass_t > 1774 const 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 1786 template< typename pass_t > 1787 const 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 1795 template< typename pass_t > 1796 const 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 1804 template< typename pass_t > 1805 const 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 1813 template< typename pass_t > 1814 const 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 1823 template< typename pass_t > 1824 const 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 } 1562 1831 1563 1832 //-------------------------------------------------------------------------- -
src/AST/Stmt.hpp
r51ff278 re0016a5 330 330 public: 331 331 struct Target { 332 ptr<Expr> func tion;333 std::vector<ptr<Expr>> arg uments;332 ptr<Expr> func; 333 std::vector<ptr<Expr>> args; 334 334 }; 335 335
Note: See TracChangeset
for help on using the changeset viewer.