Ignore:
Timestamp:
May 22, 2019, 3:18:34 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:
e9b44489
Parents:
09ab71a
Message:

Fixed errors in the pass visitor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Pass.impl.hpp

    r09ab71a rb0abc8a0  
    841841                for( const auto & clause : node->clauses ) {
    842842
    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;
    844844                        if(func != clause.target.func) mutated = true;
    845845
     
    852852                        }
    853853
    854                         Stmt * stmt = clause.stmt ? clause.stmt->accept(*this) : nullptr;
     854                        const Stmt * stmt = clause.stmt ? clause.stmt->accept(*this) : nullptr;
    855855                        if(stmt != clause.stmt) mutated = true;
    856856
    857                         Expr * cond = clause.cond ? clause.cond->accept(*this) : nullptr;
     857                        const Expr * cond = clause.cond ? clause.cond->accept(*this) : nullptr;
    858858                        if(cond != clause.cond) mutated = true;
    859859
     
    15671567                bool mutated = false;
    15681568                for( const auto & assoc : node->associations ) {
    1569                         Type * type = nullptr;
     1569                        const Type * type = nullptr;
    15701570                        if( assoc.type ) {
    15711571                                guard_indexer guard { *this };
     
    15731573                                if( type != assoc.type ) mutated = true;
    15741574                        }
    1575                         Expr * expr = nullptr;
     1575                        const Expr * expr = nullptr;
    15761576                        if( assoc.expr ) {
    15771577                                expr = assoc.expr->accept( *this );
     
    16851685        VISIT_START( node );
    16861686
    1687         __pass::indexer::addStruct( node->name, 0, pass );
     1687        __pass::indexer::addStruct( pass, 0, node->name );
    16881688
    16891689        VISIT({
     
    17021702        VISIT_START( node );
    17031703
    1704         __pass::indexer::addStruct( node->name, 0, pass );
     1704        __pass::indexer::addStruct( pass, 0, node->name );
    17051705
    17061706        {
     
    18851885}
    18861886
    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 // }
     1887//--------------------------------------------------------------------------
     1888// TypeSubstitution
     1889template< typename pass_t >
     1890const 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}
    19291929
    19301930#undef VISIT_START
Note: See TracChangeset for help on using the changeset viewer.