Changeset b0abc8a0
- Timestamp:
- May 22, 2019, 3:18:34 PM (5 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:
- e9b44489
- Parents:
- 09ab71a
- Location:
- src
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.impl.hpp
r09ab71a rb0abc8a0 841 841 for( const auto & clause : node->clauses ) { 842 842 843 Expr * func = clause.target.func ? clause.target.func->accept(*this) : nullptr;843 const Expr * func = clause.target.func ? clause.target.func->accept(*this) : nullptr; 844 844 if(func != clause.target.func) mutated = true; 845 845 … … 852 852 } 853 853 854 Stmt * stmt = clause.stmt ? clause.stmt->accept(*this) : nullptr;854 const Stmt * stmt = clause.stmt ? clause.stmt->accept(*this) : nullptr; 855 855 if(stmt != clause.stmt) mutated = true; 856 856 857 Expr * cond = clause.cond ? clause.cond->accept(*this) : nullptr;857 const Expr * cond = clause.cond ? clause.cond->accept(*this) : nullptr; 858 858 if(cond != clause.cond) mutated = true; 859 859 … … 1567 1567 bool mutated = false; 1568 1568 for( const auto & assoc : node->associations ) { 1569 Type * type = nullptr;1569 const Type * type = nullptr; 1570 1570 if( assoc.type ) { 1571 1571 guard_indexer guard { *this }; … … 1573 1573 if( type != assoc.type ) mutated = true; 1574 1574 } 1575 Expr * expr = nullptr;1575 const Expr * expr = nullptr; 1576 1576 if( assoc.expr ) { 1577 1577 expr = assoc.expr->accept( *this ); … … 1685 1685 VISIT_START( node ); 1686 1686 1687 __pass::indexer::addStruct( node->name, 0, pass);1687 __pass::indexer::addStruct( pass, 0, node->name ); 1688 1688 1689 1689 VISIT({ … … 1702 1702 VISIT_START( node ); 1703 1703 1704 __pass::indexer::addStruct( node->name, 0, pass);1704 __pass::indexer::addStruct( pass, 0, node->name ); 1705 1705 1706 1706 { … … 1885 1885 } 1886 1886 1887 // //--------------------------------------------------------------------------1888 // //TypeSubstitution1889 //template< typename pass_t >1890 //const ast::TypeSubstitution * ast::Pass< pass_t >::visit( const ast::TypeSubstitution * node ) {1891 //VISIT_START( node );1892 1893 //VISIT(1894 //{1895 //bool mutated = false;1896 //std::unordered_map< std::string, ast::ptr< ast::Type > > new_map;1897 //for ( const auto & p : node->typeEnv ) {1898 //guard_indexer guard { *this };1899 //auto new_node = p.second->accept( *this );1900 //if (new_node != p.second) mutated = false;1901 //new_map.insert({ p.first, new_node });1902 //}1903 //if (mutated) {1904 //auto new_node = mutate( node );1905 //new_node->typeEnv.swap( new_map );1906 //node = new_node;1907 //}1908 //}1909 1910 //{1911 //bool mutated = false;1912 //std::unordered_map< std::string, ast::ptr< ast::Expr > > new_map;1913 //for ( const auto & p : node->varEnv ) {1914 //guard_indexer guard { *this };1915 //auto new_node = p.second->accept( *this );1916 //if (new_node != p.second) mutated = false;1917 //new_map.insert({ p.first, new_node });1918 //}1919 //if (mutated) {1920 //auto new_node = mutate( node );1921 //new_node->varEnv.swap( new_map );1922 //node = new_node;1923 //}1924 //}1925 //)1926 1927 //VISIT_END( TypeSubstitution, node );1928 //}1887 //-------------------------------------------------------------------------- 1888 // TypeSubstitution 1889 template< typename pass_t > 1890 const ast::TypeSubstitution * ast::Pass< pass_t >::visit( const ast::TypeSubstitution * node ) { 1891 VISIT_START( node ); 1892 1893 VISIT( 1894 { 1895 bool mutated = false; 1896 std::unordered_map< std::string, ast::ptr< ast::Type > > new_map; 1897 for ( const auto & p : node->typeEnv ) { 1898 guard_indexer guard { *this }; 1899 auto new_node = p.second->accept( *this ); 1900 if (new_node != p.second) mutated = false; 1901 new_map.insert({ p.first, new_node }); 1902 } 1903 if (mutated) { 1904 auto new_node = mutate( node ); 1905 new_node->typeEnv.swap( new_map ); 1906 node = new_node; 1907 } 1908 } 1909 1910 { 1911 bool mutated = false; 1912 std::unordered_map< std::string, ast::ptr< ast::Expr > > new_map; 1913 for ( const auto & p : node->varEnv ) { 1914 guard_indexer guard { *this }; 1915 auto new_node = p.second->accept( *this ); 1916 if (new_node != p.second) mutated = false; 1917 new_map.insert({ p.first, new_node }); 1918 } 1919 if (mutated) { 1920 auto new_node = mutate( node ); 1921 new_node->varEnv.swap( new_map ); 1922 node = new_node; 1923 } 1924 } 1925 ) 1926 1927 VISIT_END( TypeSubstitution, node ); 1928 } 1929 1929 1930 1930 #undef VISIT_START -
src/AST/Pass.proto.hpp
r09ab71a rb0abc8a0 126 126 template<typename pass_t, typename node_t> 127 127 static inline auto previsit( pass_t & pass, const node_t * & node, int ) -> decltype( pass.previsit( node ), void() ) { 128 static_assert( 129 std::is_base_of<const node_t, typename std::remove_pointer<decltype( pass.previsit( node ) )>::type >::value, 130 "Previsit may not change the type of the node. Use postvisit instead." 131 ); 128 132 node = pass.previsit( node ); 129 133 assert(node); -
src/AST/module.mk
r09ab71a rb0abc8a0 24 24 AST/LinkageSpec.cpp \ 25 25 AST/Node.cpp \ 26 AST/Pass.cpp \ 26 27 AST/Print.cpp \ 27 28 AST/Stmt.cpp \ -
src/Makefile.in
r09ab71a rb0abc8a0 169 169 AST/Expr.$(OBJEXT) AST/Init.$(OBJEXT) \ 170 170 AST/LinkageSpec.$(OBJEXT) AST/Node.$(OBJEXT) \ 171 AST/P rint.$(OBJEXT) AST/Stmt.$(OBJEXT) AST/Type.$(OBJEXT) \172 AST/Type Substitution.$(OBJEXT)171 AST/Pass.$(OBJEXT) AST/Print.$(OBJEXT) AST/Stmt.$(OBJEXT) \ 172 AST/Type.$(OBJEXT) AST/TypeSubstitution.$(OBJEXT) 173 173 am__objects_2 = CodeGen/CodeGenerator.$(OBJEXT) \ 174 174 CodeGen/FixMain.$(OBJEXT) CodeGen/GenType.$(OBJEXT) \ … … 577 577 AST/LinkageSpec.cpp \ 578 578 AST/Node.cpp \ 579 AST/Pass.cpp \ 579 580 AST/Print.cpp \ 580 581 AST/Stmt.cpp \ … … 742 743 AST/$(DEPDIR)/$(am__dirstamp) 743 744 AST/Node.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp) 745 AST/Pass.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp) 744 746 AST/Print.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp) 745 747 AST/Stmt.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp) … … 1174 1176 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/LinkageSpec.Po@am__quote@ 1175 1177 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Node.Po@am__quote@ 1178 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Pass.Po@am__quote@ 1176 1179 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Print.Po@am__quote@ 1177 1180 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Stmt.Po@am__quote@
Note: See TracChangeset
for help on using the changeset viewer.